Possible to test for existence of a remote rrd file?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible to test for existence of a remote rrd file?

stphnwallace
This post has NOT been accepted by the mailing list yet.
Hi,

I'm trying to split off the RRD function from Nagios XI to isolate IO load. I know I could use rrdcached to schedule the processing of RRD on localhost but this is not what I'm trying to do.

When Nagios PNP is about to process the performance data, it does a test (-e $rrdfile) to check if the file already exists. If so, it does an rrdtool update. If the file does not exist, it does an rrdtool create

Now, we introduce rrdcached (and rrdsrv) running on the remote RRD processing box, and the question is, how do we test for the existence of the remote $rrdfile?

Would be nice, neat n tidy if there was an rrdtool switch to do this;

e.g. rrdtool check-exist --daemon=192.168.122.32:42217 dc2-web1.localdomain/Ping.rrd

Maybe this would be a useful feature request?

Assuming one can't achieve the goal as above, any other ideas using rrdsrv or rrdcached? Failing this, I will NFS mount the perfdata directory, then do a -e test to the NFS presented filesystem.

The rrdtool *update* works a treat now using rrdcached TCP socket.  NB I can't get anything out of of rrdtool info, last, etc when using TCP socket, and don't understand how I could issue the command from remote server to interrogate domain socket, or "cd into the rrdcached daemon base (-b) directory. Maybe somebody else has done this? My head hurts ;)

Once I'm able to do this, I'm assuming I should be issuing the rrdtool create command via one of the following;

1) As per here - http://mathias-kettner.de/checkmk_livestatus.html - ability to issue SSH command to run rrdtool create against the domain socket???

2) echo "create file.rrd" | netcat remote_ip rrdsrv_port

3) Was thinking about doing the create via rrdcached, but this feature is not available until v1.5 :(

Thanks in advance guys.

Stephen
Reply | Threaded
Open this post in threaded view
|

Re: Possible to test for existence of a remote rrd file?

stphnwallace
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@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@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@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.
Reply | Threaded
Open this post in threaded view
|

Re: Possible to test for existence of a remote rrd file?

S Shipway
If you are using the trunk version of rrdcached, then you can do a remote info request.  I don’t believe this will work with the 1.4 stable version though.

[root@kaoru sysconfig]# export RRDCACHED_ADDRESS=mrtg.auckland.ac.nz
[root@kaoru sysconfig]# /u01/bin/rrdtool info foo.rrd
ERROR: rrdcached: No such file: /u01/rrdtool/foo.rrd.
[root@kaoru sysconfig]# /u01/bin/rrdtool info zmdbdev.its-load.rrd
filename = "/u01/rrdtool/zmdbdev.its-load.rrd"
rrd_version = "0003"
step = 300
last_update = 1331853826
header_size = 2764


Steve


Steve Shipway
ITS Unix Services Design Lead
University of Auckland, New Zealand
Floor 1, 58 Symonds Street, Auckland
Phone: +64 (0)9 3737599 ext 86487
DDI: +64 (0)9 924 6487
Mobile: +64 (0)21 753 189
Email: [hidden email]
 Please consider the environment before printing this e-mail




_______________________________________________
rrd-users mailing list
[hidden email]
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users

smime.p7s (8K) Download Attachment