RRD Tool integration

Mark Musone mmusone at shatterit.com
Tue Oct 15 04:25:03 CEST 2002


I'm not sure if this is what people are looking for, but I'm using the
perfdata (kinda) with nagios and rrdtool
Quite a bit..mostly from the ncsa passive checks...heres my scenario:

1. I have the perfdata command defined in the nagios.cfg file:

host_perfdata_command=process-host-rrdperfdata
service_perfdata_command=process-service-rrdperfdata

2. in the misccommands.cfg file, I define the specific commands:

define command{
        command_name    process-host-rrdperfdata
        command_line    /usr/local/nagios/bin/perfdata.sh "$HOSTNAME$"
host "$PERFDATA$" "$OUTPUT$"
        }

define command{
        command_name    process-service-rrdperfdata
        command_line    /usr/local/nagios/bin/perfdata.sh  "$HOSTNAME$"
"$SERVICEDESC$" "$PERFDATA$" "$OUTPUT$"
        }

3. The perfdata.sh script is a VERY simple shell script to parse out the
last part of the data, and to stuff it in an RRD:

Note: a couple of things:

The first argument is the hostname, followed by the service description
(or the word host if it's host perfdata)
I cleanse the service description to make it more filesystem friendly.
Lastly, the perfdata is the last argument.

I store all the RRDs as separate files in the form
"host-description.rrd"
I originally wanted just one rrd per host, and each service is simply a
variable but it got more complicated
Than I wanted to putz around with. Also, it gets confusing if you have a
service that gives multiple perfdata information, for example load
giving a 1 minute,5 minute, and 15 minute value.

So right now I actually like the format for host-description. It's very
easy to programatically get what you want,
And it keeps the file sizes down. Note, although it was made to handle
multiple perfdata variables/values, it currently does NOT.

#!/bin/sh

hostname=$1
desc=`echo $2 | tr -c  -d [a-zA-Z0-9_]`
perfdata=$3


if [ -n "$perfdata" ]; then

if [ ! -e /root/rrdb/$hostname-$desc.rrd ]; then
    /usr/local/bin/rrdtool create /root/rrdb/$hostname-$desc.rrd --step
60 DS:$desc:GAUGE:600:U:U RRA:AVERAGE:0.5:1:6000 RRA:MIN:0.5:60:2400
RRA:MAX:0.5:60:2400 RRA:AVERAGE:0.5:60:2400
fi
echo HOST:$hostname DESC:$desc:PREF:$perfdata:OUTPUT:$4>> /tmp/perf.out
echo "/usr/local/bin/rrdtool update /root/rrdb/$hostname-$desc.rrd
N:$perfdata" >> /tmp/perfrun.out
#/usr/local/bin/rrdtool update /root/rrdb/$hostname.rrd -t $desc
N:$perfdata
/usr/local/bin/rrdtool update /root/rrdb/$hostname-$desc.rrd N:$perfdata
fi



MORE NOTES: 
A. one other VERY important thing: the perfdata it expectes is purely a
single NUMBER that it stuffs into the rrd. It does NOT handle
variable=value data.

It expects something like this (taken from the nagios.log file):

[1034647869] EXTERNAL COMMAND:
PROCESS_SERVICE_CHECK_RESULT;zev;CPU;0;load average: 0.00, 0.00,
0.00|0.00
[1034647869] EXTERNAL COMMAND:
PROCESS_SERVICE_CHECK_RESULT;zev;Disk1;0;DISK OK - [507180 kB (26%) free
on /dev/sda1]|1374424
[1034647869] EXTERNAL COMMAND:
PROCESS_SERVICE_CHECK_RESULT;zev;Disk2;0;DISK OK - [11739460 kB (83%)
free on /dev/sda3]|2354936
[1034647869] EXTERNAL COMMAND:
PROCESS_SERVICE_CHECK_RESULT;zev;Disk3;0;DISK OK - [16586568 kB (99%)
free on /dev/sdb1]|156632

Notice, that after the | symbol on the output line is simply a number
that I want logged.


B. If the rrd does NOT exist it'll automatically create it and
initialize it (yea!!) it's awesome simply putting in the perfdata
command in the nagios.cfg file and minutes later seeing tens of rrd's
automagically creating and updating :^)

C. If there is NO perfdata, it simply ignores and exists. This way it
works seemlessly with or without plugins with perfdata.


Now, on the CLIENT end (again ,I use this mostly with nsca)
I have a cron job that runs every 5 minutes to do the local checks and
send it to the nagios server:

