Another perfdata script (perl)

Al Tobey albert.tobey at priority-health.com
Fri Oct 25 23:04:15 CEST 2002


WARNING: you will not have much success with this script unless you know
some perl.

Here is a first whack at a(nother) tool to put Nagios perfdata into rrd
files.  It's GPL and, as usual, comes with NO WARRANTY.  It's still a
little rough on the edges, but it does what I want it to.  I still have
yet to write the matching CGI, which might involve adding a function to
this script to write some metadata.

It's fairly customized to my particular setup, so unless you're as
demented as I am, you'll have to make some changes to get anything
useful out of it.

For one thing, I define all my process monitors (using my
snmp_process_monitor.pl that is somewhere in nagiosplugs contrib now)
with a service name ending in _PROC so I can parse it out here.  Also,
all of my disks (another plugin in contrib I wrote) are named like
STD_DISK or WEB_DISK so I can use that to find out what I'm actually
graphing.  You'll have to modify the if() series in the middle of the
script (lines 44-70) to match the style of service naming you use. 
Also, it's likely that if you're not using the plugins I wrote, you'll
have to modify (or rewrite your own) the functions at the bottom
(process_multi() and process_single()).

About those functions, you'll notice in the aforementioned if() tree
that $process_func gets assigned a subref in a couple places.  This is
how the script is told which style of processing to use on a input
source.  Hopefully, this should make it easy to extend the script to
handle a bunch of different perfdata outputs without modifying the core
logic (or illogic - you decide).  Basically, a plugin author could write
one subroutine to be plugged in (via require()?) to parse their
particular style of perfdata output.  Hopefully there won't be too many
styles to handle, but this script can handle them ;)

If you don't like all the subdirs, just erase the concatenations and
they won't get created. (i.e. $rrd_dir .= '/interfaces'; # delete this
line)

Here are some example command definitions I use:
; FILE: misccommands.cfg
define command {
	command_name	process-service-perfdata
    command_line    /opt/nagios/libexec/process_perfdata.pl $HOSTNAME$ $SERVICEDESC$ $LASTCHECK$ $PERFDATA$
}
define command {
	command_name	process-host-perfdata
    command_line    /opt/nagios/libexec/process_perfdata.pl $HOSTNAME$ HOSTCHECK $LASTCHECK$ $PERFDATA$
}

; FILE: checkcommands.cfg
; this disk command can check and return multiple disks at a time
define command {
    command_name    check_disk
    command_line    $USER1$/snmp_disk_monitor.pl -s -H $HOSTADDRESS$ -C $SNMPCOMMUNITY$ -m $ARG1$
}
; this will watch how much CPU and memory a process is using according to the host-resources MIB
define command {
    command_name    check_process_perf
    command_line    $USER1$/snmp_process_monitor.pl -t 60 --memory --cpu -s -H $HOSTADDRESS$ -C $SNMPCOMMUNITY$ -e $ARG1$
}


Have fun and send me any feedback you may have.
-Al Tobey
Unix Administrator
Priority Health Managed Benefits




********************************************************************
This email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity
to whom they are addressed.  If you have received this 
email in error please notify the Priority Health Information
Services Department at (616) 942-0954.
********************************************************************

-------------- next part --------------
A non-text attachment was scrubbed...
Name: process_perfdata.pl
Type: text/x-perl
Size: 6797 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/users/attachments/20021025/f7bb1a2d/attachment.pl>


More information about the Users mailing list