From: Maciej S. Szmigiero Date: Sun, 19 Apr 2020 15:57:07 +0000 (+0200) Subject: Provide an udev rule with ID_SERIAL based, disk plugin usable ID attribute X-Git-Tag: collectd-5.12.0~43^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0e4e1994b1775d7e924d8f051c2d21924bb03af;p=thirdparty%2Fcollectd.git Provide an udev rule with ID_SERIAL based, disk plugin usable ID attribute 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 --- diff --git a/contrib/99-storage-collectd.rules b/contrib/99-storage-collectd.rules new file mode 100644 index 000000000..d8c9a3b00 --- /dev/null +++ b/contrib/99-storage-collectd.rules @@ -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" diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 89df66c78..5e8408c99 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -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) will result in +data about the whole disk and each partition being mixed together incorrectly. +In this case, you can use B attribute that is provided by +I udev rule file instead. + =back =head2 Plugin C