Benutzer-Werkzeuge

Webseiten-Werkzeuge


Action disabled: source
linux:systemd_file_for_rrdcached

systemd file for rrdcached

Summary

This article provides some init scripts for rrdcached.

Main

Warranty

There is no warranty that this how-to works for any system.
I'm just providing these information because it worked for me this way.
If you have questions you can leave a message here but I decide whether I'll answer and help or not.

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.

Installation

If you are using systemd you have to copy the following service file to /etc/systemd/system/multi-user.target.wants/rrdcached.service:

/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:

/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:

/etc/conf.d/rrdcached
# 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=""

Comments

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.

1 |
Gerwin
| 2015/03/19 08:33 | reply


B N N Q M
linux/systemd_file_for_rrdcached.txt · Zuletzt geändert: 2013/07/27 21:14 von Andrwe Lord Weber