From sghosh at sghosh.org Tue Jul 2 07:00:55 2002 From: sghosh at sghosh.org (Subhendu Ghosh) Date: Tue Jul 2 07:00:55 2002 Subject: [Nagiosplug-devel] Re: [Nagios-users] nagios plugins, check_ping and slackeare 8.1 In-Reply-To: Message-ID: could you post the output of of the Slackware 8.1 ping and if possible post a patch to chack_ping.c -sg On Tue, 2 Jul 2002, Federico Lombardo wrote: > I wanna inform you that also configure of nagios plugins 1.0beta3) when try to identify ping syntax on a slackware 8.1 fails. > > I think that this problem must be solved > > > cheers. > > Federico. > > > -- From egopfe at hotmail.com Tue Jul 2 07:36:46 2002 From: egopfe at hotmail.com (Federico Lombardo) Date: Tue Jul 2 07:36:46 2002 Subject: [Nagiosplug-devel] Re: [Nagios-users] nagios plugins, check_ping and slackeare 8.1 References: Message-ID: root at tbox:/bin# ./ping usage: ping [-LRdfnqrv] [-c count] [-i wait] [-l preload] [-p pattern] [-s packetsize] [-t ttl] [-I interface address] host I'm trin' hard to make a patch, but I'm not a programmer... btw... I didn't want to be polemic... I only think that check_ping is the most important and reliable command of the program. ----- Original Message ----- From: "Subhendu Ghosh" To: "Federico Lombardo" Cc: ; "NagiosPlug Devel" Sent: Tuesday, July 02, 2002 3:53 PM Subject: Re: [Nagios-users] nagios plugins, check_ping and slackeare 8.1 > > > could you post the output of of the Slackware 8.1 ping > > and if possible post a patch to chack_ping.c > > -sg > > > On Tue, 2 Jul 2002, Federico Lombardo wrote: > > > I wanna inform you that also configure of nagios plugins 1.0beta3) when try to identify ping syntax on a slackware 8.1 fails. > > > > I think that this problem must be solved > > > > > > cheers. > > > > Federico. > > > > > > > > -- > From sghosh at sghosh.org Tue Jul 2 08:02:38 2002 From: sghosh at sghosh.org (Subhendu Ghosh) Date: Tue Jul 2 08:02:38 2002 Subject: [Nagiosplug-devel] Re: [Nagios-users] nagios plugins, check_ping and slackeare 8.1 In-Reply-To: Message-ID: On Tue, 2 Jul 2002, Federico Lombardo wrote: > root at tbox:/bin# ./ping > > usage: ping [-LRdfnqrv] [-c count] [-i wait] [-l preload] [-p pattern] [-s > packetsize] [-t ttl] [-I interface address] host could also you post the output of "ping -n -c 5 somehost" The above looks like it is already supported.. > > > > I'm trin' hard to make a patch, but I'm not a programmer... btw... I didn't > want to be polemic... I only think that check_ping is the most important and > reliable command of the program. > we understand, but if the os vendors keep changing the options and outout of ping, all we can do is keep up and fix as changes are reported. We don't have access to all flavors of OS releases.. > > > > > ----- Original Message ----- > From: "Subhendu Ghosh" > To: "Federico Lombardo" > Cc: ; "NagiosPlug Devel" > > Sent: Tuesday, July 02, 2002 3:53 PM > Subject: Re: [Nagios-users] nagios plugins, check_ping and slackeare 8.1 > > > > > > > > could you post the output of of the Slackware 8.1 ping > > > > and if possible post a patch to chack_ping.c > > > > -sg > > > > > > On Tue, 2 Jul 2002, Federico Lombardo wrote: > > > > > I wanna inform you that also configure of nagios plugins 1.0beta3) when > try to identify ping syntax on a slackware 8.1 fails. > > > > > > I think that this problem must be solved > > > > > > > > > cheers. > > > > > > Federico. > > > -- From jtytgat at websurg.com Thu Jul 4 00:54:06 2002 From: jtytgat at websurg.com (Jerome Tytgat) Date: Thu Jul 4 00:54:06 2002 Subject: [Nagiosplug-devel] New plugin contrib : check_procl - %CPU/%MEM/CPUTIME checks Message-ID: <007701c2232f$9c86a4e0$2601a8c0@websurg.fr> Hello, I've written a plugin for nagios in shell unix, I know it's dirty, maybe sometimes slow, especially on some commands (checking the %all% keyword, returning a sum of all process) but, i've developped this for the enterprise for which I'm working and it do a great job. Ok if this can go to the contrib directory, it's GPL of course. It has several functionnality : - can return the percentage of CPU used by a process - can return the percentage of Memory used by a process - can return the CPU time used by a process - can accumulate several process (ie : CPUTIME used by SMTP + DNS) - Have a MAX special feature : return the process which eat the max of CPU/MEM/CPUTIME - Have a ALL special feature : return the sum of all process - Have the possibility to exclude some process (usefull to ignore things like kapmd-idle for example) Bug known : - The Warning and Critical values are not checked enough to be really robust - I've seen something weird with the --mem switch, sometimes it can go higher that 100 %, can someone check the ps command and see if I'm wrong ? - The MAX feature does not calculate the cumumlative max of a process , but return the cumulative of the process : ex : % MEM command 20.7 SMTP 5.1 HTTPD 5.9 HTTPD 15.9 HTTPD The function return SMTP as the process which eat the more %MEM but it's HTTPD in real who eat the MAX... - The program can be very slow (shell loop problem) with the ALL keyword - Several problems with solaris... - The cputime format is not fixed size on solaris and may vary, I do not handle DAY for the moment. - The type command return error code 1 if we use SH (??!??), had to use BASH, so yes you need BASH - The let command does not exist under SH, had to use BASH, so yes you need BASH - The ps command format is really different from linux one, so I had to tweak it a lot... Dependencies : The program is based on these tools : - bash (let / test / type) - cut - egrep - expr - grep - ps - sed - sort - tail - tr - wc Greets goes to Websurg, for allowing me to program this during my work time (Of course it's for them, I've developped it...), and goes to Manu Feig and Jacques Kern, my beta testers and friends :) BTW : hail to the developpers of NAGIOS and NAGIOS plugins, GREAT job guys ! J?r?me Tytgat Network security Engineer @ Websurg.com mailto:j.tytgat at sioban.net / mailto:jtytgat at websurg.com -------------- next part -------------- A non-text attachment was scrubbed... Name: check_procl.sh Type: application/octet-stream Size: 12390 bytes Desc: not available URL: From jtytgat at websurg.com Thu Jul 4 23:48:02 2002 From: jtytgat at websurg.com (Jerome Tytgat) Date: Thu Jul 4 23:48:02 2002 Subject: [Nagiosplug-devel] New plugin contrib : check_procl - %CPU/%MEM/CPUTIME checks References: <007701c2232f$9c86a4e0$2601a8c0@websurg.fr> Message-ID: <003401c223ef$8922a460$2601a8c0@websurg.fr> For the one which are not on the mailing list : +-------------------------------------------- BEGIN CUT THERE -----------------------------------------+ #!/bin/bash # # Check_procl.sh # # Program: Process load check plugin for Nagios # License : GPL # Copyright (c) 2002 Jerome Tytgat (j.tytgat at sioban.net) # # check_procl.sh,v 1.1 2002/07/04 09:35 # # Description : # # This plugin is for check the %cpu, %mem or cputime of one or more process # # Usage : # # check_procl.sh -p process1,process2,... -w a.b -c c.d --cpu # check_procl.sh -p process1,process2,... -w a.b -c c.d --mem # check_procl.sh -p process1,process2,... -w a:b:c -c d:e:f --cputime # # check_procl.sh -p %all% -e process1,process2,... -w -c <--cpu | --mem | --cputime> # check_procl.sh -p %max% -e process1,process2,... -w -c <--cpu | --mem | --cputime> # # Example : # # To know the memory eaten by HTTPD processes, be warned when it reach 50% and be critical when it reach 75% # check_procl.sh -p httpd -w 50.0 -c 75.0 --mem # > OK - total %MEM for process httpd : 46.1 # # To know the process which eat the more cpu time, but as we are under linux and are using kapm we do : # check_procl.sh -p %max% -e kapmd-idle,kapmd -w 0:1:0 -c 0:2:0 --cputime # > CRITICAL - total CPUTIME for process named : 02:32:10 # # Tested on solaris 7/8, Linux Redhat 7.3 and Linux Suse 7.1 # # BUGS : problems with handling time on solaris... help_usage() { echo "Usage:" echo " $0 -p " echo " [-e ] -w warning -c critical < --cpu | --mem | --cputime>" echo " $0 (-v | --version)" echo " $0 (-h | --help)" } help_version() { echo "check_procl.sh (nagios-plugins) 1.1" echo "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute" echo "copies of the plugins under the terms of the GNU General Public License." echo "For more information about these matters, see the file named COPYING." echo "Copyright (c) 2002 Jerome Tytgat - j.tytgat at sioban.net" echo "Greetings goes to Websurg which kindly let me took time to develop this" echo " Manu Feig and Jacques Kern who were my beta testers, thanks to them !" } verify_dep() { needed="bash cut egrep expr grep let ps sed sort tail test tr wc" for i in `echo $needed` do type $i > /dev/null 2>&1 /dev/null if [ $? -eq 1 ] then echo "I am missing an important component : $i" echo "Cannot continue, sorry, try to find the missing one..." exit 3 fi done } myself=$0 verify_dep if [ "$1" = "-h" -o "$1" = "--help" ] then help_version echo "" echo "This plugin will check either the cumulutative %cpu, %mem or cputime" echo "of a process." echo "" help_usage echo "" echo "Required Arguments:" echo " -p, --process STRING1,STRING2,..." echo " names of the processes we want to monitor," echo " you can add as much as process as you want, separated by comma," echo " hey will be cumulated" echo " -p, --process %all%" echo " The special keyword %all% will check the cumulative cpu/mem/time of all process" echo " WARNING : Can be very slow on heavy loaded servers, watch your timeout !" echo " -p, --process %max%" echo " The special keyword %max% will check the process which eat the most" echo " WARNING : only select the process which eat the more, not the cumulative," echo " but return the cumulative" echo " -w, --warning INTEGER.INTEGER or INTERGER:INTEGER:INTEGER" echo " generate warning state if process count is outside this range" echo " -c, --critical INTEGER.INTEGER or INTERGER:INTEGER:INTEGER" echo " generate critical state if process count is outside this range" echo " --cpu" echo " return the current cpu usage for the given process" echo " --mem" echo " return the current memory usage for the given process" echo " --cputime" echo " return the total cputime usage for the given process" echo "" echo "Optional Argument:" echo " -e, --exclude-process STRING1,STRING2,..." echo " names of the processes we want don't want to monitor" echo " only useful when associated with %all% or %max% keywords, else ignored" echo " ex : kapm-idled on linux is a process which eat memory / cputime but not really... ;-)" echo "" exit 3 fi if [ "$1" = "-v" -o "$1" = "--version" ] then help_version exit 3 fi if [ `echo $@|tr "=" " "|wc -w` -lt 7 ] then echo "Bad arguments number (need at least 7)!" help_usage exit 3 fi tt=0 process_name="" exclude_process_name="" wt="" ct="" # Test of the command lines arguments while test $# -gt 0 do case "$1" in -p|--process) if [ -n "$process_name" ] then echo "Only one --process argument is useful..." help_usage exit 3 fi shift process_name="`echo $1|tr \",\" \"|\"`" ;; -e|--exclude-process) if [ -n "$exclude_process_name" ] then echo "Only one --exclude-process argument is useful..." help_usage exit 3 fi shift exclude_process_name="`echo $1|tr \",\" \"|\"`" ;; -w|--warning) if [ -n "$wt" ] then echo "Only one --warning argument needed... Trying to test bad things ? :-)" help_usage exit 3 fi shift wt=$1 ;; -c|--critical) if [ -n "$ct" ] then echo "Only one --critical argument needed... Trying to test bad things ? :-)" help_usage exit 3 fi shift ct=$1 ;; --cpu) if [ $tt -eq 0 ] then tt=1 else echo "Only one of the arguments --cpu/--mem/--cputime can be used at a time !" help_usage exit 3 fi type_arg_aff="%CPU" type_arg="pcpu" delim="." ;; --mem) if [ $tt -eq 0 ] then tt=2 else echo "Only one of the arguments --cpu/--mem/--cputime can be used at a time !" help_usage exit 3 fi type_arg_aff="%MEM" type_arg="pmem" delim="." ;; --cputime) if [ $tt -eq 0 ] then tt=3 else echo "Only one of the arguments --cpu/--mem/--cputime can be used at a time !" help_usage exit 3 fi type_arg_aff="TIME" type_arg="time" delim=":" ;; *) echo "Unknown argument $1" help_usage exit 3 ;; esac shift done # Is the process running ? if [ -z "`ps -e | egrep \"$process_name?\"`" -a "$process_name" != "%all%" -a "$process_name" != "%max%" ] then echo "WARNING: process $process_name not running !" exit 3 fi # Cut of warning and critical values wt_value1=`echo $wt|cut -d"$delim" -f1` wt_value2=`echo $wt|cut -d"$delim" -f2` ct_value1=`echo $ct|cut -d"$delim" -f1` ct_value2=`echo $ct|cut -d"$delim" -f2` if [ $tt -eq 3 ] then wt_value3=`echo $wt|cut -d"$delim" -f3` ct_value3=`echo $ct|cut -d"$delim" -f3` else wt_value3=0 ct_value3=0 fi # Integrity check of warning and critical values if [ -z "$wt_value1" -o -z "$wt_value2" -o -z "$wt_value3" ] then echo "Bad expression in the WARNING field : $wt" help_usage exit 3 fi if [ "`echo $wt_value1|tr -d \"[:digit:]\"`" != "" -o "`echo $wt_value2|tr -d \"[:digit:]\"`" != "" -o "`echo $wt_value3|tr -d \"[:digit:]\"`" != "" ] then echo "Bad expression in the WARNING field : $wt" help_usage exit 3 fi if [ -z "$ct_value1" -o -z "$ct_value2" -o -z "$ct_value3" ] then echo "Bad expression in the CRITICAL field : $ct" help_usage exit 3 fi if [ "`echo $ct_value1|tr -d \"[:digit:]\"`" != "" -o "`echo $ct_value2|tr -d \"[:digit:]\"`" != "" -o "`echo $ct_value3|tr -d \"[:digit:]\"`" != "" ] then echo "Bad expression in the CRITICAL field : $ct" help_usage exit 3 fi # ps line construction set... case "$process_name" in %all%) if [ -z "$exclude_process_name" ] then psline=`ps -eo $type_arg,comm|egrep -v "$myself|$type_arg_aff?"|sed "s/^ *\([0-9]\)/\1/"|cut -d" " -f1` else psline=`ps -eo $type_arg,comm|egrep -v "$myself|$type_arg_aff|$exclude_process_name?"|sed "s/^ *\([0-9]\)/\1/"|cut -d" " -f1` fi ;; %max%) if [ -z "$exclude_process_name" ] then pstmp=`ps -eo $type_arg,comm|egrep -v "$myself|$type_arg_aff?"|sort|tail -1|sed "s/^ *\([0-9]\)/\1/"|cut -d" " -f2` else pstmp=`ps -eo $type_arg,comm|egrep -v "$myself|$type_arg_aff|$exclude_process_name?"|sort|tail -1|sed "s/^ *\([0-9]\)/\1/"|cut -d" " -f2` fi psline=`ps -eo $type_arg,comm|grep $pstmp|sed "s/^ *\([0-9]\)/\1/"|cut -d" " -f1` process_name=$pstmp ;; *) psline=`ps -eo $type_arg,comm|egrep "$process_name?"|sed "s/^ *\([0-9]\)/\1/"|cut -d" " -f1` ;; esac total1=0 total2=0 total3=0 # fetching the values for i in $psline do # Special case for solaris - several format exist for the time function... if [ ${#i} -le 6 -a "$tt" -eq 3 ] then i="00:$i" fi value1=`echo $i|cut -d$delim -f1` value2=`echo $i|cut -d$delim -f2` value3=`echo $i|cut -d$delim -f3` value3=`test -z "$value3" && echo 0 || echo $value3` total1=`expr $total1 + $value1` total2=`expr $total2 + $value2` total3=`expr $total3 + $value3` if [ $tt -eq 3 ] then if [ $total3 -ge 60 ] then let total2+=1 let total3-=60 fi if [ $total2 -ge 60 ] then let total1+=1 let total2-=60 fi else if [ $total2 -ge 10 ] then let total1+=1 let total2=total2-10 fi fi done warn=0 crit=0 # evaluation of the cumulative values vs warning and critical values case "$tt" in 1) return_total="$total1.$total2" test $total1 -gt $ct_value1 && crit=1 test $total1 -eq $ct_value1 -a $total2 -ge $ct_value2 && crit=1 test $total1 -gt $wt_value1 && warn=1 test $total1 -eq $wt_value1 -a $total2 -ge $wt_value2 && warn=1 ;; 2) return_total="$total1.$total2" test $total1 -gt $ct_value1 && crit=1 test $total1 -eq $ct_value1 -a $total2 -ge $ct_value2 && crit=1 test $total1 -gt $wt_value1 && warn=1 test $total1 -eq $wt_value1 -a $total2 -ge $wt_value2 && warn=1 ;; 3) return_total="`test ${#total1} -eq 1 && echo 0`$total1:`test ${#total2} -eq 1 && echo 0`$total2:`test ${#total3} -eq 1 && echo 0`$total3" test $total1 -gt $ct_value1 && crit=1 test $total1 -eq $ct_value1 -a $total2 -gt $ct_value2 && crit=1 test $total1 -eq $ct_value1 -a $total2 -eq $ct_value2 -a $total3 -ge $ct_value3 && crit=1 test $total1 -gt $wt_value1 && warn=1 test $total1 -eq $wt_value1 -a $total2 -gt $wt_value2 && warn=1 test $total1 -eq $wt_value1 -a $total2 -eq $wt_value2 -a $total3 -ge $wt_value3 && warn=1 ;; esac # last check ... if [ $crit -eq 1 -a $warn -eq 0 ] then echo "Critical value must be greater than warning value !" help_usage exit 3 fi # Finally Inform Nagios of what we found... if [ $crit -eq 1 ] then echo "CRITICAL - total $type_arg_aff for process `echo $process_name|tr \"|\" \",\"` : $return_total" exit 2 elif [ $warn -eq 1 ] then echo "WARNING - total $type_arg_aff for process `echo $process_name|tr \"|\" \",\"` : $return_total" exit 1 else echo "OK - total $type_arg_aff for process `echo $process_name|tr \"|\" \",\"` : $return_total" exit 0 fi # Hey what are we doing here ??? exit 3 +-------------------------------------------- END CUT THERE -----------------------------------------+ J?r?me Tytgat Network security Engineer @ Websurg.com mailto:j.tytgat at sioban.net / mailto:jtytgat at websurg.com From cal at calevans.com Fri Jul 5 07:33:10 2002 From: cal at calevans.com (Cal Evans) Date: Fri Jul 5 07:33:10 2002 Subject: [Nagiosplug-devel] First Post - check_smb Message-ID: This is a script I put together to monitor samba. Since I already monitored the disk usage check_smb_disk wasn't of much use. So I put this one together. I hope it's useful to someone other than myself. Please be kind, it's my first nagios plugin. =C= * * Cal Evans * The Virtual CIO * http://www.calevans.com * --- #!/bin/bash # # Program : check_smb # : # Author : Cal Evans # : # Purpose : Nagios plugin to return the number of users logged into a smb # : server and the number of files open. # : # Parameters : --help # : --version # : # Returns : Standard Nagios status_* codes as defined in utils.sh # : # Notes : #============:============================================================== == # 1.0 : 06/27/2002 # : Initial coding # : # 1.1 : 06/28/2002 # : Re-wrote the user counter to match the file-lock counter. # : # # Shamelessly stolen from other Nagios plugins. # PROGNAME=`/usr/bin/basename $0` PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'` REVISION=`echo '$Revision: 1.1 $' | sed -e 's/[^0-9.]//g'` . $PROGPATH/utils.sh print_usage() { echo "Usage: $PROGNAME --help" echo "Usage: $PROGNAME --version" } print_help() { print_revision $PROGNAME $REVISION echo "" print_usage echo "" echo "Samba status check." echo "" support } # No command line arguments are required for this script. We accept only 2, # --help and --version. If more than 1 is passed in then we have an error # condition. if [ $# -gt 1 ]; then print_usage exit $STATE_UNKNOWN fi # # If we have arguments, process them. # exitstatus=$STATE_WARNING #default while test -n "$1"; do case "$1" in --help) print_help exit $STATE_OK ;; -h) print_help exit $STATE_OK ;; --version) print_revision $PROGNAME $REVISION exit $STATE_OK ;; -V) print_revision $PROGNAME $REVISION exit $STATE_OK ;; *) echo "Unknown argument: $1" print_usage exit $STATE_UNKNOWN ;; esac shift done # # No arguments. Let's kick this pig. # total_users=$(smbstatus -b | grep "^[0-9]" | wc -l) # # Ok, now let's grab a count of the files. # total_files=$(smbstatus | grep "^[0-9]" | wc -l) # # now for the dismount. # echo "Total Users:$total_users Total Files:$total_files" # # let Nagios know that everything is ok. # exit $STATE_OK From thom.berre at samlerhuset.no Sun Jul 7 12:17:12 2002 From: thom.berre at samlerhuset.no (Thom Berre) Date: Sun Jul 7 12:17:12 2002 Subject: [Nagiosplug-devel] RE: [Nagios-users] nagios plugins, check_ping and slackeare 8.1 Message-ID: <693E33DF086A0940925DB185A440BE8406E209@obelix.samlerhuset.no> Hi! I have the same problem on Slack 8.0. I have tried CVS, nagiosplug-1.3-beta1, netsaint-plugins-1.2.9-2 and netsaint-plugins-1.2.9-4. Here are some output: ---------------------------- ./configure checking for ping... /bin/ping configure: warning: unable to find usable ping syntax ./check_ping -H 10.0.0.3 -w 100,60% -c 200,100% You've got a big problem buddy! You need more args!!! (even tried ;-) ./check_ping -H 10.0.0.3 -w 100,60%% -c 200,100%% You've got a big problem buddy! You need more args!!! /bin/ping usage: ping [-LRdfnqrv] [-c count] [-i wait] [-l preload] [-p pattern] [-s packetsize] [-t ttl] [-I interface address] host /bin/ping -n -c 5 10.0.0.3 PING 10.0.0.3 (10.0.0.3): 56 octets data 64 octets from 10.0.0.3: icmp_seq=0 ttl=128 time=4.3 ms 64 octets from 10.0.0.3: icmp_seq=1 ttl=128 time=3.0 ms 64 octets from 10.0.0.3: icmp_seq=2 ttl=128 time=3.9 ms 64 octets from 10.0.0.3: icmp_seq=3 ttl=128 time=3.3 ms 64 octets from 10.0.0.3: icmp_seq=4 ttl=128 time=3.1 ms --- 10.0.0.3 ping statistics --- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 3.0/3.5/4.3 ms --------------------------- I'm unfortuneatly not able to read anything from the code as I'm no programmer. It it possible to get support for this flavour of ping? -- Best regards Thom Mikail Berre / IT / Samlerhuset -----Original Message----- From: Subhendu Ghosh [mailto:sghosh at sghosh.org] Sent: 2. juli 2002 16:45 To: nagios-users at lists.sourceforge.net Cc: NagiosPlug Devel Subject: Re: [Nagios-users] nagios plugins, check_ping and slackeare 8.1 On Tue, 2 Jul 2002, Federico Lombardo wrote: > root at tbox:/bin# ./ping > > usage: ping [-LRdfnqrv] [-c count] [-i wait] [-l preload] [-p pattern] > [-s packetsize] [-t ttl] [-I interface address] host could also you post the output of "ping -n -c 5 somehost" The above looks like it is already supported.. > > > > I'm trin' hard to make a patch, but I'm not a programmer... btw... I > didn't want to be polemic... I only think that check_ping is the most > important and reliable command of the program. > we understand, but if the os vendors keep changing the options and outout of ping, all we can do is keep up and fix as changes are reported. We don't have access to all flavors of OS releases.. > > > > > ----- Original Message ----- > From: "Subhendu Ghosh" > To: "Federico Lombardo" > Cc: ; "NagiosPlug Devel" > > Sent: Tuesday, July 02, 2002 3:53 PM > Subject: Re: [Nagios-users] nagios plugins, check_ping and slackeare > 8.1 > > > > > > > > could you post the output of of the Slackware 8.1 ping > > > > and if possible post a patch to chack_ping.c > > > > -sg > > > > > > On Tue, 2 Jul 2002, Federico Lombardo wrote: > > > > > I wanna inform you that also configure of nagios plugins 1.0beta3) > > > when > try to identify ping syntax on a slackware 8.1 fails. > > > > > > I think that this problem must be solved > > > > > > > > > cheers. > > > > > > Federico. > > > -- ------------------------------------------------------- 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 From mmchenry at origix.net Mon Jul 8 13:02:03 2002 From: mmchenry at origix.net (Mike McHenry) Date: Mon Jul 8 13:02:03 2002 Subject: [Nagiosplug-devel] RPMs available for nagios-plugins Message-ID: <494AA9CDA52E2A4885D158663B684FBF0CC317@server1.origix.net> Hello all, I have created some RPMS and SRPMS based on the original RPMS I created a long time ago for netsaint-plugins. Please find these files at the following location... ftp://development.origix.net/pub/SRPMS ftp://development.origix.net/pub/RPMS Mike McHenry -------------- next part -------------- An HTML attachment was scrubbed... URL: From sghosh at sghosh.org Wed Jul 10 22:42:02 2002 From: sghosh at sghosh.org (Subhendu Ghosh) Date: Wed Jul 10 22:42:02 2002 Subject: [Nagiosplug-devel] mostly working version Message-ID: Hi Alex Fixed the non-working HP code. Working code for standard Mib support with a warning being generated on alerts (that do not have power save or warming up on the display) Let me know how it is working... If you get a chance to look at RFC1759 mib - prtAlertLocation (%std_mib_alert_code in the program) has a bunch of predefined problem types. The mib also supports alert severity levels, but there seems to a different interpretation between HP and Xerox. HP return a "other" alert status and Xerox returns a "warning" status for Power Saver... I would think that only critical from the mib should be mapped to the critical plugin output. We need to be selective about the other/warning status and selectively go through the elements in %std_mib_alert_code and see what merits a warning plugin output. Copying it to the list to get some more feedback on the alrt levels. -- -sg -------------- next part -------------- #!/usr/local/bin/perl -w # check_snmp_printer - check for printer status via snmp # Supports both standard PRINT-MIB (RFC-1759) and HP Enterprise print-mib # that is supported by some of the older JetDirect interfaces # Acknowledgements: # the JetDirect code is taken from check_hpjd.c by Ethan Galstad # # The idea for the plugin (as well as some code) were taken from Jim # Trocki's pinter alert script in his "mon" utility, found at # http://www.kernel.org/software/mon # # Notes: # 'JetDirect' is copyrighted by Hewlett-Packard # # # License Information: # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ############################################################################ use POSIX; use strict; use Getopt::Long; use vars qw($opt_V $opt_h $opt_H $opt_P $opt_t $session $error $answer $key $response $PROGNAME $port $hostname ); use lib "."; use utils qw(%ERRORS &print_revision &support &usage ); use Net::SNMP; sub print_help (); sub print_usage (); $ENV{'PATH'}=''; $ENV{'BASH_ENV'}=''; $ENV{'ENV'}=''; # defaults my $ptype = 1; # to standard RFC printer type my $state = $ERRORS{'UNKNOWN'}; my $community = "public"; my $snmp_version = 1; my $port = 161; Getopt::Long::Configure('bundling'); GetOptions ("V" => \$opt_V, "version" => \$opt_V, "P=s" => \$opt_P, "Printer=s" => \$opt_P, # printer type - HP or RFC "v=i" => \$snmp_version, "snmp_version=i" => \$snmp_version, "p=i" => \$port, "port=i" => \$port, "C=s" => \$community,"community=s" => \$community, "h" => \$opt_h, "help" => \$opt_h, "H=s" => \$opt_H, "hostname=s" => \$opt_H); $PROGNAME = "check_snmp_printer"; if ($opt_V) { print_revision($PROGNAME,'$Revision: 1.1.1.1 $'); exit $ERRORS{'OK'}; } if ($opt_h) {print_help(); exit $ERRORS{'OK'};} unless (defined $opt_H) { print "No target hostname specified\n"; exit $ERRORS{"UNKNOWN"}; } $hostname = $opt_H; if (! utils::is_hostname($hostname)){ usage(" $hostname did not match pattern\n"); exit $ERRORS{"UNKNOWN"}; } if (defined $opt_P) { if ($opt_P eq "HP" ) { $ptype = 2; }elsif ($opt_P eq "RFC" ) { $ptype = 1; }else{ print "Only \"HP\" and \"RFC\" are supported as printer options at this time.\n"; exit $ERRORS{"UNKNOWN"}; } } if ( $snmp_version =~ /[12]/ ) { ($session, $error) = Net::SNMP->session( -hostname => $hostname, -community => $community, -port => $port, -version => $snmp_version ); if (!defined($session)) { $state='UNKNOWN'; $answer=$error; print ("$state: no session - $answer\n"); exit $ERRORS{$state}; } }elsif ( $snmp_version =~ /3/ ) { $state='UNKNOWN'; print ("$state: No support for SNMP v3 yet\n"); exit $ERRORS{$state}; }else{ $state='UNKNOWN'; print ("$state: No support for SNMP v$snmp_version yet\n"); exit $ERRORS{$state}; } ### main logic if ( $ptype == 1 ) { # STD MIB my %snmp_response; my $snmp_index; my $col_oid; my %std_mib_inst_count ; my %std_mib_instances; my $display; my $inst; my $group; #### RFC1759 MIB OIDS # sub-unit status - textual convention my $subunit_status; # integer from 0-126 # column oid - not instances my %std_mib = ( std_mib_input_status => ".1.3.6.1.2.1.43.8.2.1.11", # 2 element index std_mib_input_name => ".1.3.6.1.2.1.43.8.2.1.13", std_mib_output_remaining_capacity => ".1.3.6.1.2.1.43.9.2.1.5", std_mib_output_status => ".1.3.6.1.2.1.43.9.2.1.6", std_mib_marker_tech => ".1.3.6.1.2.1.43.10.2.1.2", std_mib_marker_status => ".1.3.6.1.2.1.43.10.2.1.15", std_mib_supplies_type => ".1.3.6.1.2.1.43.11.1.1.5", std_mib_supplies_level => ".1.3.6.1.2.1.43.11.1.1.9", std_mib_media_path_type => ".1.3.6.1.2.1.43.13.4.1.9", std_mib_media_path_status => ".1.3.6.1.2.1.43.13.4.1.11", std_mib_status_display => ".1.3.6.1.2.1.43.16.5.1.2", # 2 element index std_mib_alert_sev_level => ".1.3.6.1.2.1.43.18.1.1.2", std_mib_alert_grp => ".1.3.6.1.2.1.43.18.1.1.4", std_mib_alert_location => ".1.3.6.1.2.1.43.18.1.1.5", ); my %std_mib_alert_groups = ( 1 => "unspecifiedOther", 3 => "printerStorageMemory", # hostResourcesMIBStorageTable 4 => "internalDevice", # hostResourcesMIBDeviceTable 5 => "generalPrinter", 6 => "cover", 7 => "localization", 8 => "input", 9 => "output", 10 => "marker", 11 => "markerSupplies", 12 => "markerColorant", 13 => "mediaPath", 14 => "connectionChannel", 15 => "interpreter", 16 => "consoleDisplayBuffer", 17 => "consoleLights", ); my %std_mib_prt_alert_code = ( 1 => "other", # ok if on power save 2 => "unknown", # -- codes common to serveral groups 3 => "coverOpen", 4 => "coverClosed", 5 => "interlockOpen", 6 => "interlockClosed", 7 => "configurationChange", 8 => "jam", # critical # -- general Printer group 501 => "doorOpen", 502 => "doorClosed", 503 => "powerUp", 504 => "powerDown", # -- Input Group 801 => "inputMediaTrayMissing", 802 => "inputMediaSizeChange", 803 => "inputMediaWeightChange", 804 => "inputMediaTypeChange", 805 => "inputMediaColorChange", 806 => "inputMediaFormPartsChange", 807 => "inputMediaSupplyLow", 808 => "inputMediaSupplyEmpty", # -- Output Group 901 => "outputMediaTrayMissing", 902 => "outputMediaTrayAlmostFull", 903 => "outputMediaTrayFull", # -- Marker group 1001 => "markerFuserUnderTemperature", 1002 => "markerFuserOverTemperature", # -- Marker Supplies group 1101 => "markerTonerEmpty", 1102 => "markerInkEmpty", 1103 => "markerPrintRibbonEmpty", 1104 => "markerTonerAlmostEmpty", 1105 => "markerInkAlmostEmpty", 1106 => "markerPrintRibbonAlmostEmpty", 1107 => "markerWasteTonerReceptacleAlmostFull", 1108 => "markerWasteInkReceptacleAlmostFull", 1109 => "markerWasteTonerReceptacleFull", 1110 => "markerWasteInkReceptacleFull", 1111 => "markerOpcLifeAlmostOver", 1112 => "markerOpcLifeOver", 1113 => "markerDeveloperAlmostEmpty", 1114 => "markerDeveloperEmpty", # -- Media Path Device Group 1301 => "mediaPathMediaTrayMissing", 1302 => "mediaPathMediaTrayAlmostFull", 1303 => "mediaPathMediaTrayFull", # -- interpreter Group 1501 => "interpreterMemoryIncrease", 1502 => "interpreterMemoryDecrease", 1503 => "interpreterCartridgeAdded", 1504 => "interpreterCartridgeDeleted", 1505 => "interpreterResourceAdded", 1506 => "interpreterResourceDeleted", ); ## Need multiple passes as oids are all part of tables foreach $col_oid (keys %std_mib ){ if ( !defined( $response = $session->get_table($std_mib{$col_oid}) ) ) { if (! ($col_oid =~ m/std_mib_alert/ ) ) { # alerts don't have to exist all the time! $answer=$session->error; $session->close; $state = 'CRITICAL'; print ("$state: $answer for $std_mib{$col_oid}\n"); exit $ERRORS{$state}; } } foreach $key (keys %{$response}) { $key =~ /.*\.(\d+)\.(\d+)$/; # all oids have a two part index appended $snmp_index = $1 . "." . $2; #print "$key => $col_oid.$snmp_index = $response->{$key} \n"; $snmp_response{$key} = $response->{$key} ; $std_mib_inst_count{$col_oid} += 1 ; # count how many instances $std_mib_instances{$col_oid} .= ":" . $snmp_index; } } #foreach $key ( keys %std_mib_inst_count) { # print "$key = $std_mib_inst_count{$key} $std_mib_instances{$key} \n"; #} # combine all lines of status display into one line $std_mib_instances{'std_mib_status_display'} = substr($std_mib_instances{'std_mib_status_display'}, 1); my @display_index = split(/:/, $std_mib_instances{'std_mib_status_display'} ); foreach $inst (@display_index) { $display .= $snmp_response{$std_mib{'std_mib_status_display'} . "." . $inst} . " "; } # see if there are any alerts if (defined ( $std_mib_inst_count{'std_mib_alert_sev_level'} ) ) { if ( ( lc($display) =~ /save/ || lc($display) =~ /warm/ ) && $std_mib_inst_count{'std_mib_alert_sev_level'} == 1 ) { $state='OK'; $answer = "Printer ok - $display "; print $answer . "\n"; exit $ERRORS{$state}; } # sometime during transitions from power save to warming there are 2 alerts # if the 2nd alert is for something else it should get caught in the # next call since warmup typically is much smaller than check time # interval. if ( lc($display) =~ /warm/ && $std_mib_inst_count{'std_mib_alert_sev_level'} == 2 ) { $state='OK'; $answer = "Printer ok - $display "; print $answer . "\n"; exit $ERRORS{$state}; } # We have alerts and the display does not say power save or warming up $std_mib_instances{'std_mib_alert_sev_level'} = substr($std_mib_instances{'std_mib_alert_sev_level'}, 1); @display_index = split(/:/, $std_mib_instances{'std_mib_alert_sev_level'} ); $answer = "Alert location(s): "; for $inst (@display_index) { $state = 'WARNING'; if ( $snmp_response{$std_mib{'std_mib_alert_location'} . "." . $inst} < 1) { $answer .= "unknown location "; }else{ $answer .= $std_mib_prt_alert_code{$snmp_response{$std_mib{'std_mib_alert_location'} . "." . $inst} } . " "; #print $std_mib_prt_alert_code{$snmp_response{$std_mib{'std_mib_alert_location'}. "." . $inst}} ; } } print "$state: $answer \n"; exit $ERRORS{$state}; }else{ $state='OK'; $answer = "Printer ok - $display "; print $answer . "\n"; exit $ERRORS{$state}; } } elsif( $ptype == 2 ) { # HP MIB - JetDirect #### HP MIB OIDS - instance OIDs my $HPJD_LINE_STATUS= ".1.3.6.1.4.1.11.2.3.9.1.1.2.1.0"; my $HPJD_PAPER_STATUS= ".1.3.6.1.4.1.11.2.3.9.1.1.2.2.0"; my $HPJD_INTERVENTION_REQUIRED= ".1.3.6.1.4.1.11.2.3.9.1.1.2.3.0"; my $HPJD_GD_PERIPHERAL_ERROR= ".1.3.6.1.4.1.11.2.3.9.1.1.2.6.0"; my $HPJD_GD_PAPER_JAM= ".1.3.6.1.4.1.11.2.3.9.1.1.2.8.0"; my $HPJD_GD_PAPER_OUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.9.0"; my $HPJD_GD_TONER_LOW= ".1.3.6.1.4.1.11.2.3.9.1.1.2.10.0"; my $HPJD_GD_PAGE_PUNT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.11.0"; my $HPJD_GD_MEMORY_OUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.12.0"; my $HPJD_GD_DOOR_OPEN= ".1.3.6.1.4.1.11.2.3.9.1.1.2.17.0"; my $HPJD_GD_PAPER_OUTPUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.19.0"; my $HPJD_GD_STATUS_DISPLAY= ".1.3.6.1.4.1.11.2.3.9.1.1.3.0"; #define ONLINE 0 #define OFFLINE 1 my @hp_oids = ( $HPJD_LINE_STATUS,$HPJD_PAPER_STATUS,$HPJD_INTERVENTION_REQUIRED,$HPJD_GD_PERIPHERAL_ERROR, $HPJD_GD_PAPER_JAM,$HPJD_GD_PAPER_OUT,$HPJD_GD_TONER_LOW,$HPJD_GD_PAGE_PUNT,$HPJD_GD_MEMORY_OUT, $HPJD_GD_DOOR_OPEN,$HPJD_GD_PAPER_OUTPUT,$HPJD_GD_STATUS_DISPLAY); $state = $ERRORS{'OK'}; if (!defined($response = $session->get_request(@hp_oids))) { $answer=$session->error; $session->close; $state = 'CRITICAL'; print ("$state: $answer \n"); exit $ERRORS{$state}; } # cycle thru the responses and set the appropriate state if($response->{$HPJD_GD_PAPER_JAM} ) { $state='WARNING'; $answer = "Paper Jam"; } elsif($response->{$HPJD_GD_PAPER_OUT} ) { $state='WARNING'; $answer = "Out of Paper"; } elsif($response->{$HPJD_LINE_STATUS} ) { if ($response->{$HPJD_LINE_STATUS} ne "POWERSAVE ON" ) { $state='WARNING'; $answer = "Printer Offline"; } } elsif($response->{$HPJD_GD_PERIPHERAL_ERROR} ) { $state='WARNING'; $answer = "Peripheral Error"; } elsif($response->{$HPJD_INTERVENTION_REQUIRED} ) { $state='WARNING'; $answer = "Intervention Required"; } elsif($response->{$HPJD_GD_TONER_LOW} ) { $state='WARNING'; $answer = "Toner Low"; } elsif($response->{$HPJD_GD_MEMORY_OUT} ) { $state='WARNING'; $answer = "Insufficient Memory"; } elsif($response->{$HPJD_GD_DOOR_OPEN} ) { $state='WARNING'; $answer = "Insufficient Memory"; } elsif($response->{$HPJD_GD_PAPER_OUTPUT} ) { $state='WARNING'; $answer = "OutPut Tray is Full"; } elsif($response->{$HPJD_GD_PAGE_PUNT} ) { $state='WARNING'; $answer = "Data too slow for Engine"; } elsif($response->{$HPJD_PAPER_STATUS} ) { $state='WARNING'; $answer = "Unknown Paper Error"; } else # add code to parse STATUS DISPLAY here { $state='OK'; $answer = "Printer ok - $response->{$HPJD_GD_STATUS_DISPLAY} "; } # print and exit print "$state: $answer \n"; exit $ERRORS{$state}; } else{ # 3rd printer type - not yet supported print "Printer type $opt_P has not been implemented\n"; $state='UNKNOWN'; exit $ERRORS{$state}; } #### subroutines sub unit_status { my $stat = shift; } sub print_usage () { print "Usage: $PROGNAME -H [-C community] [-P HP or RFC] [-p port] [-v snmp_version] [-h help] [-V version]\n"; } sub print_help () { print_revision($PROGNAME,'$Revision: 1.1.1.1 $'); print "Copyright (c) 2002 Subhendu Ghosh/Ethan Galstad. This plugin reports the status of an network printer with an SNMP management module. "; print_usage(); print " -H, --hostname=HOST Name or IP address of host to check -C --community snmp community string (default: public) -P --Printer supported values are \"HP\" for Jetdirect printers and \"RFC\" for RFC 1759 Print MIB based implementations (default: RFC) -p --port Port where snmp agent is listening (default: 161) -v --snmp_version SNMP version to use (default: version 1) -h --help This screen -V --version Plugin version "; support(); } From daniel.geske at yoc.de Thu Jul 11 06:16:08 2002 From: daniel.geske at yoc.de (Daniel Geske) Date: Thu Jul 11 06:16:08 2002 Subject: [Nagiosplug-devel] nagios plugin written in sh Message-ID: Hi all, I am writing a shell script which ought to select a certain cell from a mysql database (specified in the parameter) and, if found, return OK/0, if not a CRITICAL/2. Now something really strange happens. I test the plugin on the command line, being the same user as the nagios process. Everything works fine. So I put the plugin command into my checkcommands.cfg and associate a service with it, wait... and now comes the surpise: mysql exits with a status 1 - not 0 as it should, even if it does NOT find the cell I'm asking for. Anybody ever had such problems? What can I do about this? TIA. Sincerely Daniel Geske -- Daniel Geske IT, YOC AG e-mail: daniel.geske at yoc.de From michaelm at kw.com Thu Jul 11 06:21:04 2002 From: michaelm at kw.com (Michael Marziani) Date: Thu Jul 11 06:21:04 2002 Subject: [Nagiosplug-devel] nagios plugin written in sh Message-ID: More info on this would be good. Could you forward the script to the list? -Michael ____________________________ Michael D. Marziani Sr. Systems Administrator Keller Williams Realty Int'l -----Original Message----- From: Daniel Geske [mailto:daniel.geske at yoc.de] Sent: Thursday, July 11, 2002 8:16 AM To: nagiosplug-devel at lists.sourceforge.net Subject: [Nagiosplug-devel] nagios plugin written in sh Hi all, I am writing a shell script which ought to select a certain cell from a mysql database (specified in the parameter) and, if found, return OK/0, if not a CRITICAL/2. Now something really strange happens. I test the plugin on the command line, being the same user as the nagios process. Everything works fine. So I put the plugin command into my checkcommands.cfg and associate a service with it, wait... and now comes the surpise: mysql exits with a status 1 - not 0 as it should, even if it does NOT find the cell I'm asking for. Anybody ever had such problems? What can I do about this? TIA. Sincerely Daniel Geske -- Daniel Geske IT, YOC AG e-mail: daniel.geske at yoc.de ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek PC Mods, Computing goodies, cases & more http://thinkgeek.com/sf _______________________________________________ Nagiosplug-devel mailing list Nagiosplug-devel at lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel From Tom.Bertelson at gecapital.com Thu Jul 11 06:23:04 2002 From: Tom.Bertelson at gecapital.com (Bertelson, Tom (CAP, CARD)) Date: Thu Jul 11 06:23:04 2002 Subject: [Nagiosplug-devel] nagios plugin written in sh Message-ID: <41BE560FEB5CD411AB0100D0B784C03901F49D34@EXC004GPTCCSGE> Carefully check your environment variables. This is the problem I run into most often. You may have things exported at the command line that the nagios daemon doesn't. -- Tom Bertelson "Any sufficiently advanced technology GE Card Services is indistinguishable from magic." Tom.Bertelson at gecapital.com -- Arthur C. Clarke -----Original Message----- From: Daniel Geske [mailto:daniel.geske at yoc.de] Sent: Thursday, July 11, 2002 9:16 AM To: nagiosplug-devel at lists.sourceforge.net Subject: [Nagiosplug-devel] nagios plugin written in sh Hi all, I am writing a shell script which ought to select a certain cell from a mysql database (specified in the parameter) and, if found, return OK/0, if not a CRITICAL/2. Now something really strange happens. I test the plugin on the command line, being the same user as the nagios process. Everything works fine. So I put the plugin command into my checkcommands.cfg and associate a service with it, wait... and now comes the surpise: mysql exits with a status 1 - not 0 as it should, even if it does NOT find the cell I'm asking for. Anybody ever had such problems? What can I do about this? From daniel.geske at yoc.de Thu Jul 11 07:08:09 2002 From: daniel.geske at yoc.de (Daniel Geske) Date: Thu Jul 11 07:08:09 2002 Subject: [Nagiosplug-devel] nagios plugin written in sh In-Reply-To: <41BE560FEB5CD411AB0100D0B784C03901F49D34@EXC004GPTCCSGE> Message-ID: > Carefully check your environment variables. This is the problem > I run into > most often. You may have things exported at the command line that the > nagios daemon doesn't. > -- > Tom Bertelson I don't think I use any env variables. > More info on this would be good. Could you forward the script to the > list? > > -Michael Sure can. Just have to add some explanations. I actually tried to make things simple by writing about selecting a cell. It's not really like that. I have scripts running on several servers in my location. All scripts send some kind of "Hi, I'm alive" into my local database by updating a row "last_updated" to now(). This shell script compares now() and last_updated and if this time is longer than waring_period it sends WARNING, if longer than critical_period it sends CRITICAL. If it does not find the $script running on $hostname, both specified as parameters of the script, it returns UNKNOWN. If started by nagios, the script always returns UNKNOWN. I did some checking for over 2 hours now and found that the mysql command causes the problem. Like I said, when I start the shell from a terminal (of course I did su to nagios user first) it runs all right, but in the one nagios starts mysql selects NULL and exits with 1. Maybe it doesn't get to do the SELECT and that's why it is NULL. But why would it work for me on the shell then? No ideas. I'd be really happy if you guys have any and let me know. Thanks for taking the time. Here comes the shell script working on my SuSE Linux 7.3 box: #!/bin/sh # syntax: check_yocScripts