For statistics collection I like to use Cricket (http://cricket.sourceforge.net/).
Sure, it is old school but it does the job, and it does it well. I enjoy having a flat configuration and storage structure for the RRD. No fancy database!!! Of course, this comes to the cost of some very old fashioned perl code and performance issues (but have a look at the CVS version).
Never the less, a few days ago I update the rrdtool version I was using on my SNMP collector host and started to run the new RRDcached service. This was a real pleasure as I could see some real performance improvments and I had to do nothing in term of code for Cricket. Yep, worked out of the box with it.
What I did was:
- Get rrdtool 1.4.2 . As I am running OpenSuse11.1 I wanted to stick to a clean package installation and tried to find the RPM for it. No luck at that time. So second option was to of course make the rrdtool package myself with OBS. Package can be downloaded from http://download.opensuse.org/repositories/home:/sbarbereau/openSUSE_11.1/ .
- Install package
- Start rrdcached. That was probably the most "complex" part. As I wanted to keep this clean I created a pseudo initd scripts as well as a separate config file. For simplicity I could have packed everything together. Here are the files:
======== rrdcached.defaults ========
RUN_RRDCACHED=1
RRDCACHED_USER="cricket"
OPTS="-w 300 -z 300 -f 1800 -F"
PIDFILE="/shared/netmonb/cricket/var/run/rrdcached/rrdcached.pid"
SOCKFILE="/shared/netmonb/cricket/var/run/rrdcached/rrdcached.socket"
JOURNAL="/shared/netmonb/cricket/var/run/rrdcached/rrdcached.journal"
SOCKPERMS=0660
======== rrdcached.defaults ========
======== rrdcached.init ========
RRDCACHED_BIN=/usr/bin/rrdcached
test -x $RRDCACHED_BIN || { echo "$RRDCACHED_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
RRDCACHED_CONFIG=/shared/netmonb/cricket/cricket/util/rrdcached/rrdcached.defaults
test -r $RRDCACHED_CONFIG || { echo "$RRDCACHED_CONFIG not existing";
if [ "$1" = "stop" ]; then exit 0;
else exit 6; fi; }
. $RRDCACHED_CONFIG
. /etc/rc.status
rc_reset
case "$1" in
start)
echo -n "Starting rrdcached "
startproc -u $RRDCACHED_USER -p $PIDFILE $RRDCACHED_BIN $OPTS \
-p $PIDFILE -l $SOCKFILE -j $JOURNAL
rc_status -v
echo -n "Setting Permissions "
chmod $SOCKPERMS "${SOCKFILE}"
rc_status -v
;;
stop)
echo -n "Shutting down rrdcached "
killproc -TERM -p $PIDFILE $RRDCACHED_BIN
rc_status -v
;;
try-restart|condrestart)
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
rc_status
;;
try-start)
$0 status
if test $? = 0; then
rc_reset # Not running is not a failure.
else
$0 restart
fi
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
force-reload)
$0 try-restart
rc_status
;;
reload)
echo -n "Reload service rrdcached : not supported"
rc_status -v
;;
status)
echo -n "Checking for service rrdcached "
checkproc -p $PIDFILE $RRDCACHED_BIN
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|try- start|restart|force-reload|reload}"
exit 1
;;
esac
rc_exit
======== rrdcached.init ========
Obviously you will need to change a few things in the files to (path, users, ...)
But as said, no change in any of the perl stuff from cricket was then required. I just had to set RRDCACHED_ADDRESS in my environment ...
It is really nice to use rrdcached as it really works out of the box with any properly coded program using the standard rrdtool API. Wether it is Cacti, MRTG or similar tools ... it should work!
But there are 2 drawback I found out:
- if RRDCACHED_ADDRESS is set but points to a non existing socket/file you are going to have problems as RRD will not update your data files.
- if you use your RRD files to do some monitoring (thresholds detection or similar) the added write delay from the rrdcache is going to pose some problems.
Anyway was fun.
2 comments:
I'm curious, how/where are you setting the RRDCACHED_ADDRESS environment variable for cricket? I've put $ENV{'RRDCACHED_ADDRESS'} = '/var/run/rrdcached.sock';
at the bottom of my cricket-conf.pl file but I'm not sure it's being used.
Thanks for the tips!
-nic
The RRDCACHED_ADDRESS has to be set prior to calling the collector.pl scripts or equivalent.
Post a Comment