Sunday, October 25, 2009

Logging smartd (or any daemon) messages with rsyslog

Rsyslog is the enhanced syslogd for Linux and Unix, extending the good syslog-ng.

If you use smartmontools to monitor your disks with smartd, you can see that your logs are filled with too many information related to your disks. The first solution is to tell smartd to send messages into a local facility (1-7 are available) and then in syslog-ng write all messages sent to that facility into file smartd.log. It's a good solution, as long as this facility is not used for something else.

With rsyslog you can do better by creating /etc/rsyslog.d/smartd.conf with the following:
:programname, isequal, "smartd" -/var/log/smartd.log
& ~

According to rsyslog.conf(5) man page, programname matches the program name sending the message to the syslog. Therefore with this configuration, all messages sent by smartd are now logged into /var/log/smartd.log. Easy!

Reload rsyslog and you're done.
/etc/init.d/rsyslog reload

This feature can be extended to other daemons that you want to log into a separate file, for instance ntpd.

No comments:

Post a Comment