[rrd-users] Possible to test for existence of a remote rrd file?

stphnwallace whizbang.wallace at gmail.com
Thu Mar 15 23:40:52 CET 2012


I think I have a solution to my own question......

Set up rrdtool as a service in xinetd.d with base directory for the daemon
pointing to your perfdata dir.

[root at rrdcache localhost]# cat /etc/xinetd.d/rrdsrv 
# default: on
# description: RRDServer
service rrdsrv

#         server_args       = - /tmp/rrdsrv
#         serv_args       = - /usr/local/nagios/share/perfdata
{
         disable         = no
         socket_type     = stream
         protocol        = tcp
         wait            = no
         user            = root
	 only_from	= 192.168.122.0/24
         server          = /usr/bin/rrdtool
         server_args       = - /usr/local/nagios/share/perfdata
}

e.g. /usr/local/nagios/share/perfdata is base dir
e.g. /usr/local/nagios/share/perfdata/localhost/PING.rrd is an example to a
file.

Let's test to see if a remote rrd file exists...

[root at nagios var]# echo "info localhost/PING.rrrrrrrrrd" | nc 192.168.122.32
13900
| grep "No such file or directory" ; echo $?
ERROR: opening 'localhost/PING.rrrrrrrrrd': No such file or directory
0
[root at nagios var]# echo "info localhost/PING.rrd" | nc 192.168.122.32 13900
| grep
"No such file or directory" ; echo $?
1

So, if 0, rrdtool create. If 1, rrdtool update :)

I'm sure there's a prettier way of scripting this using ....

fileexists=0
[test condition] || fileexists=1    (or something similar?)
if $fileexists=0
then
   rrdtool create
else
   rrdtool update
fi

Any takers?

I hope this helps someone.

--
View this message in context: http://rrd-mailinglists.937164.n2.nabble.com/Possible-to-test-for-existence-of-a-remote-rrd-file-tp7367471p7377293.html
Sent from the RRDtool Users Mailinglist mailing list archive at Nabble.com.



More information about the rrd-users mailing list