Tags
Tags
This article provides some init scripts for rrdcached.
Warranty
I'm using collectd to collect system information of my server.
In general collectd write the data directly to rrd files.
Since I got more than one system my collectd installation is responsible for I ran into some I/O performance issues.
That is why I set up rrdcached which already is provided by rrdtool-packages. It can be set between the rrd files and any program writing rrd data.
Because it stores the data in RAM it takes the data faster then rrd files can be written.
After a configurable timeout the data then will be written to rrd files.
Unfortunately there are no init scripts and systemd service files provided by the packages of Arch Linux.
So I've written them myself.
If you are using systemd you have to copy the following service file to /etc/systemd/system/multi-user.target.wants/rrdcached.service
:
[Unit] Description=Cache daemon for rrd values Before=collectd.service [Service] EnvironmentFile=/etc/conf.d/rrdcached ExecStart=/usr/bin/rrdcached -s "${RRDGROUP}" -m "${RRDMODE}" -l "${RRDADDRESS}" -p "${RRDPIDFILE}" ${RRDARGS} StandardOutput=journal StandardError=journal RemainAfterExit=yes [Install] WantedBy=multi-user.target
If you are still using the old init system (sysv) then you have to copy the following script to /etc/rc.d/rrdcached
:
#!/bin/bash . /etc/rc.conf . /etc/rc.d/functions . /etc/conf.d/rrdcached DAEMON=rrdcached PID="$(get_pid $DAEMON)" ck_pidfile ${RRDPIDFILE} ${DAEMON} || rm -f ${RRDPIDFILE} case "$1" in start) stat_busy "Starting $DAEMON daemon" [[ -z "$PID" ]] && $DAEMON -s ${RRDGROUP} -m ${RRDMODE} -l ${RRDADDRESS} -p ${RRDPIDFILE} ${RRDARGS} if [[ $? -eq 0 ]] then add_daemon $DAEMON; stat_done; else stat_fail; fi ;; stop) stat_busy "Stopping $DAEMON daemon" [[ -n "$PID" ]] && kill $PID &>/dev/null if [[ $? -eq 0 ]] then rm_daemon $DAEMON; stat_done; else stat_fail; fi ;; restart) $0 stop sleep 2 $0 start ;; *) echo "usage: $0 {start|stop|restart}" ;; esac
For both version you have to copy the following configuration file to /etc/conf.d/rrdcached
and adapt according to your needs:
# address rrdcached will be listen for connections (can be socket or IP) RRDADDRESS="unix:/tmp/rrdcached.sock" # group used by rrdcached to write rrd files RRDGROUP="http" # mode the rrd files are created with RRDMODE="775" # path to rrdcached pid file RRDPIDFILE="/run/rrdcached.pid" # additional arguments for rrdcached RRDARGS=""
FYI we had a lot of trouble to get rrdcached either running with systemctl and supervisord. Problems with stale pids left behind.
But we solved this by running rrdcached in combination with -g (foreground mode) under systemd. Also with Restart=always is handy.