Enabling RRDcached for Munin on OpenBSD
404 words, 2 minutes
RRDcached is a daemon that caches a bunch of RRD write requests and apply them at once. This enables to speed up RRD files update. When you install Munin on OpenBSD, RRDcached is also installed by default. But there are things to do to actually use it. Here’s how I did it.
First thing to know is that Munin and RRDcached run with there own user. This allows RRDcached to be used by any other process than Munin. Munin’s documentation explains how to run RRDcached with the Munin’s user. In may case, I’ll go for “Any user in the _rrdcached group can write to RRDcached socket. Any user in the _munin group can write the RRD files”.
# usermod -G _rrdcached _munin
# usermod -G _munin _rrdcached
# chmod 0775 /home/munin/db/net
# chmod 0664 /home/munin/db/net/*rrd
There’s a case when one may do unexpected things to Munin’s RRD files. An X user being in _rrdcached group may ask RRDcached to write sh!t in Munin’s RDD files. I consider that I know who will be able to talk to RRDcached and that the risk is minimal. But on multi-admin host, this may not be the case.
Next, we start the RRDcached daemon.
# rcctl enable rrdcached
# rcctl start rrdcached
Finally, we tell Munin to use RRDcached.
# vi /etc/munin/munin.conf
(...)
rrdcached_socket /var/run/rrd/rrdcached.sock
(...)
When Munin updates the RRD files, requests will go through RRDcached. One can check for gain looking at the log files.
# grep 'Munin-update finished' /var/log/munin/munin-update.log
(...)
2015/07/31 09:10:03 [INFO]: Munin-update finished for node net;tumfatig.net (1.81 sec)
2015/07/31 09:10:03 [INFO]: Munin-update finished (1.87 sec)
2015/07/31 09:15:03 [INFO]: Munin-update finished for node net;tumfatig.net (1.81 sec)
2015/07/31 09:15:03 [INFO]: Munin-update finished (1.87 sec)
2015/07/31 09:20:03 [INFO]: Munin-update finished for node net;tumfatig.net (1.78 sec)
2015/07/31 09:20:03 [INFO]: Munin-update finished (1.83 sec)
2015/07/31 09:25:03 [INFO]: Munin-update finished for node net;tumfatig.net (1.79 sec)
2015/07/31 09:25:03 [INFO]: Munin-update finished (1.84 sec)
# switch to RRDcached happened here.
2015/07/31 09:30:03 [INFO]: Munin-update finished for node net;tumfatig.net (1.78 sec)
2015/07/31 09:30:03 [INFO]: Munin-update finished (1.84 sec)
2015/07/31 09:35:03 [INFO]: Munin-update finished for node net;tumfatig.net (1.78 sec)
2015/07/31 09:35:03 [INFO]: Munin-update finished (1.84 sec)
2015/07/31 09:40:03 [INFO]: Munin-update finished for node net;tumfatig.net (1.79 sec)
2015/07/31 09:40:03 [INFO]: Munin-update finished (1.85 sec)
(...)
In my case, with only one monitored host and less than 20 checks, it doesn’t seem to help. But I guess monitoring a thousand hosts would benefit from RRDcached.