Arnaud Quette
2005-Dec-16 08:22 UTC
[Nut-upsdev] Re: Bug#343530: nut: logging to rrd database
2005/12/15, Alexander V. Inyukhin <shurick@sectorb.msk.ru>:> > Package: nut > Version: 2.0.2-2 > Severity: wishlist > > Hello.Hi Alexander, I think it is a good idea to log ups variables to rrd> database instead of log file. So, I create standalone > rrd logger dervied from upslog nut client. > Of course, this could be easily implemented using > upsc or upslog clients and a cron script > but stanalone application is better for some reasons. > > Does anybody else need this functionality? > Should such a client be included in the nut > (with additional librrd dependency) or nut-rrd > package or distributed separately?interesting point: I'm thinking of some logging improvements, such as: - making upslog a real daemon, able to log data from several UPSs, - making log asynchronous and smart (ie log only things that have changed), - switching by default to a NUT specific logfile (ie upsd.log), instead of the syslog default, - adding the ability to log to other system, such as RRD... So, I'm definitly interested in your work. The final aim of all of that is to be able to use these data for plotting and other graphic / textual display... I've planned to get back on this when working on some MGE PSP [1] evolution such as the History feature in our case. Arnaud -- [1] http://www.mgeups.com/products/pdt230/software/sp97/solpaclinux.htm -- Linux / Unix Expert - MGE UPS SYSTEMS - R&D Dpt Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/ Debian Developer - http://people.debian.org/~aquette/ OpenSource Developer - http://arnaud.quette.free.fr/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20051216/45486f92/attachment.htm
Alexander V. Inyukhin
2005-Dec-17 02:25 UTC
[Nut-upsdev] Re: Bug#343530: nut: logging to rrd database
On Fri, Dec 16, 2005 at 09:22:49AM +0100, Arnaud Quette wrote:> 2005/12/15, Alexander V. Inyukhin <shurick@sectorb.msk.ru>: > > > I think it is a good idea to log ups variables to rrd > > database instead of log file. So, I create standalone > > rrd logger dervied from upslog nut client. > > Of course, this could be easily implemented using > > upsc or upslog clients and a cron script > > but stanalone application is better for some reasons. > > > > Does anybody else need this functionality? > > Should such a client be included in the nut > > (with additional librrd dependency) or nut-rrd > > package or distributed separately? > > > interesting point: I'm thinking of some logging improvements, such as: > - making upslog a real daemon, able to log data from several UPSs, > - making log asynchronous and smart (ie log only things that have changed), > - switching by default to a NUT specific logfile (ie upsd.log), instead of > the syslog default, > - adding the ability to log to other system, such as RRD... > > So, I'm definitly interested in your work.Source files of upsrrd daemon and sample init.d script are attached. Differences from upslog are minimal: data is recorded by rrd_update using fixed log format, log format can't be changed from command line, so option -f and most parts of parser are removed, invalid values are printed as 'U', and there is no need for log rotation. Errors while updating database will be written to syslog. I intentionally left the rest of parser for possible modifications of list variables in the future. To complile daemon sources should be placed into the clients subdirectory of nut package and appropriate Makefile rules should be created (based on upslog rules). Obviously, upsrrd should be linked with -lrrd and requres librrd2-dev for building and librrd2 for execution. Sample init.d script has hardcoded daemon command line, which should be placed into config file. Database could be created with following command (I also use rrdcollect and place ups logs there): rrdtool create /var/lib/rrdcollect/ups.rrd -s 30 \ DS:bat_charge:GAUGE:75:0:100 DS:line_voltage:GAUGE:75:0:U \ DS:ups_load:GAUGE:75:0:100 DS:ups_temp:GAUGE:75:U:U \ DS:line_freq:GAUGE:75:0:U DS:bat_voltage:GAUGE:75:0:U \ DS:bat_runtime:GAUGE:75:0:U RRA:AVERAGE:0.5:10:210000 I think this daemon with some reasonable defaults might be appropriate for most users. -------------- next part -------------- A non-text attachment was scrubbed... Name: upsrrd.c Type: text/x-csrc Size: 8540 bytes Desc: not available Url : http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20051217/100c4adb/upsrrd.c -------------- next part -------------- A non-text attachment was scrubbed... Name: upsrrd.h Type: text/x-chdr Size: 359 bytes Desc: not available Url : http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20051217/100c4adb/upsrrd.h -------------- next part -------------- #! /bin/sh # # skeleton example file to build /etc/init.d/ scripts. # This file should be used to construct scripts for /etc/init.d. # # Written by Miquel van Smoorenburg <miquels@cistron.nl>. # Modified for Debian GNU/Linux # by Ian Murdock <imurdock@gnu.ai.mit.edu>. # # Version: @(#)skeleton 1.8 03-Mar-1998 miquels@cistron.nl # # This file was automatically customized by dh-make on Tue, 3 Sep 2002 14:53:55 +0200 PATH=/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/sbin/upsrrd NAME=upsrrd DESC=upsrrd if [ -f /etc/default/upsrrd ]; then . /etc/default/upsrrd fi test -f $DAEMON || exit 0 set -e case "$1" in start) echo -n "Starting $DESC: $NAME" start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \ --exec $DAEMON -- -s ups@localhost -l /var/lib/rrdcollect/ups.rrd -u nobody -i 60 echo "." ;; stop) echo -n "Stopping $DESC: $NAME" start-stop-daemon --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \ --exec $DAEMON echo "." ;; restart|force-reload) # # If the "reload" option is implemented, move the "force-reload" # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart". # echo -n "Restarting $DESC: $NAME" start-stop-daemon --stop --quiet --pidfile --make-pidfile \ /var/run/$NAME.pid --exec $DAEMON sleep 1 start-stop-daemon --start --quiet --pidfile \ /var/run/$NAME.pid --exec $DAEMON echo "." ;; *) N=/etc/init.d/$NAME # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0