Make smartd_log plugin also search /var/lib/smartmontools on ubuntu instead of failing when /var/log/smartd is missing

ubuntu smartd version 6.5+svn4324-1ubuntu0 and later (ubuntu 18.04 and newer) does not run with -A but still writes metrics into /var/lib/smartmontools csv files

it would be useful to make the plugin also search for this path instead of the default /var/log/smartd, which would allow smartd support out of the box

from ubuntu 18.04 man page

       -A PREFIX, --attributelog=PREFIX

If  this  option is not specified, attribute information is written to files ´/var/lib/smartmontools/attrlog.MODEL-SERIAL.ata.csv´.  To
              disable attribute log files, specify this option with an empty string argument: ´-A ""´.

also instructions are incomplete for redhat & clones, because selinux

Aug 18 00:00:33 server python[17067]: SELinux is preventing /usr/sbin/smartd from write access on the directory /var/log/smartd/.

                                         *****  Plugin catchall (100. confidence) suggests   **************************

                                         If you believe that smartd should be allowed write access on the  directory by default.
                                         Then you should report this as a bug.
                                         You can generate a local policy module to allow this access.
                                         Do
                                         allow this access for now by executing:
                                         # ausearch -c 'smartd' --raw | audit2allow -M my-smartd
                                         # semodule -i my-smartd.pp

you would have to do the ausearch/audit2allow/semodule dance for about 4-5 iterations of restarting smartd, because after each run you get new type of denials

also debian has csv files /var/lib/smartmontools/ enabled by default

Hey @ml35! This is interesting indeed. Wondering if this is still valid for newer Ubuntu versions, I would assume so. Let me see why we had -A option as a requirement.

@ml35 we just opened a PR for this → feat(python.d/smartd_log): add 2nd job that tries to read from '/var/lib/smartmontools/' by ilyam8 · Pull Request #13188 · netdata/netdata · GitHub

1 Like

@ml35 FYI, the above PR has been merged and will be available in our tonight’s nightlies.

1 Like