]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
Provide an udev rule with ID_SERIAL based, disk plugin usable ID attribute 3441/head
authorMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Sun, 19 Apr 2020 15:57:07 +0000 (17:57 +0200)
committerMaciej S. Szmigiero <mail@maciej.szmigiero.name>
Sun, 19 Apr 2020 15:59:01 +0000 (17:59 +0200)
Disk plugin UdevNameAttr option is very useful for making sure that the
same disk always ends in the same RRD file no matter which particular
device node it ends being assigned by the OS.

However, using the most fitting ID_SERIAL udev attribute for this purpose
results in data about the whole disk and each partition being mixed
together incorrectly, since this attribute has exactly the same value for
the whole disk device node and its particular partition nodes.

Let's introduce an ID_COLLECTD attribute instead which differentiates
between the whole disk and its particular partitions in a new udev rule
file provided in "contrib" directory.
To warn users about the issue let's also add a relevant note to the
UdevNameAttr option description.

Based on Stewart Adam's workaround from
https://github.com/collectd/collectd/issues/823

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
contrib/99-storage-collectd.rules [new file with mode: 0644]
src/collectd.conf.pod

diff --git a/contrib/99-storage-collectd.rules b/contrib/99-storage-collectd.rules
new file mode 100644 (file)
index 0000000..d8c9a3b
--- /dev/null
@@ -0,0 +1,15 @@
+# Using ID_SERIAL attribute for naming disks in collectd results in
+# data about the whole disk and each partition being mixed together
+# incorrectly, see: https://github.com/collectd/collectd/issues/823
+#
+# The rules below provide a ID_COLLECTD attribute instead, which
+# differentiates between the whole disk and its particular partitions.
+
+ACTION=="remove", GOTO="collectd_end"
+
+SUBSYSTEM!="block", GOTO="collectd_end"
+
+ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", ENV{ID_COLLECTD}="$env{ID_SERIAL}-disk"
+ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", ENV{PARTN}=="?*", ENV{ID_COLLECTD}="$env{ID_SERIAL}-part$env{PARTN}"
+
+LABEL="collectd_end"
index 89df66c78d0b69420f22f94fdc85882beeb6ff72..5e8408c99b92a4ab645a15d8ca7dfaae3c8700e8 100644 (file)
@@ -2881,6 +2881,12 @@ given device, the default name is used. Example:
 
   UdevNameAttr "DM_NAME"
 
+Please note that using an attribute that does not differentiate between the
+whole disk and its particular partitions (like B<ID_SERIAL>) will result in
+data about the whole disk and each partition being mixed together incorrectly.
+In this case, you can use B<ID_COLLECTD> attribute that is provided by
+I<contrib/99-storage-collectd.rules> udev rule file instead.
+
 =back
 
 =head2 Plugin C<dns>