0,5,10,15,20,25,30,35,40,45,50,55 * * * *
/usr/local/nagios/libexec/nagios_client.sh 1>/dev/null 2>/dev/null



The nagios_client.sh is shell script that does the following:


#!/bin/sh
(rest=`/usr/local/nagios/libexec/check_load  -w 1,2,3 -c 4,5,6 2>&1` ;
load=`awk '{gsub("/"," "); print $2}' /proc/loadavg` ; echo -e
"zev\tCPU\t$?\t$rest|$load"
rest=`/usr/local/nagios/libexec/check_disk -w 10% -c 2% -p / 2>&1` ;
disk=`df -k |grep sda1 |awk '{print $3}'`; echo -e
"zev\tDisk1\t$?\t$rest|$disk"

rest=`/usr/local/nagios/libexec/check_disk -w 10% -c 2% -p /local 2>&1`
; disk=`df -k |grep sda3 |awk '{print $3}'` ;echo -e
"zev\tDisk2\t$?\t$rest|$disk"

rest=`/usr/local/nagios/libexec/check_disk -w 10% -c 2% -p
/var/lib/mysql 2>&1` ; disk=`df -k |grep sdb1 |awk '{print $3}'`; echo
-e "zev\tDisk3\t$?\t$rest|$disk"


rest=`/usr/local/nagios/libexec/check_procs -w 1: -c 1: -C mysqld -u
mysql 2>&1` ; procs=`/usr/local/nagios/libexec/check_procs -w 1: -c 1:
-C mysqld -u mysql| awk '{print $3}'` ;echo -e "zev\tMysql
Proc\t$?\t$rest|$procs"

rest=`/usr/local/nagios/libexec/check_procs -w 1: -c 1: -C postmaster -u
postgres  2>&1` ; procs=`/usr/local/nagios/libexec/check_procs -w 1: -c
1: -C postmaster -u postgres |  awk '{print $3}'` ;echo -e
"zev\tPostgress Proc\t$?\t$rest|$procs"



) | /usr/local/nagios/libexec/send_nsca MY_NAGIOS_SERVER.COMPANY>COM -c
/usr/local/nagios/libexec/send_nsca.cfg


In a nutshell, it runs the plugin, and right now I'm simply munging the
output and/or manually stuffing the output with the perfdata that I
want..in this exmaple you see how I munge in disk utilization, cpu load
(only doing 5 minute in perfdata), and process checks.

There, everything is in the rrd...just use the normal stuff..attached is
a little screenshot of what it looks like
All graphed out on a web page...all courtesy of nagios and rrdtool!!!
Thanks! :^)

Hope this helps someone...




-----Original Message-----
From: nagios-users-admin at lists.sourceforge.net
[mailto:nagios-users-admin at lists.sourceforge.net] On Behalf Of Carroll,
Jim P [Contractor]
Sent: Monday, October 14, 2002 1:01 PM
To: 'Atul Gosain'; nagios-users at lists.sourceforge.net
Subject: RE: [Nagios-users] RRD Tool integration


I can't speak about RRDTool directly, but at some point I plan to take a
crack at leveraging cacti (or another RRDTool-based solution).  I'll
share my solution once I've been there, done that.

Off the cuff, I speculate that I'll be running the NRPE plugins from
cacti. The only disadvantage I can see here is that each plugin worth
tracking metrics will be run once from Nagios, once from cacti.  Less
than optimal, but I don't know the internals of Nagios well enough to
approach this otherwise.

If someone better versed on the Nagios internals (nagios.cmd, perhaps?)
would care to make helpful suggestions when I cross that bridge, ping me
now
(off-list) just to say, "Hey, let me know when you're ready to give this
a go; I should be able to spare a few cycles here and there."

As usual, once I've cracked this nut, I'll share with the list.

jc

> -----Original Message-----
> From: Atul Gosain [mailto:atul at mindsw.com]
> Sent: Monday, October 14, 2002 5:56 AM
> To: nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] RRD Tool integration
> 
> 
> hi
> 
> Hey what happened to RRD tool integration . Someone was going
> to provide 
> some script to take the data from the rrd instead  of 
> executing the ping 
> plugin.
> 
> Thanks
> Atul.
> :)
> 
> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf 
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> 


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf _______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rrdtool.GIF
Type: image/gif
Size: 226311 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/users/attachments/20021014/2a25738a/attachment.gif>


More information about the Users mailing list