From b15adb7762b6caaecaa83637abfcf5fdb4802092 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Mon, 2 Sep 2013 13:16:24 +0200 Subject: Remove "contrib" plugins These days, sites such as "Nagios Exchange" are a much better place for publishing plugins not maintained by the Plugins Development Team. --- Makefile.am | 2 +- contrib-reporting/process_perfdata.pl | 193 -------- contrib/README.TXT | 56 --- contrib/aix/check_failed | 48 -- contrib/aix/check_io | 69 --- contrib/aix/check_kerberos | 49 -- contrib/aix/check_queue | 67 --- contrib/aix/pg_stat | 45 -- contrib/check_adptraid.sh | 75 --- contrib/check_apache.pl | 283 ----------- contrib/check_apc_ups.pl | 307 ------------ contrib/check_appletalk.pl | 210 -------- contrib/check_arping.pl | 120 ----- contrib/check_asterisk.pl | 259 ---------- contrib/check_axis.sh | 95 ---- contrib/check_backup.pl | 114 ----- contrib/check_bgpstate.pl | 215 --------- contrib/check_breeze.pl | 22 - contrib/check_cluster.c | 332 ------------- contrib/check_cluster2.README | 5 - contrib/check_cluster2.c | 232 --------- contrib/check_compaq_insight.pl | 296 ------------ contrib/check_cpqarray.c | 430 ----------------- contrib/check_digitemp.pl | 252 ---------- contrib/check_dlswcircuit.pl | 221 --------- contrib/check_dns_random.pl | 74 --- contrib/check_email_loop.pl | 309 ------------ contrib/check_fan_cpq_present | 133 ----- contrib/check_fan_fsc_present | 135 ------ contrib/check_flexlm.pl | 82 ---- contrib/check_frontpage | 151 ------ contrib/check_hltherm.c | 209 -------- contrib/check_hprsc.pl | 221 --------- contrib/check_hw.sh | 66 --- contrib/check_ica_master_browser.pl | 228 --------- contrib/check_ica_metaframe_pub_apps.pl | 381 --------------- contrib/check_ica_program_neigbourhood.pl | 618 ------------------------ contrib/check_inodes-freebsd.pl | 127 ----- contrib/check_inodes.pl | 69 --- contrib/check_ipxping.c | 201 -------- contrib/check_javaproc.pl | 278 ----------- contrib/check_joy.sh | 69 --- contrib/check_linux_raid.pl | 125 ----- contrib/check_lmmon.pl | 19 - contrib/check_log2.pl | 202 -------- contrib/check_lotus.pl | 260 ---------- contrib/check_maxchannels.pl | 231 --------- contrib/check_maxwanstate.pl | 201 -------- contrib/check_mem.pl | 146 ------ contrib/check_ms_spooler.pl | 324 ------------- contrib/check_mssql.sh | 104 ---- contrib/check_nagios.pl | 48 -- contrib/check_nagios_db.pl | 89 ---- contrib/check_nagios_db_pg.pl | 91 ---- contrib/check_netapp.pl | 178 ------- contrib/check_nmap.py | 441 ----------------- contrib/check_ora_table_space.pl | 82 ---- contrib/check_oracle_instance.pl | 470 ------------------ contrib/check_oracle_tbs | 218 --------- contrib/check_pcpmetric.py | 106 ---- contrib/check_pfstate | 75 --- contrib/check_qmailq.pl | 121 ----- contrib/check_rbl.c | 328 ------------- contrib/check_remote_nagios_status.pl | 666 -------------------------- contrib/check_rrd_data.pl | 129 ----- contrib/check_sap.sh | 89 ---- contrib/check_smart.pl | 180 ------- contrib/check_smb.sh | 111 ----- contrib/check_snmp_disk_monitor.pl | 185 ------- contrib/check_snmp_printer.pl | 605 ----------------------- contrib/check_snmp_process_monitor.pl | 331 ------------- contrib/check_snmp_procs.pl | 590 ----------------------- contrib/check_sockets.pl | 145 ------ contrib/check_temp_cpq | 162 ------- contrib/check_temp_fsc | 160 ------- contrib/check_timeout.c | 55 --- contrib/check_traceroute-pure_perl.pl | 119 ----- contrib/check_traceroute.pl | 209 -------- contrib/check_uptime.c | 99 ---- contrib/check_vcs.pl | 165 ------- contrib/check_wave.pl | 77 --- contrib/check_wins.pl | 247 ---------- contrib/checkciscotemp.pl | 166 ------- contrib/mrtgext.pl | 291 ----------- contrib/nagios_sendim.pl | 66 --- contrib/packet_utils.pm | 119 ----- contrib/rblcheck-dns | 69 --- contrib/rblcheck-web | 37 -- contrib/restrict.pl | 26 - contrib/sched_downtime.pl | 47 -- contrib/tarballs/bowen-langley_plugins.tar.gz | Bin 28742 -> 0 bytes contrib/tarballs/check_bgp-1.0.tar.gz | Bin 1469 -> 0 bytes contrib/tarballs/check_radius.tar.gz | Bin 25190 -> 0 bytes contrib/tarballs/check_traffic-0.91b.tar.gz | Bin 12198 -> 0 bytes contrib/tarballs/fetchlog-0.94.tar.gz | Bin 23179 -> 0 bytes contrib/urlize.pl | 29 -- contrib/utils.py | 310 ------------ 97 files changed, 1 insertion(+), 16690 deletions(-) delete mode 100644 contrib-reporting/process_perfdata.pl delete mode 100644 contrib/README.TXT delete mode 100644 contrib/aix/check_failed delete mode 100644 contrib/aix/check_io delete mode 100644 contrib/aix/check_kerberos delete mode 100644 contrib/aix/check_queue delete mode 100644 contrib/aix/pg_stat delete mode 100644 contrib/check_adptraid.sh delete mode 100644 contrib/check_apache.pl delete mode 100644 contrib/check_apc_ups.pl delete mode 100644 contrib/check_appletalk.pl delete mode 100644 contrib/check_arping.pl delete mode 100644 contrib/check_asterisk.pl delete mode 100644 contrib/check_axis.sh delete mode 100644 contrib/check_backup.pl delete mode 100644 contrib/check_bgpstate.pl delete mode 100644 contrib/check_breeze.pl delete mode 100644 contrib/check_cluster.c delete mode 100644 contrib/check_cluster2.README delete mode 100644 contrib/check_cluster2.c delete mode 100644 contrib/check_compaq_insight.pl delete mode 100644 contrib/check_cpqarray.c delete mode 100755 contrib/check_digitemp.pl delete mode 100755 contrib/check_dlswcircuit.pl delete mode 100644 contrib/check_dns_random.pl delete mode 100644 contrib/check_email_loop.pl delete mode 100644 contrib/check_fan_cpq_present delete mode 100644 contrib/check_fan_fsc_present delete mode 100644 contrib/check_flexlm.pl delete mode 100644 contrib/check_frontpage delete mode 100644 contrib/check_hltherm.c delete mode 100755 contrib/check_hprsc.pl delete mode 100644 contrib/check_hw.sh delete mode 100755 contrib/check_ica_master_browser.pl delete mode 100755 contrib/check_ica_metaframe_pub_apps.pl delete mode 100755 contrib/check_ica_program_neigbourhood.pl delete mode 100644 contrib/check_inodes-freebsd.pl delete mode 100755 contrib/check_inodes.pl delete mode 100644 contrib/check_ipxping.c delete mode 100644 contrib/check_javaproc.pl delete mode 100755 contrib/check_joy.sh delete mode 100644 contrib/check_linux_raid.pl delete mode 100644 contrib/check_lmmon.pl delete mode 100644 contrib/check_log2.pl delete mode 100755 contrib/check_lotus.pl delete mode 100644 contrib/check_maxchannels.pl delete mode 100644 contrib/check_maxwanstate.pl delete mode 100644 contrib/check_mem.pl delete mode 100755 contrib/check_ms_spooler.pl delete mode 100755 contrib/check_mssql.sh delete mode 100644 contrib/check_nagios.pl delete mode 100644 contrib/check_nagios_db.pl delete mode 100644 contrib/check_nagios_db_pg.pl delete mode 100755 contrib/check_netapp.pl delete mode 100644 contrib/check_nmap.py delete mode 100644 contrib/check_ora_table_space.pl delete mode 100644 contrib/check_oracle_instance.pl delete mode 100644 contrib/check_oracle_tbs delete mode 100644 contrib/check_pcpmetric.py delete mode 100644 contrib/check_pfstate delete mode 100755 contrib/check_qmailq.pl delete mode 100644 contrib/check_rbl.c delete mode 100644 contrib/check_remote_nagios_status.pl delete mode 100644 contrib/check_rrd_data.pl delete mode 100755 contrib/check_sap.sh delete mode 100644 contrib/check_smart.pl delete mode 100644 contrib/check_smb.sh delete mode 100644 contrib/check_snmp_disk_monitor.pl delete mode 100755 contrib/check_snmp_printer.pl delete mode 100644 contrib/check_snmp_process_monitor.pl delete mode 100644 contrib/check_snmp_procs.pl delete mode 100644 contrib/check_sockets.pl delete mode 100644 contrib/check_temp_cpq delete mode 100644 contrib/check_temp_fsc delete mode 100644 contrib/check_timeout.c delete mode 100644 contrib/check_traceroute-pure_perl.pl delete mode 100755 contrib/check_traceroute.pl delete mode 100644 contrib/check_uptime.c delete mode 100644 contrib/check_vcs.pl delete mode 100644 contrib/check_wave.pl delete mode 100755 contrib/check_wins.pl delete mode 100644 contrib/checkciscotemp.pl delete mode 100644 contrib/mrtgext.pl delete mode 100644 contrib/nagios_sendim.pl delete mode 100755 contrib/packet_utils.pm delete mode 100755 contrib/rblcheck-dns delete mode 100755 contrib/rblcheck-web delete mode 100755 contrib/restrict.pl delete mode 100644 contrib/sched_downtime.pl delete mode 100644 contrib/tarballs/bowen-langley_plugins.tar.gz delete mode 100644 contrib/tarballs/check_bgp-1.0.tar.gz delete mode 100644 contrib/tarballs/check_radius.tar.gz delete mode 100644 contrib/tarballs/check_traffic-0.91b.tar.gz delete mode 100644 contrib/tarballs/fetchlog-0.94.tar.gz delete mode 100644 contrib/urlize.pl delete mode 100644 contrib/utils.py diff --git a/Makefile.am b/Makefile.am index cbca5d77..aae8ec9b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@ EXTRA_DIST = config.rpath \ ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS BUGS CODING FAQ LEGAL NEWS \ NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \ - NPTest.pm contrib pkg nagios-plugins.spec \ + NPTest.pm pkg nagios-plugins.spec \ config_test/Makefile config_test/run_tests config_test/child_test.c \ perlmods tools/build_perl_modules \ tools/tinderbox_build diff --git a/contrib-reporting/process_perfdata.pl b/contrib-reporting/process_perfdata.pl deleted file mode 100644 index c97d4832..00000000 --- a/contrib-reporting/process_perfdata.pl +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/local/bin/perl -w -# author: Al Tobey -# what: process perfdata from Nagios and put it into RRD files -# license: GPL - http://www.fsf.org/licenses/gpl.txt -# -# Todo: -# * more documentation (POD) & comments -# * clean up a bit, make it more configurable - possibly a config file - -use strict; -use lib qw( /opt/nagios/libexec ); -use utils qw( %ERRORS ); -use vars qw( $debug_file %data $debug $rrd_base $process_func $rrd_type ); -use RRDs; -$debug_file = undef; #"/var/opt/nagios/perfdata.out"; -$rrd_base = '/var/opt/nagios/rrds'; -$process_func = \&process_multi; -$rrd_type = 'GAUGE'; -$data{hostname} = shift(@ARGV); -$data{metric} = shift(@ARGV); -$data{timestamp} = shift(@ARGV); -$data{perfdata} = join( " ", @ARGV ); $data{perfdata} =~ s/\s+/ /g; - -# make sure there's data to work with -exit $ERRORS{OK} if ( !defined($data{hostname}) || !defined($data{metric}) - || !defined($data{timestamp}) || !defined($data{perfdata}) - || $data{perfdata} eq ' ' || $data{perfdata} eq '' ); - -if ( defined($debug_file) ) { - open( LOGFILE, ">>$debug_file" ); - print LOGFILE "$data{hostname}\t$data{metric}\t$data{timestamp}\t$data{perfdata}\n\n"; -} - -# make sure host directory exists -if ( !-d "$rrd_base/$data{hostname}" ) { - mkdir( "$rrd_base/$data{hostname}" ) - || warn "could not create host directory $rrd_base/$data{hostname}: $!"; -} -our $rrd_dir = $rrd_base .'/'. $data{hostname}; - -# --------------------------------------------------------------------------- # -# do some setup based on the name of the metric - -# host data -if ( $data{metric} eq "HOSTCHECK" ) { - $rrd_dir .= '/hostperf'; -} -# processing disk information -elsif ( $data{metric} =~ /_DISK$/ ) { - $rrd_dir .= '/disk'; -} -# network interface information -elsif ( $data{metric} =~ /^IFACE_/ ) { - $rrd_dir .= '/interfaces'; - $rrd_type = [ 'COUNTER', 'COUNTER' ]; -} -# process performance statistics -elsif ( $data{metric} =~ /_PROC$/ ) { - $rrd_dir .= '/processes'; - $process_func = \&process_single; - $rrd_type = [ 'COUNTER', 'GAUGE' ]; -} -# a resonable guess -elsif ( $data{perfdata} =~ /=/ ) { - $process_func = \&process_single; -} -# everything else -else { - $rrd_dir .= '/other'; -} - -# --------------------------------------------------------------------------- # -# call the proper processing function set up above (functions defined below) -our @processed = ( $process_func->() ); - -# --------------------------------------------------------------------------- # - -if ( !-d $rrd_dir ) { - mkdir( $rrd_dir ) || warn "could not mkdir( $rrd_dir ): $!"; -} -foreach my $datum ( @processed ) { - if ( defined($debug_file) ) { - print LOGFILE $datum->{rrd_name}, " = ", join('--',@{$datum->{data}}), "\n" - } - - my $rrdfile = $rrd_dir.'/'.$datum->{rrd_name}; - - # create the RRD file if it doesn't already exist - if ( !-e $rrdfile ) { - # create a non-useful datasource title for each "part" - RRDs::create( $rrdfile, "-b", $data{timestamp}, "-s", 300, $process_func->($datum, 1), - "RRA:AVERAGE:0.5:1:600", - "RRA:MAX:0.5:1:600", - "RRA:AVERAGE:0.5:6:600", - "RRA:MAX:0.5:6:600", - "RRA:AVERAGE:0.5:24:600", - "RRA:MAX:0.5:24:600", - "RRA:AVERAGE:0.5:288:600", - "RRA:MAX:0.5:288:600" - ); - if ( my $ERROR = RRDs::error ) { print "ERROR: $ERROR\n"; exit $ERRORS{UNKNOWN}; } - } - else { - # create a template to make sure data goes into the RRD as planned - if ( defined($debug_file) ) { - print LOGFILE "updating $rrdfile with data:\n\t", - join(':', $data{timestamp}, @{$datum->{data}}), "\n"; - } - # update the RRD file - RRDs::update( $rrdfile, '-t', $process_func->($datum), - join(':', $data{timestamp}, @{$datum->{data}}) ); - if ( my $ERROR = RRDs::error ) { print "ERROR: $ERROR\n"; exit $ERRORS{UNKNOWN}; } - } -} - -# --------------------------------------------------------------------------- # - -if ( defined($debug_file) ) { - print LOGFILE "-------------------------------------------------------------------------------\n"; - close( LOGFILE ); -} - -exit $ERRORS{OK}; - -# /opt=value,value,value:/=value,value,value - into multiple rrd's -sub process_multi { - my( $datum, $create ) = @_; - - # return a string for creating new RRDs - if ( defined($create) && $create == 1 ) { - my @DS = (); - for ( my $i=0; $i{data}}); $i++ ) { - # allow the RRD type to be set in the switch/if above - my $tmp_rrd_type = $rrd_type; - if ( ref($rrd_type) eq 'ARRAY' ) { $tmp_rrd_type = $rrd_type->[$i] } - # put the new datasource into the list - push( @DS, "DS:$data{metric}$i:GAUGE:86400:U:U" ); - } - return @DS; - } - # return a template for updating an RRD - elsif ( defined($datum) && !defined($create) ) { - my @template = (); - for ( my $i=0; $i{data}}); $i++ ) { - push( @template, $data{metric}.$i ); - } - return join( ':', @template ); - } - # break the data up into parts for processing (updates and creates) - else { - my @processed = (); - foreach my $part ( split(/:/, $data{perfdata}) ) { # break the line into parts - my @parts = split( /,/, $part ); # break the part into parts - my $rrd_name = $parts[0]; # figure out a good name for the RRD - if ( $parts[0] =~ /^\// ) { # handle /'s in disk names - $rrd_name = $parts[0]; - $rrd_name =~ s#/#_#g; $rrd_name =~ s/^_//; $rrd_name =~ s/_$//; - if ( $parts[0] eq '/' ) { $rrd_name = 'root' }; - } - # store our munged data in an array of hashes - push( @processed, { rrd_name => $rrd_name, name => shift(@parts), data => [ @parts ] } ); - } - return @processed; - } -} - -# name=value:name=value - into one rrd -sub process_single { - my( $datum, $create ) = @_; - - my( @names, @values ) = (); - foreach my $part ( split(/:/, $data{perfdata}) ) { - my( $name, $value ) = split( /=/, $part ); - push( @names, $name ); - push( @values, $value ); - } - - if ( defined($create) && $create == 1 ) { - my @DS = (); - for( my $i=0; $i[$i] } - push( @DS, 'DS:'.$names[$i].":$tmp_rrd_type:86400:U:U" ); - } - return @DS; - } - elsif ( defined($datum) && !defined($create) ) { - return join( ':', @names ); - } - else { - return( {rrd_name=>lc($data{metric}), name=>$data{metric}, data=>[@values]} ); - } -} diff --git a/contrib/README.TXT b/contrib/README.TXT deleted file mode 100644 index bd9df3c4..00000000 --- a/contrib/README.TXT +++ /dev/null @@ -1,56 +0,0 @@ -Contrib Plugins README ----------------------- - -This directory contains plugins which have been contributed by various people, but that -have not yet been incorporated into the core plugins distribution. - -Most Perl plugins should work without modification. Some of the C plugins may require -a few tweaks to compile. - -If you have questions regarding the use of these plugins, try contacting the author(s) -or post a message to the nagiosplug-help mailing list (nagiosplug-help@lists.sourceforge.net) -requesting assistance. - - - -Contrib Tarballs ----------------- - -In addition to the plugins located in this directory, there are some additional tarballs -containing plugins in the tarballs/ subdirectory. They have not yet been organized. -A brief description of their contents follows. - - -berger-ping.tar.gz - Perl script version of the check_ping plugin and a corresponding - CGI (mtr.cgi) that uses mtr to traceroute a path to a host. - (Gary Berger) - -bowen-langley_plugins.tar.gz - - Several C plugins including check_inode, check_boot, etc. - (Adam Bown & Thomas Langley) - - -check_bgp-1.0.tar.gz - Perl script intended for monitoring BGP sessions on Cisco routers. - Uses Net::Telnet to telnet into a cisco router and - run "sh ip bgp" - -check_memory.tgz - C plugin to check available system memory - -check_radius.tar.gz - C program to check RADIUS authentication. This is a hacked version of - the Cistron Radiusd program radtest that acts as a plugin for Nagios. - The vast majority of the code was written by someone at Livingston - Enterprises and Cistron. NOTE: Due to the copyright restrictions in - this code, it cannot be distributed under the GPL license, and thus - will not appear in the core plugin distribution! - (Adam Jacob) - -radius.tar.gz - Code modifications necessary to make the radexample app - supplied with the radiusclient code work as a RADIUS plugin - for Nagios (Nick Shore) - -fetchlog-0.94.tar.gz - C program: The fetchlog utility displays the last new messages of a - logfile. It is similar like tail(1) but offers some extra functionality - for output formatting. fetchlog can be used standalone or as a Nagios - plugin to monitor local logfiles or together with Net-SNMP to monitor - remote logfiles. The README shows how to setup fetchlog for Nagios. - (Alexander Haderer) diff --git a/contrib/aix/check_failed b/contrib/aix/check_failed deleted file mode 100644 index 50cdf7e1..00000000 --- a/contrib/aix/check_failed +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/perl -#====================== -# Created May 25, 2000 -#====================== - -# This scripts is for checking for failed root login attempts on -# any machine running AIX which has a failedlogin file in /etc/security -# The purpose is to thwart (good word) any unauthorised people from -# even trying to log in as root. This plugin has been developed for Nagios -# running on AIX. -# Lonny Selinger SpEnTBoY lonny@abyss.za.org -# May - - -my $server = $ARGV[0]; - -if (!$ARGV[0]) { - print "You must specify a server to check\n"; - print "usage: ./check_failed \n"; - exit (-1); - } else { - open (DATE, "/bin/date '+%b %d' |"); - while () { - $dline = $_; - @dresults = $dline; - chop $dresults[0]; - } - open (SULOG, "rsh $server -l root who /etc/security/failedlogin | grep root |"); - while () { - $line = $_; - @results = split (/\s+/,$line); - if ($line =~ /^root/) { - if (join(' ', @results[2,3]) eq $dresults[0]) { - print "FAILED root login on $dresults[0], node: $ARGV[0] from $results[5]\n"; - exit(2); - } - } - } -} -if (join(' ', @results[2,3]) ne $dresults[0]) { - print "No Failed Root Logins on This Node\n"; - exit(0); -} -exit(0); -close(SULOG); -close(DATE); - - diff --git a/contrib/aix/check_io b/contrib/aix/check_io deleted file mode 100644 index 58b25f6d..00000000 --- a/contrib/aix/check_io +++ /dev/null @@ -1,69 +0,0 @@ -#! /bin/sh - -#================================================================= -# -# I/O Checker (KBPS) -# This Script uses iostat to monitor disk io -# Useful for notifications of disk thrashing. -# -# Authors: TheRocker -# SpEnTBoY -# -# Email: therocker@pawprints.2y.net -# lonny@abyss.za.org -# -#================================================================ - -NUMBER1=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c1 | line` -NUMBER2=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c2 | line` -TMPFILE=/tmp/iotest.hndl -TMPTOO=/tmp/iotwo.hndl - -#=========================================================== -# -# We do an evaluation on $NUMBER1 and $NUMBER2 to see if -# disk io is exceeding 40%. -# -#=========================================================== - -if [ "$NUMBER1" -gt 4 ] && [ "$NUMBER2" -gt 0 ] -then - - `rsh $1 -l root iostat -d | grep -v cd0 | tr -s ' '| cut -d' ' -f1,2 | grep -e "4[0-9]." >> $TMPFILE` - -#==================================================================== -# -# Of course, there may be more than one hard disk on the node -# so we use this bit of code to report on more than one instance -# of excessive disk IO. -# -#==================================================================== - - LINES=`wc -l /tmp/iotest.hndl | cut -c8` - LINESCTL=`wc -l /tmp/iotest.hndl | cut -c8 ` - echo "WARNING!!! Disk I/O Exceeding 40% on --> \c" - - while [ $LINESCTL != 0 ] - do - - cat $TMPFILE | tail -$LINESCTL > $TMPTOO - cat $TMPTOO > $TMPFILE - LINESCTL=$(( $LINESCTL -1 )) - LINES=$(( $LINES -1 )) - DATA=`head -1 /tmp/iotest.hndl` - echo "( $DATA ) " - - - done - echo "\n" - - rm -f $TMPFILE - rm -f $TMPTOO - exit 1 - -else - - print "No Disk I/O Exceeding 40%...OK" - exit 0 - -fi diff --git a/contrib/aix/check_kerberos b/contrib/aix/check_kerberos deleted file mode 100644 index 443ab109..00000000 --- a/contrib/aix/check_kerberos +++ /dev/null @@ -1,49 +0,0 @@ -#! /bin/sh - -#========================================================================= -# Kerberos Ticket Checker -# -# This script is handy if you allow kerberos tickets to expire -# on your nodes. The script will simply warn you when a node has -# kerberos tickets expiring on the current date. This will allow to -# re-initialize the tickets if you wish to do so. -# -# Nothing fancy here, all Nagios will show is the number of tickets -# that are going to (or already have) expired. -# -# An item of note: -# -# We made no provisions for the weekend. If tickets expire on the -# weekend and nobody is around, you won't see a warning on the -# Nagios console because we look for expired on the current day -# only. It's a good idea to have this warning emailed to the -# appropriate admin and if there is something critical that relies -# on Kerberos, you might want to send a page. -# -# Authors: TheRocker -# SpEnTBoY -# -# Email: therocker@pawprints.2y.net -# lonny@abyss.za.org -#========================================================================= - -TMPFILE=/tmp/kerbtmp.hndl -DATE=`date +%b' '%d` - -rsh $1 -l root /usr/lpp/ssp/kerberos/bin/klist | tr -s ' ' | cut -d' ' -f4,5,6 | grep -e "$DATE" > $TMPFILE - - -if [ -s $TMPFILE ] -then - - LINES=`wc -l /tmp/kerbtmp.hndl | cut -c7-8` - echo "Kerberos Tickets set to expire --> \c" - echo "$LINES \c" - echo "\n" - - rm -f $TMPFILE - exit 1 - -fi - echo "Kerberos Tickets are valid" - exit 0 diff --git a/contrib/aix/check_queue b/contrib/aix/check_queue deleted file mode 100644 index 9f709c54..00000000 --- a/contrib/aix/check_queue +++ /dev/null @@ -1,67 +0,0 @@ -#! /bin/sh - -#=============================================================== -# Print Queue Checker -# -# The print queue checker simply looks for an occurance of a -# DOWN queue. A note of warning, if you use remote queues in -# AIX to redirect print jobs from the AIX queue to an NT print -# server that print through DLC rather than IP, it will be very -# s - l - o - w. But it will work. -# -# Author: TheRocker -# Email: therocker@pawprints.2y.net -#=============================================================== - -TMPFILE=/tmp/qtmp.hndl -TMPTOO=/tmp/qtwo.hndl - -#======================================================================= -# -# This script will also work on AIX 4.2.1 BUT you have to change -# the following line. AIX 4.2.1 does not support the -W option -# with lpstat. For AIX 4.2.1 just remove the -W option and it should -# work just fine. -# -#======================================================================= - -`rsh $1 -l root lpstat -W | grep -e "DOWN" | tr -s ' ' | cut -d' ' -f1,3 > /tmp/qtmp.hndl 2> /tmp/q_err` - -if [ -s $TMPFILE ] -then - -#======================================================= -# -# If you've seen the other AIX scripts I wrote you may -# notice that I use this bit of code a lot. Well it -# works and appears to be all purpose. -# -#======================================================= - - LINES=`wc -l /tmp/qtmp.hndl | cut -c8` - LINESCTL=`wc -l /tmp/qtmp.hndl | cut -c8` - - echo "Print Queue DOWN --> \c" - - while [ $LINESCTL != 0 ] - do - - cat $TMPFILE | tail -$LINESCTL > $TMPTOO - cat $TMPTOO > $TMPFILE - LINESCTL=$(( $LINESCTL -1 )) - LINES=$(( $LINES -1 )) - DATA=`head -1 /tmp/qtmp.hndl` - echo "( $DATA ) \c" - - - done - - echo "\n" - - rm -f $TMPFILE - rm -f $TMPTOO - exit 2 - -fi - echo "Print Queues Running... OK" - exit 0 diff --git a/contrib/aix/pg_stat b/contrib/aix/pg_stat deleted file mode 100644 index e0603ec4..00000000 --- a/contrib/aix/pg_stat +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/ksh - -#============================================================================== -# Script was originally created to collect stats and dump then to a log file -# every five minutes. But we like this better (the log file thing is still -# good if you want to track availability). -# -# Authors: SpEnTBoY -# TheRocker -# -# Email: lonny@abyss.za.org -# therocker@pawprints.2y.net -#============================================================================== - -#========================================================================================= -# -# The best way to do this is to use Kerberos but we use rsh here because our monitoring -# workstation doesn't have Kerberos installed. In order for this to work, the remote -# host ($1) must have a .rhosts file that contains a line like: -# -# monitorhost nagiosuser -# -#========================================================================================= - -PAGING2=`rsh $1 -l root lsps -a -s | grep -v Paging | tr -s ' '| cut -d' ' -f3 | cut -d'%' -f1` - - -if [ "$PAGING2" -gt "35" ] && [ "$PAGING2" -lt "50" ] -then - echo "Paging Space is over 35% ("$PAGING2")%" -exit 1 -fi - -if [ "$PAGING2" -gt "49" ] -then - echo "WARNING! Paging Space is over 50% ("$PAGING2")%" -exit 2 -fi - -if [ "$PAGING2" -lt "34" ] -then - echo "Paging Space is less than 34% ("$PAGING2")%" -exit 0 -fi - diff --git a/contrib/check_adptraid.sh b/contrib/check_adptraid.sh deleted file mode 100644 index e3c47bee..00000000 --- a/contrib/check_adptraid.sh +++ /dev/null @@ -1,75 +0,0 @@ -#! /bin/sh -# -# Modified check_sensors to check the alarm status of an Adaptec 3200S RAID -# controller. -# -# Scott Lambert -- lambert@lambertfam.org -# -# Tested on FreeBSD 4.7 with the adptfbsd_323.tgz package installed. This -# package installs all it's programs into /usr/dpt. -# - -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin - -PROGNAME=`basename $0` -PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` -REVISION=`echo '$Revision: 302 $' | sed -e 's/[^0-9.]//g'` - -. $PROGPATH/utils.sh - -RAIDUTIL_CMD="/usr/dpt/raidutil -A ?" - -print_usage() { - echo "Usage: $PROGNAME" -} - -print_help() { - print_revision $PROGNAME $REVISION - echo "" - print_usage - echo "" - echo "This plugin checks alarm status of Adaptec 3200S RAID controller." - echo "" - support - exit 0 -} - -case "$1" in - --help) - print_help - exit 0 - ;; - -h) - print_help - exit 0 - ;; - --version) - print_revision $PROGNAME $REVISION - exit 0 - ;; - -V) - print_revision $PROGNAME $REVISION - exit 0 - ;; - *) - raidutiloutput=`$RAIDUTIL_CMD 2>&1` - status=$? - if test "$1" = "-v" -o "$1" = "--verbose"; then - echo ${raidutiloutput} - fi - if test ${status} -eq 127; then - echo "RAIDUTIL UNKNOWN - command not found (did you install raidutil?)" - exit -1 - elif test ${status} -ne 0 ; then - echo "WARNING - raidutil returned state $status" - exit 1 - fi - if echo ${raidutiloutput} | egrep On > /dev/null; then - echo RAID CRITICAL - RAID alarm detected! - exit 2 - else - echo raid ok - exit 0 - fi - ;; -esac diff --git a/contrib/check_apache.pl b/contrib/check_apache.pl deleted file mode 100644 index b9e69a0c..00000000 --- a/contrib/check_apache.pl +++ /dev/null @@ -1,283 +0,0 @@ -#!/usr/bin/perl -# -# (c)2001 Sebastian Hetze, Linux Information Systems AG -# send bug reports to -# -# 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 (or with Nagios); if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA -# -# -# Check apache status information provided by mod_status to find -# out about the load (number of servers working) and the -# performance (average response time for recent requests). -# -# Usage: -# check_apache -H [-lhV] [-w ] [-c ] [-u ] -# -# check_apache (if you cannot avoid it) -# - -use LWP::UserAgent; -use URI::URL; -use Getopt::Long; -Getopt::Long::Configure('bundling'); - -$version=0.01; - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - - -# -# some default values -# -$perf_w=500; -$perf_c=1000; -$load_w=20; -$load_c=30; -$TIMEOUT=15; - -# -# get command line options the regular way -# -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "l" => \$opt_l, "load" => \$opt_l, - "v" => \$verbose, "verbose" => \$verbose, - "w=s" => \$opt_w, "warning=s" => \$opt_w, - "c=s" => \$opt_c, "critical=s" => \$opt_c, - "H=s" => \$opt_H, "hostname=s" => \$opt_H, - "u=s" => \$opt_u, "url=s" => \$opt_u); - -# -# handle the verbose stuff first -# -if ($opt_V) { - print "\n"; - print "check_apache nagios plugin version $version\n"; - print "\n"; - print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n"; - print "copies of the plugins under the terms of the GNU General Public License.\n"; - print "For more information about these matters, see the file named COPYING.\n"; - print "\n"; - print "Copyright (c) 2001 Sebastian Hetze Linux Information Systems AG\n"; - print "\n"; - print "\n"; - exit $ERRORS{'UNKNOWN'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'UNKNOWN'}; -} - -# -# now get options the weired way and set the defaults -# if nothing else is provided -# -$opt_H = shift unless ($opt_H); -print_usage() unless ($opt_H); - -if($opt_l) { - $autostring="?auto"; - ($opt_w) || ($opt_w = shift) || ($opt_w = $load_w); - $warn = $1 if ($opt_w =~ /([0-9]+)/); - ($opt_c) || ($opt_c = shift) || ($opt_c = $load_c); - $alert = $1 if ($opt_c =~ /([0-9]+)/); -} else { - $autostring=""; - ($opt_w) || ($opt_w = shift) || ($opt_w = $perf_w); - $warn = $1 if ($opt_w =~ /([0-9]+)/); - ($opt_c) || ($opt_c = shift) || ($opt_c = $perf_c); - $alert = $1 if ($opt_c =~ /([0-9]+)/); -} - -($opt_u) || ($opt_u = shift) || ($opt_u = "/server-status"); - - -# -# dont let us wait forever... -# -$SIG{'ALRM'} = sub { - print ("ERROR: No response from HTTP server (alarm)\n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -# -# now we set things up for the real work -# and fire up the request -# -$ua = new LWP::UserAgent; -$ua->agent("Nagios/0.1 " . $ua->agent); - - -$urlstring = "http://" . $opt_H . $opt_u . $autostring; -$url = url($urlstring); - -my $req = new HTTP::Request 'GET', $url; -my $res = $ua->request($req); - -# -# hopefully we´ve got something usefull -# -if ($res->is_success) { - if($opt_l) { - foreach $_ (split /^/m, $res->content) { - next if /^\s*$/; -# -# this is the load checking section -# we parse the whole content, just in case someone -# wants to use this some day in the future -# - if (/^Total Accesses:\s+([0-9.]+)/) { $accesses = $1; next; } - if (/^Total kBytes:\s+([0-9.]+)/) { $kbytes = $1; next; } - if (/^CPULoad:\s+([0-9.]+)\s+/) { $load = $1; next; } - if (/^Uptime:\s+([0-9.]+)\s+/) { $uptime = $1; next; } - if (/^ReqPerSec:\s+([0-9.]+)\s+/) { $rps = $1; next; } - if (/^BytesPerSec:\s+([0-9.]+)\s+/) { $bps = $1; next; } - if (/^BytesPerReq:\s+([0-9.]+)\s+/) { $bpr = $1; next; } - if (/^BusyServers:\s+([0-9.]+)\s+/) { $busy = $1; next; } - if (/^IdleServers:\s+([0-9.]+)\s+/) { $idle = $1; next; } - if (/^Scoreboard:\s+([SRWKDLG_.]+)\s+/) { $score = $1; next; } - print "Unknown Status\n"; - exit $ERRORS{"UNKNOWN"}; - } -# -# now we even parse the whole scoreboard, just for fun -# - foreach $scorepoint (split //m, $score) { - if($scorepoint eq '.') { $scores{'.'}+=1; next; } # Unused - if($scorepoint eq '_') { $scores{'_'}+=1; next; } # Waiting - if($scorepoint eq 'S') { $scores{'S'}+=1; next; } # Starting - if($scorepoint eq 'R') { $scores{'R'}+=1; next; } # Reading - if($scorepoint eq 'W') { $scores{'W'}+=1; next; } # Writing - if($scorepoint eq 'K') { $scores{'K'}+=1; next; } # Keepalive - if($scorepoint eq 'D') { $scores{'D'}+=1; next; } # DNS Lookup - if($scorepoint eq 'L') { $scores{'L'}+=1; next; } # Logging - if($scorepoint eq 'G') { $scores{'G'}+=1; next; } # Going - } - - if($busy>$alert) { - printf "HTTPD CRITICAL: %.0f servers running\n", $busy; - exit $ERRORS{"CRITICAL"}; - } - if($busy>$warn) { - printf "HTTPD WARNING: %.0f servers running\n", $busy; - exit $ERRORS{"WARNING"}; - } - printf "HTTPD ok: %.0f servers running, %d idle\n", $busy, $idle; - exit $ERRORS{"OK"}; - - } else { -# -# this is the performance check section -# We are a bit lazy here, no parsing of the initial data -# block and the scoreboard. -# However, you have the whole set of per server -# information to play with ;-) -# The actual performance is measured by adding up the -# milliseconds required to process the most recent -# requests of all instances and then taking the average. -# - foreach $tablerow (split //m, $res->content) { - ($empty,$Srv,$PID,$Acc,$M,$CPU,$SS,$Req,$Conn,$Child,$Slot,$Client,$VHost,$Request) - = split //, $tablerow; - if($Req) { - $lines+=1; - $req_sum+=$Req; - } - undef $Req; - } - $average=$req_sum/$lines; - if($average>$alert) { - printf "HTTPD CRITICAL: average response time %.0f - milliseconds\n", $average; - exit $ERRORS{"CRITICAL"}; - } - if($average>$warn) { - printf "HTTPD WARNING: average response time %.0f - milliseconds\n", $average; - exit $ERRORS{"WARNING"}; - } - if($average>0) { - printf "HTTPD ok: average response time %.0f milliseconds\n", - $average; - exit $ERRORS{"OK"}; - } - print "Unknown Status\n"; - exit $ERRORS{"UNKNOWN"}; - } -} else { - print "HTTP request failed\n"; - exit $ERRORS{"CRITICAL"}; -} - - -# -# ok, now we are almost through -# These last subroutines do the things for those that do not -# read source code. -# -sub print_usage () { - print "Usage: $0 -H [-lhV] [-w ] [-c ] [-u ]\n"; } - -sub print_help () { - print "\n"; - print "\n"; - print "check_apache nagios plugin version $version\n"; - print "\n"; - print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n"; - print "copies of the plugins under the terms of the GNU General Public License.\n"; - print "For more information about these matters, see the file named COPYING.\n"; - print "\n"; - print "Copyright (c) 2001 Sebastian Hetze Linux Information Systems AG\n"; - print "\n"; - print "\n"; - print "This plugin checks the apache HTTP service on the specified host.\n"; - print "It uses the mod_status facilities provided by the apache server.\n"; - print "The monitoring server must be authorized in httpd.conf.\n"; - print "\n"; - print "\n"; - print_usage(); - print "\n"; - print "Options:\n"; - print " -H, --hostname=ADDRESS\n"; - print " host name argument for server.\n"; - print " -l, --load\n"; - print " check load instead of performance.\n"; - print " -h, --help\n"; - print " print detailed help screen.\n"; - print " -V, --version\n"; - print " print version information.\n"; - print " -w, --warning=INTEGER\n"; - print " load / performance level at which a warning message will be gererated.\n"; - print " -c, --critical=INTEGER\n"; - print " load / performance level at which a critical message will be gererated.\n"; - print " -u, --url=PATH\n"; - print " location to call mod_status.\n"; - print "\n"; - print " Defaults for performance checking are $perf_w/$perf_c msec.\n"; - print " Defaults for load checking are $load_w/$load_c servers running.\n"; - print "\n"; - print "\n"; -} -# -# the end -# diff --git a/contrib/check_apc_ups.pl b/contrib/check_apc_ups.pl deleted file mode 100644 index 6bf17662..00000000 --- a/contrib/check_apc_ups.pl +++ /dev/null @@ -1,307 +0,0 @@ -#! /usr/bin/perl -wT -# -# Check_apc_ups - Check APC UPS status via SNMP -# Shamelessly copied from check_breeze.pl -# -# To do: -# - Send SNMP queries directly, instead of forking `snmpget`. -# - Make the status less verbose. Maybe we can send an "onLine, time -# remaining: hh:mm:ss" if all is well, and a list of specific problems -# if something is broken. - -use strict; -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_H $opt_T $opt_t $opt_R $opt_r - $opt_L $opt_l $PROGNAME); -use lib "/usr/local/nagios/libexec"; -use utils qw(%ERRORS &print_revision &support &usage); - -sub print_help (); -sub print_usage (); -sub get_snmp_int_val ($); -sub escalate_exitval ($); - -$ENV{'PATH'}=''; -$ENV{'BASH_ENV'}=''; -$ENV{'ENV'}=''; - -Getopt::Long::Configure('bundling'); -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "T=s" => \$opt_T, "temp-critical" => \$opt_T, - "t=s" => \$opt_t, "temp-warning" => \$opt_t, - "R=s" => \$opt_R, "runtime-critical" => \$opt_R, - "r=s" => \$opt_r, "runtime-warning" => \$opt_r, - "L=s" => \$opt_L, "load-critical" => \$opt_L, - "l=s" => \$opt_l, "load-warning" => \$opt_l, - "H=s" => \$opt_H, "hostname=s" => \$opt_H); - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1771 $'); - exit $ERRORS{'OK'}; -} - -if ($opt_h) {print_help(); exit $ERRORS{'OK'};} - -($opt_H) || ($opt_H = shift) || usage("Host name/address not specified\n"); -my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); -($host) || usage("Invalid host: $opt_H\n"); - -# Defaults - -$opt_R *= 60 * 100 if (defined $opt_R); # Convert minutes to secs/100 -$opt_r *= 60 * 100 if (defined $opt_R); - -my $tempcrit = $opt_T || 60; -my $tempwarn = $opt_t || 40; -my $runtimecrit = $opt_R || 30 * 60 * 100; # Secs / 100 -my $runtimewarn = $opt_r || 60 * 60 * 100; -my $loadcrit = $opt_L || 85; -my $loadwarn = $opt_l || 50; - -if ($tempcrit !~ /\d+/) { usage ("Invalid critical temperature threshold.\n"); } -if ($tempwarn !~ /\d+/) { usage ("Invalid critical temperature threshold.\n"); } - -if ($runtimecrit !~ /\d+/) { - usage ("Invalid critical run time threshold.\n"); -} -if ($runtimewarn !~ /\d+/) { - usage ("Invalid warning run time threshold.\n"); -} - -if ($loadcrit !~ /\d+/ || $loadcrit < 0 || $loadcrit > 100) { - usage ("Invalid critical load threshold.\n"); -} -if ($loadwarn !~ /\d+/ || $loadwarn < 0 || $loadwarn > 100) { - usage ("Invalid warning load threshold.\n"); -} - - -# APC UPS OIDs -# APC MIBs are available at ftp://ftp.apcftp.com/software/pnetmib/mib -my $upsBasicOutputStatus = ".1.3.6.1.4.1.318.1.1.1.4.1.1.0"; -my $upsBasicBatteryStatus = ".1.3.6.1.4.1.318.1.1.1.2.1.1.0"; -my $upsAdvInputLineFailCause = ".1.3.6.1.4.1.318.1.1.1.3.2.5.0"; -my $upsAdvBatteryTemperature = ".1.3.6.1.4.1.318.1.1.1.2.2.2.0"; -my $upsAdvBatteryRunTimeRemaining = ".1.3.6.1.4.1.318.1.1.1.2.2.3.0"; -my $upsAdvBatteryReplaceIndicator = ".1.3.6.1.4.1.318.1.1.1.2.2.4.0"; -my $upsAdvOutputLoad = ".1.3.6.1.4.1.318.1.1.1.4.2.3.0"; -my $upsAdvTestDiagnosticsResults = ".1.3.6.1.4.1.318.1.1.1.7.2.3.0"; - -my @outputStatVals = ( - [ undef, undef ], # pad 0 - [ undef, undef ], # pad 1 - [ "onLine", $ERRORS{'OK'} ], # 2 - [ "onBattery", $ERRORS{'WARNING'} ], # 3 - [ "onSmartBoost", $ERRORS{'WARNING'} ], # 4 - [ "timedSleeping", $ERRORS{'WARNING'} ], # 5 - [ "softwareBypass", $ERRORS{'WARNING'} ], # 6 - [ "off", $ERRORS{'CRITICAL'} ], # 7 - [ "rebooting", $ERRORS{'WARNING'} ], # 8 - [ "switchedBypass", $ERRORS{'WARNING'} ], # 9 - [ "hardwareFailureBypass", $ERRORS{'CRITICAL'} ], # 10 - [ "sleepingUntilPowerReturn", $ERRORS{'CRITICAL'} ], # 11 - [ "onSmartTrim", $ERRORS{'WARNING'} ], # 12 -); - -my @failCauseVals = ( - undef, - "noTransfer", - "highLineVoltage", - "brownout", - "blackout", - "smallMomentarySag", - "deepMomentarySag", - "smallMomentarySpike", - "largeMomentarySpike", - "selfTest", - "rateOfVoltageChnage", -); - -my @battStatVals = ( - [ undef, undef ], # pad 0 - [ undef, undef ], # pad 1 - [ "batteryNormal", $ERRORS{'OK'} ], # 2 - [ "batteryLow", $ERRORS{'CRITICAL'} ], # 3 -); - -my @battReplVals = ( - [ undef, undef ], # pad 0 - [ "noBatteryNeedsReplacing", $ERRORS{'OK'} ], # 1 - [ "batteryNeedsReplacing", $ERRORS{'CRITICAL'} ], # 2 -); - -my @diagnosticsResultsVals = ( - [ undef, undef ], # pad 0 - [ "OK", $ERRORS{'OK'} ], # 1 - [ "failed", $ERRORS{'CRITICAL'} ], # 2 - [ "invalidTest", $ERRORS{'CRITICAL'} ], # 3 - [ "testInProgress", $ERRORS{'OK'} ], # 4 -); - -my $exitval = $ERRORS{'UNKNOWN'}; -my $data; -my $onbattery = 3; - -$data = get_snmp_int_val( $upsBasicOutputStatus ); - -print "Output status: "; -if (defined ($data) && defined ($outputStatVals[$data][0])) { - print "$outputStatVals[$data][0] | "; - escalate_exitval($outputStatVals[$data][1]); -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsAdvBatteryRunTimeRemaining ); - -print "Rem time: "; -if (defined ($data)) { - my $hrs = int($data / (60 * 60 * 100)); # Data is hundredths of a second - my $mins = int($data / (60 * 100)) % 60; - my $secs = ($data % 100) / 100; - printf "%d:%02d:%05.2f | ", $hrs, $mins, $secs; - if ($data <= $runtimecrit) { - escalate_exitval($ERRORS{'CRITICAL'}); - } elsif ($data <= $runtimewarn) { - escalate_exitval($ERRORS{'WARNING'}); - } else { - escalate_exitval($ERRORS{'OK'}); - } -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsBasicBatteryStatus ); - -print "Battery status: "; -if (defined ($data) && defined ($battStatVals[$data][0])) { - my $failcause = "unknown"; - my $fc = get_snmp_int_val( $upsAdvInputLineFailCause ); - if ($data == $onbattery) { - if (defined ($failCauseVals[$fc])) { $failcause = $failCauseVals[$fc]; } - print "$battStatVals[$data][0] ($failcause) | "; - } else { - print "$battStatVals[$data][0] | "; - } - escalate_exitval($battStatVals[$data][1]); -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsAdvBatteryTemperature ); - -print "Battery temp(C): "; -if (defined ($data)) { - print "$data | "; - if ($data >= $tempcrit) { - escalate_exitval($ERRORS{'CRITICAL'}); - } elsif ($data >= $tempwarn) { - escalate_exitval($ERRORS{'WARNING'}); - } else { - escalate_exitval($ERRORS{'OK'}); - } -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsAdvBatteryReplaceIndicator ); - -print "Battery repl: "; -if (defined ($data) && defined ($battReplVals[$data][0])) { - print "$battReplVals[$data][0] | "; - escalate_exitval($battReplVals[$data][1]); -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsAdvOutputLoad ); - -print "Output load (%): "; -if (defined ($data)) { - print "$data | "; - if ($data >= $loadcrit) { - escalate_exitval($ERRORS{'CRITICAL'}); - } elsif ($data >= $loadwarn) { - escalate_exitval($ERRORS{'WARNING'}); - } else { - escalate_exitval($ERRORS{'OK'}); - } -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsAdvTestDiagnosticsResults ); - -print "Diag result: "; -if (defined ($data) && defined ($diagnosticsResultsVals[$data][0])) { - print "$diagnosticsResultsVals[$data][0]\n"; - escalate_exitval($diagnosticsResultsVals[$data][1]); -} else { - print "unknown\n"; -} - - -exit $exitval; - - -sub print_usage () { - print "Usage: $PROGNAME -H -T temp -t temp -R minutes -r minutes\n"; - print " -L percent -l percent\n"; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1771 $'); - print "Copyright (c) 2001 Gerald Combs/Jeffrey Blank/Karl DeBisschop - -This plugin reports the status of an APC UPS equipped with an SNMP management -module. - -"; - print_usage(); - print " --H, --hostname=HOST - Name or IP address of host to check --T --temp-critical - Battery degrees C above which a CRITICAL status will result (default: 60) --t --temp-warning - Battery degrees C above which a WARNING status will result (default: 40) --R --runtime-critical - Minutes remaining below which a CRITICAL status will result (default: 30) --r --runtime-warning - Minutes remaining below which a WARNING status will result (default: 60) --L --load-critical - Output load pct above which a CRITICAL status will result (default: 85 --l --load-warning - Output load pct above which a WARNING status will result (default: 50 - -"; - support(); -} - -sub get_snmp_int_val ($) { - my $val=0; - my $oid = shift(@_); - - $val = `/usr/bin/snmpget $host public $oid 2> /dev/null`; - my @test = split(/ /,$val,3); - - return undef unless (defined ($test[2])); - - if ($test[2] =~ /\(\d+\)/) { # Later versions of UCD SNMP - ($val) = ($test[2] =~ /\((\d+)\)/); - } elsif ($test[2] =~ /: \d+/) { - ($val) = ($test[2] =~ /: (\d+)/); - } else { - $val = $test[2]; - } - - return $val; -} - -sub escalate_exitval ($) { - my $newval = shift(@_); - - if ($newval > $exitval) { $exitval = $newval; } -} diff --git a/contrib/check_appletalk.pl b/contrib/check_appletalk.pl deleted file mode 100644 index 9277686c..00000000 --- a/contrib/check_appletalk.pl +++ /dev/null @@ -1,210 +0,0 @@ -#! /usr/bin/perl -wT -# -# check_atalk_ping plugin for nagios -# -# usage: -# check_atalk_ping atalkaddress -# -# Checks if an atalkhost responds to an atalk echo -# using "aecho" -# -# initial version: 23 October 2002 by Stefan Beck, IT Software Solutions -# current status: $Revision: 1771 $ -# -# Copyright Notice: GPL -# -BEGIN { - if ( $0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/ ) { - $runtimedir = $1; - $PROGNAME = $2; - } - delete $ENV{'LANG'}; -} - -use strict; -use lib "/usr/local/nagios/libexec"; - -use utils qw($TIMEOUT %ERRORS &print_revision &support); -use vars qw($PROGNAME); - -$PROGNAME = "check_atalk"; - -my ( - $verbose, $host, $warning_avg, $warning_loss, - $critical_avg, $critical_loss, $count, $cmd, - $avg, $loss, $line -); -my ( $opt_c, $opt_w, $opt_H, $opt_p ); -$opt_c = $opt_w = $opt_p = $opt_H = ''; - -sub print_help (); -sub print_usage (); -sub help (); -sub version (); - -# Just in case of problems, let's not hang NetSaint -$SIG{'ALRM'} = sub { - print "Plugin Timeout\n"; - exit 2; -}; -alarm($TIMEOUT); - -delete @ENV{ 'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV' }; - -use Getopt::Long; -Getopt::Long::Configure( 'bundling', 'no_ignore_case' ); -GetOptions( - "V|version" => \&version, - "h|help" => \&help, - "p|packets=i" => \$opt_p, - "c|critical=s" => \$opt_c, - "w|warning=s" => \$opt_w, - "H|hostname=s" => \$opt_H -); - - -# appletalk hostname ot address -$opt_H = shift unless ($opt_H); -unless ($opt_H) { print_usage (); exit $ERRORS{'UNKNOWN'}; } -if ( $opt_H && $opt_H =~ m/^([-a-zA-Z\.\:0-9]+)$/ ) { - $host = $1; -} -else { - print "$opt_H is not a valid host name\n"; - exit $ERRORS{'UNKNOWN'}; -} - -# number of packets -$opt_p = 5 unless $opt_p; -if ( $opt_p && $opt_p =~ m/^([1-9]+[0-9]*)$/ ) { - $count = $1; -} -else { - print "$opt_p is not a valid packet number\n"; - exit $ERRORS{'UNKNOWN'}; -} - -if ( $opt_w && $opt_w =~ m/^([1-9]+[0-9]*),([1-9][0-9]*)%$/ ) { - $warning_avg = $1; - $warning_loss = $2; -} -else { - print "$opt_w is not a valid threshold\n"; - exit $ERRORS{'UNKNOWN'}; -} - -if ( $opt_c && $opt_c =~ m/^([1-9]+[0-9]*),([1-9][0-9]*)%$/ ) { - $critical_avg = $1; - $critical_loss = $2; -} -else { - print "$opt_c is not a valid threshold\n"; - exit $ERRORS{'UNKNOWN'}; -} - -$cmd = "/usr/bin/aecho -c $count $host 2>&1 |"; -print "$cmd\n" if ($verbose); -open CMD, $cmd; - -while () { - print $_ if ($verbose); - $line = $_; - - # 5 packets sent, 5 packets received, 0% packet loss - # round-trip (ms) min/avg/max = 0/0/0 - - if (/received, ([0-9]+)% packet loss/) { - $loss = $1; - } - if (/min\/avg\/max = [0-9]+\/([0-9]+)\/[0-9]+/) { - $avg = $1; - } -} - -sub print_help() { - print_revision( $PROGNAME, '$Revision: 1771 $ ' ); - print "Copyright (c) 2002 Stefan Beck\n"; - print "\n"; - print "Check if an atalkhost responds to an atalk echo using\n"; - print " aecho -c \n"; - print "\n"; - print_usage (); - print "\n"; - print "-H, --hostname=HOST\n"; - print " host to ping\n"; - print "-w, --warning=THRESHOLD\n"; - print " warning threshold pair\n"; - print "-c, --critical=THRESHOLD\n"; - print " critical threshold pair\n"; - print "-p, --packets=INTEGER\n"; - print " number of ICMP ECHO packets to send (Default: 5)\n"; - print "\n"; - print - "THRESHOLD is ,% where is the round trip average -travel\n"; - print - "time (ms) which triggers a WARNING or CRITICAL state, and -is the\n"; - print "percentage of packet loss to trigger an alarm state.\n"; - print "\n"; - - support(); -} - -sub print_usage () { - print "$PROGNAME -H atalkhost -w ,% -c ,%\n"; - print " [-p packets] [-t timeout] [-L]\n"; - print "$PROGNAME [-h | --help]\n"; - print "$PROGNAME [-V | --version]\n"; -} - -sub version () { - print_revision( $PROGNAME, '$Revision: 1771 $ ' ); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help (); - exit $ERRORS{'OK'}; -} - -my $state = "OK"; -my $answer = undef; - -if ( defined $loss && defined $avg ) { - if ( $loss >= $critical_loss ) { - $state = "CRITICAL"; - } - elsif ( $avg >= $critical_avg ) { - $state = "CRITICAL"; - } - elsif ( $loss >= $warning_loss ) { - $state = "WARNING"; - } - elsif ( $avg >= $warning_avg ) { - $state = "WARNING"; - } - else { - $state = "OK"; - } - $answer = "Appletalk PING $state - Packet loss = $loss%, RTA = $avg -ms\n"; -} -else { - $state = "UNKNOWN"; - $answer = "UNKNOWN - $line"; -} -print $answer; -exit $ERRORS{$state}; - - - - -------------------------------------------------------- -This sf.net email is sponsored by:ThinkGeek -Welcome to geek heaven. -http://thinkgeek.com/sf -_______________________________________________ -Nagios-devel mailing list -Nagios-devel@lists.sourceforge.net -https://lists.sourceforge.net/lists/listinfo/nagios-devel diff --git a/contrib/check_arping.pl b/contrib/check_arping.pl deleted file mode 100644 index c41c4a8a..00000000 --- a/contrib/check_arping.pl +++ /dev/null @@ -1,120 +0,0 @@ -#! /usr/bin/perl -w -# -# check_arping.pl - Nagios plugin to check host status via ARP ping -# -# usage: -# check_arping -H hostname -I interface -T timeout -# -# -# Copyright (C) 2003 Kenny Root -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# -# Report bugs to: kenny@the-b.org, nagiosplug-help@lists.sf.net - -use POSIX; -use strict; -use lib "/usr/lib/nagios/plugins" ; -use utils qw($TIMEOUT %ERRORS &print_revision &support); - -use Net::Arping; -use Getopt::Long; - -my $PROGNAME = "check_arping"; - -my($status, $state, $answer); -my($opt_V, $opt_h, $opt_t, $opt_I, $opt_H); - - -#Option checking -$status = GetOptions( - "V|version" => \$opt_V, - "help" => \$opt_h, - "I|interface=s" => \$opt_I, - "H|host=s" => \$opt_H, - "t|timeout=i" => \$opt_t); - -if ($status == 0) -{ - print_help() ; - exit $ERRORS{'OK'}; -} - - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1112 $ '); - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -if ($opt_t) { - if ($opt_t ne int($opt_t)) { - print "Timeout not in seconds!\n"; - print_help(); - exit $ERRORS{'OK'}; - } - $opt_t = int($opt_t); -} else { - $opt_t = 3; -} - -if (! utils::is_hostname($opt_H)){ - usage(); - exit $ERRORS{"UNKNOWN"}; -} - -my $ping = Net::Arping->new(); - -my $reply = $ping->arping(Host => $opt_H, Interface => $opt_I, Timeout => $opt_t); - -if ($reply eq "0") { - $state = "CRITICAL"; - print "$state: no reply from $opt_H on interface $opt_I in $opt_t seconds.\n"; - exit $ERRORS{$state}; -} else { - $state = "OK"; - $answer = "replied with MAC address $reply"; -} - -print "ARPING $state - $answer\n"; -exit $ERRORS{$state}; - - -sub usage { - print "\nMissing arguments!\n"; - print "\n"; - print "check_arping -I -H [-t ]\n"; - print "\n\n"; - support(); - exit $ERRORS{"UNKNOWN"}; -} - -sub print_help { - print "check_arping pings hosts that normally wouldn't allow\n"; - print "ICMP packets but are still on the local network.\n"; - print "\nUsage:\n"; - print " -H (--host) IP to query - (required)\n"; - print " -I (--interface) Interface to use.\n"; - print " -t (--timeout) Timeout in seconds.\n"; - print " -V (--version) Plugin version\n"; - print " -h (--help) usage help \n\n"; - print_revision($PROGNAME, '$Revision: 1112 $'); - -} diff --git a/contrib/check_asterisk.pl b/contrib/check_asterisk.pl deleted file mode 100644 index 179d3671..00000000 --- a/contrib/check_asterisk.pl +++ /dev/null @@ -1,259 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use IO::Socket; -use Getopt::Long; -$|=1; - -my ( - $host, $username, $password, $verbose, $help, $command, $mode, - $ipaddr, $respaddr, $sendto, $msg, $recvfrom, - $version, $response, $message, $line, - $sock, $port, $reply, - $warning, $critical, - %warnval, %critval, - %channels, - $runmode, - $key, - $s, -); -my $stop = 0; -my $mgr_port = 5038; -my $iax_port = 4569; -my $exitcode = 0; -my $cause = ""; - -my $iax_answer = 0; -my $iax_maxlen = 1024; -my $iax_timeout = 5; -my $iax_src_call = "8000"; #8000 most siginificant bit is IAX packet type full ... required for a poke etc... -my $iax_dst_call = "0000"; -my $iax_timestamp = "00000000"; -my $iax_outbound_seq = "00"; -my $iax_inbound_seq = "00"; -my $iax_type = "06"; #IAX_Control - -sub ok { - $s = shift; - $s =~ s/[\r\n]//g; - print "OK: $s\n"; - exit(0); -} - -sub warning { - $s = shift; - $s =~ s/[\r\n]//g; - print "WARNING: $s\n"; - exit(1); -} - -sub error { - $s = shift; - $s =~ s/[\r\n]//g; - print "ERROR: $s\n"; - exit(2); -} - -sub unknown { - $s = shift; - $s =~ s/[\r\n]//g; - print "UNKNOWN: $s\n"; - exit(3); -} - -sub syntax { - $s = shift; - unless ($s =~ m/Help:/) { - $s = "Error: (".$s.")" or $s = 'Unknown'; - } - print "$s\n" unless ($help); - print "Syntax: $0 -m mgr -h -u -p [-cwv]\n"; - print "Syntax: $0 -m iax -h [-v]\n"; - print "* --host -h Host\n"; - print "* --mode -m Mode - eithr 'mgr' or 'iax'\n"; - print " --username -u Username\n"; - print " --password -p Password\n"; - print " --port -P n Port (if not using $mgr_port for manager or $iax_port for IAX)\n"; - print " --warning xxx=n Return warning if > n channels of type xxx.\n"; - print " --critical xxx=n Return critical if > n channels of type xxx.\n"; - print " --verbose -v Verbose\n"; - print " --help -h This help\n"; - exit(3); -} - -Getopt::Long::Configure('bundling'); -GetOptions - ("p=s" => \$password, "password=s" => \$password, - "u=s" => \$username, "username=s" => \$username, - "h=s" => \$host, "host=s" => \$host, - "P=i" => \$port, "port=i" => \$port, - "H" => \$help, "help" => \$help, - "v" => \$verbose, "verbose" => \$verbose, - "m=s" => \$mode, "mode=s" => \$mode, - "critical=s" => \$critical, "warning=s" => \$warning); - -syntax("Help:") if ($help); -syntax("Missing host") unless (defined($host)); -syntax("Missing mode") unless (defined($mode)); -if ($mode =~ /^iax$/i) { - print "Running in IAX mode\n" if ($verbose); - $runmode = 1; -} elsif ($mode =~ /^mgr$/i) { - print "Running in Manager mode\n" if ($verbose); - $runmode = 2; -} else { - syntax("Unknown mode $mode") -} - -############################################################################## - -if ($runmode == 2) { - $port = $mgr_port; - syntax("Missing username") unless (defined($username)); - syntax("Missing password") unless (defined($password)); - if (defined($warning)) { - foreach $s (split(/,/, $warning)) { - syntax("Warning value given, $s, is invalid") - unless ($s =~ /^(\w+)=(\d+)$/); - $warnval{$1} = $2; - print "Clear to give WARNING after $2 connections on $1\n" if ($verbose); - } - } - if (defined($critical)) { - foreach $s (split(/,/, $critical)) { - syntax("Critical value given, $s, is invalid") - unless ($s =~ /^(\w+)=(\d+)$/); - $critval{$1} = $2; - print "Clear to give CRITICAL after $2 connections on $1\n" if ($verbose); - } - } - - print "Connecting to $host:$port\n" if ($verbose); - unless ($sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp')) { - print("Could not connect to asterisk server ".$host.":".$port."\n"); - exit(2); - } - print "Connected to $host:$port\n" if ($verbose); - $version = <$sock>; - print $version if ($verbose); - - print $sock "Action: Login\r\nUsername: $username\r\nSecret: $password\r\nEvents: off\r\n\r\n"; - print "Action: Login\r\nUsername: $username\r\nSecret: $password\r\n\r\n" if ($verbose); - $response = <$sock>; - $message = <$sock>; - $s = <$sock>; - print $response.$message if ($verbose); - print $s if ($verbose); - - exit(1) unless ($response =~ m/^Response:\s+(.*)$/i); - exit(1) unless ($1 =~ m/Success/i); - - print $sock "Action: Status\r\n\r\n"; - print "Action: Status\r\n\r\n" if ($verbose); - - $response = <$sock>; - $message = <$sock>; - print $response.$message if ($verbose); - - &unknown("Unknown answer $response (wanted Response: something)") unless ($response =~ m/^Response:\s+(.*)$/i); - &unknown("$response didn't say Success") unless ($1 =~ m/Success/i); - &unknown("Unknown answer $response (wanted Message: something)") unless ($message =~ m/^Message:\s+(.*)$/i); - &unknown("didn't understand message $message") unless ($1 =~ m/Channel status will follow/i); - - $stop=0; - while (($stop == 0) && ($line = <$sock>)) { - print "$line" if ($verbose); - if ($line =~ m/Channel:\s+(\w+)\//) { - $channels{$1}++; - print "Found $1 channel\n" if ($verbose); - } - if ($line =~ m/Event:\s*StatusComplete/i) { - $stop++; - } - } - -# Log out - print $sock "Action: Logoff\r\n\r\n"; - - undef($s); - foreach $key (keys %channels) { - $s .= " " . $key . " (" . $channels{$key} . ")"; - } - - foreach $key (keys %critval) { - print "key = $key\n" if ($verbose); - if (defined($channels{$key}) && ($channels{$key} > $critval{$key})) { - $exitcode = 2; - $cause .= $channels{$key} . " $key channels detected. "; - } - } - - if ($exitcode < 2) { - foreach $key (keys %warnval) { - print "key = $key\n" if ($verbose); - if (defined($channels{$key}) && ($channels{$key} > $warnval{$key})) { - $exitcode = 1; - $cause .= $channels{$key} . " $key channels detected. "; - } - } - } - - if ($exitcode == 0) { - print "OK "; - } elsif ($exitcode == 1) { - print "WARNING "; - } elsif ($exitcode == 2) { - print "CRITICAL "; - } elsif ($exitcode > 2) { - print "UNKNOWN "; - } - if (defined($s)) { - $cause .= " Channels:$s"; - } else { - $cause .= " (idle)"; - } - - print $cause; - - print "\n" if ($verbose); - - exit($exitcode); -} elsif ($runmode == 1) { - $port = $iax_port; - - socket(PING, PF_INET, SOCK_DGRAM, getprotobyname("udp")); - - $msg = pack "H24", $iax_src_call . $iax_dst_call . $iax_timestamp . - $iax_outbound_seq . $iax_inbound_seq . $iax_type . $iax_type; - - $ipaddr = inet_aton($host); - $sendto = sockaddr_in($port,$ipaddr); - - send(PING, $msg, 0, $sendto) == length($msg) or die "cannot send to $host : $port : $!\n"; - - eval { - local $SIG{ALRM} = sub { die("alarm time out"); }; - alarm $iax_timeout; - - while (1) { - $recvfrom = recv(PING, $msg, $iax_maxlen, 0) or die "recv: $!"; - ($port, $ipaddr) = sockaddr_in($recvfrom); - $respaddr = inet_ntoa($ipaddr); - $iax_answer++; - # print "Response from $respaddr : $port\n"; - } - - }; - - if ($iax_answer) { - if ($iax_answer == 1) { - $reply = "reply"; - } else { - $reply = "replies"; - } - &ok("Got $iax_answer $reply"); - } else { - &error("Got no reply"); - } -} - diff --git a/contrib/check_axis.sh b/contrib/check_axis.sh deleted file mode 100644 index 231d9da4..00000000 --- a/contrib/check_axis.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/sh - -box=$1 -port=$2 -usr=$3 -pass=$4 - -if [ ! "$#" == "4" ]; then - echo -e "\nYou did not supply enough command line arguments. \nUsage: ./check_axis.sh \n \nCheck_axis.sh checks the status of LPT ports on Axis print servers. \nIt was written by Tom De Blende (tom.deblende@village.uunet.be) in 2002. \n" && exit "3" -fi - -tempfile=/tmp/status-$box.tmp -exit="3" - -ftp -in $box &>/dev/null < \&version, - "h|help" => \&help, - "v|verbose" => \$verbose, - "d|directory=s" => \$opt_d, - "s|minsize=s" => \$opt_s, - "t|timeout=s" => \$opt_t, - ); - -($opt_s) || ($opt_s = shift) || usage("Minimum File size not specified\n"); -usage("File size must be numeric value") unless ($opt_s =~ m/^[0-9]+$/); - -(($opt_t) && ($TIMEOUT = $opt_t)) || ($TIMEOUT = 120); -usage("TIMEOUT must be numeric value") unless ($TIMEOUT =~ m/^[0-9]+$/); - -# Don't hang if there are timeout issues -$SIG{'ALRM'} = sub { - print ("ERROR: No response from ftp server (alarm)\n"); - exit $ERRORS{'UNKNOWN'}; -}; -alarm($TIMEOUT); - -# Do stuff - -my $time = time; - -opendir(THISDIR, "$dir") or die "Can't open directory! $!"; -my @allfiles = grep !/^\./, readdir THISDIR; -closedir THISDIR; -while (my $file = $dir . pop @allfiles){ - my ($size, $mtime) = (stat($file))[7,9]; - if (((my $a = ($time - $mtime)) <= $within) and ($size >= $opt_s)){ - display_res("OK: File $file is <= $within and >=$opt_s bytes.\n","OK"); - } -} - -# If we got here nothing matched.... -display_res("CRITICAL: No files in $dir are <= $within and >= $minsize.", "CRITICAL"); - -exit; - -sub print_usage () { - print "Usage: $PROGNAME -s -t \n"; -} - -sub print_help () { - print_revision($PROGNAME,'$ Revision: 1.0 $ '); - print_usage(); - support(); -} - -sub version () { - print_revision($PROGNAME,'$ Revision: 1.0 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - -sub display_res ($$) { - my ($answer, $state) = @_; - print $answer; - exit $ERRORS{$state}; -} diff --git a/contrib/check_bgpstate.pl b/contrib/check_bgpstate.pl deleted file mode 100644 index 645d7505..00000000 --- a/contrib/check_bgpstate.pl +++ /dev/null @@ -1,215 +0,0 @@ -#!/usr/bin/perl -w -# -# check_bgpstate.pl - nagios plugin -# -# Copyright (C) 2000 Christoph Kron -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# -# Report bugs to: ck@zet.net -# -# 11.01.2000 Version 1.0 - - - -use strict; - -use Net::SNMP; -use Getopt::Long; -&Getopt::Long::config('auto_abbrev'); - - -# whois programm for RIPE database queries -my $whois = '/usr/bin/whois'; -my $status; -my $TIMEOUT = 30; - -# critical bgp sessions -my %uplinks = ( 1273, 'Uplink ECRC', - 1755, 'Uplink EBONE', - 3300, 'Uplink AUCS' - ); - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - - -my %bgpPeerState = ( - '1',"idle", - '2',"connect", - '3',"active", - '4',"opensent", - '5',"openconfirm", - '6',"established" - ); -my $state = "UNKNOWN"; -my $answer = ""; -my $snmpkey; -my $snmpoid; -my $key; -my $community = "public"; -my $port = 161; -my @snmpoids; -my $snmpbgpPeerState = '1.3.6.1.2.1.15.3.1.2'; -my $snmpbgpPeerLocalAddr = '1.3.6.1.2.1.15.3.1.5'; -my $snmpbgpPeerRemoteAddr = '1.3.6.1.2.1.15.3.1.7'; -my $snmpbgpPeerRemoteAs = '1.3.6.1.2.1.15.3.1.9'; -my $hostname; -my $session; -my $error; -my $response; -my %bgpStatus; -my $bgpestablished =0 ; -my $bgpcritical =0; -my $bgpdown =0; -my $bgpidle =0; -my $bgpmessage; -my $asname; -my $remoteas; -my @output; - -sub usage { - printf "\nMissing arguments!\n"; - printf "\n"; - printf "Perl bgpstate plugin for Nagios\n"; - printf "monitors all BGP sessions\n"; - printf "usage: \n"; - printf "check_bgpstate.pl -c -p \n"; - printf "Copyright (C) 2000 Christoph Kron\n"; - printf "check_bgpstate.pl comes with ABSOLUTELY NO WARRANTY\n"; - printf "This programm is licensed under the terms of the "; - printf "GNU General Public License\n(check source code for details)\n"; - printf "\n\n"; - exit $ERRORS{"UNKNOWN"}; -} - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print ("ERROR: No snmp response from $hostname (alarm)\n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -$status = GetOptions("community=s",\$community, - "port=i",\$port); -if ($status == 0) -{ - &usage; -} - - #shift; - $hostname = shift || &usage; - - -push(@snmpoids, $snmpbgpPeerState); -push(@snmpoids, $snmpbgpPeerLocalAddr); -push(@snmpoids, $snmpbgpPeerRemoteAddr); -push(@snmpoids, $snmpbgpPeerRemoteAs); - -foreach $snmpoid (@snmpoids) { - - ($session, $error) = Net::SNMP->session( - -hostname => $hostname, - -community => $community, - -port => $port - ); - - if (!defined($session)) { - $state='UNKNOWN'; - $answer=$error; - print ("$state: $answer"); - exit $ERRORS{$state}; - } - - if (!defined($response = $session->get_table($snmpoid))) { - $answer=$session->error; - $session->close; - $state = 'CRITICAL'; - print ("$state: $answer,$snmpkey"); - exit $ERRORS{$state}; - } - - foreach $snmpkey (keys %{$response}) { - $snmpkey =~ m/.*\.(\d+\.\d+\.\d+\.\d+$)/; - $key = $1; -# printf "debug: $snmpkey: $key -> $response->{$snmpkey}\n"; - $bgpStatus{$key}{$snmpoid} = $response->{$snmpkey}; - } - $session->close; -} - -foreach $key (keys %bgpStatus) { - if ($bgpStatus{$key}{$snmpbgpPeerState} == 6 ) { - $bgpestablished++; - } - elsif ($bgpStatus{$key}{$snmpbgpPeerState} == 1 ) { - $bgpidle++; - } - else { - $bgpdown++ ; - if (exists($uplinks{$bgpStatus{$key}{$snmpbgpPeerRemoteAs}}) ) { - $bgpcritical++; - } - @output = `$whois -T aut-num AS$bgpStatus{$key}{$snmpbgpPeerRemoteAs}`; - - $asname = ""; - foreach (@output) { - if (m/as-name/) { - $asname = $_; - $asname =~ s/as-name://; - last; - } - if ( $asname =~ "" && m/descr/ ) { - $asname = $_; - $asname =~ s/descr://; - } - } - $asname =~ s/^\s*//; - $asname =~ s/\s*$//; - $bgpmessage .= sprintf("Peering with AS%s not established -> %s
", - $bgpStatus{$key}{$snmpbgpPeerRemoteAs}, - $asname); - } -} - - - if ($bgpdown > 0) { - if ($bgpcritical > 0) { - $state = 'CRITICAL'; - } - else { - $state = 'WARNING'; - } - $answer = sprintf("host '%s', sessions up: %d, down: %d, shutdown: %d
", - $hostname, - $bgpestablished, - $bgpdown, $bgpidle); - $answer = $answer . $bgpmessage . "\n"; - } - else { - $state = 'OK'; - $answer = sprintf("host '%s', sessions up: %d, down: %d, shutdown: %d\n", - $hostname, - $bgpestablished, - $bgpdown,$bgpidle); - } - -print ("$state: $answer"); -exit $ERRORS{$state}; - diff --git a/contrib/check_breeze.pl b/contrib/check_breeze.pl deleted file mode 100644 index bb837657..00000000 --- a/contrib/check_breeze.pl +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/perl - -# Plugin to test signal strength on Breezecom wireless equipment -# Contributed by Jeffrey Blank - -$Host=$ARGV[0]; -$sig_crit=$ARGV[1]; -$sig_warn=$ARGV[2]; -$sig=0; -$sig = `snmpget $Host public .1.3.6.1.4.1.710.3.2.3.1.3.0`; -@test=split(/ /,$sig); -$sig=@test[2]; -$sig=int($sig); -if ($sig>100){$sig=100} - -print "Signal Strength at: $sig%\n"; -if ($sig<$sig_crit) - {exit(2)} -if ($sig<$sig_warn) - {exit(1)} - -exit(0); diff --git a/contrib/check_cluster.c b/contrib/check_cluster.c deleted file mode 100644 index 06519e61..00000000 --- a/contrib/check_cluster.c +++ /dev/null @@ -1,332 +0,0 @@ -/***************************************************************************** - * - * CHECK_CLUSTER.C - Host and Service Cluster Plugin for NetSaint - * - * Copyright (c) 2000 Ethan Galstad (netsaint@netsaint.org) - * License: GPL - * Last Modified: 07-08-2000 - * - * License: - * - * 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. - * - *****************************************************************************/ - - -#include -#include - -#define OK 0 -#define ERROR -1 - -#define TRUE 1 -#define FALSE 0 - -#define CHECK_SERVICES 1 -#define CHECK_HOSTS 2 - -#define MAX_INPUT_BUFFER 1024 - -#define STATE_OK 0 -#define STATE_WARNING 1 -#define STATE_CRITICAL 2 -#define STATE_UNKNOWN 3 - -typedef struct clustermember_struct{ - char *host_name; - char *svc_description; - struct clustermember_struct *next; - }clustermember; - - -int check_cluster_status(void); -int add_clustermember(char *,char *); -void free_memory(void); - -clustermember *clustermember_list=NULL; - -int total_services_ok=0; -int total_services_warning=0; -int total_services_unknown=0; -int total_services_critical=0; - -int total_hosts_up=0; -int total_hosts_down=0; -int total_hosts_unreachable=0; - -char status_log[MAX_INPUT_BUFFER]=""; -int warning_threshold=0; -int critical_threshold=0; - -int check_type=CHECK_SERVICES; - - -int main(int argc, char **argv){ - char input_buffer[MAX_INPUT_BUFFER]; - char *host_name; - char *svc_description; - int return_code=STATE_OK; - int error=FALSE; - - if(argc!=5){ - - printf("Invalid arguments supplied\n"); - printf("\n"); - - printf("Host/Service Cluster Plugin for NetSaint\n"); - printf("Copyright (c) 2000 Ethan Galstad (netsaint@netsaint.org)\n"); - printf("Last Modified: 07-08-2000\n"); - printf("License: GPL\n"); - printf("\n"); - printf("Usage: %s <--service | --host> \n",argv[0]); - printf("\n"); - printf("Options:\n"); - printf(" --service = Check service cluster status\n"); - printf(" --host = Check host cluster status\n"); - printf(" = This is the location of the NetSaint status log\n"); - printf(" = This is the number of hosts or services in\n"); - printf(" the cluster that must be in a non-OK state\n"); - printf(" in order to result in a warning status level\n"); - printf(" = This is the number of hosts or services in\n"); - printf(" the cluster that must be in a non-OK state\n"); - printf(" in order to result in a critical status level\n"); - printf("\n"); - printf("Notes:\n"); - printf("Members of the host or service cluster are read from STDIN.\n"); - printf("One host or service can be specified per line, services must\n"); - printf("be in the format of ;\n"); - printf("\n"); - - return STATE_UNKNOWN; - } - - /* see if we're checking a host or service clust */ - if(!strcmp(argv[1],"--host")) - check_type=CHECK_HOSTS; - else - check_type=CHECK_SERVICES; - - /* get the status log */ - strncpy(status_log,argv[2],sizeof(status_log)-1); - status_log[sizeof(status_log)-1]='\x0'; - - /* get the warning and critical thresholds */ - warning_threshold=atoi(argv[3]); - critical_threshold=atoi(argv[4]); - - - /* read all data from STDIN until there isn't anymore */ - while(fgets(input_buffer,sizeof(input_buffer)-1,stdin)){ - - if(feof(stdin)) - break; - - /*strip(input_buffer);*/ - - if(!strcmp(input_buffer,"")) - continue; - - if(!strcmp(input_buffer,"\n")) - continue; - - /* get the host name */ - if(check_type==CHECK_SERVICES) - host_name=(char *)strtok(input_buffer,";"); - else - host_name=(char *)strtok(input_buffer,"\n"); - if(host_name==NULL || !strcmp(host_name,"")){ - printf("Error: Host name is NULL!\n"); - continue; - } - - if(check_type==CHECK_SERVICES){ - - /* get the service description */ - svc_description=(char *)strtok(NULL,"\n"); - if(svc_description==NULL || !strcmp(svc_description,"")){ - printf("Error: Service description is NULL!\n"); - continue; - } - } - - /* add the cluster member to the list in memory */ - if(add_clustermember(host_name,svc_description)!=OK) - printf("Error: Could not add cluster member\n"); -#ifdef DEBUG - else - printf("Added cluster member\n"); -#endif - } - - - /* check the status of the cluster */ - if(check_cluster_status()==OK){ - - if(check_type==CHECK_SERVICES){ - if((total_services_warning+total_services_unknown+total_services_critical) >= critical_threshold) - return_code=STATE_CRITICAL; - else if((total_services_warning+total_services_unknown+total_services_critical) >= warning_threshold) - return_code=STATE_WARNING; - else - return_code=STATE_OK; - - printf("Service cluster %s: %d ok, %d warning, %d unknown, %d critical\n",(return_code==STATE_OK)?"ok":"problem",total_services_ok,total_services_warning,total_services_unknown,total_services_critical); - } - else{ - if((total_hosts_down+total_hosts_unreachable) >= critical_threshold) - return_code=STATE_CRITICAL; - else if((total_hosts_down+total_hosts_unreachable) >= warning_threshold) - return_code=STATE_WARNING; - else - return_code=STATE_OK; - - printf("Host cluster %s: %d up, %d down, %d unreachable\n",(return_code==STATE_OK)?"ok":"problem",total_hosts_up,total_hosts_down,total_hosts_unreachable); - } - } - else - return_code=STATE_UNKNOWN; - - free_memory(); - - return return_code; - } - - - -int add_clustermember(char *hst,char *svc){ - clustermember *new_clustermember; - - new_clustermember=(clustermember *)malloc(sizeof(clustermember)); - if(new_clustermember==NULL) - return ERROR; - - new_clustermember->host_name=NULL; - new_clustermember->svc_description=NULL; - - if(hst!=NULL){ - new_clustermember->host_name=(char *)malloc(strlen(hst)+1); - if(new_clustermember->host_name==NULL){ - free(new_clustermember); - return ERROR; - } - strcpy(new_clustermember->host_name,hst); - } - - if(svc!=NULL){ - new_clustermember->svc_description=(char *)malloc(strlen(svc)+1); - if(new_clustermember->svc_description==NULL){ - if(new_clustermember->host_name!=NULL) - free(new_clustermember->host_name); - free(new_clustermember); - return ERROR; - } - strcpy(new_clustermember->svc_description,svc); - } - - new_clustermember->next=clustermember_list; - clustermember_list=new_clustermember; - - return OK; - } - - -void free_memory(void){ - clustermember *this_clustermember; - clustermember *next_clustermember; - - for(this_clustermember=clustermember_list;this_clustermember!=NULL;this_clustermember=next_clustermember){ - next_clustermember=this_clustermember->next; - if(this_clustermember->host_name!=NULL) - free(this_clustermember->host_name); - if(this_clustermember->svc_description!=NULL) - free(this_clustermember->svc_description); - free(this_clustermember); - } - - return; - } - - - -int check_cluster_status(void){ - FILE *fp; - clustermember *temp_clustermember; - char input_buffer[MAX_INPUT_BUFFER]; - char matching_entry[MAX_INPUT_BUFFER]; - - fp=fopen(status_log,"r"); - if(fp==NULL){ - printf("Error: Could not open status log '%s' for reading\n",status_log); - return ERROR; - } - -#ifdef DEBUG - for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){ - if(check_type==CHECK_HOSTS) - printf("Cluster member: '%s'\n",temp_clustermember->host_name); - else - printf("Cluster member: '%s'/'%s'\n",temp_clustermember->host_name,temp_clustermember->svc_description); - } -#endif - - for(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp);!feof(fp);fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){ - - /* this is a host entry */ - if(strstr(input_buffer,"] HOST;") && check_type==CHECK_HOSTS){ - - /* this this a match? */ - for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){ - - snprintf(matching_entry,sizeof(matching_entry)-1,";%s;",temp_clustermember->host_name); - - if(strstr(input_buffer,matching_entry)){ - if(strstr(input_buffer,";DOWN;")) - total_hosts_down++; - else if(strstr(input_buffer,";UNREACHABLE;")) - total_hosts_unreachable++; - else if(strstr(input_buffer,";UP;")) - total_hosts_up++; - } - } - - } - - /* this is a service entry */ - else if(strstr(input_buffer,"] SERVICE;") && check_type==CHECK_SERVICES){ - - /* this this a match? */ - for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){ - - snprintf(matching_entry,sizeof(matching_entry)-1,";%s;%s;",temp_clustermember->host_name,temp_clustermember->svc_description); - - if(strstr(input_buffer,matching_entry)){ - if(strstr(input_buffer,";HOST DOWN;") || strstr(input_buffer,";UNREACHABLE;") || strstr(input_buffer,";CRITICAL;")) - total_services_critical++; - else if(strstr(input_buffer,";WARNING;")) - total_services_warning++; - else if(strstr(input_buffer,";UNKNOWN;")) - total_services_unknown++; - else if(strstr(input_buffer,";OK;") || strstr(input_buffer,";RECOVERY;")) - total_services_ok++; - } - } - - } - } - - fclose(fp); - - return OK; - } diff --git a/contrib/check_cluster2.README b/contrib/check_cluster2.README deleted file mode 100644 index a0149841..00000000 --- a/contrib/check_cluster2.README +++ /dev/null @@ -1,5 +0,0 @@ -check_cluster2 is now part of the core Nagios-Plugins distribution and has -been renamed check_cluster. It will be installed automatically. - -The threshold format has changed and is not backward-compatible; be sure to -understand it correctly. Use --help to print the full help. diff --git a/contrib/check_cluster2.c b/contrib/check_cluster2.c deleted file mode 100644 index e60948d6..00000000 --- a/contrib/check_cluster2.c +++ /dev/null @@ -1,232 +0,0 @@ -/***************************************************************************** - * - * CHECK_CLUSTER2.C - Host and Service Cluster Plugin for Nagios 2.x - * - * Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org) - * License: GPL - * Last Modified: 03-11-2004 - * - * License: - * - * 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. - * - *****************************************************************************/ - - -#include -#include -#include -#include -#include - -#define OK 0 -#define ERROR -1 - -#define TRUE 1 -#define FALSE 0 - -#define CHECK_SERVICES 1 -#define CHECK_HOSTS 2 - -#define MAX_INPUT_BUFFER 1024 - -#define STATE_OK 0 -#define STATE_WARNING 1 -#define STATE_CRITICAL 2 -#define STATE_UNKNOWN 3 - -int total_services_ok=0; -int total_services_warning=0; -int total_services_unknown=0; -int total_services_critical=0; - -int total_hosts_up=0; -int total_hosts_down=0; -int total_hosts_unreachable=0; - -int warning_threshold=1; -int critical_threshold=1; - -int check_type=CHECK_SERVICES; - -char *data_vals=NULL; -char *label=NULL; - - -int process_arguments(int,char **); - - - -int main(int argc, char **argv){ - char input_buffer[MAX_INPUT_BUFFER]; - char *ptr; - int data_val; - int return_code=STATE_OK; - int error=FALSE; - - if(process_arguments(argc,argv)==ERROR){ - - printf("Invalid arguments supplied\n"); - printf("\n"); - - printf("Host/Service Cluster Plugin for Nagios 2\n"); - printf("Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)\n"); - printf("Last Modified: 03-11-2004\n"); - printf("License: GPL\n"); - printf("\n"); - printf("Usage: %s (-s | -h) [-l label] [-w threshold] [-c threshold] [-d val1,val2,...,valn]\n",argv[0]); - printf("\n"); - printf("Options:\n"); - printf(" -s, --service = Check service cluster status\n"); - printf(" -h, --host = Check host cluster status\n"); - printf(" -l, --label = Optional prepended text output (i.e. \"Host cluster\")\n"); - printf(" -w, --warning = Specifies the number of hosts or services in cluster that must be in\n"); - printf(" a non-OK state in order to return a WARNING status level\n"); - printf(" -c, --critical = Specifies the number of hosts or services in cluster that must be in\n"); - printf(" a non-OK state in order to return a CRITICAL status level\n"); - printf(" -d, --data = The status codes of the hosts or services in the cluster, separated\n"); - printf(" by commas\n"); - printf("\n"); - - return STATE_UNKNOWN; - } - - /* check the data values */ - for(ptr=strtok(data_vals,",");ptr!=NULL;ptr=strtok(NULL,",")){ - - data_val=atoi(ptr); - - if(check_type==CHECK_SERVICES){ - switch(data_val){ - case 0: - total_services_ok++; - break; - case 1: - total_services_warning++; - break; - case 2: - total_services_critical++; - break; - case 3: - total_services_unknown++; - break; - default: - break; - } - } - else{ - switch(data_val){ - case 0: - total_hosts_up++; - break; - case 1: - total_hosts_down++; - break; - case 2: - total_hosts_unreachable++; - break; - default: - break; - } - } - } - - - /* return the status of the cluster */ - if(check_type==CHECK_SERVICES){ - if((total_services_warning+total_services_unknown+total_services_critical) >= critical_threshold) - return_code=STATE_CRITICAL; - else if((total_services_warning+total_services_unknown+total_services_critical) >= warning_threshold) - return_code=STATE_WARNING; - else - return_code=STATE_OK; - printf("%s %s: %d ok, %d warning, %d unknown, %d critical\n",(label==NULL)?"Service cluster":label,(return_code==STATE_OK)?"ok":"problem",total_services_ok,total_services_warning,total_services_unknown,total_services_critical); - } - else{ - if((total_hosts_down+total_hosts_unreachable) >= critical_threshold) - return_code=STATE_CRITICAL; - else if((total_hosts_down+total_hosts_unreachable) >= warning_threshold) - return_code=STATE_WARNING; - else - return_code=STATE_OK; - printf("%s %s: %d up, %d down, %d unreachable\n",(label==NULL)?"Host cluster":label,(return_code==STATE_OK)?"ok":"problem",total_hosts_up,total_hosts_down,total_hosts_unreachable); - } - - return return_code; - } - - - -int process_arguments(int argc, char **argv){ - int c; - int option=0; - static struct option longopts[]={ - {"data", required_argument,0,'d'}, - {"warning", required_argument,0,'w'}, - {"critical", required_argument,0,'c'}, - {"label", required_argument,0,'l'}, - {"host", no_argument, 0,'h'}, - {"service", no_argument, 0,'s'}, - {0,0,0,0} - }; - - /* no options were supplied */ - if(argc<2) - return ERROR; - - while(1){ - - c=getopt_long(argc,argv,"hsw:c:d:l:",longopts,&option); - - if(c==-1 || c==EOF || c==1) - break; - - switch(c){ - - case 'h': /* host cluster */ - check_type=CHECK_HOSTS; - break; - - case 's': /* service cluster */ - check_type=CHECK_SERVICES; - break; - - case 'w': /* warning threshold */ - warning_threshold=atoi(optarg); - break; - - case 'c': /* warning threshold */ - critical_threshold=atoi(optarg); - break; - - case 'd': /* data values */ - data_vals=(char *)strdup(optarg); - break; - - case 'l': /* text label */ - label=(char *)strdup(optarg); - break; - - default: - return ERROR; - break; - } - } - - if(data_vals==NULL) - return ERROR; - - return OK; - } diff --git a/contrib/check_compaq_insight.pl b/contrib/check_compaq_insight.pl deleted file mode 100644 index dfb04402..00000000 --- a/contrib/check_compaq_insight.pl +++ /dev/null @@ -1,296 +0,0 @@ -From mm@elabnet.de Mon Nov 18 09:59:04 2002 -Date: Mon, 18 Nov 2002 12:19:04 +0100 -From: Michael Markstaller -To: nagiosplug-devel@lists.sourceforge.net -Subject: [Nagiosplug-devel] Submission: check_insight / checking Compaq - Insight Agent status - -Hi, - -I've been looking to check the status/health of Compaq Insight Agents on -servers and found a spong plugin -(http://spong.sourceforge.net/downloads/plugins/spong-network/check_insi -ght) which I've slightly changed to work with Nagios. -I have pretty no idea of perl at all, just wanted to make it work for -me, so please don't shoot me for this copy-paste-code. I've tested some -basic things, it seems to work at least to report a warning if smthg is -degraded and OK of xcourse ;) -I'm also quite unsure if this is the right way to submit, so I'll just -try ;) -There're some "unknown" components on all servers I've checked so far, -if anybody has a documentation of what's exactly returned when getting -the OID 1.3.6.1.4.1.232.11.2.10.1.0 (CPQHOST_MIB isn't very descriptive) -I'd be happy to fix this. - ---- cut --- -#!/usr/bin/perl -# -# (c)2002 Michael Markstaller, Elaborated Networks GmbH -# send bug reports to -# -# 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 (or with Nagios); if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA -# -# -# Check Comapq Insight Management Agents Systems Status by SNMP -# based on the spong-plugin check_insight from: -# -http://spong.sourceforge.net/downloads/plugins/spong-network/check_insig -ht -# -# Usage: -# check_insight -H -C community -# - -use Net::SNMP; -use Getopt::Long; -Getopt::Long::Configure('bundling'); - -$version=0.01; - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - - -# -# some default values -# -$TIMEOUT=15; - -# -# get command line options the regular way -# -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "v" => \$verbose, "verbose" => \$verbose, - "H=s" => \$opt_H, "hostname=s" => \$opt_H, - "C=s" => \$opt_C, "community=s" => \$opt_C); - -# -# handle the verbose stuff first -# -if ($opt_V) { - print "\n"; - print "check_insight nagios plugin version $version\n"; - print "\n"; - print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You -may redistribute\n"; - print "copies of the plugins under the terms of the GNU General -Public License.\n"; - print "For more information about these matters, see the file -named COPYING.\n"; - print "\n"; - print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n"; - print "\n"; - print "\n"; - exit $ERRORS{'UNKNOWN'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'UNKNOWN'}; -} - -# -# now get options the weired way and set the defaults -# if nothing else is provided -# -$opt_H = shift unless ($opt_H); -print_usage() unless ($opt_H); - -# -# dont let us wait forever... -# -$SIG{'ALRM'} = sub { - print ("ERROR: No response from server (alarm)\n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -# -# now we set things up for the real work -# and fire up the request -# - -######################################################################## -######## -my ($host) = ($opt_H); -my ($color, $summary, $message ) = ( "green", "", "" ); -($opt_C) || ($opt_C = shift) || ($opt_C = "public"); -my ($community) = $opt_C; - -# We use some look up tables for checking some config options. -my (@State) = ("Not Available", "Other", "OK", "Degraded", "Failed"); - -my (@MIBName) = ("", "Std", "Unknown", "Array", - "Netware", "SCSI", "Health","Unknown", - "Store", "SM2", "Thresh", "OS", "UPS", - "Unknown", "IDE", "Clusters", "Fibre", - "MIB", "NIC"); - -# These are the positions within the table to actually look at. -my (@MIBs) = (1, 2, 3, 5, 6, 10, 11, 14, 18); - -my ($oid) = "1.3.6.1.4.1.232.11.2.10.1.0"; # SysArray - -# Open the connection. -my ($session, $error) = Net::SNMP->session(Hostname => $host, - Community => $community); - -# If we can't open a connection, just return red straight away. -if (! defined $session) { - print ("ERROR: Unable to contact server '$opt_H'\n"); - exit $ERRORS{"UNKNOWN"}; -} - - -$session->translate; -my ($response) = $session->get_request($oid); - - if (!defined $response) { - # If there's no response, something screwy is going on, give up. - $summary = $session->error; - print ("ERROR: $summary\n"); - exit $ERRORS{"UNKNOWN"}; - $session->close; - } else { - $session->close; - - # I'm not convinced that this is the easiest way to go about this, -this is - # from some code which I've inherited and I've modified for use in -here. - # Hi George! - %h = %$response; - my ($d) = $h{$oid}; - - my (@list) = (); - - # Gobble the first two char's. - $d = substr $d,2; - - while (length($d) > 0) { - my ($v) = substr($d,0,2); - $v = hex($v); - $d = substr $d,2; - push @list, $v; - } - - # Value in $MIBs[1] is the overall status of the machine... - my ($cond) = $MIBs[1]; - $message .= "Status: $State[$cond] "; - - foreach my $v (@MIBs) { - $cond = $list[($v*4)+1]; # A little bit of magic. - - # We only bother printing the status out if it's actually -available, - # as if it's N/A or Unknown then it's probably because the machine - # isn't available. - $message .= "$MIBName[$v]: $State[$cond] " if $cond > 1; - next if $cond < 2; - - # What follows is some trickery to try and not to override a -previous - # message at the same or lower color. - if ($cond == 4) { - if ($color ne 'red') { - $color = 'red'; - $summary = "$MIBName[$v] is failed"; - } - } elsif ($cond == 3) { - if ($color ne 'red') { - $color = 'yellow'; - $summary = "$MIBName[$v] is degraded" if $summary eq ""; - } - } elsif ($cond < 2) { - if ($color eq 'green') { - $color = 'yellow'; - $summary = "$MIBName[$v] is unknown ($cond)" if $summary eq -""; - } - } - } - } - - $summary = "Ok" if $summary eq ""; - -# return ($color, $summary, $message); - -if ($color eq 'red') { - print ("red Output: $message\n"); - exit $ERRORS{"CRITICAL"}; - } elsif ($color eq 'yellow') { - print ("$summary $message\n"); - exit $ERRORS{"WARNING"}; - } elsif ($color eq 'green') { - print ("$message\n"); - exit $ERRORS{"OK"}; -} - - -sub print_usage () { - print "Usage: $0 -H -C \n"; } - -sub print_help () { - print "\n"; - print "\n"; - print "check_insight nagios plugin version $version\n"; - print "\n"; - print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You -may redistribute\n"; - print "copies of the plugins under the terms of the GNU General -Public License.\n"; - print "For more information about these matters, see the file -named COPYING.\n"; - print "\n"; - print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n"; - print "\n"; - print "\n"; - print "This plugin checks the Compaq Insight Management agents -system status via SNMP on the specified host.\n"; - print "\n"; - print "\n"; - print_usage(); - print "\n"; - print "Options:\n"; - print " -H, --hostname=ADDRESS\n"; - print " host name argument for server.\n"; - print " -C, --community=STRING\n"; - print " SNMP Read-community string.\n"; - print " -h, --help\n"; - print " print detailed help screen.\n"; - print " -V, --version\n"; - print " print version information.\n"; - print "\n"; - print "\n"; -} ---- cut --- - -Michael - - -------------------------------------------------------- -This sf.net email is sponsored by: To learn the basics of securing -your web site with SSL, click here to get a FREE TRIAL of a Thawte -Server Certificate: http://www.gothawte.com/rd524.html -_______________________________________________ -Nagiosplug-devel mailing list -Nagiosplug-devel@lists.sourceforge.net -https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel diff --git a/contrib/check_cpqarray.c b/contrib/check_cpqarray.c deleted file mode 100644 index badffeb4..00000000 --- a/contrib/check_cpqarray.c +++ /dev/null @@ -1,430 +0,0 @@ -/* - check_cpqarray, an extension for Netsaint / Nagios to check the - status of a Compaq SmartArray controller from the commandline. - Copyright (C) 2003 Guenther Mair - - based on the work and using main parts of - - CpqArray Deamon, a program to monitor and remotely configure a - SmartArray controller. - Copyright (C) 1999 Hugo Trippaers - - 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "/usr/src/linux/drivers/block/ida_ioctl.h" -#include "/usr/src/linux/drivers/block/ida_cmd.h" -#include "/usr/src/linux/drivers/block/cpqarray.h" - - -const char *controllers[] = -{ - "/dev/ida/c0d0", - "/dev/ida/c1d0", - "/dev/ida/c2d0", - "/dev/ida/c3d0", - "/dev/ida/c4d0", - "/dev/ida/c5d0", - "/dev/ida/c6d0", - "/dev/ida/c7d0" -}; - -const char *statusstr[] = { - "Logical drive /dev/ida/c%dd%d: OK\n", - "Logical drive /dev/ida/c%dd%d: FAILED\n", - "Logical drive /dev/ida/c%dd%d: not configured.\n", - "Logical drive /dev/ida/c%dd%d: using interim recovery mode, %3.2f%% done.\n", - "Logical drive /dev/ida/c%dd%d: ready for recovery operation.\n", - "Logical drive /dev/ida/c%dd%d: is currently recovering, %3.2f%% done.\n", - "Wrong physical drive was replaced.\n", - "A physical drive is not properly connected.\n", - "Hardware is overheating.\n", - "Hardware has overheated.\n", - "Logical drive /dev/ida/c%dd%d: currently expanding, %3.2f%% done.\n", - "Logical drive /dev/ida/c%dd%d: not yet available.\n", - "Logical drive /dev/ida/c%dd%d: queued for expansion.\n", -}; - -extern char *optarg; -extern int optind, opterr, optopt; - -int ctrls_found_num; -int exit_code = 0; -struct controller ctrls_found[8]; - -#define DEBUG(x) fprintf(stderr, x) - -struct opts -{ - char debug; -}; - -struct slog_disk -{ - int status; - float pvalue; -}; - -struct controller -{ - char ctrl_devicename[20]; - int num_logd_found; - struct slog_disk log_disk[16]; -}; - - - -int status_check (struct opts opts) -{ - int devicefd; - int ctrl_cntr; - int logd_cntr; - ida_ioctl_t io, io2; - int status, nr_blks, blks_tr; - float pvalue; - int counter; - - for ( ctrl_cntr=0; - ctrl_cntr < ctrls_found_num; - ctrl_cntr++) { - - devicefd = open (controllers[ctrl_cntr], O_RDONLY); - - for ( logd_cntr=0; - logd_cntr < ctrls_found[ctrl_cntr].num_logd_found; - logd_cntr++) { - - memset (&io, 0, sizeof (io)); - - io.cmd = SENSE_LOG_DRV_STAT; - io.unit = logd_cntr | UNITVALID; - - if (ioctl (devicefd, IDAPASSTHRU, &io) < 0) - { - perror ("SENSE_LOG_DRV_STAT ioctl"); - return 0; - } - - status=io.c.sense_log_drv_stat.status; - - if ((status == 3) || (status == 5) || (status == 7)) { - /* is a progress indicator required? - */ - memset (&io2, 0, sizeof (io)); - - io2.cmd = ID_LOG_DRV; - io2.unit = logd_cntr | UNITVALID; - - if (ioctl (devicefd, IDAPASSTHRU, &io2) < 0) - { - perror ("ID_LOG_DRV ioctl"); - /* return 0; no return this isn't fatal for now */ - } - else - { - nr_blks = io2.c.id_log_drv.nr_blks; - blks_tr = io.c.sense_log_drv_stat.blks_to_recover; - - pvalue = ((float)(nr_blks - blks_tr)/(float)nr_blks) * 100; - } - } - else { - pvalue = 0.0; - } - - if (opts.debug) { - fprintf(stdout, "DEBUG: Status of controller %d unit %d is %d\n", - ctrl_cntr, logd_cntr, status); - fprintf(stdout, "DEBUG: "); - fprintf(stdout, statusstr[status], - ctrl_cntr, logd_cntr, pvalue); - fprintf(stdout, "\n"); - } - - printf(statusstr[status], ctrl_cntr, logd_cntr, pvalue); - - switch(status) - { - case 1: - case 2: - case 6: - case 7: - case 9: - /* CRITICAL */ - exit_code = 2; - break; - case 3: - case 4: - case 5: - case 8: - case 10: - case 11: - case 12: - /* WARNING (only if not yet at CRITICAL LEVEL) */ - if (exit_code < 2) exit_code = 1; - break; - case 0: - default: - /* do nothing */ - break; - } - - ctrls_found[ctrl_cntr].log_disk[logd_cntr].pvalue = pvalue; - ctrls_found[ctrl_cntr].log_disk[logd_cntr].status = status; - } - close (devicefd); - } - - return 1; -} - -int discover_controllers (struct opts opts) -{ - int cntr; - int foundone = 0; - - for (cntr = 0; cntr < 8; cntr++) - { - /* does this device exist ? */ - if ((access (controllers[cntr], R_OK | F_OK)) == 0) - { - /* it does :) */ - if (interrogate_controller (opts, cntr)) - { - foundone = 1; - if (opts.debug) - fprintf (stderr, "DEBUG: %s is a existing controller\n", - controllers[cntr]); - } - } - else if (opts.debug) - { - fprintf (stderr, "DEBUG: Device %s could not be opened\n", controllers[cntr]); - perror ("DEBUG: reason"); - } - } - return foundone; -} - -void boardid2str (unsigned long board_id, char *name) -{ - switch (board_id) - { - case 0x0040110E: /* IDA */ - strcpy (name, "Compaq IDA"); - break; - case 0x0140110E: /* IDA-2 */ - strcpy (name, "Compaq IDA-2"); - break; - case 0x1040110E: /* IAES */ - strcpy (name, "Compaq IAES"); - break; - case 0x2040110E: /* SMART */ - strcpy (name, "Compaq SMART"); - break; - case 0x3040110E: /* SMART-2/E */ - strcpy (name, "Compaq SMART-2/E"); - break; - case 0x40300E11: /* SMART-2/P or SMART-2DH */ - strcpy (name, "Compaq SMART-2/P (2DH)"); - break; - case 0x40310E11: /* SMART-2SL */ - strcpy (name, "Compaq SMART-2SL"); - break; - case 0x40320E11: /* SMART-3200 */ - strcpy (name, "Compaq SMART-3200"); - break; - case 0x40330E11: /* SMART-3100ES */ - strcpy (name, "Compaq SMART-3100ES"); - break; - case 0x40340E11: /* SMART-221 */ - strcpy (name, "Compaq SMART-221"); - break; - case 0x40400E11: /* Integrated Array */ - strcpy (name, "Compaq Integrated Array"); - break; - case 0x40500E11: /* Smart Array 4200 */ - strcpy (name, "Compaq Smart Array 4200"); - break; - case 0x40510E11: /* Smart Array 4250ES */ - strcpy (name, "Compaq Smart Array 4250ES"); - break; - case 0x40580E11: /* Smart Array 431 */ - strcpy (name, "Compaq Smart Array 431"); - break; - default: - /* - * Well, its a SMART-2 or better, don't know which - * kind. - */ - strcpy (name, "Unknown Controller Type"); - } -} - -int interrogate_controller (struct opts opts, int contrnum) -{ - int devicefd; - ida_ioctl_t io; - char buffer[30]; - int foundone = 0; - int cntr; - - devicefd = open (controllers[contrnum], O_RDONLY); - /* no checks, did that before */ - - /* clear io */ - memset (&io, 0, sizeof (io)); - - io.cmd = ID_CTLR; - - if (ioctl (devicefd, IDAPASSTHRU, &io) < 0) - { - if (opts.debug) perror ("DEBUG: ioctl"); - return 0; - } - - boardid2str (io.c.id_ctlr.board_id, buffer); - - strncpy (ctrls_found[ctrls_found_num].ctrl_devicename, - buffer, 20); - - ctrls_found[ctrls_found_num].num_logd_found = 0; - - for (cntr = 0; cntr < io.c.id_ctlr.nr_drvs; cntr++) - { - if (interrogate_logical (opts, devicefd, cntr)) - { - /* logical drive found, this could be used later one */ - foundone = 1; - } - } - - switch (ctrls_found[ctrls_found_num].num_logd_found) - { - case 0: - printf("Found a %s with no logical drives.\n", buffer); - break; - case 1: - printf("Found a %s with one Logical drive.\n", buffer, - ctrls_found[ctrls_found_num].num_logd_found); - break; - default: - printf("Found a %s with %d Logical drives.\n", buffer, - ctrls_found[ctrls_found_num].num_logd_found); - break; - } - - ctrls_found_num++; - - close (devicefd); - return 1; -} - -int interrogate_logical (struct opts opts, int devicefd, int unit_nr) -{ - ida_ioctl_t io; - ida_ioctl_t io2; - int nr_blks, blks_tr; - - if (opts.debug) printf ("DEBUG: interrogating unit %d\n", unit_nr); - - memset (&io, 0, sizeof (io)); - - io.cmd = ID_LOG_DRV; - io.unit = unit_nr | UNITVALID; - - if (ioctl (devicefd, IDAPASSTHRU, &io) < 0) - { - perror ("FATAL: ID_LOG_DRV ioctl"); - return 0; - } - - memset (&io2, 0, sizeof (io2)); - - io2.cmd = SENSE_LOG_DRV_STAT; - io2.unit = unit_nr | UNITVALID; - - if (ioctl (devicefd, IDAPASSTHRU, &io2) < 0) - { - perror ("FATAL: SENSE_LOG_DRV_STAT ioctl"); - return 0; - } - - ctrls_found[ctrls_found_num].num_logd_found++; - /* ctrls_found[ctrls_found_num].log_disk[unit_nr].status = - * io2.c.sense_log_drv_stat.status; - - * nr_blks = io2.c.id_log_drv.nr_blks; - * blks_tr = io.c.sense_log_drv_stat.blks_to_recover; - * ctrls_found[ctrls_found_num].log_disk[unit_nr].pvalue = - * ((float)(nr_blks - blks_tr)/(float)nr_blks) * 100; - */ - ctrls_found[ctrls_found_num].log_disk[unit_nr].status = 0; - ctrls_found[ctrls_found_num].log_disk[unit_nr].pvalue = 0; - - return 1; -} - - -void print_usage() -{ - printf("cpqarrayd [options]\n"); - printf(" -h prints this text\n"); - printf(" -d enables debugging\n"); -} - - -int main(int argc, char *argv[]) -{ - char option; - struct opts opts; /* commandline options */ - - memset(&opts, 0, sizeof(struct opts)); - - /* check options */ - while ((option = getopt (argc, argv, "dh:")) != EOF) - { - switch (option) - { - case 'd': - opts.debug = 1; - break; - case '?': - case 'h': - default: - print_usage(); - exit(0); - break; - } - } - - /* Check for existance of array controllers */ - if (!discover_controllers(opts)) { - printf("No array controller found!\n\n"); - exit(1); - } - - status_check(opts); - - return exit_code; -} diff --git a/contrib/check_digitemp.pl b/contrib/check_digitemp.pl deleted file mode 100755 index d2b40a10..00000000 --- a/contrib/check_digitemp.pl +++ /dev/null @@ -1,252 +0,0 @@ -#!/usr/bin/perl -w - -# check_digitemp.pl Copyright (C) 2002 by Brian C. Lane -# -# This is a NetSaint plugin script to check the temperature on a local -# machine. Remote usage may be possible with SSH -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# =========================================================================== -# Howto Install in NetSaint (tested with v0.0.7) -# -# 1. Copy this script to /usr/local/netsaint/libexec/ or wherever you have -# placed your NetSaint plugins -# -# 2. Create a digitemp config file in /usr/local/netsaint/etc/ -# eg. digitemp -i -s/dev/ttyS0 -c /usr/local/netsaint/etc/digitemp.conf -# -# 3. Make sure that the webserver user has permission to access the serial -# port being used. -# -# 4. Add a command to /usr/local/netsaint/etc/commands.cfg like this: -# command[check-temp]=$USER1$/check_digitemp.pl -w $ARG1$ -c $ARG2$ \ -# -t $ARG3$ -f $ARG4$ -# (fold into one line) -# -# 5. Tell NetSaint to monitor the temperature by adding a service line like -# this to your hosts.cfg file: -# service[kermit]=Temperature;0;24x7;3;5;1;home-admins;120;24x7;1;1;1;; \ -# check-temp!65!75!1!/usr/local/netsaint/etc/digitemp.conf -# (fold into one line) -# 65 is the warning temperature -# 75 is the critical temperature -# 1 is the sensor # (as reported by digitemp -a) to monitor -# digitemp.conf is the path to the config file -# -# 6. If you use Centigrade instead of Fahrenheit, change the commands.cfg -# line to include the -C argument. You can then pass temperature limits in -# Centigrade in the service line. -# -# =========================================================================== -# Howto Install in Nagios (tested with v1.0b4) -# -# 1. Copy this script to /usr/local/nagios/libexec/ or wherever you have -# placed your Nagios plugins -# -# 2. Create a digitemp config file in /usr/local/nagios/etc/ -# eg. digitemp -i -s/dev/ttyS0 -c /usr/local/nagios/etc/digitemp.conf -# -# 3. Make sure that the webserver user has permission to access the serial -# port being used. -# -# 4. Add a command to /usr/local/nagios/etc/checkcommands.cfg like this: -# -# #DigiTemp temperature check command -# define command{ -# command_name check_temperature -# command_line $USER1$/check_digitemp.pl -w $ARG1$ -c $ARG2$ \ -# -t $ARG3$ -f $ARG4$ -# (fold above into one line) -# } -# -# 5. Tell NetSaint to monitor the temperature by adding a service line like -# this to your service.cfg file: -# -# #DigiTemp Temperature check Service definition -# define service{ -# use generic-service -# host_name kermit -# service_description Temperature -# is_volatile 0 -# check_period 24x7 -# max_check_attempts 3 -# normal_check_interval 5 -# retry_check_interval 2 -# contact_groups home-admins -# notification_interval 240 -# notification_period 24x7 -# notification_options w,u,c,r -# check_command check_temperature!65!75!1! \ -# /usr/local/nagios/etc/digitemp.conf -# (fold into one line) -# } -# -# 65 is the warning temperature -# 75 is the critical temperature -# 1 is the sensor # (as reported by digitemp -a) to monitor -# digitemp.conf is the path to the config file -# -# 6. If you use Centigrade instead of Fahrenheit, change the checkcommands.cfg -# line to include the -C argument. You can then pass temperature limits in -# Centigrade in the service line. -# -# =========================================================================== - -# Modules to use -use strict; -use Getopt::Std; - -# Define all our variable usage -use vars qw($opt_c $opt_f $opt_t $opt_w $opt_F $opt_C - $temperature $conf_file $sensor $temp_fmt - $crit_level $warn_level $null - %exit_codes - $percent $fmt_pct - $verb_err $command_line); - - -# Predefined exit codes for NetSaint -%exit_codes = ('UNKNOWN' ,-1, - 'OK' , 0, - 'WARNING' , 1, - 'CRITICAL', 2,); - -# Default to Fahrenheit input and result (use -C to change this) -$temp_fmt = 3; - - -# Get the options -if ($#ARGV le 0) -{ - &usage; -} else { - getopts('f:t:FCc:w:'); -} - -# Shortcircuit the switches -if (!$opt_w or $opt_w == 0 or !$opt_c or $opt_c == 0) -{ - print "*** You must define WARN and CRITICAL levels!"; - &usage; -} - -# Check if levels are sane -if ($opt_w >= $opt_c) -{ - print "*** WARN level must not be greater than CRITICAL when checking temperature!"; - &usage; -} - - -$warn_level = $opt_w; -$crit_level = $opt_c; - -# Default sensor to read is #0 -if(!$opt_t) -{ - $sensor = 0; -} else { - $sensor = $opt_t; -} - -# Default config file is /etc/digitemp.conf -if(!$opt_f) -{ - $conf_file = "/etc/digitemp.conf"; -} else { - $conf_file = $opt_f; -} - -# Check for config file -if( !-f $conf_file ) { - print "*** You must have a digitemp.conf file\n"; - &usage; -} - - -if($opt_C) -{ - $temp_fmt = 2; -} - -# Read the output from digitemp -# Output in form 0\troom\tattic\tdrink -open( DIGITEMP, "/usr/local/bin/digitemp -c $conf_file -t $sensor -q -o $temp_fmt |" ); - -# Process the output from the command -while( ) -{ -# print "$_\n"; - chomp; - - if( $_ =~ /^nanosleep/i ) - { - print "Error reading sensor #$sensor\n"; - close(DIGITEMP); - exit $exit_codes{'UNKNOWN'}; - } else { - # Check for an error from digitemp, and report it instead - if( $_ =~ /^Error.*/i ) { - print $_; - close(DIGITEMP); - exit $exit_codes{'UNKNOWN'}; - } else { - ($null,$temperature) = split(/\t/); - } - } -} -close( DIGITEMP ); - -if( $temperature and $temperature >= $crit_level ) -{ - print "Temperature CRITICAL - Sensor #$sensor = $temperature "; - if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; } - exit $exit_codes{'CRITICAL'}; -} elsif ($temperature and $temperature >= $warn_level ) { - print "Temperature WARNING - Sensor #$sensor = $temperature "; - if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; } - exit $exit_codes{'WARNING'}; -} elsif( $temperature ) { - print "Temperature OK - Sensor #$sensor = $temperature "; - if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; } - exit $exit_codes{'OK'}; -} else { - print "Error parsing result for sensor #$sensor\n"; - exit $exit_codes{'UNKNOWN'}; -} - -# Show usage -sub usage() -{ - print "\ncheck_digitemp.pl v1.0 - NetSaint Plugin\n"; - print "Copyright 2002 by Brian C. Lane \n"; - print "See source for License\n"; - print "usage:\n"; - print " check_digitemp.pl -t -f -w -c \n\n"; - print "options:\n"; - print " -f DigiTemp Config File\n"; - print " -t DigiTemp Sensor #\n"; - print " -F Temperature in Fahrenheit\n"; - print " -C Temperature in Centigrade\n"; - print " -w temperature temperature >= to warn\n"; - print " -c temperature temperature >= when critical\n"; - - exit $exit_codes{'UNKNOWN'}; -} diff --git a/contrib/check_dlswcircuit.pl b/contrib/check_dlswcircuit.pl deleted file mode 100755 index f6ef9311..00000000 --- a/contrib/check_dlswcircuit.pl +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/perl -w -# -# check_dlswcircuit.pl - nagios plugin -# -# Checks if a Cisco Dlsw circuit is connected. -# -# -# Copyright (C) 2000 Carsten Foss & Christoph Kron -# -# Basically this is an adapted version of Christoph Kron's (ck@zet.net) check_ifoperstatus.pl plugin. -# most of the thanks should go to him. -# -# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Arguments : -s -d -c -p -# - -# Source & Dest Mac/Sap arguments must be given in Hex as this example : 40.00.01.37.45.01.ss (Where ss is the sap) -# -# Sample command line : check_dlswcircuit.pl -s 40.00.01.37.45.01.04 -d 40.00.02.37.45.02.04 -c secret 1.2.3.4 -# -# Sample host.cfg entry : -#service[Dlsw-xx]=NCP1-NCP2;0;24x7;3;5;1;router-admins;240;24x7;1;1;0;;check_dlswcircuit!-s 40.00.01.37.45.01.04!-d 40.00..01.37.45.02.04!-c secret!1.2.3.4 -# remember to add the service to commands.cfg , something like this: -# command[check_dlswcircuit]=$USER1$/check_dlswcircuit.pl $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ -# -# Report bugs to: cfo@dmdata.dk -# -# 11.03.2000 Version 1.0 - -use strict; - -use Net::SNMP; -use Getopt::Long; -&Getopt::Long::config('auto_abbrev'); - - -my $status; -my $TIMEOUT = 15; - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - -my %dlswCircuitStatus = ( - '1','disconnected', - '2','circuitStart', - '3','resolvePending', - '4','circuitPending', - '5','circuitEstablished', - '6','connectPending', - '7','contactPending', - '8','connected', - '9','disconnectPending', - '10','haltPending', - '11','haltPendingNoack', - '13','circuitRestart', - '14','restartPending'); - -my $state = "UNKNOWN"; -my $answer = ""; -my $smac = ""; -my $dmac = ""; -my $community = "public"; -my $port = 161; -#Dlsw Circuit Oid enterprises.9.10.9.1.5.2.1.17.6.0.96.148.47.230.166.4.6.64.0.1.55.69.2.4 = 8 -my $enterpriseOid = "1.3.6.1.4.1"; -my $ciscoDlswCircuitOid = ".9.10.9.1.5.2.1.17."; -my $unknownOid = "6."; -my $smacOid = ""; -my $dmacOid = ""; -my $tmpOid = ""; -my @tmparg; -my $snmpoid; -my @snmpoids; -my $hostname; -my $session; -my $error; -my $response; -my $p = ""; -my $q = ""; - -sub usage { - printf "\nMissing arguments!\n"; - printf "\n"; - printf "Perl Check Cisco Dlsw Circuit State plugin for Nagios\n"; - printf "checks operational status of specified DLSW Circuit\n"; - printf "usage: \n"; - printf "check_dlswcircuit.pl -s -d -c -p "; - printf "\nCopyright (C) 2000 Carsten Foss\n"; - printf "check_dlswcircuit.pl comes with ABSOLUTELY NO WARRANTY\n"; - printf "This programm is licensed under the terms of the "; - printf "GNU General Public License\n(check source code for details)\n"; - printf "\n\n"; - exit $ERRORS{"UNKNOWN"}; -} - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print ("ERROR: No snmp response from $hostname (alarm)\n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -$status = GetOptions("sourcemac=s",\$smac,"destmac=s",\$dmac, - "community=s",\$community, - "port=i",\$port); -if ($status == 0) -{ - &usage; -} - -# -#Convert Source Mac & Sap -# - @tmparg = split(/\./,$smac); - #print "-$smac-\n"; - #print "@tmparg\n"; - #print "$#tmparg\n"; - if($#tmparg != 6) - { - print "SourceMac/Sap format $smac not valid\n"; - &usage; - } - while($p = shift @tmparg) - { - $q = hex($p); - $smacOid = $smacOid.$q; - $smacOid = $smacOid.'.'; - } - - #print "@tmparg1\n"; - #print "$smacOid\n"; - -# -#Convert Dest Mac & Sap -# - @tmparg = split(/\./,$dmac); - #print "-$dmac-\n"; - #print "@tmparg\n"; - #print "$#tmparg\n"; - if($#tmparg != 6) - { - print "DestMac/Sap format $dmac not valid\n"; - &usage; - } - - while($p = shift @tmparg) - { - $q = hex($p); - $dmacOid = $dmacOid.$q; - $dmacOid = $dmacOid.'.'; - } -# Remove Trailing Dot - $dmacOid = substr($dmacOid,0,length($dmacOid)-1); - - - #print "@tmparg1\n"; - #print "$dmacOid\n"; -#Build the Dlsw Oic to use - $snmpoid = $enterpriseOid.$ciscoDlswCircuitOid.$unknownOid.$smacOid.$unknownOid.$dmacOid ; - #print "$snmpoid\n"; - - #shift; - $hostname = shift || &usage; - - ($session, $error) = Net::SNMP->session( - -hostname => $hostname, - -community => $community, - -port => $port - ); - - if (!defined($session)) { - $state='UNKNOWN'; - $answer=$error; - print ("$state: $answer"); - exit $ERRORS{$state}; - } - - push(@snmpoids,$snmpoid); - #push(@snmpoids,$snmpLocIfDescr); - - if (!defined($response = $session->get_request(@snmpoids))) { - $answer=$session->error; - $session->close; - $state = 'CRITICAL'; - print ("$state: $answer,$community,$smac - $dmac"); - exit $ERRORS{$state}; - } - - $answer = sprintf("dlsw circuit %s - %s at host '%s',is %s\n", - $smac, - $dmac, - $hostname, - $dlswCircuitStatus{$response->{$snmpoid}} - ); - - $session->close; - - if ( $response->{$snmpoid} == 8 ) { - $state = 'OK'; - } - else { - $state = 'CRITICAL'; - } - -print ("$state: $answer"); -exit $ERRORS{$state}; diff --git a/contrib/check_dns_random.pl b/contrib/check_dns_random.pl deleted file mode 100644 index 4bed4120..00000000 --- a/contrib/check_dns_random.pl +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/perl -# ------------------------------------------------------------------------------ -# File Name: check_dns_random.pl -# Author: Richard Mayhew - South Africa -# Date: 2000/01/26 -# Version: 1.0 -# Description: This script will check to see if dns resolves hosts -# randomly from a list using the check_dns plugin. -# Email: netsaint@splash.co.za -# ------------------------------------------------------------------------------ -# Copyright 1999 (c) Richard Mayhew -# Credits go to Ethan Galstad for coding Nagios -# If any changes are made to this script, please mail me a copy of the -# changes :) -# License GPL -# ------------------------------------------------------------------------------ -# Date Author Reason -# ---- ------ ------ -# 1999/09/26 RM Creation -# ------------------------------------------------------------------------------ - -# -----------------------------------------------------------------[ Require ]-- -require 5.004; - -# --------------------------------------------------------------------[ Uses ]-- -use Socket; -use strict; - -# --------------------------------------------------------------[ Enviroment ]-- -$ENV{PATH} = "/bin"; -$ENV{BASH_ENV} = ""; -$|=1; - -my $host = shift || &usage; - -my $domainfile = "/usr/local/nagios/etc/domains.list"; -my $wc = `/usr/bin/wc -l $domainfile`; -my $check = "/usr/local/nagios/libexec/check_dns"; -my $x = 0; -my $srv_file = ""; -my $z = ""; -my $y = ""; - -open(DOMAIN,"<$domainfile") or die "Error Opening $domainfile File!\n"; - while () { - $srv_file .= $_; -} - close(DOMAIN); - my @data = split(/\n/,$srv_file); - -chomp $wc; -$wc =~ s/ //g; -$wc =~ s/domains//g; - -$x = rand $wc; -($z,$y) = split(/\./,$x); - -system($check, $data[$z], $host); -exit ($? / 256); - -sub usage -{ - print "Minimum arguments not supplied!\n"; - print "\n"; - print "Perl Check Random DNS plugin for Nagios\n"; - print "Copyright (c) 2000 Richard Mayhew\n"; - print "\n"; - print "Usage: check_dns_random.pl \n"; - print "\n"; - print " = DNS server you would like to query.\n"; - exit -1; - -} - diff --git a/contrib/check_email_loop.pl b/contrib/check_email_loop.pl deleted file mode 100644 index 1b02ea3c..00000000 --- a/contrib/check_email_loop.pl +++ /dev/null @@ -1,309 +0,0 @@ -#!/usr/bin/perl -w -# -# $Id: check_email_loop.pl 1290 2005-11-29 23:21:06Z harpermann $ -# -# (c)2000 Benjamin Schmid, blueshift@gmx.net (emergency use only ;-) -# Copyleft by GNU GPL -# -# -# check_email_loop Nagios Plugin -# -# This script sends a mail with a specific id in the subject via -# an given smtp-server to a given email-adress. When the script -# is run again, it checks for this Email (with its unique id) on -# a given pop3 account and send another mail. -# -# -# Example: check_email_loop.pl -poph=mypop -popu=user -pa=password -# -smtph=mailer -from=returnadress@yoursite.com -# -to=remaileradress@friend.com -pendc=2 -lostc=0 -# -# This example will send eacht time this check is executed a new -# mail to remaileradress@friend.com using the SMTP-Host mailer. -# Then it looks for any back-forwarded mails in the POP3 host -# mypop. In this Configuration CRITICAL state will be reached if -# more than 2 Mails are pending (meaning that they did not came -# back till now) or if a mails got lost (meaning a mail, that was -# send later came back prior to another mail). -# -# Michael Markstaller, mm@elabnet.de various changes/additions -# MM 021003: fixed some unquoted strings -# MM 021116: fixed/added pendwarn/lostwarn -# MM 030515: added deleting of orphaned check-emails -# changed to use "top" instead of get to minimize traffic (required changing match-string from "Subject: Email-ping [" to "Email-Ping [" - -use Net::POP3; -use Net::SMTP; -use strict; -use Getopt::Long; -&Getopt::Long::config('auto_abbrev'); - -# ---------------------------------------- - -my $TIMEOUT = 120; -my %ERRORS = ('OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - 'UNKNOWN' , '3'); - -my $state = "UNKNOWN"; -my ($sender,$receiver, $pophost, $popuser, $poppasswd, $smtphost,$keeporphaned); -my ($poptimeout,$smtptimeout,$pinginterval,$maxmsg)=(60,60,5,50); -my ($lostwarn, $lostcrit,$pendwarn, $pendcrit,$debug); -$debug = 0; - -# Internal Vars -my ($pop,$msgcount,@msglines,$statinfo,@messageids,$newestid); -my (%other_smtp_opts); -my ($matchcount,$statfile) = (0,"check_email_loop.stat"); - -# Subs declaration -sub usage; -sub messagematchs; -sub nsexit; - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print ("ERROR: $0 Time-Out $TIMEOUT s \n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -# Evaluate Command Line Parameters -my $status = GetOptions( - "from=s",\$sender, - "to=s",\$receiver, - "debug", \$debug, - "pophost=s",\$pophost, - "popuser=s",\$popuser, - "passwd=s",\$poppasswd, - "poptimeout=i",\$poptimeout, - "smtphost=s",\$smtphost, - "smtptimeout=i",\$smtptimeout, - "statfile=s",\$statfile, - "interval=i",\$pinginterval, - "lostwarn=i",\$lostwarn, - "lostcrit=i",\$lostcrit, - "pendwarn=i",\$pendwarn, - "pendcrit=i",\$pendcrit, - "maxmsg=i",\$maxmsg, - "keeporphaned=s",\$keeporphaned, - ); -usage() if ($status == 0 || ! ($pophost && $popuser && $poppasswd && - $smtphost && $receiver && $sender )); - -# Try to read the ids of the last send emails out of statfile -if (open STATF, "$statfile") { - @messageids = ; - chomp @messageids; - close STATF; -} - -# Try to open statfile for writing -if (!open STATF, ">$statfile") { - nsexit("Failed to open mail-ID database $statfile for writing",'CRITICAL'); -} - -# Ok - check if it's time to release another mail - -# ... - -# creating new serial id -my $serial = time(); -$serial = "ID#" . $serial . "#$$"; - - -# sending new ping email -%other_smtp_opts=(); -if ( $debug == 1 ) { - $other_smtp_opts{'Debug'} = 1; -} - -my $smtp = Net::SMTP->new($smtphost,Timeout=>$smtptimeout, %other_smtp_opts) - || nsexit("SMTP connect timeout ($smtptimeout s)",'CRITICAL'); -($smtp->mail($sender) && - $smtp->to($receiver) && - $smtp->data() && - $smtp->datasend("To: $receiver\nSubject: E-Mail Ping [$serial]\n\n". - "This is an automatically sent E-Mail.\n". - "It is not intended for a human reader.\n\n". - "Serial No: $serial\n") && - $smtp->dataend() && - $smtp->quit - ) || nsexit("Error delivering message",'CRITICAL'); - -# no the interessting part: let's if they are receiving ;-) - -$pop = Net::POP3->new( $pophost, - Timeout=>$poptimeout) - || nsexit("POP3 connect timeout (>$poptimeout s, host: $pophost)",'CRITICAL'); - -$msgcount=$pop->login($popuser,$poppasswd); - -$statinfo="$msgcount mails on POP3"; - -nsexit("POP3 login failed (user:$popuser)",'CRITICAL') if (!defined($msgcount)); - -# Check if more than maxmsg mails in pop3-box -nsexit(">$maxmsg Mails ($msgcount Mails on POP3); Please delete !",'WARNING') if ($msgcount > $maxmsg); - -my ($mid, $nid); -# Count messages, that we are looking 4: -while ($msgcount > 0) { - @msglines = @{$pop->top($msgcount,1)}; - for (my $i=0; $i < scalar @messageids; $i++) { - if (messagematchsid(\@msglines,$messageids[$i])) { - $matchcount++; - # newest received mail than the others, ok remeber id. - if (!defined $newestid) { - $newestid = $messageids[$i]; - } else { - $messageids[$i] =~ /\#(\d+)\#/; - $mid = $1; - $newestid =~ /\#(\d+)\#/; - $nid = $1; - if ($mid > $nid) { - $newestid = $messageids[$i]; - } - } - $pop->delete($msgcount); # remove E-Mail from POP3 server - splice @messageids, $i, 1;# remove id from List - last; # stop looking in list - } - } - # Delete orphaned Email-ping msg - my @msgsubject = grep /^Subject/, @msglines; - chomp @msgsubject; - # Scan Subject if email is an Email-Ping. In fact we match and delete also successfully retrieved messages here again. - if (!defined $keeporphaned && $msgsubject[0] =~ /E-Mail Ping \[/) { - $pop->delete($msgcount); # remove E-Mail from POP3 server - } - - $msgcount--; -} - -$pop->quit(); # necessary for pop3 deletion! - -# traverse through the message list and mark the lost mails -# that mean mails that are older than the last received mail. -if (defined $newestid) { - $newestid =~ /\#(\d+)\#/; - $newestid = $1; - for (my $i=0; $i < scalar @messageids; $i++) { - $messageids[$i] =~ /\#(\d+)\#/; - my $akid = $1; - if ($akid < $newestid) { - $messageids[$i] =~ s/^ID/LI/; # mark lost - } - } -} - -# Write list to id-Database -foreach my $id (@messageids) { - print STATF "$id\n"; -} -print STATF "$serial\n"; # remember send mail of this session -close STATF; - -# ok - count lost and pending mails; -my @tmp = grep /^ID/, @messageids; -my $pendingm = scalar @tmp; -@tmp = grep /^LI/, @messageids; -my $lostm = scalar @tmp; - -# Evaluate the Warnin/Crit-Levels -if (defined $pendwarn && $pendingm > $pendwarn) { $state = 'WARNING'; } -if (defined $lostwarn && $lostm > $lostwarn) { $state = 'WARNING'; } -if (defined $pendcrit && $pendingm > $pendcrit) { $state = 'CRITICAL'; } -if (defined $lostcrit && $lostm > $lostcrit) { $state = 'CRITICAL'; } - -if ((defined $pendwarn || defined $pendcrit || defined $lostwarn - || defined $lostcrit) && ($state eq 'UNKNOWN')) {$state='OK';} - - -# Append Status info -$statinfo = $statinfo . ", $matchcount mail(s) came back,". - " $pendingm pending, $lostm lost."; - -# Exit in a Nagios-compliant way -nsexit($statinfo); - -# ---------------------------------------------------------------------- - -sub usage { - print "check_email_loop 1.1 Nagios Plugin - Real check of a E-Mail system\n"; - print "=" x 75,"\nERROR: Missing or wrong arguments!\n","=" x 75,"\n"; - print "This script sends a mail with a specific id in the subject via an given\n"; - print "smtp-server to a given email-adress. When the script is run again, it checks\n"; - print "for this Email (with its unique id) on a given pop3 account and sends \n"; - print "another mail.\n"; - print "\nThe following options are available:\n"; - print " -from=text email adress of send (for mail returnr on errors)\n"; - print " -to=text email adress to which the mails should send to\n"; - print " -pophost=text IP or name of the POP3-host to be checked\n"; - print " -popuser=text Username of the POP3-account\n"; - print " -passwd=text Password for the POP3-user\n"; - print " -poptimeout=num Timeout in seconds for the POP3-server\n"; - print " -smtphost=text IP oder name of the SMTP host\n"; - print " -smtptimeout=num Timeout in seconds for the SMTP-server\n"; - print " -statfile=text File to save ids of messages ($statfile)\n"; - print " -interval=num Time (in minutes) that must pass by before sending\n"; - print " another Ping-mail (gibe a new try);\n"; - print " -lostwarn=num WARNING-state if more than num lost emails\n"; - print " -lostcrit=num CRITICAL \n"; - print " -pendwarn=num WARNING-state if more than num pending emails\n"; - print " -pendcrit=num CRITICAL \n"; - print " -maxmsg=num WARNING if more than num emails on POP3 (default 50)\n"; - print " -keeporphaned Set this to NOT delete orphaned E-Mail Ping msg from POP3\n"; - print " -debug send SMTP tranaction info to stderr\n\n"; - print " Options may abbreviated!\n"; - print " LOST mails are mails, being sent before the last mail arrived back.\n"; - print " PENDING mails are those, which are not. (supposed to be on the way)\n"; - print "\nExample: \n"; - print " $0 -poph=host -pa=pw -popu=popts -smtph=host -from=root\@me.com\n "; - print " -to=remailer\@testxy.com -lostc=0 -pendc=2\n"; - print "\nCopyleft 19.10.2000, Benjamin Schmid / 2003 Michael Markstaller, mm\@elabnet.de\n"; - print "This script comes with ABSOLUTELY NO WARRANTY\n"; - print "This programm is licensed under the terms of the "; - print "GNU General Public License\n\n"; - exit $ERRORS{"UNKNOWN"}; -} - -# --------------------------------------------------------------------- - -sub nsexit { - my ($msg,$code) = @_; - $code=$state if (!defined $code); - print "$code: $msg\n" if (defined $msg); - exit $ERRORS{$code}; -} - -# --------------------------------------------------------------------- - -sub messagematchsid { - my ($mailref,$id) = (@_); - my (@tmp); - my $match = 0; - - # ID - $id =~ s/^LI/ID/; # evtl. remove lost mail mark - @tmp = grep /E-Mail Ping \[/, @$mailref; - chomp @tmp; - if (($tmp[0] =~ /$id/)) - { $match = 1; } - - # Sender: -# @tmp = grep /^From:\s+/, @$mailref; -# if (@tmp && $sender ne "") -# { $match = $match && ($tmp[0]=~/$sender/); } - - # Receiver: -# @tmp = grep /^To: /, @$mailref; -# if (@tmp && $receiver ne "") -# { $match = $match && ($tmp[0]=~/$receiver/); } - - return $match; -} - -# --------------------------------------------------------------------- diff --git a/contrib/check_fan_cpq_present b/contrib/check_fan_cpq_present deleted file mode 100644 index 0bd13909..00000000 --- a/contrib/check_fan_cpq_present +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/perl -# -# -# check_most.pl -i -p -c community -o [warn] [critical] -# -# NetSaint host script to get the disk usage from NT snmp -# -# Changes and Modifications -# ========================= -# 3-Aug-2000 - Xavier Dusart -# Created -# 2003 - Rainer Duffner - -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} - - - -require 5.004; -use POSIX; -#use strict; -use Getopt::Std ; -use BER; -require 'SNMP_Session.pm'; -use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME); -use lib $main::runtimedir; -use utils qw($TIMEOUT %ERRORS &print_revision &usage &support); -use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED); - -delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer - -getopts('H:p:C:f:hV') ; - -my $ip_address=undef ; - -if ($opt_h) {&help();} - -if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA --Z0-9]*)*)$/) { - $ip_address = $opt_H ; - } -else { - usage(); - print "IP-Address format wrong\n"; - exit $ERRORS{'UNKNOWN'}; - } - -#if ($opt_p =~ m/^[0-9] - -my $port = $opt_p; - -my $community = $opt_C; - -my $fan = $opt_f ; - -#my $err_counter=0 ; -#my $err_status=""; - - my $fan_locale_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,3,0,$fan ); -# not used for the moment - gives no usable output -# if reused, enter at end of list to avoid renumbering ! - my $fan_present_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,4,0,$fan ); - my $fan_speed_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,6,0,$fan ); - my $fan_condition_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,9,0,$fan ); - my $count=1 ; - my $label ; - my @r_array=(); - my $q ; - my $diff ; - $warning=$warning/100 ; - $crititcal=$critical/100 ; - - -# get temperature, temperature_threshold bfore shutdown - my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ; - - if ($session->get_request_response ($fan_present_oid, $fan_locale_oid, $fan_speed_oid, $fan_condition_oid )) { - (my $bindings) = $session->decode_get_response ($session->{pdu_buffer}); - while ($bindings ne '') { - ($binding, $bindings) = &decode_sequence ($bindings) ; - ($oid,$value) = &decode_by_template ($binding,"%O%@"); - $r_array[$count]=&pretty_print($value); - $count++; - } - } else { - print "No response from agent\n"; - exit $ERRORS{'CRITICAL'}; - } - $result_fan_present= $r_array[1]; - $result_fan_locale= $r_array[2]; - $result_fan_speed= $r_array[3]; - $result_fan_condition=$r_array[4]; - - - if ( $result_fan_present != 3 || $result_fan_speed !=2 ) { - print "Fan ". $fan . " ".$CPQ_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - Critical: Fan ".$CPQ_FAN_PRESENT{$result_fan_present}.". Speed: ". $CPQ_FAN_SPEED{$result_fan_speed}.". Overall condition: ". $CPQ_FAN_OVERALL_COND{$result_fan_condition} ."\n" ; - exit $ERRORS{'CRITICAL'} ; - } - else { - print "Fan " .$fan . " ".$CPQ_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - OK: Fan ".$CPQ_FAN_PRESENT{$result_fan_present}.". Speed: ". $CPQ_FAN_SPEED{$result_fan_speed}.". Overall condition: ". $CPQ_FAN_OVERALL_COND{$result_fan_condition} ."\n" ; - exit $ERRORS{'OK'} ; - } - - -sub print_usage () { - print "Usage: $PROGNAME -H -p -C -f \n"; - } - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1113 $\n '); - print "Copyright (c) 2003 Rainer Duffner\n "; - print_usage(); - print "\n"; - print " = IP-Address or DNS-Name of the W2K-Server\n"; - print " = SNMP-Port (normaly 161)\n"; - print " = SNMP v1 community\n"; - print " = Fannumber (1, 2, 3 etc.)\n"; - } - -sub version () { - print_revision($PROGNAME,'$Revision: 1113 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - diff --git a/contrib/check_fan_fsc_present b/contrib/check_fan_fsc_present deleted file mode 100644 index 19f8e7f0..00000000 --- a/contrib/check_fan_fsc_present +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/perl -# -# -# check_most.pl -i -p -c community -o [warn] [critical] -# -# NetSaint host script to get the disk usage from NT snmp -# -# Changes and Modifications -# ========================= -# 3-Aug-2000 - Xavier Dusart -# Created -# 2003 - Rainer Duffner - -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} - - - -require 5.004; -use POSIX; -#use strict; -use Getopt::Std ; -use BER; -require 'SNMP_Session.pm'; -use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME); -use lib $main::runtimedir; -use utils qw($TIMEOUT %ERRORS &print_revision &usage &support); -use snmputil qw(%FSC_LOCALE %FSC_FAN_STATUS); - -delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer - -getopts('H:p:C:f:hV') ; - -my $ip_address=undef ; - -if ($opt_h) {&help();} - -if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA --Z0-9]*)*)$/) { - $ip_address = $opt_H ; - } -else { - usage(); - print "IP-Address format wrong\n"; - exit $ERRORS{'UNKNOWN'}; - } - -#if ($opt_p =~ m/^[0-9] - -my $port = $opt_p; - -my $community = $opt_C; - -my $fan = $opt_f ; - -#my $err_counter=0 ; -#my $err_status=""; - - my $fan_locale_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,4,0,$fan-1 ); -# not used for the moment - gives no usable output -# if reused, enter at end of list to avoid renumbering ! - my $fan_cur_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,8,0,$fan-1 ); - my $fan_nom_max_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,9,0,$fan-1 ); - my $fan_cur_max_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,10,0,$fan-1 ); - my $fan_condition_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,3,0,$fan-1 ); - my $count=1 ; - my $label ; - my @r_array=(); - my $q ; - my $diff ; - $warning=$warning/100 ; - $crititcal=$critical/100 ; - - -# get temperature, temperature_threshold bfore shutdown - my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ; - - if ($session->get_request_response ($fan_locale_oid, $fan_cur_speed_oid, $fan_nom_max_speed_oid, $fan_cur_max_speed_oid, $fan_condition_oid )) { - (my $bindings) = $session->decode_get_response ($session->{pdu_buffer}); - while ($bindings ne '') { - ($binding, $bindings) = &decode_sequence ($bindings) ; - ($oid,$value) = &decode_by_template ($binding,"%O%@"); - $r_array[$count]=&pretty_print($value); - $count++; - } - } else { - print "No response from agent\n"; - exit $ERRORS{'CRITICAL'}; - } - $result_fan_locale= $r_array[1]; - $result_fan_cur_speed= $r_array[2]; - $result_fan_nom_max_speed= $r_array[3]; - $result_fan_cur_max_speed= $r_array[4]; - $result_fan_condition=$r_array[5]; - - - if ( $result_fan_condition != "3" ) { - print "Fan ". $fan . " ".$FSC_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - Critical: Cur./Nom./Cur-Max-Speed: ". $result_fan_cur_speed."/". $result_fan_nom_max_speed."/".$result_fan_cur_max_speed.". Overall condition: ". $FSC_FAN_STATUS{$result_fan_condition} ."\n" ; - exit $ERRORS{'CRITICAL'} ; - } - else { - print "Fan " .$fan . " ".$FSC_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - OK: Cur./Nom./Cur-Max-Speed: ". $result_fan_cur_speed."/". $result_fan_nom_max_speed."/".$result_fan_cur_max_speed.". Overall condition: ". $FSC_FAN_STATUS{$result_fan_condition} ."\n" ; - exit $ERRORS{'OK'} ; - } - - -sub print_usage () { - print "Usage: $PROGNAME -H -p -C -f \n"; - } - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1113 $\n '); - print "Copyright (c) 2003 Rainer Duffner\n "; - print_usage(); - print "\n"; - print " = IP-Address or DNS-Name of the W2K-Server\n"; - print " = SNMP-Port (normaly 161)\n"; - print " = SNMP v1 community\n"; - print " = Fannumber (1, 2, 3 etc.)\n"; - } - -sub version () { - print_revision($PROGNAME,'$Revision: 1113 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - diff --git a/contrib/check_flexlm.pl b/contrib/check_flexlm.pl deleted file mode 100644 index 8fa0e334..00000000 --- a/contrib/check_flexlm.pl +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/local/bin/perl -# -# usage: -# check_flexlm.pl license_file -# -# Check available flexlm license managers. -# Use lmstat to check the status of the license server -# described by the license file given as argument. -# Check and interpret the output of lmstat -# and create returncodes and output. -# -# Contrary to the nagios concept, this script takes -# a file, not a hostname as an argument and returns -# the status of hosts and services described in that -# file. Use these hosts.cfg entries as an example -# -#host[anchor]=any host will do;some.address.com;;check-host-alive;3;120;24x7;1;1;1; -#service[anchor]=yodel;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yodel_lic -#service[anchor]=yeehaw;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yeehaw_lic -#command[check_flexlm]=/some/path/libexec/check_flexlm.pl $ARG1$ -# -# Notes: -# - you need the lmstat utility which comes with flexlm. -# - set the correct path in the variable $lmstat. -# -# initial version: 9-10-99 Ernst-Dieter Martin edmt@infineon.com -# current status: looks like working -# -# Copyright Notice: Do as you please, credit me, but don't blame me -# - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print "No Answer from Client\n"; - exit 2; -}; -alarm(20); - -$lmstat = "/opt/lic/sw/cadadm/default/bin/lmstat"; - -$licfile = shift; - -#print "$licfile \n"; - -open CMD,"$lmstat -c $licfile |"; - -$serverup = 0; - -while ( ) { - if ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*)/ ) { - $ls1 = $1; - $ls2 = $2; - $ls3 = $3; - $lf1 = $lf2 = $lf3 = 0; - $servers = 3; - } elsif ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*)/ ) { - $ls1 = $1; - $ls2 = $ls3 = ""; - $lf1 = $lf2 = $lf3 = 0; - $servers = 1; - } elsif ( / *$ls1: license server UP/ ) { - print "$ls1 UP, "; - $lf1 = 1 - } elsif ( / *$ls2: license server UP/ ) { - print "$ls2 UP, "; - $lf2 = 1 - } elsif ( / *$ls3: license server UP/ ) { - print "$ls3 UP, "; - $lf3 = 1 - } elsif ( / *([^:]*: UP .*)/ ) { - print " license server for $1\n"; - $serverup = 1; - } -} -if ( $serverup == 0 ) { - print " license server not running\n"; - exit 2; -} - -exit 0 if ( $servers == $lf1 + $lf2 + $lf3 ); -exit 1 if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 ); -exit 2; diff --git a/contrib/check_frontpage b/contrib/check_frontpage deleted file mode 100644 index 21c5267b..00000000 --- a/contrib/check_frontpage +++ /dev/null @@ -1,151 +0,0 @@ -#! /usr/bin/perl -w -# -# $Id: check_frontpage 1112 2005-01-27 04:46:08Z stanleyhopcroft $ -# -# Check that FrontPage extensions appear to be working on a specified host. -# Currently only checks that the hit counter is not returning an error. -# -# Probably not a good idea to use this on a host that someone's counting -# the hits on, so create a separate vhost for frontpage extensions testing, -# or just install the extensions on the default/root host for your server, and -# point it against that hostname, running it against all vhosts on a server is -# probably rather wasteful. -# -# Kev Green, oRe Net (http://www.orenet.co.uk/). - - -use strict; -use lib "/usr/lib/nagios/plugins"; -use utils qw($TIMEOUT %ERRORS &print_revision &support); -use vars qw($PROGNAME); -use Getopt::Long; -use LWP; -use vars qw($opt_V $opt_h $verbose $opt_w $opt_c $opt_H); -my ($tt,$url,$response,$stime, $etime,$warning,$critical,$mimetype,$failtype,$temp,$message); -my $rt = 0; - -$PROGNAME = "check_frontpage"; -sub print_help (); -sub print_usage (); - -$ENV{'PATH'}=''; -$ENV{'BASH_ENV'}=''; -$ENV{'ENV'}=''; - -Getopt::Long::Configure('bundling'); -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "v" => \$verbose, "verbose" => \$verbose, - "w=s" => \$opt_w, "warning=s" => \$opt_w, - "c=s" => \$opt_c, "critical=s" => \$opt_c, - "H=s" => \$opt_H, "hostname=s" => \$opt_H); - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1112 $'); #' - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -$opt_H = shift unless ($opt_H); -print_usage() unless $opt_H; -my $host = $1 if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]+(\.[a-zA-Z0-9][-a-zA-Z0-9]+)*)$/); -print_usage() unless $host; - -($opt_c) || ($opt_c = shift) || ($opt_c = 120); -if ($opt_c =~ /([0-9]+)/) { - $critical = $1; -} else { - $critical = 10; -} - -($opt_w) || ($opt_w = shift) || ($opt_w = 60); -if ($opt_w =~ /([0-9]+)/) { - $warning = $1; -} else { - $warning = 5; -} - -# Guts go here, once we're through argument parsing and have warning and -# critical thresholds. -my $browser = LWP::UserAgent->new; - -my @urls = ( - # This is the "Hit Counter", which continues to work if frontpage extensions - # are 'uninstall'ed from the site, but not when they are 'fulluninstall'ed. - { - url => "_vti_bin/fpcount.exe?Page=_borders/right.htm|Image=4", - mimetype => "image/gif", - message => "None, or broken frontpage extensions on server, or virtual site 'fulluninstall'ed?", - failtype => "CRITICAL" - }, - # This is the "FrontPage Configuration Information" file, which is removed - # when you 'uninstall' the extensions from a site. - { - url => "_vti_inf.html", - mimetype => "text/html", - message => "Someone 'uninstall'ed extensions on virtual site?", - failtype => "WARNING" - } -); - -print "FRONTPAGE: "; - -foreach $temp (@urls) { - $url = $temp->{'url'}; - $mimetype = $temp->{'mimetype'}; - $failtype = $temp->{'failtype'}; - $message = $temp->{'message'}; - $stime = time(); - $response=$browser->get("http://".$host."/".$url); - $etime = time(); - $tt = $etime - $stime; - -# If we got a server error, or unknown output type, report back as critical. - if ($response->status_line !~ "^200") { - print $message." (".$response->status_line.")\r\n"; - exit $ERRORS{$failtype}; - } elsif ($response->content_type !~ $mimetype) { - print $message." (Wrong Content-type: ".$response->content_type.")\r\n"; - exit $ERRORS{$failtype}; - } else { - # Because we're dealing with multiple URL's - $rt += $tt; - } - -# Decide if the response time was critical or not. -# - if ($rt > $critical) { - print "Response time ".$rt." over critical threshold ".$critical."\r\n"; - exit($ERRORS{'CRITICAL'}); - } elsif ($rt > $warning) { - print "Response time ".$rt." over warning threshold ".$warning."\r\n"; - exit($ERRORS{'WARNING'}); - } -} -printf(" %s - %s second response time, ",$response->status_line, $rt); - -# If all the required URL's give the right responses quick enough, then we -# should be okay. -exit($ERRORS{'OK'}); - -sub print_usage () { - print "Usage: $PROGNAME -H [-w ] [-c ]\n"; - exit; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1112 $'); - print "Copyright (c) 2003 Kev Green\n"; - print "\n"; - print "FrontPage remains a copyright/trademark of Microsoft Corporation.\n"; - print_usage(); - print "\n"; - print " = Unknown.\n"; - print " = Server error from FrontPage extensions.\n\n"; - support(); -} diff --git a/contrib/check_hltherm.c b/contrib/check_hltherm.c deleted file mode 100644 index 85c989f5..00000000 --- a/contrib/check_hltherm.c +++ /dev/null @@ -1,209 +0,0 @@ -/****************************************************************************************** - * - * CHECK_HLTHERM.C - * - * Program: Hot Little Therm temperature plugin for Nagios - * License: GPL - * Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org) - * - * Last Modified: 02-28-2002 - * - * Command line: check_hltherm [-l label] [-s scale] [-lower] - * - * Description: - * - * This plugin checks the temperature of a given temperature probe on a - * Hot Little Therm digital thermometer. The plugin uses the 'therm' utility - * that is included with the HLT software to check the probe temperature. Both - * the HLT digital thermometer and software are produced by Spiderplant. See - * their website at http://www.spiderplant.com/hlt for more information. - * - *****************************************************************************************/ - -#include "config.h" -#include "common.h" -#include "popen.h" - -#define DEFAULT_TIMEOUT 10 /* default timeout in seconds */ - -#define HLTHERM_COMMAND "/usr/local/bin/therm" /* this should be moved out to the configure script */ - - -static void timeout_alarm_handler(int); /* author must provide */ -int process_arguments(int, char **); - -int timeout_interval=DEFAULT_TIMEOUT; - -double wtemp=0.0L; -double ctemp=0.0L; - -int check_lower_temps=FALSE; - -char probe[MAX_INPUT_BUFFER]=""; -char label[MAX_INPUT_BUFFER]="Temperature"; -char scale[MAX_INPUT_BUFFER]="Degrees"; - -FILE *fp; - - -int main(int argc, char **argv){ - int result=STATE_OK; - char command[MAX_INPUT_BUFFER]; - double temp=0.0L; - char input_buffer[MAX_INPUT_BUFFER]; - int found=0; - - /* process command line arguments */ - result=process_arguments(argc,argv); - - /* display usage if there was a problem */ - if(result==ERROR){ - printf("Incorrect arguments supplied\n"); - printf("\n"); - printf("Hot Little Therm temperature plugin for Nagios\n"); - printf("Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org)\n"); - printf("Last Modified: 02-28-2002\n"); - printf("License: GPL\n"); - printf("\n"); - printf("Usage: %s [-l label] [-s scale] [-lower]\n",argv[0]); - printf("\n"); - printf("Options:\n"); - printf(" = Temperature necessary to result in a WARNING state\n"); - printf(" = Temperature necessary to result in a CRITICAL state\n"); - printf(" [label] = A descriptive label for the probe. Example: \"Outside Temp\"\n"); - printf(" [scale] = A descriptive label for the temperature scale. Example: \"Celsius\"\n"); - printf(" [-lower] = Evaluate temperatures with lower values being more critical\n"); - printf("\n"); - printf("This plugin checks the temperature of a given temperature probe on a\n"); - printf("Hot Little Therm digital thermometer. The plugin uses the 'therm' utility\n"); - printf("included with the HLT software to check the probe temperature. Both the\n"); - printf("HLT digital thermometer and software are produced by Spiderplant. See\n"); - printf("their website at http://www.spiderplant.com/hlt for more information.\n"); - printf("\n"); - return STATE_UNKNOWN; - } - - - result=STATE_OK; - - /* Set signal handling and alarm */ - if(signal(SIGALRM,timeout_alarm_handler)==SIG_ERR){ - printf("Cannot catch SIGALRM"); - return STATE_UNKNOWN; - } - - /* handle timeouts gracefully */ - alarm(timeout_interval); - - /* create the command line we're going to use */ - snprintf(command,sizeof(command),"%s %s",HLTHERM_COMMAND,probe); - command[sizeof(command)-1]='\x0'; - - /* run the command to check the temperature on the probe */ - fp=spopen(command); - if(fp==NULL){ - printf("Could not open pipe: %s\n",command); - return STATE_UNKNOWN; - } - - if(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){ - found=1; - temp=(double)atof(input_buffer); - } - - /* close the pipe */ - spclose(fp); - - if(result==STATE_OK){ - - if(found==0){ - printf("Therm problem - Could not read program output\n"); - result=STATE_CRITICAL; - } - else{ - if(check_lower_temps==TRUE){ - if(temp<=ctemp) - result=STATE_CRITICAL; - else if(temp<=wtemp) - result=STATE_WARNING; - } - else{ - if(temp>=ctemp) - result=STATE_CRITICAL; - else if(temp>=wtemp) - result=STATE_WARNING; - } - - printf("Therm %s: %s = %2.1f %s\n",(result==STATE_OK)?"ok":"problem",label,temp,scale); - } - } - - return result; - } - - -/* process command-line arguments */ -int process_arguments(int argc, char **argv){ - int x; - - /* not enough options were supplied */ - if(argc<4) - return ERROR; - - /* first option is always the probe name */ - strncpy(probe,argv[1],sizeof(probe)-1); - probe[sizeof(probe)-1]='\x0'; - - /* 2nd and 3rd options are temperature thresholds */ - wtemp=(double)atof(argv[2]); - ctemp=(double)atof(argv[3]); - - /* process all remaining arguments */ - for(x=5;x<=argc;x++){ - - /* we got the lower temperature option */ - if(!strcmp(argv[x-1],"-lower")) - check_lower_temps=TRUE; - - /* we got the label */ - else if(!strcmp(argv[x-1],"-l")){ - if(x \$chk_fs, - "show-filesystems" => \$show_fs, - "check-filesystemID" => \$chk_fsid, - "check-cpu" => \$chk_cpu, - "host=s" => \$target_host, - "community=s" => \$target_community, - "filesystemID1=i" => \$fsid1_opt, - "filesystem=s" => \$fs_opt, - "protocol:s" => \$proto_opt, - "warning=i" => \$warning_opt, - "critical=i" => \$critical_opt); - -$proto_opt = 1 - unless $proto_opt == 1 || - $proto_opt == '2c' || - $proto_opt == 3; - -if ($chk_fs) { - walk_data($snmpwalk, $target_host, $target_community, $mounted_OID,$proto_opt ); - walk_data($snmpwalk, $target_host, $target_community, $totalspace_OID,$proto_opt ); - walk_data($snmpwalk, $target_host, $target_community, $freespace_OID,$proto_opt ); check_filesystem($fs_opt, $warning_opt, $critical_opt); -} elsif ($show_fs) { - walk_data($snmpwalk, $target_host, $target_community, $filesystemID1_OID,$proto_opt); - walk_data($snmpwalk, $target_host, $target_community, $mounted_OID,$proto_opt ); - walk_data($snmpwalk, $target_host, $target_community, $path_OID,$proto_opt); - show_filesystem(); -} elsif ($chk_fsid){ - $totalspace_fsID_OID = "$totalspace_OID.$fsid1_opt"; - $freespace_fsID_OID = "$freespace_OID.$fsid1_opt"; - walk_data($snmpwalk, $target_host, $target_community, $totalspace_fsID_OID,$proto_opt); - walk_data($snmpwalk, $target_host, $target_community, $freespace_fsID_OID,$proto_opt); - check_filesystemID1($fsid1_opt, $warning_opt, $critical_opt); -} elsif ($chk_cpu) { - get_cpu_load($snmpwalk, $target_host, $target_community, $cpu_5min_OID,$proto_opt); - check_cpu_5min($cpu, $warning_opt, $critical_opt); -} else { - print "\n\nUsage:\n"; - print "Checking 5-min CPU Load:\n"; - print " $0 --check-cpu -warning --critical --host --community --protocol \n\n"; - print "Checking local filesystem mounted on a host:\n"; - print " $0 --show-filesystems --host --community --protocol \n\n"; - print "Checking by filesystem name:\n"; - print " $0 --check-filesystem --filesystem --warning <% used space> --critical <% used space> --host --community --protocol \n\n"; - print "Checking by filesystem ID:\n"; - print " $0 --check-filesystemID --filesystemID --warning <% used space> --critical <% used space> --host --community --protocol \n\n"; -} - -sub get_cpu_load { - my ($snmpwalk, $target_host, $target_community, $OID,$vers) = @_; - die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|")); - - if ($pid) { # parent - while () { - my @snmpdata = split(/:/,$_); - $cpu = $snmpdata[1]/100; - } - close(SNMPWALK) or warn "kid exited $?"; - } else { # child - exec($snmpwalk,'-c',$target_community,'-v',$vers,$target_host,$OID) or die "can't exec program: $!"; - } -} - -sub walk_data { -#This function queries the SNMP daemon for the specific OID - my ($snmpwalk, $target_host, $target_community, $OID,$vers) = @_; - - die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|")); - - if ($pid) { # parent - while () { - $output = $_; - sort_walk_data($output); - } - close(SNMPWALK) or warn "kid exited $?"; - } else { # child - exec($snmpwalk,'-c',$target_community,'-v',$vers,$target_host,$OID) or die "can't exec program: $!"; - } -} - -sub sort_walk_data { - my ($snmp_data) = @_; - @fields = split(/\./,$snmp_data); - $item = $fields[8]; - $filesystemID1 = $fields[9]; - @fields2 = split(/=/,$fields[10]); -# $filesystemID2 = $fields2[0]; - $value = $fields2[1]; - chomp($value); - if ($value =~ /"/) { - @fields3 = split(/"/,$value); - $value = $fields3[1]; - } - if ($item == 3) { - $mounted{$filesystemID1} = "$value"; - } elsif ($item == 4) { - $totalspace{$filesystemID1} = "$value"; - } elsif ($item == 6) { - $freespace{$filesystemID1} = "$value"; - } elsif ($item == 10) { - $filesystempath{$filesystemID1} = "$value"; - } -} - -sub show_filesystem { - print "\n\nfilesystemID1\tmounted filesystem\tfilesystem path\n"; - foreach $element (keys %mounted) { - print "$element\t$mounted{$element}\t\t$filesystempath{$element}\n"; - } - print "\n\n"; -} - -sub check_filesystem { - -# Warning = percentage of used space >= $warning and < $critical -# Critical = percentage of used space > $warning and >= $critical -# OK = percentage of used space < $warning and < $critical - - my ($mounted_filesystem, $warning, $critical) = @_; - foreach $element (keys %mounted) { - if ($mounted{$element} eq $mounted_filesystem) { - my $warning_result = $totalspace{$element}*(100-$warning)/100; - my $critical_result = $totalspace{$element}*(100-$critical)/100; - my $result_percent = $freespace{$element}*100/$totalspace{$element}; - if (($freespace{$element} <= $warning_result) && ($freespace{$element} > $critical_result)) { - printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 1; - } elsif ($freespace{$element} <= $critical_result) { - printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 2; - } else { - printf "Disk ok - %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 0; - } - } - } - print "$mounted_filesystem doesn't exist in $target_host\n\n"; - exit -1; -} - -sub check_filesystemID1{ -# Warning = percentage of used space >= $warning and < $critical -# Critical = percentage of used space > $warning and >= $critical -# OK = percentage of used space < $warning and < $critical - - my ($fsid1, $warning, $critical) = @_; - foreach $element (keys %totalspace) { - if ($element eq $fsid1) { - my $warning_result = $totalspace{$element}*(100-$warning)/100; - my $critical_result = $totalspace{$element}*(100-$critical)/100; - my $result_percent = $freespace{$element}*100/$totalspace{$element}; - if (($freespace{$element} <= $warning_result) && ($freespace{$element} >= $critical_result)) { - printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 1; - } elsif ($freespace{$element} <= $critical_result) { - printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 2; - } else { - printf "Disk ok - %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 0; - } - } - } - print "$fsid1 doesn't exist in $target_host\n\n"; - exit -1; -} - -sub check_cpu_5min { - my ($cpu, $warn, $crit) = @_; - if ($cpu >= $crit) { - print "Critical- 5-min load: $cpu\n"; - exit 2; - } elsif ($cpu >= $warn) { - print "Warning - 5-min load: $cpu\n"; - exit 1; - } else { - print "Load ok - 5-min load: $cpu\n"; - exit 0; - } -} - - - diff --git a/contrib/check_hw.sh b/contrib/check_hw.sh deleted file mode 100644 index 9d3b5743..00000000 --- a/contrib/check_hw.sh +++ /dev/null @@ -1,66 +0,0 @@ -#! /bin/sh -# -# Tested on SuSE 9.1 Professional with the hwinfo-8.62-0.2 package installed. -# -# Before you can run this plugin, you must do: -# /usr/sbin/hwinfo --short > /etc/hw.original -# add to cron job: -# /usr/sbin/hwinfo --short > /etc/hw.current -# /usr/bin/diff /etc/hw.original /etc/hw.current > /tmp/hw.check -# -# -# Rok Debevc -- rok.debevc@agenda.si -# -# -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin - -PROGNAME=`basename $0` -PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` -REVISION=`echo '$Revision: 939 $' | sed -e 's/[^0-9.]//g'` - -. $PROGPATH/utils.sh - - -print_usage() { - echo "Usage: $PROGNAME" -} - -print_help() { - print_revision $PROGNAME $REVISION - echo "" - print_usage - echo "" - echo "This plugin checks hardware changes." - echo "" - support - exit 0 -} - -case "$1" in - --help) - print_help - exit 0 - ;; - -h) - print_help - exit 0 - ;; - --version) - print_revision $PROGNAME $REVISION - exit 0 - ;; - -V) - print_revision $PROGNAME $REVISION - exit 0 - ;; - *) - if `du /tmp/hw.check | cut -c 1|grep "^[0]" > /dev/null` ; then - echo No hardware is changed - exit 0 - else - echo ***hardware is changed*** look into /tmp/hw.check - exit 2 - fi - ;; -esac - diff --git a/contrib/check_ica_master_browser.pl b/contrib/check_ica_master_browser.pl deleted file mode 100755 index 922e7187..00000000 --- a/contrib/check_ica_master_browser.pl +++ /dev/null @@ -1,228 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: check_ica_master_browser.pl 1099 2005-01-25 09:09:33Z stanleyhopcroft $ - -# Revision 1.1 2005/01/25 09:09:33 stanleyhopcroft -# New plugin - checks that ICA master browser is what it should be (important for firewalled dialup) -# - -use strict ; - -use IO::Socket; -use IO::Select; -use Getopt::Long ; - -use lib qw(/usr/local/nagios/libexec) ; -use utils qw(%ERRORS &print_revision &support &usage); -use packet_utils qw(&pdump &tethereal) ; - -my $PROGNAME = 'check_ica_master_browser' ; - -# You might have to change this... - -my $PACKET_TIMEOUT = 1; - # Number of seconds to wait for further UDP packets -my $TEST_COUNT = 2; - # Number of datagrams sent without reply -my $BUFFER_SIZE = 1500; - # buffer size used for 'recv' calls. -my $ICA_PORT = 1604; - # what port ICA runs on. Unlikely to change. - -# End user config. - -my ($debug, $preferred_master, $bcast_addr, $ica_browser, $timeout) ; - -Getopt::Long::Configure('bundling', 'no_ignore_case'); -GetOptions - ("V|version" => \&version, - "h|help" => \&help, - "v|verbose" => \$debug, - "B|broadcast_addr:s" => \$bcast_addr, - "I|ica_browser:s" => \$ica_browser, - "P|preferred_master:s" => \$preferred_master, - "T|Packet_timeout:i" => \$timeout, -) ; - - -my $broadcast_addr = $1 if $bcast_addr and $bcast_addr =~ m#(\d+\.\d+\.\d+\.\d+)# ; -usage("Invalid broadcast address: $bcast_addr") - if $bcast_addr and not defined($broadcast_addr) ; - -usage("You must provide either the name of an ICA browser or the broadcast address of the subnet containing them\n") - unless ($ica_browser or $broadcast_addr) ; - -usage("You must provide the name or address of a preferred ICA master browser\n") - unless ($preferred_master) ; - -my $preferred_master_n = $preferred_master =~ m#(\d+\.\d+\.\d+\.\d+)# - ? $preferred_master - : inet_ntoa(scalar gethostbyname($preferred_master)) ; - -my $Timeout = $timeout || $PACKET_TIMEOUT ; - - # Definitions of query strings. Change at your own risk :) - # this info was gathered with tcpdump whilst trying to use an ICA client, - # so I'm not 100% sure of what each value is. - -my $bcast_helo = &tethereal(<<'End_of_Tethereal_trace', '1e') ; -0020 ff ff 04 d6 06 44 00 26 4a 76 1e 00 01 30 02 fd .....D.&Jv...0.. -0030 a8 e3 00 02 f5 95 9f f5 30 07 00 00 00 00 00 00 ........0....... -0040 00 00 00 00 00 00 01 00 ........ -End_of_Tethereal_trace - -my $direct_helo = &tethereal(<<'End_of_Tethereal_trace', '20') ; -0020 64 17 05 0f 06 44 00 28 ab b5 20 00 01 30 02 fd d....D.(.. ..0.. -0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0040 00 00 00 00 00 00 00 00 00 00 ........ -End_of_Tethereal_trace - -my $Udp = IO::Socket::INET->new( Proto => 'udp' ) - || die "Socket failure: $!"; - - # select is here to allow us to set timeouts on the connections. Otherwise they - # just 'stop' until a server appears. - -my $select = IO::Select->new($Udp) - || die "Select failure: $!"; - -$Udp->sockopt(SO_BROADCAST, 1 ); - -my ($remote_host, $buff, $destination, $raddr, $rport, $rhost, @remote_response); -my ($query_message, $send_addr, $this_test) ; - -$buff = ''; -$this_test = 0; - - # If there is no response to the first helo packet it will be resent - # up to $TEST_COUNT (see at the top). - -$query_message = $broadcast_addr ? $bcast_helo : $direct_helo ; -$destination = $broadcast_addr ? $broadcast_addr: $ica_browser ; -$send_addr = sockaddr_in($ICA_PORT, inet_aton($destination) ) ; - -while ( ++$this_test <= $TEST_COUNT && !$buff ) { - - print "Sending helo datagram. datagram number: ", $this_test, "\n" - if $debug ; - - print "Querying $destination for master browser\n" - if $debug ; - &pdump($query_message) - if $debug ; - $Udp->send($query_message, 0, $send_addr ); - if ( $select->can_read($Timeout) ) { - $remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 ); - } - - last - if $buff ; - sleep 1 ; - -} - - # Ok we've looped several times, looking for a response. If we don't have one - # yet, we simply mark the whole lot as being unavailable. - -unless ( $buff ) { - print "Failed. No response to helo datagram (master browser query) from $destination.\n" ; - exit $ERRORS{CRITICAL} ; -} - -($rport, $raddr) = sockaddr_in( $remote_host ); -$rhost = gethostbyaddr( $raddr, AF_INET ); -my @tmpbuf = unpack('C*', $buff ); -if ( $debug ) { - print "$rhost:$rport responded with: ",length($buff), " bytes\n"; - &pdump($buff) ; -} - - # Now we have a response, then we need to figure out the master browser, and - # query it for published applications... - -my $master_browser = join '.', @tmpbuf[32..35] ; -my ($master_browser_a) = gethostbyaddr(inet_aton($master_browser), AF_INET) =~ /^(\w+?)\./ ; - - # Ok should probably error check this, because it's remotely possible - # that a server response might be completely wrong... - -print "Master browser = $master_browser_a/$master_browser\n" - if $debug ; - -$send_addr = sockaddr_in($ICA_PORT, inet_aton($master_browser)); - -my $subject_clause = $bcast_addr ? "of the \"$destination\" subnet" : "known to ICA server \"$destination\"" ; - -if ( $master_browser eq $preferred_master_n ) { - print "Preferred master browser \"$preferred_master\" __is__ the master browser (\"$master_browser_a/$master_browser\") $subject_clause.\n" ; - exit $ERRORS{OK} ; -} else { - print "\"\u$preferred_master\" is __not__ the master browser (\"$master_browser_a/$master_browser\") $subject_clause: remote clients (dialup) may not find Published applications from Master Browser.\n" ; - exit $ERRORS{CRITICAL} ; -} - -close $Udp; - - -sub print_usage () { - print "Usage: $PROGNAME (-B | -I ) - P " ; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1099 $ '); - print "Copyright (c) 2002 Ed Rolison/Tom De Blende/S Hopcroft - -Perl Check Citrix Master Browser plugin for Nagios. - -Returns OK if the Citrix master browser is that given by the -P option. - -The plugin works by - If the -B option is specified, sends a broadcast helo to find the address of the Citrix master browser in the specified subnet. - return critical if there is no reply; - Else if the -I option is specified - send a direct helo to the specified server until there is a response (containing the address of the Citrix master browser) - - - return Critical if the response does not contain the address of the 'preferred master browser' (-P option). - return OK - - How ICA Clients Use the Master ICA Browser. - -Citrix ICA Clients must locate the master browser to get the address of a server or published application. - -The Citrix ICA Client can locate the master browser by sending out broadcast packets, or, -if the address of a Citrix server is specified in the Citrix ICA Client or in an ICA file, -the ICA Client locates the master browser by sending directed packets to the specified address. -The ICA Client requests the address of the ICA master browser from the Citrix server. - -"; - print_usage(); - print ' --B, --broadcast_address:STRING - The broadcast address that should contain Citrix master browser. This option takes precedence over -I. --I, --ica_browser:STRING - Optional name or address of an ICA server that could be the master browser (used when broadcast not possible). --P, --preferred_master:STRING - Name or address of the ICA server that _should_ be the master browser. - Required. --T, --packet-timeout:INTEGER - Time to wait for UDP packets (default 1 sec). --v, --verbose - Debugging output. --h, --help - This stuff. - -'; - support(); -} - -sub version () { - print_revision($PROGNAME,'$Revision: 1099 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - diff --git a/contrib/check_ica_metaframe_pub_apps.pl b/contrib/check_ica_metaframe_pub_apps.pl deleted file mode 100755 index 0edbdcaf..00000000 --- a/contrib/check_ica_metaframe_pub_apps.pl +++ /dev/null @@ -1,381 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: check_ica_metaframe_pub_apps.pl 1098 2005-01-25 09:07:39Z stanleyhopcroft $ - -# Revision 1.1 2005/01/25 09:07:39 stanleyhopcroft -# Replacement (structured name mainly) for check_citrix: check of ICA browse service -# -# Revision 1.1 2005-01-25 17:00:24+11 anwsmh -# Initial revision -# - -use strict ; - -use IO::Socket; -use IO::Select; -use Getopt::Long ; - -my ($bcast_addr, $timeout, $debug, @citrix_servers, $crit_pub_apps, $warn_pub_apps, $long_list) ; - -use lib qw(/usr/local/nagios/libexec) ; -use utils qw(%ERRORS &print_revision &support &usage) ; -use packet_utils qw(&pdump &tethereal) ; - -my $PROGNAME = 'check_ica_metaframe_pub_apps' ; - -sub print_help (); -sub print_usage (); -sub help (); -sub version (); - - # You might have to change this... - -my $PACKET_TIMEOUT = 1; - # Number of seconds to wait for further UDP packets -my $TEST_COUNT = 2; -# Number of datagrams sent without reply -my $BUFFER_SIZE = 1500; - # buffer size used for 'recv' calls. -my $LONG_LIST = 0 ; - # this is for if you have many published applications. - # if you set it, it won't do any harm, but may slow the test - # down a little. (Since it does a 'recv' twice instead of - # once and therefore may have to wait for a timeout). -my $ICA_PORT = 1604; - # what port ICA runs on. Unlikely to change. - -Getopt::Long::Configure('bundling', 'no_ignore_case'); -GetOptions - ("V|version" => \&version, - "h|help" => \&help, - "v|verbose" => \$debug, - "B|broadcast_addr:s" => \$bcast_addr, - "C|citrix_servers:s" => \@citrix_servers, - "L|long_list" => \$long_list, - "P|crit_pub_apps:s" => \$crit_pub_apps, - "T|Packet_timeout:i" => \$timeout, - "W|warn_pub_apps:s" => \$warn_pub_apps, -) ; - - -my $broadcast_addr = $1 if $bcast_addr and $bcast_addr =~ m#(\d+\.\d+\.\d+\.\d+)# ; -usage("Invalid broadcast address: $bcast_addr\n") - if $bcast_addr and not defined($broadcast_addr) ; - -usage("You must provide either the names of citrix servers or the broadcast address of the subnet containing them\n") - unless (@citrix_servers or $broadcast_addr) ; - -my @target = defined $broadcast_addr ? ($broadcast_addr) : @citrix_servers ; - -usage("You must provide the names of the published applications that the Citrix browser should be advertising\n") - unless $crit_pub_apps or $warn_pub_apps ; - -my $Timeout = $timeout - if defined $timeout ; -$Timeout = $PACKET_TIMEOUT - unless defined $Timeout ; -$long_list = $LONG_LIST - unless defined $long_list ; - -my @crit_pub_apps = $crit_pub_apps ? split(/,/, $crit_pub_apps) : () ; -my @warn_pub_apps = $warn_pub_apps ? split(/,/, $warn_pub_apps) : () ; - - # Definitions of query strings. Change at your own risk :) - # this info was gathered with tcpdump whilst trying to use an ICA client, - # so I'm not 100% sure of what each value is. - -my $bcast_helo = &tethereal(<<'End_of_Tethereal_trace', '1e') ; -0020 ff ff 04 d6 06 44 00 26 4a 76 1e 00 01 30 02 fd .....D.&Jv...0.. -0030 a8 e3 00 02 f5 95 9f f5 30 07 00 00 00 00 00 00 ........0....... -0040 00 00 00 00 00 00 01 00 ....... -End_of_Tethereal_trace - -my $bcast_query_app = &tethereal(<<'End_of_Tethereal_trace', '24') ; -0020 64 17 04 50 06 44 00 2c 85 6a 24 00 01 32 02 fd d..P.D.,.j$..2.. -0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0040 00 00 00 00 00 00 21 00 02 00 00 00 00 00 ......!...... -End_of_Tethereal_trace - -my $direct_helo = &tethereal(<<'End_of_Tethereal_trace', '20') ; -0020 64 17 05 0f 06 44 00 28 ab b5 20 00 01 30 02 fd d....D.(.. ..0.. -0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0040 00 00 00 00 00 00 00 00 00 00 ......... -End_of_Tethereal_trace - -my $direct_query_app = &tethereal(<<'End_of_Tethereal_trace', '2c') ; -0020 64 17 05 10 06 44 00 34 7a 9a 2c 00 02 32 02 fd d....D.4z.,..2.. -0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0040 00 00 00 00 00 00 21 00 02 00 01 00 00 00 00 00 ......!......... -0050 00 00 00 00 00 00 ...... -End_of_Tethereal_trace - -my $Udp = IO::Socket::INET->new( Proto => 'udp' ) - || die "Socket failure: $!"; - - # Select is here to allow us to set timeouts on the connections. - # Otherwise they just 'stop' until a server appears. - -my $select = IO::Select->new($Udp) - || die "Select failure: $!"; - # Helo needs to be broadcastt, but query does not. -$Udp->sockopt(SO_BROADCAST, 1 ); - -my ($remote_host, $buff, $buff2, $raddr, $rport, $rhost, @remote_response); -my ($query_message, $send_addr, $this_test) ; - -$buff = $buff2 = ''; -$this_test = 0; - - # If there is no response to the first helo packet it will be resent - # up to TEST_COUNT (see at the top). - -while ( ++$this_test <= $TEST_COUNT && !$buff ) { - - print "Sending helo datagram. datagram number: ", $this_test, "\n" - if $debug ; - - # If we have multiple targets, we probe each of them until we get a - # response... - - foreach my $destination (@target) { - $query_message = $broadcast_addr ? $bcast_helo : $direct_helo ; - print "Querying $destination for master browser\n" - if $debug ; - $send_addr = sockaddr_in($ICA_PORT, inet_aton($destination) ); - &pdump($query_message) - if $debug ; - $Udp->send($query_message, 0, $send_addr ); - if ( $select->can_read($Timeout) ) { - $remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 ); - } - - last - if $buff ; - sleep 1 ; - - } -} - - # Ok we've looped several times, looking for a response. If we don't have one - # yet, we simply mark the whole lot as being unavailable. - -unless ( $buff ) { - print "Failed. No response to helo datagram (master browser query) from ", $broadcast_addr ? $broadcast_addr : "@citrix_servers", ".\n" ; - exit $ERRORS{CRITICAL} ; -} - -($rport, $raddr) = sockaddr_in( $remote_host ); -$rhost = gethostbyaddr( $raddr, AF_INET ); -my @tmpbuf = unpack('C*', $buff ); -if ( $debug ) { - print "$rhost:$rport responded with: ", length($buff), " bytes\n"; - &pdump($buff) ; -} - - # Now we have a response, then we need to figure out the master browser, and - # query it for published applications... - -my $master_browser = join '.', @tmpbuf[32..35] ; - - # Ok should probably error check this, because it's remotely possible - # that a server response might be completely wrong... - -print "Master browser = $master_browser\n" - if $debug ; - -$send_addr = sockaddr_in($ICA_PORT, inet_aton($master_browser)); - -if ( $broadcast_addr ) { - print "using broadcast query\n" - if $debug ; - $query_message = $bcast_query_app; -} else { - print "using directed query\n" - if $debug ; - $query_message = $direct_query_app; -} - - # Now we send the appropriate query string, to the master browser we've found. - -$buff = ''; -$this_test = 0 ; - -print "Querying master browser for published application list\n" - if $debug ; - -while ( ++$this_test <= $TEST_COUNT && !$buff ) { - print "Sending application query datagram. datagram number: ", $this_test, "\n" - if $debug ; - &pdump($query_message) - if $debug ; - $Udp->send($query_message, 0, $send_addr); - - if ( $select->can_read($Timeout) ) { - $remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 ); - # $buff = substr($buff, 32) ; - # Hope that ICA preamble is first 32 bytes - } - - # Long application lists are delivered in multiple packets - - my $buff2 = '' ; - while ( $long_list && $select->can_read($Timeout) ) { - $remote_host = $Udp->recv($buff2, $BUFFER_SIZE, 0); - $buff .= $buff2 - if $buff2 ; - # $buff .= substr($buff2, 32) if $buff2 ; - # Hope that ICA preamble is first 32 bytes - } - - last if $buff ; - sleep 1 ; - -} - -unless ( $buff ) { - print "Failed. No response to application query datagram from ", $master_browser, ".\n" ; - exit $ERRORS{CRITICAL} ; -} - - # we got a response from a couple of retries of the app query - -($rport, $raddr) = sockaddr_in ( $remote_host ); -$rhost = gethostbyaddr ( $raddr, AF_INET ); -if ( $debug ) { - print "$rhost:$rport responded to app query with: ", length($buff), " bytes\n"; - &pdump($buff) ; -} - -my $app_list = $buff ; - # delete nulls in unicode - # but only if there is unicode (usually from - # broadcast query) - -$app_list =~ s/(?:(\w| |-)\x00)/$1/g - if $app_list =~ /(?:(?:(?:\w| |-)\x00){3,})/ ; - # FIXME an application name is - # 3 or more unicoded characters - - # FIXME locale - # extract null terminated strings - -my (@clean_app_list, $clean_app_list) ; -$clean_app_list = join(',', @clean_app_list = $app_list =~ m#([A-Za-z](?:\w| |-|[ÄÖÜäöüß])+?(?=\x00))#g ) ; - - # patch for German umlauts et al from Herr Mike Gerber. - - # $clean_app_list = join(',', @clean_app_list = $app_list =~ m#([A-Z](?:\w| |-)+?(?=\x00))#g ) ; - - # FIXME everyones apps don't start with caps - -print qq(Received list of applications: "$clean_app_list".\n) - if $debug ; - -if ( scalar @crit_pub_apps and my @missing = &simple_diff(\@clean_app_list, \@crit_pub_apps) ) { - print qq(Failed. "@missing" not found in list of published applications), - qq(" $clean_app_list" from master browser "$master_browser".\n) ; - exit $ERRORS{CRITICAL} ; -} - -if ( my @missing = &simple_diff(\@clean_app_list, \@warn_pub_apps) ) { - print qq(Warning. "@missing" not found in list of published applications), - qq(" $clean_app_list" from master browser "$master_browser".\n) ; - exit $ERRORS{WARNING} ; -} - -my @x = (@crit_pub_apps, @warn_pub_apps) ; -my $blah = ( scalar(@x) == 1 - ? 'the published application "' . join(',', @x) . '" is available' - : 'the published applications "' . join(',', @x) . '" are available' ) ; - -print qq(Ok. Citrix master browser "$master_browser" reported that $blah.\n) ; -exit $ERRORS{OK} ; - - # sleep $Timeout; - # because otherwise we can get responses from - # the WRONG servers. DOH -close $Udp; - - -sub print_usage () { - print "Usage: $PROGNAME (-B | -C ..) -W -P \n"; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1098 $ '); - print "Copyright (c) 2002 Ed Rolison/Tom De Blende/S Hopcroft - -Perl Check Citrix plugin for Nagios. - -Returns OK if the Citrix master browser returns a 'published application' list that contain names specified by the -W or -P options - -The plugin works by - If the -B option is specified, sending a broadcast helo to find the address of the Citrix master browser in the specified subnet. - return critical if there is no reply; - Else if the -C option is specified - send a direct helo to the specified server until there is a response (containing the address of the Citrix master browser) - - Query the master browser (using a 'broadcast published applications query ' if -B) and compare the published applications returned - to those specified by -W and -P options - - return Critical if the published applications specified by -P is not a subset of the query responses; - return Warning if the published applications specified by -W is not a subset of the query responses; - return OK - -"; - print_usage(); - print ' --B, --broadcast_address=STRING - The broadcast address that should contain Citrix master browser. This option takes precedence over -C. --C, --citrix_server:STRING - Optional __name(s)__ of Citrix servers that could be the master browser (used when broadcast not possible). --L, --long_list - Set this if you have heaps of published applications (ie more than will fit in _one_ UDP packet) --P, --crit_published_app=STRING - Optional comma separated list of published application that must be in the response from the master browser. - Check returns critical otherwise. --T, --packet-timeout:INTEGER - Time to wait for UDP packets (default 1 sec). --W, --warn_published_app=STRING - Optional comma separated list of published application that should be in the response from the master browser. - Check returns warning otherwise. --v, --verbose - Debugging output. --h, --help - This stuff. - -'; - support(); -} - -sub version () { - print_revision($PROGNAME,'$Revision: 1098 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - - -sub simple_diff { - -my ( $a_list, $b_list) = @_ ; - - # simple set difference 'Recipe 4.7 Perl Cookbook', Christiansen and Torkington - - my (%seen, @missing) ; - - @seen{@$a_list} = () ; - - foreach my $item (@$b_list) { - push @missing, $item - unless exists $seen{$item} ; - } - - @missing ; -} - - - diff --git a/contrib/check_ica_program_neigbourhood.pl b/contrib/check_ica_program_neigbourhood.pl deleted file mode 100755 index 1f0fb455..00000000 --- a/contrib/check_ica_program_neigbourhood.pl +++ /dev/null @@ -1,618 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: check_ica_program_neigbourhood.pl 1097 2005-01-25 09:05:53Z stanleyhopcroft $ - -# Revision 1.1 2005/01/25 09:05:53 stanleyhopcroft -# New plugin to check Citrix Metaframe XP "Program Neighbourhood" -# -# Revision 1.1 2005-01-25 16:50:30+11 anwsmh -# Initial revision -# - -use strict ; - -use Getopt::Long; - -use utils qw($TIMEOUT %ERRORS &print_revision &support); -use LWP 5.65 ; -use XML::Parser ; - -my $PROGNAME = 'check_program_neigbourhood' ; -my ($debug, $xml_debug, $pn_server, $pub_apps, $app_servers, $server_farm, $usage) ; - -Getopt::Long::Configure('bundling', 'no_ignore_case') ; -GetOptions - ("V|version" => \&version, - "A|published_app:s" => \$pub_apps, - "h|help" => \&help, - 'usage|?' => \&usage, - "F|server_farm=s" => \$server_farm, - "P|pn_server=s" => \$pn_server, - "S|app_server=s" => \$app_servers, - "v|verbose" => \$debug, - "x|xml_debug" => \$xml_debug, -) ; - -$pn_server || do { - print "Name or IP Address of _one_ Program Neighbourhood server is required.\n" ; - &print_usage ; - exit $ERRORS{UNKNOWN} ; -} ; - -$pub_apps ||= 'Word 2003' ; -$pub_apps =~ s/["']//g ; -my @pub_apps = split /,\s*/, $pub_apps ; - -my @app_servers = split /,\s*/, $app_servers ; - -@app_servers || do { - print "IP Address of _each_ Application server in the Metaframe Citrix XP server farm is required.\n" ; - &print_usage ; - exit $ERRORS{UNKNOWN} ; -} ; - -my @non_ip_addresses = grep ! /\d+\.\d+\.\d+\.\d+/, @app_servers ; - -scalar(@non_ip_addresses) && do { - print qq(Application servers must be specified by IP Address (not name): "@non_ip_addresses".\n) ; - &print_usage ; - exit $ERRORS{UNKNOWN} ; -} ; - -$server_farm || do { - print "Name of Citrix Metaframe XP server farm is required.\n" ; - &print_usage ; - exit $ERRORS{UNKNOWN} ; -} ; - -my %xml_tag = () ; -my @tag_stack = () ; - -my $xml_p = new XML::Parser(Handlers => {Start => \&handle_start, - End => sub { pop @tag_stack }, - Char => \&handle_char}) ; - -# values required by Metaframe XP that don't appear to matter too much - -my $client_host = 'Nagios server (http://www.Nagios.ORG)' ; -my $user_name = 'nagios' ; -my $domain = 'Nagios_Uber_Alles' ; - -# end values required by Metaframe XP - -my $nilpotent_req = <<'EOR' ; - - - - - - -EOR - -my $server_farm_req = <<'EOR' ; - - - - - - - -EOR - -my $spec_server_farm_req = < - - - - - $server_farm* - - $client_host - - - - - $user_name - $domain - - - -EOR - -my $app_req = < - - - - - PUBLISHED_APP_ENCODED - - Nagios_Service_Check - - - - - $PROGNAME - $domain - - - -EOR - -my $ua = LWP::UserAgent->new ; -my $req = HTTP::Request->new('POST', "http://$pn_server/scripts/WPnBr.dll") ; - $req->content_type('text/xml') ; - -my $svr ; - -my @pubapp_encoded = map { my $x = $_ ; $x =~ s/(\W)/'&#' . ord($1) . ';'/eg; $x } @pub_apps ; - -my $error_tag_cr = sub { ! exists($xml_tag{ErrorId}) } ; - -my @app_reqs = ( - # { Content => url, Ok => ok_condition, Seq => \d+ } - - { Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 0 }, - { Content => $server_farm_req, Ok => sub { - ! exists($xml_tag{ErrorId}) && - exists( $xml_tag{ServerFarmName}) && - defined($xml_tag{ServerFarmName}) && - $xml_tag{ServerFarmName} eq $server_farm - }, Seq => 2 }, - { Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 4 }, - { Content => $spec_server_farm_req, Ok => sub { - ! exists($xml_tag{ErrorId}) && - exists( $xml_tag{ServerAddress}) && - defined($xml_tag{ServerAddress}) && - $xml_tag{ServerAddress} =~ /\d+\.\d+\.\d+\.\d+:\d+/ - }, Seq => 6 }, - { Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 8 }, - { Content => $app_req, Ok => sub { - ! exists($xml_tag{ErrorId}) && - exists( $xml_tag{ServerAddress}) && - defined($xml_tag{ServerAddress}) && - (($svr) = split(/:/, $xml_tag{ServerAddress})) && - defined($svr) && - scalar(grep $_ eq $svr, @app_servers) - }, Seq => 10 } -) ; - -my $app_location ; - -foreach my $pub_app (@pub_apps) { - - my $pubapp_enc = shift @pubapp_encoded ; - my $app_req_tmp = $app_reqs[5]{Content} ; - $app_reqs[5]{Content} =~ s/PUBLISHED_APP_ENCODED/$pubapp_enc/ ; - - foreach (@app_reqs) { - - $req->content($_->{Content}) ; - - $debug && print STDERR "App: $pub_app Seq: $_->{Seq}\n", $req->as_string, "\n" ; - - my $resp = $ua->request($req) ; - - $debug && print STDERR "App: $pub_app Seq: ", $_->{Seq} + 1, "\n", $resp->as_string, "\n" ; - - $resp->is_error && do { - my $err = $resp->as_string ; - $err =~ s/\n//g ; - &outahere(qq(Failed. HTTP error finding $pub_app at seq $_->{Seq}: "$err")) ; - } ; - my $xml = $resp->content ; - - my $xml_disp ; - ($xml_disp = $xml) =~ s/\n//g ; - $xml_disp =~ s/ \s+/ /g ; - - &outahere($resp->as_string) - unless $xml ; - - my ($xml_ok, $whine) = &valid_xml($xml_p, $xml) ; - - $xml_ok || &outahere(qq(Failed. Bad XML finding $pub_app at eq $_->{Seq} in "$xml_disp".)) ; - - &{$_->{Ok}} || &outahere(qq(Failed. \"\&\$_->{Ok}\" false finding $pub_app at seq $_->{Seq} in "$xml_disp".)) ; - - # Ugly but alternative is $_->{Ok}->(). - # eval $_->{Ok} where $_->{Ok} is an - # expression returning a bool is possible. but - # sub { } prevent recompilation. - - } - - $app_reqs[5]{Content} = $app_req_tmp ; - - $app_location .= qq("$pub_app" => $svr, ) ; - -} - -substr($app_location, -2, 2) = '' ; -print qq(Ok. Citrix XML service located all published apps $app_location.\n) ; -exit $ERRORS{'OK'} ; - -sub outahere { - print "Citrix XML service $_[0]\n" ; - exit $ERRORS{CRITICAL} ; -} - -sub valid_xml { - my ($p, $input) = @_ ; - - %xml_tag = () ; - @tag_stack = () ; - - eval { - $p->parse($input) - } ; - - return (0, qq(XML::Parser->parse failed: Bad XML in "$input".!)) - if $@ ; - - if ( $xml_debug ) { - print STDERR pack('A4 A30 A40', ' ', $_, qq(-> "$xml_tag{$_}")), "\n" - foreach (keys %xml_tag) - } - - return (1, 'valid xml') - -} - - -sub handle_start { - push @tag_stack, $_[1] ; - - $xml_debug && print STDERR pack('A8 A30 A40', ' ', 'handle_start - tag', " -> '$_[1]'"), "\n" ; - $xml_debug && print STDERR pack('A8 A30 A60', ' ', 'handle_start - @tag_stack', " -> (@tag_stack)"), "\n" ; -} - -sub handle_char { - my $text = $_[1] ; - - !($text =~ /\S/ || $text =~ /^[ \t]$/) && return ; - - $text =~ s/\n//g ; - - my $tag = $tag_stack[-1] ; - - $xml_debug && print STDERR pack('A8 A30 A30', ' ', 'handle_char - tag', " -> '$tag'"), "\n" ; - $xml_debug && print STDERR pack('A8 A30 A40', ' ', 'handle_char - text', " -> '$text'"), "\n" ; - - $xml_tag{$tag} .= $text ; - -} - - -sub print_help() { - -# 1 2 3 4 5 6 7 8 -#12345678901234567890123456789012345678901234567890123456789012345678901234567890 - - print_revision($PROGNAME,'$Revision: 1097 $ '); - -my $help = < -S -A - -F [-v -x -h -V] - -Check the Citrix Metaframe XP service by completing an HTTP dialogue with a Program -Neigbourhood server (pn_server) that returns an ICA server in the named Server farm -hosting the specified applications (an ICA server in a farm which runs some MS app). -EOHELP - - print $help ; - print "\n"; - print "\n"; - print_usage(); - print "\n"; - support(); -} - -sub print_usage () { - -# 1 2 3 4 5 6 7 8 -#12345678901234567890123456789012345678901234567890123456789012345678901234567890 - -my $usage = < - - - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:40 GMT - - -resp 1 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:40 GMT -Content-type: text/xml -Content-length: 253 - - - - - - - - - - -req 2 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 191 -Connection: Keep-Alive - - - - - - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:40 GMT - - -resp 3 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:40 GMT -Content-type: text/xml -Content-length: 293 - - - - - - - - FOOFARM01 - - - - -req 4 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 220 -Connection: Keep-Alive - - - - - - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:55 GMT - - -resp 5 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:55 GMT -Content-type: text/xml -Content-length: 253 - - - - - - - - - - -req 6 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 442 -Connection: Keep-Alive - - - - - -i - FOOFARM01* - WS09535 - - - - - foo-user - some-domain - - - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:56 GMT - - -resp 7 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:56 GMT -Content-type: text/xml -Content-length: 507 - - - - - - - 10.1.2.2:1494 - win32 - tcp - ica30 - 10.1.2.2 - ica_svr01.some.domain:443 - - - -req 8 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 220 -Connection: Keep-Alive - - - - - - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:13:29 GMT - - -resp 9 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:13:29 GMT -Content-type: text/xml -Content-length: 253 - - - - - - - - - - -req 10 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 446 -Connection: Keep-Alive - - - - - -i - - EXCEL#32;2003 - - WS09535 - - - - foo-user - some-domain - -i - - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:13:29 GMT - - -resp 11 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:13:29 GMT -Content-type: text/xml -Content-length: 509 - - - - - - - 10.1.2.14:1494 - win32 - tcp - ica30 - 10.1.2.14 - ica_svr02.some.domain:443 - - - -** One sees this XML on an error (there may well be other error XML also, but I haven't seen it) ** - - - - - - unspecified - 0x0000000E - - - - -=end comment - -=cut - - -# You never know when you may be embedded ... - - diff --git a/contrib/check_inodes-freebsd.pl b/contrib/check_inodes-freebsd.pl deleted file mode 100644 index d66e5e3f..00000000 --- a/contrib/check_inodes-freebsd.pl +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/perl - -# check_inodes.pl for FreeBSD -# Designed on FreeBSD 4.6 (although this should not matter) -# parses df output, splits, and then takes variables -# df.pl -f mountpoint -w warningnumber -c critical number -# USE NUMBERS AND NOT PERCENTS FOR wanring and critical values -# -h is help -# -v is version -# Mountpoints: -# like / or /usr or /var (whatever you mount drives NOT the device names) -# Andrew Ryder - 20020804 - atr@mrcoffee.org - - -use strict; -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_w $opt_c $opt_f $verbose $PROGNAME); -use lib "/usr/local/libexec/nagios" ; -use utils qw($TIMEOUT %ERRORS &print_revision &support); - -my $df = "/bin/df"; -my $grep = "/usr/bin/grep"; - -$PROGNAME="df.pl"; - -sub print_help (); -sub print_usage (); - - -$ENV{'PATH'}=''; -$ENV{'BASH_ENV'}=''; -$ENV{'ENV'}=''; - -Getopt::Long::Configure('bundling'); -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "w=s" => \$opt_w, "warning=s" => \$opt_w, - "c=s" => \$opt_c, "critical=s" => \$opt_c, - "f=s" => \$opt_f, "filesystem=s" => \$opt_f); - - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 72 $ '); - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -($opt_w) || ($opt_w = shift) || ($opt_w = 50); -my $warning = $1 if ($opt_w =~ /([0-9]+)/); - -($opt_c) || ($opt_c = shift) || ($opt_c = 75); -my $critical = $1 if ($opt_c =~ /([0-9]+)/); - -if ($opt_c < $opt_w) { - print "Critical offset should be larger than warning offset\n"; - print_usage(); - exit $ERRORS{"UNKNOWN"}; -} - -($opt_f) || ($opt_f = "/"); - - -unless (-e $df) { - print "UNKNOWN: $df is not where df is\n"; - exit $ERRORS{'UNKNOWN'}; - } - -unless (-e $grep) { - print "UNKNOWN: $grep is not where grep is\n"; - exit $ERRORS{'UNKNOWN'}; - } - -unless (-d $opt_f) { - print "UNKNOWN: $opt_f is not a mount point\n"; - exit $ERRORS{'UNKNOWN'}; - } - - -my $state = $ERRORS{'UNKNOWN'}; -my $answer; - -open(DF, "$df -i $opt_f| $grep -v Filesystem |"); - -while () { - - my ($fs,$onek,$used,$avail,$capacity,$iused,$ifree,$ipercent,$mounted) = split; - $ipercent =~ s/%//s; - - if ($ipercent > $opt_w) { - $state = $ERRORS{'WARNING'}; - $answer = "WARNING: $ipercent percent inodes free on $opt_f\n"; - } elsif ($ipercent > $opt_w) { - $state = $ERRORS{'CRITCAL'}; - $answer = "CRITICAL: $ipercent percent inodes free on $opt_f\n"; - } elsif ($ipercent < $opt_w) { - $state = $ERRORS{'OK'}; - $answer = "OK: $ipercent percent inodes free on $opt_f\n"; - } -} - -close(DF); - -print "$answer"; -exit $state; - -sub print_usage () { - print "Usage: $PROGNAME [-w ] [-c ]\n"; - print "Example: $PROGNAME /dev/ad0s1a -w 50 -c 75\n"; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 72 $'); - print "Copyright (c) 2002 Andrew Ryder\n"; - print "\n"; - print_usage(); - print "\n"; - print " = Inode Percent at which a warning message is returned. Defaults to 50.\n"; - print " = Inode Percent at which a critical message is returned..\n Defaults to 75.\n\n"; - support(); -} - - diff --git a/contrib/check_inodes.pl b/contrib/check_inodes.pl deleted file mode 100755 index 5767878f..00000000 --- a/contrib/check_inodes.pl +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/perl -############################################################################## -# This plugin uses df to gather filesystem statistics and check the percent # -# used of inodes. I've put a switch in here since i've got both aix and # -# linux systems...adjust for your syntax's results. # -# Note: the percentages passed in MUST NOT have % after them # -# No warranty is either implied, nor expressed herein. # -# # -############################################################################## - -$filesystem = $ARGV[0]; -$warnpercent = $ARGV[1]; -$critpercent = $ARGV[2]; - -#------Find out what kind of syntax to expect -$systype=`uname`; -chomp($systype); - -#------Make sure we got called with the right number of arguments -#------you could also put a check in here to make sure critical level is -#------greater than warning...but what the heck. -die "Usage: check_inodes filesystem warnpercent critpercent" unless @ARGV; - -if ($#ARGV < 2) { - die "Usage: check_inodes filesystem warnpercent critpercent"; -}#end if - -#------This gets the data from the df command -$inputline = `df -i $filesystem|grep -v "Filesystem"`; - -#------replaces all spaces with a single :, that way we can use split -$inputline =~ y/ /:/s; - -#------different oses give back different sets of columns from the df -i -#------(at least mine do). This way I can use this plugin on all my hosts -#------if neither of these work, add your own in, or if you've got one that -#------just flat out reports something different...well...perl is your friend. -SWITCH: { - if ($systype eq "Linux") { - ($fs,$inodes,$iused,$ifree,$ipercent,$mntpt) = split(/:/,$inputline); - last SWITCH; - }#end if - if ($systype eq "AIX") { - ($fs,$blks,$free,$percentused,$iused,$ipercent,$mntpt) = split(/:/,$inputline); - last SWITCH; - }#end if -}#end switch - -#------First we check for critical, since that is, by definition and convention -#------going to exceed the warning threshold -$ipercent =~ y/%//ds; - -if ($ipercent > $critpercent) { - print "CRITICAL: $filesystem inode use exceeds critical threshold $critpercent ($ipercent)"; - exit 1; -}# end if - -#------Next we check the warning threshold -if ($ipercent > $warnpercent) { - print "WARNING: $filesystem inode use exceeds warning threshold $warnpercent ($ipercent)"; - exit 2; -}# end if - - -#------thanks to the magic of procedural programming, we figure if we got here, -#------everything MUST be fine. -print "$filesystem inode use within limits ($ipercent)"; -exit 0; - diff --git a/contrib/check_ipxping.c b/contrib/check_ipxping.c deleted file mode 100644 index 937b921a..00000000 --- a/contrib/check_ipxping.c +++ /dev/null @@ -1,201 +0,0 @@ -/****************************************************************************************** - * - * CHECK_IPXPING.C - * - * Program: IPX ping plugin for Nagios - * License: GPL - * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) - * - * Last Modified: 09-24-1999 - * - * Command line: CHECK_IPXPING - * - * Description: - * - * This plugin will use the /usr/bin/ipxping command to ping the specified host using the - * IPX protocol. Note: Linux users must have IPX support compiled into the kernerl and - * must have IPX configured correctly in order for this plugin to work. - * If the round trip time value is above the level, a STATE_WARNING is - * returned. If it exceeds the level, a STATE_CRITICAL is returned. - * - * - * - * IMPORTANT!! - * - * This plugin will only work with the ipxping command that has been ported to Linux. - * The version for Sun takes different command line arguments and differs in its output. - * - *****************************************************************************************/ - -#include "config.h" -#include "common.h" -#include "netutils.h" -#include "popen.h" - -/* this should be moved out to the configure script! */ -#define IPXPING_COMMAND "/tmp/ipxping/ipxping" - -/* these should be moved to the common header file */ -#define MAX_IPXNET_ADDRESS_LENGTH 12 -#define MAX_IPXHOST_ADDRESS_LENGTH 18 - -int socket_timeout=DEFAULT_SOCKET_TIMEOUT; -char dest_network[MAX_IPXNET_ADDRESS_LENGTH]; -char dest_address[MAX_IPXHOST_ADDRESS_LENGTH]; -int wrtt; -int crtt; - -int process_arguments(int,char **); - -FILE * spopen(const char *); -int spclose(FILE *); - -int main(int argc, char **argv){ - char command_line[MAX_INPUT_BUFFER]; - int rtt; - int bytes_returned; - int result=STATE_OK; - FILE *fp; - char input_buffer[MAX_INPUT_BUFFER]; - char *substr; - int current_line; - - if(process_arguments(argc,argv)!=OK){ - printf("Incorrect arguments supplied\n"); - printf("\n"); - printf("IPX ping plugin for Nagios\n"); - printf("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n"); - printf("Last Modified: 09-24-1999\n"); - printf("License: GPL\n"); - printf("\n"); - printf("Usage: %s [-to to_sec]\n",argv[0]); - printf("\n"); - printf("Options:\n"); - printf(" = IPX network that the remote host lies on. (Hex Format - 00:00:00:00)\n"); - printf(" = MAC address of the remote host. (Hex Format - 00:00:00:00:00:00)\n"); - printf(" = Round trip time in milliseconds necessary to result in a WARNING state\n"); - printf(" = Round trip time in milliseconds necessary to result in a CRITICAL state\n"); - printf(" [to_sec] = Seconds before we should timeout waiting for ping result. Default = %d sec\n",DEFAULT_SOCKET_TIMEOUT); - printf("\n"); - printf("Notes:\n"); - printf("This plugin will use the /usr/bin/ipxping command to ping the specified host using\n"); - printf("the IPX protocol. IPX support must be compiled into the kernel and your host must\n"); - printf("be correctly configured to use IPX before this plugin will work! An RPM package of\n"); - printf("the ipxping binary can be found at...\n"); - printf("http://www.rpmfind.net/linux/RPM/contrib/libc5/i386/ipxping-0.0-2.i386.shtml\n"); - printf("\n"); - return STATE_UNKNOWN; - } - - /* create the command line to use... */ - sprintf(command_line,"%s %s %s",IPXPING_COMMAND,dest_network,dest_address); - - /* initialize alarm signal handling */ - signal(SIGALRM,socket_timeout_alarm_handler); - - /* set socket timeout */ - alarm(socket_timeout); - - /* run the command */ - fp = spopen(command_line); - if(fp==NULL){ - printf("Unable to open pipe: %s",command_line); - return STATE_UNKNOWN; - } - - current_line=0; - while(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){ - - current_line++; - - /* skip the first line of the output */ - if(current_line==1) - continue; - - /* we didn't get the "is alive" */ - if(current_line==2 && !strstr(input_buffer,"is alive")) - result=STATE_CRITICAL; - - /* get the round trip time */ - if(current_line==3){ - substr=strtok(input_buffer,":"); - substr=strtok(NULL,"\n"); - rtt=atoi(substr); - } - - /* get the number of bytes returned */ - if(current_line==4 && strstr(input_buffer,"bytes returned")){ - bytes_returned=atoi(input_buffer); - } - } - - /* close the pipe */ - spclose(fp); - - /* reset the alarm */ - alarm(0); - - if(current_line==1 || result==STATE_CRITICAL) - printf("IPX Ping problem - No response from host\n"); - else{ - - if(rtt>crtt) - result=STATE_CRITICAL; - else if(rtt>wrtt) - result=STATE_WARNING; - - printf("IPX Ping %s - RTT = %d ms, %d bytes returned from %s %s\n",(result==STATE_OK)?"ok":"problem",rtt,bytes_returned,dest_network,dest_address); - } - - - return result; - } - - - -/* process all arguments passed on the command line */ -int process_arguments(int argc, char **argv){ - int x; - - /* no options were supplied */ - if(argc<5) - return ERROR; - - /* get the destination network address */ - strncpy(dest_network,argv[1],sizeof(dest_network)-1); - dest_network[sizeof(dest_network)-1]='\x0'; - - /* get the destination host address */ - strncpy(dest_address,argv[2],sizeof(dest_address)-1); - dest_address[sizeof(dest_address)-1]='\x0'; - - /* get the round trip time variables */ - wrtt=atoi(argv[3]); - crtt=atoi(argv[4]); - - /* process remaining arguments */ - for(x=6;x<=argc;x++){ - - /* we got the timeout to use */ - if(!strcmp(argv[x-1],"-to")){ - if(x \&version, - "h|help" => \&help, - "v|verbose" => \$verbose, - "w|warning=s" => \$opt_w, - "c|critical=s" => \$opt_c, - "n|name=s" => \$classname - ); - - -my $state = 'OK'; -my $min_warn = undef -my $max_warn = undef; -my $min_crit = undef; -my $max_crit = undef; - - -($opt_w) || ($opt_w = shift); -check_ranges($opt_w,\$min_warn, \$max_warn, "warning"); -($opt_c) || ($opt_c = shift); -check_ranges($opt_c,\$min_crit, \$max_crit, "critical"); - - -# -# Determine # of running processes for the java programs that interest us. -# -my @javalist = getJavaList(); - -my $total = 0; -my $msgout = ""; -my @fields; - -if ( defined $classname ) { - - #filter out a single java process based on class name - foreach (@javalist) { - @fields = split(/\s+/, $_); - $total = $fields[-1] and last if $classname eq $fields[0]; - } - $msgout .= "$total processes for $classname\n"; -} else { - #Handle all java processes - $msgout .= "\n"; - foreach (@javalist) { - @fields = split(/\s+/, $_); - - $total += $fields[-1]; - $msgout .= " $fields[-1] processes for "; - $msgout .= (scalar @fields > 1)? $fields[0] : "unknown" ; - $msgout .= "\n"; - } - my $msgtotal = "$total java processes for ". scalar @javalist . " applications"; - - if ( defined $verbose ) { - $msgout = $msgtotal . $msgout; - } else { - $msgout = $msgtotal; - } - -} - -# -# Set the state with the data we now have accumulated -# Note that due to the order of testing, warnings have precedence over -# criticals. This is logical, since you should be able to create a criticals -# range which encompasses a warning range. eg. following should be possible: -# -# check_javaproc -w 5:10 -c 3:12 -# proper specification of the ranges is the responsibility of the script user. -# -$state = 'CRITICAL' if (defined $min_crit && $total < $min_crit); -$state = 'CRITICAL' if (defined $max_crit && $total > $max_crit); -$state = 'CRITICAL' if (!defined $min_crit && !defined $max_crit && $total==0 ); -$state = 'WARNING' if (defined $min_warn && $total < $min_warn); -$state = 'WARNING' if (defined $max_warn && $total > $max_warn); - -print $msgout; -print "$state\n" if ($verbose); -exit $ERRORS{$state}; - -################################### -# Support routines for Nagios -################################### -sub check_ranges($$$$) { - my ($opt, $min, $max, $rangename) = @_; - - if ( defined $opt ) { - if ( $opt =~ /^([0-9]*)\:([0-9]*)$/) { - $$min = $1 if $1 > 0; - $$max= $2 if $2 > 0; - } else { - usage("Invalid $rangename range: $opt\n"); - } - } - - if ( defined $$min && defined $$max ) { - usage("Min value of $rangename range larger than max value: $opt\n") if ( $$min > $$max); - } -} - -sub print_usage () { - print "Usage: $PROGNAME [-v] [-w ] [-c ] [ -n ]\n"; -} - -sub print_help () { - revision(); - print "Copyright (c) 2002 by Wim Rijnders - -Perl Check java processes plugin for Nagios - -"; - print_usage(); - print " --v, --verbose - Return additional information. - Intended as a command-line aid, not recommended for Nagios script usage. - --w, --warning=INTEGER:INTEGER - Minimum and maximum number of processes outside of which a warning will be - generated. If omitted, no warning is generated. - --c, --critical=INTEGER:INTEGER - Minimum and maximum number of processes outside of which a critical will be - generated. If omitted, a critical is generated if no processes are running. - --n, --name=STRING - Name of class specified on the java command line (from which main() is run). - If omitted, all java processes are taken into account. - -"; - support(); -} - -sub revision() { - print_revision($PROGNAME,'$Revision: 211 $ '); -} - -sub version () { - revision(); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - -################################### -# Routines for delivering the data -################################### - -# -# Generate a formatted list of running java processes. -# -# Returns an array of strings having the following syntax: -# -# <#processes for this class> -# -sub getJavaList() { - - my @output; - - # Untaint - local $ENV{'PATH'} = '/bin:/usr/bin'; - local $ENV{'BASH_ENV'} = '~/.bashrc'; - - # We are only interested in the full command line - # The -H opstion is important for the order of the processes; - # this option ensures that all child processes are listed under - # their parents - @output=`ps -AHo \"\%a\" -ww`; - - #remove preceding whitespace and final EOL - foreach (@output) { - s/^\s*//; - chop; - } - - #Combine any consecutive processes with exactly the same command line - #into a single item - @output = checkSameLine(@output); - - #Filter out all java processes - my @javalist; - for (my $i = 0; $i < scalar @output; ++$i) { - push @javalist, $output[$i] if $output[$i] =~ /^\S*java/; - } - - foreach (@javalist) { - #The java statement at the beginning is redundant; remove it - s/^\S*java//; - - #remove all defines - s/\-D\S+//g; - - #remove classpath - s/\-(classpath|cp)\s+\S+//g; - - #remove any other parameters we don't want to see - s/\-server\s+//g; - s/\-X\S*\s+//g; - - #remove any redundant whitespaces at the beginning - s/^\s+//; - - } - - @javalist; -} - - -# -# Combine all consecutive lines with an identical command line -# to a signle line with a count at the end -# -sub checkSameLine { - my @input = @_; - my @output; - my $prevline= ""; - my $prevcount = 0; - - foreach my $a (@input) { - if ( $prevline eq $a) { - ++$prevcount; - } else { - push @output, $prevline . " " . ($prevcount + 1); - $prevcount = 0; - } - $prevline = $a; - } - - #don't forget the last item! - if ( $prevcount > 0 ) { - push @output, $prevline . " " . ($prevcount + 1); - } - - @output; -} - -#======= end check_javaproc ===== diff --git a/contrib/check_joy.sh b/contrib/check_joy.sh deleted file mode 100755 index 8783a59f..00000000 --- a/contrib/check_joy.sh +++ /dev/null @@ -1,69 +0,0 @@ -#! /bin/sh - -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin - -PROGNAME=`basename $0` -PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` -REVISION=`echo '$Revision: 2 $' | sed -e 's/[^0-9.]//g'` -STATUS="" - -. $PROGPATH/utils.sh - - -print_usage() { - echo "Usage: $PROGNAME /dev/js<#>