summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-09-02 11:16:24 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-09-02 11:16:24 (GMT)
commitb15adb7762b6caaecaa83637abfcf5fdb4802092 (patch)
tree64eddbe2aa1a7f98a140be0f7973f05d7a781ae0
parentc4d5882b9e1d07c7b61091062b7d085fa5f00284 (diff)
downloadmonitoring-plugins-b15adb7762b6caaecaa83637abfcf5fdb4802092.tar.gz
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.
-rw-r--r--Makefile.am2
-rw-r--r--contrib-reporting/process_perfdata.pl193
-rw-r--r--contrib/README.TXT56
-rw-r--r--contrib/aix/check_failed48
-rw-r--r--contrib/aix/check_io69
-rw-r--r--contrib/aix/check_kerberos49
-rw-r--r--contrib/aix/check_queue67
-rw-r--r--contrib/aix/pg_stat45
-rw-r--r--contrib/check_adptraid.sh75
-rw-r--r--contrib/check_apache.pl283
-rw-r--r--contrib/check_apc_ups.pl307
-rw-r--r--contrib/check_appletalk.pl210
-rw-r--r--contrib/check_arping.pl120
-rw-r--r--contrib/check_asterisk.pl259
-rw-r--r--contrib/check_axis.sh95
-rw-r--r--contrib/check_backup.pl114
-rw-r--r--contrib/check_bgpstate.pl215
-rw-r--r--contrib/check_breeze.pl22
-rw-r--r--contrib/check_cluster.c332
-rw-r--r--contrib/check_cluster2.README5
-rw-r--r--contrib/check_cluster2.c232
-rw-r--r--contrib/check_compaq_insight.pl296
-rw-r--r--contrib/check_cpqarray.c430
-rwxr-xr-xcontrib/check_digitemp.pl252
-rwxr-xr-xcontrib/check_dlswcircuit.pl221
-rw-r--r--contrib/check_dns_random.pl74
-rw-r--r--contrib/check_email_loop.pl309
-rw-r--r--contrib/check_fan_cpq_present133
-rw-r--r--contrib/check_fan_fsc_present135
-rw-r--r--contrib/check_flexlm.pl82
-rw-r--r--contrib/check_frontpage151
-rw-r--r--contrib/check_hltherm.c209
-rwxr-xr-xcontrib/check_hprsc.pl221
-rw-r--r--contrib/check_hw.sh66
-rwxr-xr-xcontrib/check_ica_master_browser.pl228
-rwxr-xr-xcontrib/check_ica_metaframe_pub_apps.pl381
-rwxr-xr-xcontrib/check_ica_program_neigbourhood.pl618
-rw-r--r--contrib/check_inodes-freebsd.pl127
-rwxr-xr-xcontrib/check_inodes.pl69
-rw-r--r--contrib/check_ipxping.c201
-rw-r--r--contrib/check_javaproc.pl278
-rwxr-xr-xcontrib/check_joy.sh69
-rw-r--r--contrib/check_linux_raid.pl125
-rw-r--r--contrib/check_lmmon.pl19
-rw-r--r--contrib/check_log2.pl202
-rwxr-xr-xcontrib/check_lotus.pl260
-rw-r--r--contrib/check_maxchannels.pl231
-rw-r--r--contrib/check_maxwanstate.pl201
-rw-r--r--contrib/check_mem.pl146
-rwxr-xr-xcontrib/check_ms_spooler.pl324
-rwxr-xr-xcontrib/check_mssql.sh104
-rw-r--r--contrib/check_nagios.pl48
-rw-r--r--contrib/check_nagios_db.pl89
-rw-r--r--contrib/check_nagios_db_pg.pl91
-rwxr-xr-xcontrib/check_netapp.pl178
-rw-r--r--contrib/check_nmap.py441
-rw-r--r--contrib/check_ora_table_space.pl82
-rw-r--r--contrib/check_oracle_instance.pl470
-rw-r--r--contrib/check_oracle_tbs218
-rw-r--r--contrib/check_pcpmetric.py106
-rw-r--r--contrib/check_pfstate75
-rwxr-xr-xcontrib/check_qmailq.pl121
-rw-r--r--contrib/check_rbl.c328
-rw-r--r--contrib/check_remote_nagios_status.pl666
-rw-r--r--contrib/check_rrd_data.pl129
-rwxr-xr-xcontrib/check_sap.sh89
-rw-r--r--contrib/check_smart.pl180
-rw-r--r--contrib/check_smb.sh111
-rw-r--r--contrib/check_snmp_disk_monitor.pl185
-rwxr-xr-xcontrib/check_snmp_printer.pl605
-rw-r--r--contrib/check_snmp_process_monitor.pl331
-rw-r--r--contrib/check_snmp_procs.pl590
-rw-r--r--contrib/check_sockets.pl145
-rw-r--r--contrib/check_temp_cpq162
-rw-r--r--contrib/check_temp_fsc160
-rw-r--r--contrib/check_timeout.c55
-rw-r--r--contrib/check_traceroute-pure_perl.pl119
-rwxr-xr-xcontrib/check_traceroute.pl209
-rw-r--r--contrib/check_uptime.c99
-rw-r--r--contrib/check_vcs.pl165
-rw-r--r--contrib/check_wave.pl77
-rwxr-xr-xcontrib/check_wins.pl247
-rw-r--r--contrib/checkciscotemp.pl166
-rw-r--r--contrib/mrtgext.pl291
-rw-r--r--contrib/nagios_sendim.pl66
-rwxr-xr-xcontrib/packet_utils.pm119
-rwxr-xr-xcontrib/rblcheck-dns69
-rwxr-xr-xcontrib/rblcheck-web37
-rwxr-xr-xcontrib/restrict.pl26
-rw-r--r--contrib/sched_downtime.pl47
-rw-r--r--contrib/tarballs/bowen-langley_plugins.tar.gzbin28742 -> 0 bytes
-rw-r--r--contrib/tarballs/check_bgp-1.0.tar.gzbin1469 -> 0 bytes
-rw-r--r--contrib/tarballs/check_radius.tar.gzbin25190 -> 0 bytes
-rw-r--r--contrib/tarballs/check_traffic-0.91b.tar.gzbin12198 -> 0 bytes
-rw-r--r--contrib/tarballs/fetchlog-0.94.tar.gzbin23179 -> 0 bytes
-rw-r--r--contrib/urlize.pl29
-rw-r--r--contrib/utils.py310
97 files changed, 1 insertions, 16690 deletions
diff --git a/Makefile.am b/Makefile.am
index cbca5d7..aae8ec9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,7 @@ SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@
5EXTRA_DIST = config.rpath \ 5EXTRA_DIST = config.rpath \
6 ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS BUGS CODING FAQ LEGAL NEWS \ 6 ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS BUGS CODING FAQ LEGAL NEWS \
7 NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \ 7 NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \
8 NPTest.pm contrib pkg nagios-plugins.spec \ 8 NPTest.pm pkg nagios-plugins.spec \
9 config_test/Makefile config_test/run_tests config_test/child_test.c \ 9 config_test/Makefile config_test/run_tests config_test/child_test.c \
10 perlmods tools/build_perl_modules \ 10 perlmods tools/build_perl_modules \
11 tools/tinderbox_build 11 tools/tinderbox_build
diff --git a/contrib-reporting/process_perfdata.pl b/contrib-reporting/process_perfdata.pl
deleted file mode 100644
index c97d483..0000000
--- a/contrib-reporting/process_perfdata.pl
+++ /dev/null
@@ -1,193 +0,0 @@
1#!/usr/local/bin/perl -w
2# author: Al Tobey <albert.tobey@priority-health.com>
3# what: process perfdata from Nagios and put it into RRD files
4# license: GPL - http://www.fsf.org/licenses/gpl.txt
5#
6# Todo:
7# * more documentation (POD) & comments
8# * clean up a bit, make it more configurable - possibly a config file
9
10use strict;
11use lib qw( /opt/nagios/libexec );
12use utils qw( %ERRORS );
13use vars qw( $debug_file %data $debug $rrd_base $process_func $rrd_type );
14use RRDs;
15$debug_file = undef; #"/var/opt/nagios/perfdata.out";
16$rrd_base = '/var/opt/nagios/rrds';
17$process_func = \&process_multi;
18$rrd_type = 'GAUGE';
19$data{hostname} = shift(@ARGV);
20$data{metric} = shift(@ARGV);
21$data{timestamp} = shift(@ARGV);
22$data{perfdata} = join( " ", @ARGV ); $data{perfdata} =~ s/\s+/ /g;
23
24# make sure there's data to work with
25exit $ERRORS{OK} if ( !defined($data{hostname}) || !defined($data{metric})
26 || !defined($data{timestamp}) || !defined($data{perfdata})
27 || $data{perfdata} eq ' ' || $data{perfdata} eq '' );
28
29if ( defined($debug_file) ) {
30 open( LOGFILE, ">>$debug_file" );
31 print LOGFILE "$data{hostname}\t$data{metric}\t$data{timestamp}\t$data{perfdata}\n\n";
32}
33
34# make sure host directory exists
35if ( !-d "$rrd_base/$data{hostname}" ) {
36 mkdir( "$rrd_base/$data{hostname}" )
37 || warn "could not create host directory $rrd_base/$data{hostname}: $!";
38}
39our $rrd_dir = $rrd_base .'/'. $data{hostname};
40
41# --------------------------------------------------------------------------- #
42# do some setup based on the name of the metric
43
44# host data
45if ( $data{metric} eq "HOSTCHECK" ) {
46 $rrd_dir .= '/hostperf';
47}
48# processing disk information
49elsif ( $data{metric} =~ /_DISK$/ ) {
50 $rrd_dir .= '/disk';
51}
52# network interface information
53elsif ( $data{metric} =~ /^IFACE_/ ) {
54 $rrd_dir .= '/interfaces';
55 $rrd_type = [ 'COUNTER', 'COUNTER' ];
56}
57# process performance statistics
58elsif ( $data{metric} =~ /_PROC$/ ) {
59 $rrd_dir .= '/processes';
60 $process_func = \&process_single;
61 $rrd_type = [ 'COUNTER', 'GAUGE' ];
62}
63# a resonable guess
64elsif ( $data{perfdata} =~ /=/ ) {
65 $process_func = \&process_single;
66}
67# everything else
68else {
69 $rrd_dir .= '/other';
70}
71
72# --------------------------------------------------------------------------- #
73# call the proper processing function set up above (functions defined below)
74our @processed = ( $process_func->() );
75
76# --------------------------------------------------------------------------- #
77
78if ( !-d $rrd_dir ) {
79 mkdir( $rrd_dir ) || warn "could not mkdir( $rrd_dir ): $!";
80}
81foreach my $datum ( @processed ) {
82 if ( defined($debug_file) ) {
83 print LOGFILE $datum->{rrd_name}, " = ", join('--',@{$datum->{data}}), "\n"
84 }
85
86 my $rrdfile = $rrd_dir.'/'.$datum->{rrd_name};
87
88 # create the RRD file if it doesn't already exist
89 if ( !-e $rrdfile ) {
90 # create a non-useful datasource title for each "part"
91 RRDs::create( $rrdfile, "-b", $data{timestamp}, "-s", 300, $process_func->($datum, 1),
92 "RRA:AVERAGE:0.5:1:600",
93 "RRA:MAX:0.5:1:600",
94 "RRA:AVERAGE:0.5:6:600",
95 "RRA:MAX:0.5:6:600",
96 "RRA:AVERAGE:0.5:24:600",
97 "RRA:MAX:0.5:24:600",
98 "RRA:AVERAGE:0.5:288:600",
99 "RRA:MAX:0.5:288:600"
100 );
101 if ( my $ERROR = RRDs::error ) { print "ERROR: $ERROR\n"; exit $ERRORS{UNKNOWN}; }
102 }
103 else {
104 # create a template to make sure data goes into the RRD as planned
105 if ( defined($debug_file) ) {
106 print LOGFILE "updating $rrdfile with data:\n\t",
107 join(':', $data{timestamp}, @{$datum->{data}}), "\n";
108 }
109 # update the RRD file
110 RRDs::update( $rrdfile, '-t', $process_func->($datum),
111 join(':', $data{timestamp}, @{$datum->{data}}) );
112 if ( my $ERROR = RRDs::error ) { print "ERROR: $ERROR\n"; exit $ERRORS{UNKNOWN}; }
113 }
114}
115
116# --------------------------------------------------------------------------- #
117
118if ( defined($debug_file) ) {
119 print LOGFILE "-------------------------------------------------------------------------------\n";
120 close( LOGFILE );
121}
122
123exit $ERRORS{OK};
124
125# /opt=value,value,value:/=value,value,value - into multiple rrd's
126sub process_multi {
127 my( $datum, $create ) = @_;
128
129 # return a string for creating new RRDs
130 if ( defined($create) && $create == 1 ) {
131 my @DS = ();
132 for ( my $i=0; $i<scalar(@{$datum->{data}}); $i++ ) {
133 # allow the RRD type to be set in the switch/if above
134 my $tmp_rrd_type = $rrd_type;
135 if ( ref($rrd_type) eq 'ARRAY' ) { $tmp_rrd_type = $rrd_type->[$i] }
136 # put the new datasource into the list
137 push( @DS, "DS:$data{metric}$i:GAUGE:86400:U:U" );
138 }
139 return @DS;
140 }
141 # return a template for updating an RRD
142 elsif ( defined($datum) && !defined($create) ) {
143 my @template = ();
144 for ( my $i=0; $i<scalar(@{$datum->{data}}); $i++ ) {
145 push( @template, $data{metric}.$i );
146 }
147 return join( ':', @template );
148 }
149 # break the data up into parts for processing (updates and creates)
150 else {
151 my @processed = ();
152 foreach my $part ( split(/:/, $data{perfdata}) ) { # break the line into parts
153 my @parts = split( /,/, $part ); # break the part into parts
154 my $rrd_name = $parts[0]; # figure out a good name for the RRD
155 if ( $parts[0] =~ /^\// ) { # handle /'s in disk names
156 $rrd_name = $parts[0];
157 $rrd_name =~ s#/#_#g; $rrd_name =~ s/^_//; $rrd_name =~ s/_$//;
158 if ( $parts[0] eq '/' ) { $rrd_name = 'root' };
159 }
160 # store our munged data in an array of hashes
161 push( @processed, { rrd_name => $rrd_name, name => shift(@parts), data => [ @parts ] } );
162 }
163 return @processed;
164 }
165}
166
167# name=value:name=value - into one rrd
168sub process_single {
169 my( $datum, $create ) = @_;
170
171 my( @names, @values ) = ();
172 foreach my $part ( split(/:/, $data{perfdata}) ) {
173 my( $name, $value ) = split( /=/, $part );
174 push( @names, $name );
175 push( @values, $value );
176 }
177
178 if ( defined($create) && $create == 1 ) {
179 my @DS = ();
180 for( my $i=0; $i<scalar(@names); $i++ ) {
181 my $tmp_rrd_type = $rrd_type;
182 if ( ref($rrd_type) eq 'ARRAY' ) { $tmp_rrd_type = $rrd_type->[$i] }
183 push( @DS, 'DS:'.$names[$i].":$tmp_rrd_type:86400:U:U" );
184 }
185 return @DS;
186 }
187 elsif ( defined($datum) && !defined($create) ) {
188 return join( ':', @names );
189 }
190 else {
191 return( {rrd_name=>lc($data{metric}), name=>$data{metric}, data=>[@values]} );
192 }
193}
diff --git a/contrib/README.TXT b/contrib/README.TXT
deleted file mode 100644
index bd9df3c..0000000
--- a/contrib/README.TXT
+++ /dev/null
@@ -1,56 +0,0 @@
1Contrib Plugins README
2----------------------
3
4This directory contains plugins which have been contributed by various people, but that
5have not yet been incorporated into the core plugins distribution.
6
7Most Perl plugins should work without modification. Some of the C plugins may require
8a few tweaks to compile.
9
10If you have questions regarding the use of these plugins, try contacting the author(s)
11or post a message to the nagiosplug-help mailing list (nagiosplug-help@lists.sourceforge.net)
12requesting assistance.
13
14
15
16Contrib Tarballs
17----------------
18
19In addition to the plugins located in this directory, there are some additional tarballs
20containing plugins in the tarballs/ subdirectory. They have not yet been organized.
21A brief description of their contents follows.
22
23
24berger-ping.tar.gz - Perl script version of the check_ping plugin and a corresponding
25 CGI (mtr.cgi) that uses mtr to traceroute a path to a host.
26 (Gary Berger)
27
28bowen-langley_plugins.tar.gz
29 - Several C plugins including check_inode, check_boot, etc.
30 (Adam Bown & Thomas Langley)
31
32
33check_bgp-1.0.tar.gz - Perl script intended for monitoring BGP sessions on Cisco routers.
34 Uses Net::Telnet to telnet into a cisco router and
35 run "sh ip bgp"
36
37check_memory.tgz - C plugin to check available system memory
38
39check_radius.tar.gz - C program to check RADIUS authentication. This is a hacked version of
40 the Cistron Radiusd program radtest that acts as a plugin for Nagios.
41 The vast majority of the code was written by someone at Livingston
42 Enterprises and Cistron. NOTE: Due to the copyright restrictions in
43 this code, it cannot be distributed under the GPL license, and thus
44 will not appear in the core plugin distribution!
45 (Adam Jacob)
46
47radius.tar.gz - Code modifications necessary to make the radexample app
48 supplied with the radiusclient code work as a RADIUS plugin
49 for Nagios (Nick Shore)
50
51fetchlog-0.94.tar.gz - C program: The fetchlog utility displays the last new messages of a
52 logfile. It is similar like tail(1) but offers some extra functionality
53 for output formatting. fetchlog can be used standalone or as a Nagios
54 plugin to monitor local logfiles or together with Net-SNMP to monitor
55 remote logfiles. The README shows how to setup fetchlog for Nagios.
56 (Alexander Haderer)
diff --git a/contrib/aix/check_failed b/contrib/aix/check_failed
deleted file mode 100644
index 50cdf7e..0000000
--- a/contrib/aix/check_failed
+++ /dev/null
@@ -1,48 +0,0 @@
1#!/usr/bin/perl
2#======================
3# Created May 25, 2000
4#======================
5
6# This scripts is for checking for failed root login attempts on
7# any machine running AIX which has a failedlogin file in /etc/security
8# The purpose is to thwart (good word) any unauthorised people from
9# even trying to log in as root. This plugin has been developed for Nagios
10# running on AIX.
11# Lonny Selinger SpEnTBoY lonny@abyss.za.org
12# May
13
14
15my $server = $ARGV[0];
16
17if (!$ARGV[0]) {
18 print "You must specify a server to check\n";
19 print "usage: ./check_failed <Server Name>\n";
20 exit (-1);
21 } else {
22 open (DATE, "/bin/date '+%b %d' |");
23 while (<DATE>) {
24 $dline = $_;
25 @dresults = $dline;
26 chop $dresults[0];
27 }
28 open (SULOG, "rsh $server -l root who /etc/security/failedlogin | grep root |");
29 while (<SULOG>) {
30 $line = $_;
31 @results = split (/\s+/,$line);
32 if ($line =~ /^root/) {
33 if (join(' ', @results[2,3]) eq $dresults[0]) {
34 print "FAILED root login on $dresults[0], node: $ARGV[0] from $results[5]\n";
35 exit(2);
36 }
37 }
38 }
39}
40if (join(' ', @results[2,3]) ne $dresults[0]) {
41 print "No Failed Root Logins on This Node\n";
42 exit(0);
43}
44exit(0);
45close(SULOG);
46close(DATE);
47
48
diff --git a/contrib/aix/check_io b/contrib/aix/check_io
deleted file mode 100644
index 58b25f6..0000000
--- a/contrib/aix/check_io
+++ /dev/null
@@ -1,69 +0,0 @@
1#! /bin/sh
2
3#=================================================================
4#
5# I/O Checker (KBPS)
6# This Script uses iostat to monitor disk io
7# Useful for notifications of disk thrashing.
8#
9# Authors: TheRocker
10# SpEnTBoY
11#
12# Email: therocker@pawprints.2y.net
13# lonny@abyss.za.org
14#
15#================================================================
16
17NUMBER1=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c1 | line`
18NUMBER2=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c2 | line`
19TMPFILE=/tmp/iotest.hndl
20TMPTOO=/tmp/iotwo.hndl
21
22#===========================================================
23#
24# We do an evaluation on $NUMBER1 and $NUMBER2 to see if
25# disk io is exceeding 40%.
26#
27#===========================================================
28
29if [ "$NUMBER1" -gt 4 ] && [ "$NUMBER2" -gt 0 ]
30then
31
32 `rsh $1 -l root iostat -d | grep -v cd0 | tr -s ' '| cut -d' ' -f1,2 | grep -e "4[0-9]." >> $TMPFILE`
33
34#====================================================================
35#
36# Of course, there may be more than one hard disk on the node
37# so we use this bit of code to report on more than one instance
38# of excessive disk IO.
39#
40#====================================================================
41
42 LINES=`wc -l /tmp/iotest.hndl | cut -c8`
43 LINESCTL=`wc -l /tmp/iotest.hndl | cut -c8 `
44 echo "WARNING!!! Disk I/O Exceeding 40% on --> \c"
45
46 while [ $LINESCTL != 0 ]
47 do
48
49 cat $TMPFILE | tail -$LINESCTL > $TMPTOO
50 cat $TMPTOO > $TMPFILE
51 LINESCTL=$(( $LINESCTL -1 ))
52 LINES=$(( $LINES -1 ))
53 DATA=`head -1 /tmp/iotest.hndl`
54 echo "( $DATA ) "
55
56
57 done
58 echo "\n"
59
60 rm -f $TMPFILE
61 rm -f $TMPTOO
62 exit 1
63
64else
65
66 print "No Disk I/O Exceeding 40%...OK"
67 exit 0
68
69fi
diff --git a/contrib/aix/check_kerberos b/contrib/aix/check_kerberos
deleted file mode 100644
index 443ab10..0000000
--- a/contrib/aix/check_kerberos
+++ /dev/null
@@ -1,49 +0,0 @@
1#! /bin/sh
2
3#=========================================================================
4# Kerberos Ticket Checker
5#
6# This script is handy if you allow kerberos tickets to expire
7# on your nodes. The script will simply warn you when a node has
8# kerberos tickets expiring on the current date. This will allow to
9# re-initialize the tickets if you wish to do so.
10#
11# Nothing fancy here, all Nagios will show is the number of tickets
12# that are going to (or already have) expired.
13#
14# An item of note:
15#
16# We made no provisions for the weekend. If tickets expire on the
17# weekend and nobody is around, you won't see a warning on the
18# Nagios console because we look for expired on the current day
19# only. It's a good idea to have this warning emailed to the
20# appropriate admin and if there is something critical that relies
21# on Kerberos, you might want to send a page.
22#
23# Authors: TheRocker
24# SpEnTBoY
25#
26# Email: therocker@pawprints.2y.net
27# lonny@abyss.za.org
28#=========================================================================
29
30TMPFILE=/tmp/kerbtmp.hndl
31DATE=`date +%b' '%d`
32
33rsh $1 -l root /usr/lpp/ssp/kerberos/bin/klist | tr -s ' ' | cut -d' ' -f4,5,6 | grep -e "$DATE" > $TMPFILE
34
35
36if [ -s $TMPFILE ]
37then
38
39 LINES=`wc -l /tmp/kerbtmp.hndl | cut -c7-8`
40 echo "Kerberos Tickets set to expire --> \c"
41 echo "$LINES \c"
42 echo "\n"
43
44 rm -f $TMPFILE
45 exit 1
46
47fi
48 echo "Kerberos Tickets are valid"
49 exit 0
diff --git a/contrib/aix/check_queue b/contrib/aix/check_queue
deleted file mode 100644
index 9f709c5..0000000
--- a/contrib/aix/check_queue
+++ /dev/null
@@ -1,67 +0,0 @@
1#! /bin/sh
2
3#===============================================================
4# Print Queue Checker
5#
6# The print queue checker simply looks for an occurance of a
7# DOWN queue. A note of warning, if you use remote queues in
8# AIX to redirect print jobs from the AIX queue to an NT print
9# server that print through DLC rather than IP, it will be very
10# s - l - o - w. But it will work.
11#
12# Author: TheRocker
13# Email: therocker@pawprints.2y.net
14#===============================================================
15
16TMPFILE=/tmp/qtmp.hndl
17TMPTOO=/tmp/qtwo.hndl
18
19#=======================================================================
20#
21# This script will also work on AIX 4.2.1 BUT you have to change
22# the following line. AIX 4.2.1 does not support the -W option
23# with lpstat. For AIX 4.2.1 just remove the -W option and it should
24# work just fine.
25#
26#=======================================================================
27
28`rsh $1 -l root lpstat -W | grep -e "DOWN" | tr -s ' ' | cut -d' ' -f1,3 > /tmp/qtmp.hndl 2> /tmp/q_err`
29
30if [ -s $TMPFILE ]
31then
32
33#=======================================================
34#
35# If you've seen the other AIX scripts I wrote you may
36# notice that I use this bit of code a lot. Well it
37# works and appears to be all purpose.
38#
39#=======================================================
40
41 LINES=`wc -l /tmp/qtmp.hndl | cut -c8`
42 LINESCTL=`wc -l /tmp/qtmp.hndl | cut -c8`
43
44 echo "Print Queue DOWN --> \c"
45
46 while [ $LINESCTL != 0 ]
47 do
48
49 cat $TMPFILE | tail -$LINESCTL > $TMPTOO
50 cat $TMPTOO > $TMPFILE
51 LINESCTL=$(( $LINESCTL -1 ))
52 LINES=$(( $LINES -1 ))
53 DATA=`head -1 /tmp/qtmp.hndl`
54 echo "( $DATA ) \c"
55
56
57 done
58
59 echo "\n"
60
61 rm -f $TMPFILE
62 rm -f $TMPTOO
63 exit 2
64
65fi
66 echo "Print Queues Running... OK"
67 exit 0
diff --git a/contrib/aix/pg_stat b/contrib/aix/pg_stat
deleted file mode 100644
index e0603ec..0000000
--- a/contrib/aix/pg_stat
+++ /dev/null
@@ -1,45 +0,0 @@
1#!/bin/ksh
2
3#==============================================================================
4# Script was originally created to collect stats and dump then to a log file
5# every five minutes. But we like this better (the log file thing is still
6# good if you want to track availability).
7#
8# Authors: SpEnTBoY
9# TheRocker
10#
11# Email: lonny@abyss.za.org
12# therocker@pawprints.2y.net
13#==============================================================================
14
15#=========================================================================================
16#
17# The best way to do this is to use Kerberos but we use rsh here because our monitoring
18# workstation doesn't have Kerberos installed. In order for this to work, the remote
19# host ($1) must have a .rhosts file that contains a line like:
20#
21# monitorhost nagiosuser
22#
23#=========================================================================================
24
25PAGING2=`rsh $1 -l root lsps -a -s | grep -v Paging | tr -s ' '| cut -d' ' -f3 | cut -d'%' -f1`
26
27
28if [ "$PAGING2" -gt "35" ] && [ "$PAGING2" -lt "50" ]
29then
30 echo "Paging Space is over 35% ("$PAGING2")%"
31exit 1
32fi
33
34if [ "$PAGING2" -gt "49" ]
35then
36 echo "WARNING! Paging Space is over 50% ("$PAGING2")%"
37exit 2
38fi
39
40if [ "$PAGING2" -lt "34" ]
41then
42 echo "Paging Space is less than 34% ("$PAGING2")%"
43exit 0
44fi
45
diff --git a/contrib/check_adptraid.sh b/contrib/check_adptraid.sh
deleted file mode 100644
index e3c47be..0000000
--- a/contrib/check_adptraid.sh
+++ /dev/null
@@ -1,75 +0,0 @@
1#! /bin/sh
2#
3# Modified check_sensors to check the alarm status of an Adaptec 3200S RAID
4# controller.
5#
6# Scott Lambert -- lambert@lambertfam.org
7#
8# Tested on FreeBSD 4.7 with the adptfbsd_323.tgz package installed. This
9# package installs all it's programs into /usr/dpt.
10#
11
12PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
13
14PROGNAME=`basename $0`
15PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
16REVISION=`echo '$Revision: 302 $' | sed -e 's/[^0-9.]//g'`
17
18. $PROGPATH/utils.sh
19
20RAIDUTIL_CMD="/usr/dpt/raidutil -A ?"
21
22print_usage() {
23 echo "Usage: $PROGNAME"
24}
25
26print_help() {
27 print_revision $PROGNAME $REVISION
28 echo ""
29 print_usage
30 echo ""
31 echo "This plugin checks alarm status of Adaptec 3200S RAID controller."
32 echo ""
33 support
34 exit 0
35}
36
37case "$1" in
38 --help)
39 print_help
40 exit 0
41 ;;
42 -h)
43 print_help
44 exit 0
45 ;;
46 --version)
47 print_revision $PROGNAME $REVISION
48 exit 0
49 ;;
50 -V)
51 print_revision $PROGNAME $REVISION
52 exit 0
53 ;;
54 *)
55 raidutiloutput=`$RAIDUTIL_CMD 2>&1`
56 status=$?
57 if test "$1" = "-v" -o "$1" = "--verbose"; then
58 echo ${raidutiloutput}
59 fi
60 if test ${status} -eq 127; then
61 echo "RAIDUTIL UNKNOWN - command not found (did you install raidutil?)"
62 exit -1
63 elif test ${status} -ne 0 ; then
64 echo "WARNING - raidutil returned state $status"
65 exit 1
66 fi
67 if echo ${raidutiloutput} | egrep On > /dev/null; then
68 echo RAID CRITICAL - RAID alarm detected!
69 exit 2
70 else
71 echo raid ok
72 exit 0
73 fi
74 ;;
75esac
diff --git a/contrib/check_apache.pl b/contrib/check_apache.pl
deleted file mode 100644
index b9e69a0..0000000
--- a/contrib/check_apache.pl
+++ /dev/null
@@ -1,283 +0,0 @@
1#!/usr/bin/perl
2#
3# (c)2001 Sebastian Hetze, Linux Information Systems AG
4# send bug reports to <S.Hetze@Linux-AG.com>
5#
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; either version 2
9# of the License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty
13# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# you should have received a copy of the GNU General Public License
17# along with this program (or with Nagios); if not, write to the
18# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19# Boston, MA 02111-1307, USA
20#
21#
22# Check apache status information provided by mod_status to find
23# out about the load (number of servers working) and the
24# performance (average response time for recent requests).
25#
26# Usage:
27# check_apache -H <host> [-lhV] [-w <warn>] [-c <crit>] [-u <url>]
28#
29# check_apache <host> <warn> <crit> <url> (if you cannot avoid it)
30#
31
32use LWP::UserAgent;
33use URI::URL;
34use Getopt::Long;
35Getopt::Long::Configure('bundling');
36
37$version=0.01;
38
39my %ERRORS = ('UNKNOWN' , '-1',
40 'OK' , '0',
41 'WARNING', '1',
42 'CRITICAL', '2');
43
44
45#
46# some default values
47#
48$perf_w=500;
49$perf_c=1000;
50$load_w=20;
51$load_c=30;
52$TIMEOUT=15;
53
54#
55# get command line options the regular way
56#
57GetOptions
58 ("V" => \$opt_V, "version" => \$opt_V,
59 "h" => \$opt_h, "help" => \$opt_h,
60 "l" => \$opt_l, "load" => \$opt_l,
61 "v" => \$verbose, "verbose" => \$verbose,
62 "w=s" => \$opt_w, "warning=s" => \$opt_w,
63 "c=s" => \$opt_c, "critical=s" => \$opt_c,
64 "H=s" => \$opt_H, "hostname=s" => \$opt_H,
65 "u=s" => \$opt_u, "url=s" => \$opt_u);
66
67#
68# handle the verbose stuff first
69#
70if ($opt_V) {
71 print "\n";
72 print "check_apache nagios plugin version $version\n";
73 print "\n";
74 print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n";
75 print "copies of the plugins under the terms of the GNU General Public License.\n";
76 print "For more information about these matters, see the file named COPYING.\n";
77 print "\n";
78 print "Copyright (c) 2001 Sebastian Hetze Linux Information Systems AG\n";
79 print "\n";
80 print "\n";
81 exit $ERRORS{'UNKNOWN'};
82}
83
84if ($opt_h) {
85 print_help();
86 exit $ERRORS{'UNKNOWN'};
87}
88
89#
90# now get options the weired way and set the defaults
91# if nothing else is provided
92#
93$opt_H = shift unless ($opt_H);
94print_usage() unless ($opt_H);
95
96if($opt_l) {
97 $autostring="?auto";
98 ($opt_w) || ($opt_w = shift) || ($opt_w = $load_w);
99 $warn = $1 if ($opt_w =~ /([0-9]+)/);
100 ($opt_c) || ($opt_c = shift) || ($opt_c = $load_c);
101 $alert = $1 if ($opt_c =~ /([0-9]+)/);
102} else {
103 $autostring="";
104 ($opt_w) || ($opt_w = shift) || ($opt_w = $perf_w);
105 $warn = $1 if ($opt_w =~ /([0-9]+)/);
106 ($opt_c) || ($opt_c = shift) || ($opt_c = $perf_c);
107 $alert = $1 if ($opt_c =~ /([0-9]+)/);
108}
109
110($opt_u) || ($opt_u = shift) || ($opt_u = "/server-status");
111
112
113#
114# dont let us wait forever...
115#
116$SIG{'ALRM'} = sub {
117 print ("ERROR: No response from HTTP server (alarm)\n");
118 exit $ERRORS{"UNKNOWN"};
119};
120alarm($TIMEOUT);
121
122
123#
124# now we set things up for the real work
125# and fire up the request
126#
127$ua = new LWP::UserAgent;
128$ua->agent("Nagios/0.1 " . $ua->agent);
129
130
131$urlstring = "http://" . $opt_H . $opt_u . $autostring;
132$url = url($urlstring);
133
134my $req = new HTTP::Request 'GET', $url;
135my $res = $ua->request($req);
136
137#
138# hopefully we´ve got something usefull
139#
140if ($res->is_success) {
141 if($opt_l) {
142 foreach $_ (split /^/m, $res->content) {
143 next if /^\s*$/;
144#
145# this is the load checking section
146# we parse the whole content, just in case someone
147# wants to use this some day in the future
148#
149 if (/^Total Accesses:\s+([0-9.]+)/) { $accesses = $1; next; }
150 if (/^Total kBytes:\s+([0-9.]+)/) { $kbytes = $1; next; }
151 if (/^CPULoad:\s+([0-9.]+)\s+/) { $load = $1; next; }
152 if (/^Uptime:\s+([0-9.]+)\s+/) { $uptime = $1; next; }
153 if (/^ReqPerSec:\s+([0-9.]+)\s+/) { $rps = $1; next; }
154 if (/^BytesPerSec:\s+([0-9.]+)\s+/) { $bps = $1; next; }
155 if (/^BytesPerReq:\s+([0-9.]+)\s+/) { $bpr = $1; next; }
156 if (/^BusyServers:\s+([0-9.]+)\s+/) { $busy = $1; next; }
157 if (/^IdleServers:\s+([0-9.]+)\s+/) { $idle = $1; next; }
158 if (/^Scoreboard:\s+([SRWKDLG_.]+)\s+/) { $score = $1; next; }
159 print "Unknown Status\n";
160 exit $ERRORS{"UNKNOWN"};
161 }
162#
163# now we even parse the whole scoreboard, just for fun
164#
165 foreach $scorepoint (split //m, $score) {
166 if($scorepoint eq '.') { $scores{'.'}+=1; next; } # Unused
167 if($scorepoint eq '_') { $scores{'_'}+=1; next; } # Waiting
168 if($scorepoint eq 'S') { $scores{'S'}+=1; next; } # Starting
169 if($scorepoint eq 'R') { $scores{'R'}+=1; next; } # Reading
170 if($scorepoint eq 'W') { $scores{'W'}+=1; next; } # Writing
171 if($scorepoint eq 'K') { $scores{'K'}+=1; next; } # Keepalive
172 if($scorepoint eq 'D') { $scores{'D'}+=1; next; } # DNS Lookup
173 if($scorepoint eq 'L') { $scores{'L'}+=1; next; } # Logging
174 if($scorepoint eq 'G') { $scores{'G'}+=1; next; } # Going
175 }
176
177 if($busy>$alert) {
178 printf "HTTPD CRITICAL: %.0f servers running\n", $busy;
179 exit $ERRORS{"CRITICAL"};
180 }
181 if($busy>$warn) {
182 printf "HTTPD WARNING: %.0f servers running\n", $busy;
183 exit $ERRORS{"WARNING"};
184 }
185 printf "HTTPD ok: %.0f servers running, %d idle\n", $busy, $idle;
186 exit $ERRORS{"OK"};
187
188 } else {
189#
190# this is the performance check section
191# We are a bit lazy here, no parsing of the initial data
192# block and the scoreboard.
193# However, you have the whole set of per server
194# information to play with ;-)
195# The actual performance is measured by adding up the
196# milliseconds required to process the most recent
197# requests of all instances and then taking the average.
198#
199 foreach $tablerow (split /<tr>/m, $res->content) {
200 ($empty,$Srv,$PID,$Acc,$M,$CPU,$SS,$Req,$Conn,$Child,$Slot,$Client,$VHost,$Request)
201 = split /<td>/, $tablerow;
202 if($Req) {
203 $lines+=1;
204 $req_sum+=$Req;
205 }
206 undef $Req;
207 }
208 $average=$req_sum/$lines;
209 if($average>$alert) {
210 printf "HTTPD CRITICAL: average response time %.0f
211 milliseconds\n", $average;
212 exit $ERRORS{"CRITICAL"};
213 }
214 if($average>$warn) {
215 printf "HTTPD WARNING: average response time %.0f
216 milliseconds\n", $average;
217 exit $ERRORS{"WARNING"};
218 }
219 if($average>0) {
220 printf "HTTPD ok: average response time %.0f milliseconds\n",
221 $average;
222 exit $ERRORS{"OK"};
223 }
224 print "Unknown Status\n";
225 exit $ERRORS{"UNKNOWN"};
226 }
227} else {
228 print "HTTP request failed\n";
229 exit $ERRORS{"CRITICAL"};
230}
231
232
233#
234# ok, now we are almost through
235# These last subroutines do the things for those that do not
236# read source code.
237#
238sub print_usage () {
239 print "Usage: $0 -H <host> [-lhV] [-w <warn>] [-c <crit>] [-u <url>]\n"; }
240
241sub print_help () {
242 print "\n";
243 print "\n";
244 print "check_apache nagios plugin version $version\n";
245 print "\n";
246 print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n";
247 print "copies of the plugins under the terms of the GNU General Public License.\n";
248 print "For more information about these matters, see the file named COPYING.\n";
249 print "\n";
250 print "Copyright (c) 2001 Sebastian Hetze Linux Information Systems AG\n";
251 print "\n";
252 print "\n";
253 print "This plugin checks the apache HTTP service on the specified host.\n";
254 print "It uses the mod_status facilities provided by the apache server.\n";
255 print "The monitoring server must be authorized in httpd.conf.\n";
256 print "\n";
257 print "\n";
258 print_usage();
259 print "\n";
260 print "Options:\n";
261 print " -H, --hostname=ADDRESS\n";
262 print " host name argument for server.\n";
263 print " -l, --load\n";
264 print " check load instead of performance.\n";
265 print " -h, --help\n";
266 print " print detailed help screen.\n";
267 print " -V, --version\n";
268 print " print version information.\n";
269 print " -w, --warning=INTEGER\n";
270 print " load / performance level at which a warning message will be gererated.\n";
271 print " -c, --critical=INTEGER\n";
272 print " load / performance level at which a critical message will be gererated.\n";
273 print " -u, --url=PATH\n";
274 print " location to call mod_status.\n";
275 print "\n";
276 print " Defaults for performance checking are $perf_w/$perf_c msec.\n";
277 print " Defaults for load checking are $load_w/$load_c servers running.\n";
278 print "\n";
279 print "\n";
280}
281#
282# the end
283#
diff --git a/contrib/check_apc_ups.pl b/contrib/check_apc_ups.pl
deleted file mode 100644
index 6bf1766..0000000
--- a/contrib/check_apc_ups.pl
+++ /dev/null
@@ -1,307 +0,0 @@
1#! /usr/bin/perl -wT
2#
3# Check_apc_ups - Check APC UPS status via SNMP
4# Shamelessly copied from check_breeze.pl
5#
6# To do:
7# - Send SNMP queries directly, instead of forking `snmpget`.
8# - Make the status less verbose. Maybe we can send an "onLine, time
9# remaining: hh:mm:ss" if all is well, and a list of specific problems
10# if something is broken.
11
12use strict;
13use Getopt::Long;
14use vars qw($opt_V $opt_h $opt_H $opt_T $opt_t $opt_R $opt_r
15 $opt_L $opt_l $PROGNAME);
16use lib "/usr/local/nagios/libexec";
17use utils qw(%ERRORS &print_revision &support &usage);
18
19sub print_help ();
20sub print_usage ();
21sub get_snmp_int_val ($);
22sub escalate_exitval ($);
23
24$ENV{'PATH'}='';
25$ENV{'BASH_ENV'}='';
26$ENV{'ENV'}='';
27
28Getopt::Long::Configure('bundling');
29GetOptions
30 ("V" => \$opt_V, "version" => \$opt_V,
31 "h" => \$opt_h, "help" => \$opt_h,
32 "T=s" => \$opt_T, "temp-critical" => \$opt_T,
33 "t=s" => \$opt_t, "temp-warning" => \$opt_t,
34 "R=s" => \$opt_R, "runtime-critical" => \$opt_R,
35 "r=s" => \$opt_r, "runtime-warning" => \$opt_r,
36 "L=s" => \$opt_L, "load-critical" => \$opt_L,
37 "l=s" => \$opt_l, "load-warning" => \$opt_l,
38 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
39
40if ($opt_V) {
41 print_revision($PROGNAME,'$Revision: 1771 $');
42 exit $ERRORS{'OK'};
43}
44
45if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
46
47($opt_H) || ($opt_H = shift) || usage("Host name/address not specified\n");
48my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
49($host) || usage("Invalid host: $opt_H\n");
50
51# Defaults
52
53$opt_R *= 60 * 100 if (defined $opt_R); # Convert minutes to secs/100
54$opt_r *= 60 * 100 if (defined $opt_R);
55
56my $tempcrit = $opt_T || 60;
57my $tempwarn = $opt_t || 40;
58my $runtimecrit = $opt_R || 30 * 60 * 100; # Secs / 100
59my $runtimewarn = $opt_r || 60 * 60 * 100;
60my $loadcrit = $opt_L || 85;
61my $loadwarn = $opt_l || 50;
62
63if ($tempcrit !~ /\d+/) { usage ("Invalid critical temperature threshold.\n"); }
64if ($tempwarn !~ /\d+/) { usage ("Invalid critical temperature threshold.\n"); }
65
66if ($runtimecrit !~ /\d+/) {
67 usage ("Invalid critical run time threshold.\n");
68}
69if ($runtimewarn !~ /\d+/) {
70 usage ("Invalid warning run time threshold.\n");
71}
72
73if ($loadcrit !~ /\d+/ || $loadcrit < 0 || $loadcrit > 100) {
74 usage ("Invalid critical load threshold.\n");
75}
76if ($loadwarn !~ /\d+/ || $loadwarn < 0 || $loadwarn > 100) {
77 usage ("Invalid warning load threshold.\n");
78}
79
80
81# APC UPS OIDs
82# APC MIBs are available at ftp://ftp.apcftp.com/software/pnetmib/mib
83my $upsBasicOutputStatus = ".1.3.6.1.4.1.318.1.1.1.4.1.1.0";
84my $upsBasicBatteryStatus = ".1.3.6.1.4.1.318.1.1.1.2.1.1.0";
85my $upsAdvInputLineFailCause = ".1.3.6.1.4.1.318.1.1.1.3.2.5.0";
86my $upsAdvBatteryTemperature = ".1.3.6.1.4.1.318.1.1.1.2.2.2.0";
87my $upsAdvBatteryRunTimeRemaining = ".1.3.6.1.4.1.318.1.1.1.2.2.3.0";
88my $upsAdvBatteryReplaceIndicator = ".1.3.6.1.4.1.318.1.1.1.2.2.4.0";
89my $upsAdvOutputLoad = ".1.3.6.1.4.1.318.1.1.1.4.2.3.0";
90my $upsAdvTestDiagnosticsResults = ".1.3.6.1.4.1.318.1.1.1.7.2.3.0";
91
92my @outputStatVals = (
93 [ undef, undef ], # pad 0
94 [ undef, undef ], # pad 1
95 [ "onLine", $ERRORS{'OK'} ], # 2
96 [ "onBattery", $ERRORS{'WARNING'} ], # 3
97 [ "onSmartBoost", $ERRORS{'WARNING'} ], # 4
98 [ "timedSleeping", $ERRORS{'WARNING'} ], # 5
99 [ "softwareBypass", $ERRORS{'WARNING'} ], # 6
100 [ "off", $ERRORS{'CRITICAL'} ], # 7
101 [ "rebooting", $ERRORS{'WARNING'} ], # 8
102 [ "switchedBypass", $ERRORS{'WARNING'} ], # 9
103 [ "hardwareFailureBypass", $ERRORS{'CRITICAL'} ], # 10
104 [ "sleepingUntilPowerReturn", $ERRORS{'CRITICAL'} ], # 11
105 [ "onSmartTrim", $ERRORS{'WARNING'} ], # 12
106);
107
108my @failCauseVals = (
109 undef,
110 "noTransfer",
111 "highLineVoltage",
112 "brownout",
113 "blackout",
114 "smallMomentarySag",
115 "deepMomentarySag",
116 "smallMomentarySpike",
117 "largeMomentarySpike",
118 "selfTest",
119 "rateOfVoltageChnage",
120);
121
122my @battStatVals = (
123 [ undef, undef ], # pad 0
124 [ undef, undef ], # pad 1
125 [ "batteryNormal", $ERRORS{'OK'} ], # 2
126 [ "batteryLow", $ERRORS{'CRITICAL'} ], # 3
127);
128
129my @battReplVals = (
130 [ undef, undef ], # pad 0
131 [ "noBatteryNeedsReplacing", $ERRORS{'OK'} ], # 1
132 [ "batteryNeedsReplacing", $ERRORS{'CRITICAL'} ], # 2
133);
134
135my @diagnosticsResultsVals = (
136 [ undef, undef ], # pad 0
137 [ "OK", $ERRORS{'OK'} ], # 1
138 [ "failed", $ERRORS{'CRITICAL'} ], # 2
139 [ "invalidTest", $ERRORS{'CRITICAL'} ], # 3
140 [ "testInProgress", $ERRORS{'OK'} ], # 4
141);
142
143my $exitval = $ERRORS{'UNKNOWN'};
144my $data;
145my $onbattery = 3;
146
147$data = get_snmp_int_val( $upsBasicOutputStatus );
148
149print "Output status: ";
150if (defined ($data) && defined ($outputStatVals[$data][0])) {
151 print "$outputStatVals[$data][0] | ";
152 escalate_exitval($outputStatVals[$data][1]);
153} else {
154 print "unknown | ";
155}
156
157$data = get_snmp_int_val( $upsAdvBatteryRunTimeRemaining );
158
159print "Rem time: ";
160if (defined ($data)) {
161 my $hrs = int($data / (60 * 60 * 100)); # Data is hundredths of a second
162 my $mins = int($data / (60 * 100)) % 60;
163 my $secs = ($data % 100) / 100;
164 printf "%d:%02d:%05.2f | ", $hrs, $mins, $secs;
165 if ($data <= $runtimecrit) {
166 escalate_exitval($ERRORS{'CRITICAL'});
167 } elsif ($data <= $runtimewarn) {
168 escalate_exitval($ERRORS{'WARNING'});
169 } else {
170 escalate_exitval($ERRORS{'OK'});
171 }
172} else {
173 print "unknown | ";
174}
175
176$data = get_snmp_int_val( $upsBasicBatteryStatus );
177
178print "Battery status: ";
179if (defined ($data) && defined ($battStatVals[$data][0])) {
180 my $failcause = "unknown";
181 my $fc = get_snmp_int_val( $upsAdvInputLineFailCause );
182 if ($data == $onbattery) {
183 if (defined ($failCauseVals[$fc])) { $failcause = $failCauseVals[$fc]; }
184 print "$battStatVals[$data][0] ($failcause) | ";
185 } else {
186 print "$battStatVals[$data][0] | ";
187 }
188 escalate_exitval($battStatVals[$data][1]);
189} else {
190 print "unknown | ";
191}
192
193$data = get_snmp_int_val( $upsAdvBatteryTemperature );
194
195print "Battery temp(C): ";
196if (defined ($data)) {
197 print "$data | ";
198 if ($data >= $tempcrit) {
199 escalate_exitval($ERRORS{'CRITICAL'});
200 } elsif ($data >= $tempwarn) {
201 escalate_exitval($ERRORS{'WARNING'});
202 } else {
203 escalate_exitval($ERRORS{'OK'});
204 }
205} else {
206 print "unknown | ";
207}
208
209$data = get_snmp_int_val( $upsAdvBatteryReplaceIndicator );
210
211print "Battery repl: ";
212if (defined ($data) && defined ($battReplVals[$data][0])) {
213 print "$battReplVals[$data][0] | ";
214 escalate_exitval($battReplVals[$data][1]);
215} else {
216 print "unknown | ";
217}
218
219$data = get_snmp_int_val( $upsAdvOutputLoad );
220
221print "Output load (%): ";
222if (defined ($data)) {
223 print "$data | ";
224 if ($data >= $loadcrit) {
225 escalate_exitval($ERRORS{'CRITICAL'});
226 } elsif ($data >= $loadwarn) {
227 escalate_exitval($ERRORS{'WARNING'});
228 } else {
229 escalate_exitval($ERRORS{'OK'});
230 }
231} else {
232 print "unknown | ";
233}
234
235$data = get_snmp_int_val( $upsAdvTestDiagnosticsResults );
236
237print "Diag result: ";
238if (defined ($data) && defined ($diagnosticsResultsVals[$data][0])) {
239 print "$diagnosticsResultsVals[$data][0]\n";
240 escalate_exitval($diagnosticsResultsVals[$data][1]);
241} else {
242 print "unknown\n";
243}
244
245
246exit $exitval;
247
248
249sub print_usage () {
250 print "Usage: $PROGNAME -H <host> -T temp -t temp -R minutes -r minutes\n";
251 print " -L percent -l percent\n";
252}
253
254sub print_help () {
255 print_revision($PROGNAME,'$Revision: 1771 $');
256 print "Copyright (c) 2001 Gerald Combs/Jeffrey Blank/Karl DeBisschop
257
258This plugin reports the status of an APC UPS equipped with an SNMP management
259module.
260
261";
262 print_usage();
263 print "
264-H, --hostname=HOST
265 Name or IP address of host to check
266-T --temp-critical
267 Battery degrees C above which a CRITICAL status will result (default: 60)
268-t --temp-warning
269 Battery degrees C above which a WARNING status will result (default: 40)
270-R --runtime-critical
271 Minutes remaining below which a CRITICAL status will result (default: 30)
272-r --runtime-warning
273 Minutes remaining below which a WARNING status will result (default: 60)
274-L --load-critical
275 Output load pct above which a CRITICAL status will result (default: 85
276-l --load-warning
277 Output load pct above which a WARNING status will result (default: 50
278
279";
280 support();
281}
282
283sub get_snmp_int_val ($) {
284 my $val=0;
285 my $oid = shift(@_);
286
287 $val = `/usr/bin/snmpget $host public $oid 2> /dev/null`;
288 my @test = split(/ /,$val,3);
289
290 return undef unless (defined ($test[2]));
291
292 if ($test[2] =~ /\(\d+\)/) { # Later versions of UCD SNMP
293 ($val) = ($test[2] =~ /\((\d+)\)/);
294 } elsif ($test[2] =~ /: \d+/) {
295 ($val) = ($test[2] =~ /: (\d+)/);
296 } else {
297 $val = $test[2];
298 }
299
300 return $val;
301}
302
303sub escalate_exitval ($) {
304 my $newval = shift(@_);
305
306 if ($newval > $exitval) { $exitval = $newval; }
307}
diff --git a/contrib/check_appletalk.pl b/contrib/check_appletalk.pl
deleted file mode 100644
index 9277686..0000000
--- a/contrib/check_appletalk.pl
+++ /dev/null
@@ -1,210 +0,0 @@
1#! /usr/bin/perl -wT
2#
3# check_atalk_ping plugin for nagios
4#
5# usage:
6# check_atalk_ping atalkaddress
7#
8# Checks if an atalkhost responds to an atalk echo
9# using "aecho"
10#
11# initial version: 23 October 2002 by Stefan Beck, IT Software Solutions
12# current status: $Revision: 1771 $
13#
14# Copyright Notice: GPL
15#
16BEGIN {
17 if ( $0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/ ) {
18 $runtimedir = $1;
19 $PROGNAME = $2;
20 }
21 delete $ENV{'LANG'};
22}
23
24use strict;
25use lib "/usr/local/nagios/libexec";
26
27use utils qw($TIMEOUT %ERRORS &print_revision &support);
28use vars qw($PROGNAME);
29
30$PROGNAME = "check_atalk";
31
32my (
33 $verbose, $host, $warning_avg, $warning_loss,
34 $critical_avg, $critical_loss, $count, $cmd,
35 $avg, $loss, $line
36);
37my ( $opt_c, $opt_w, $opt_H, $opt_p );
38$opt_c = $opt_w = $opt_p = $opt_H = '';
39
40sub print_help ();
41sub print_usage ();
42sub help ();
43sub version ();
44
45# Just in case of problems, let's not hang NetSaint
46$SIG{'ALRM'} = sub {
47 print "Plugin Timeout\n";
48 exit 2;
49};
50alarm($TIMEOUT);
51
52delete @ENV{ 'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV' };
53
54use Getopt::Long;
55Getopt::Long::Configure( 'bundling', 'no_ignore_case' );
56GetOptions(
57 "V|version" => \&version,
58 "h|help" => \&help,
59 "p|packets=i" => \$opt_p,
60 "c|critical=s" => \$opt_c,
61 "w|warning=s" => \$opt_w,
62 "H|hostname=s" => \$opt_H
63);
64
65
66# appletalk hostname ot address
67$opt_H = shift unless ($opt_H);
68unless ($opt_H) { print_usage (); exit $ERRORS{'UNKNOWN'}; }
69if ( $opt_H && $opt_H =~ m/^([-a-zA-Z\.\:0-9]+)$/ ) {
70 $host = $1;
71}
72else {
73 print "$opt_H is not a valid host name\n";
74 exit $ERRORS{'UNKNOWN'};
75}
76
77# number of packets
78$opt_p = 5 unless $opt_p;
79if ( $opt_p && $opt_p =~ m/^([1-9]+[0-9]*)$/ ) {
80 $count = $1;
81}
82else {
83 print "$opt_p is not a valid packet number\n";
84 exit $ERRORS{'UNKNOWN'};
85}
86
87if ( $opt_w && $opt_w =~ m/^([1-9]+[0-9]*),([1-9][0-9]*)%$/ ) {
88 $warning_avg = $1;
89 $warning_loss = $2;
90}
91else {
92 print "$opt_w is not a valid threshold\n";
93 exit $ERRORS{'UNKNOWN'};
94}
95
96if ( $opt_c && $opt_c =~ m/^([1-9]+[0-9]*),([1-9][0-9]*)%$/ ) {
97 $critical_avg = $1;
98 $critical_loss = $2;
99}
100else {
101 print "$opt_c is not a valid threshold\n";
102 exit $ERRORS{'UNKNOWN'};
103}
104
105$cmd = "/usr/bin/aecho -c $count $host 2>&1 |";
106print "$cmd\n" if ($verbose);
107open CMD, $cmd;
108
109while (<CMD>) {
110 print $_ if ($verbose);
111 $line = $_;
112
113 # 5 packets sent, 5 packets received, 0% packet loss
114 # round-trip (ms) min/avg/max = 0/0/0
115
116 if (/received, ([0-9]+)% packet loss/) {
117 $loss = $1;
118 }
119 if (/min\/avg\/max = [0-9]+\/([0-9]+)\/[0-9]+/) {
120 $avg = $1;
121 }
122}
123
124sub print_help() {
125 print_revision( $PROGNAME, '$Revision: 1771 $ ' );
126 print "Copyright (c) 2002 Stefan Beck\n";
127 print "\n";
128 print "Check if an atalkhost responds to an atalk echo using\n";
129 print " aecho -c <packets> <atalkhost>\n";
130 print "\n";
131 print_usage ();
132 print "\n";
133 print "-H, --hostname=HOST\n";
134 print " host to ping\n";
135 print "-w, --warning=THRESHOLD\n";
136 print " warning threshold pair\n";
137 print "-c, --critical=THRESHOLD\n";
138 print " critical threshold pair\n";
139 print "-p, --packets=INTEGER\n";
140 print " number of ICMP ECHO packets to send (Default: 5)\n";
141 print "\n";
142 print
143 "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average
144travel\n";
145 print
146 "time (ms) which triggers a WARNING or CRITICAL state, and <pl>
147is the\n";
148 print "percentage of packet loss to trigger an alarm state.\n";
149 print "\n";
150
151 support();
152}
153
154sub print_usage () {
155 print "$PROGNAME -H atalkhost -w <wrta>,<wpl>% -c <crta>,<cpl>%\n";
156 print " [-p packets] [-t timeout] [-L]\n";
157 print "$PROGNAME [-h | --help]\n";
158 print "$PROGNAME [-V | --version]\n";
159}
160
161sub version () {
162 print_revision( $PROGNAME, '$Revision: 1771 $ ' );
163 exit $ERRORS{'OK'};
164}
165
166sub help () {
167 print_help ();
168 exit $ERRORS{'OK'};
169}
170
171my $state = "OK";
172my $answer = undef;
173
174if ( defined $loss && defined $avg ) {
175 if ( $loss >= $critical_loss ) {
176 $state = "CRITICAL";
177 }
178 elsif ( $avg >= $critical_avg ) {
179 $state = "CRITICAL";
180 }
181 elsif ( $loss >= $warning_loss ) {
182 $state = "WARNING";
183 }
184 elsif ( $avg >= $warning_avg ) {
185 $state = "WARNING";
186 }
187 else {
188 $state = "OK";
189 }
190 $answer = "Appletalk PING $state - Packet loss = $loss%, RTA = $avg
191ms\n";
192}
193else {
194 $state = "UNKNOWN";
195 $answer = "UNKNOWN - $line";
196}
197print $answer;
198exit $ERRORS{$state};
199
200
201
202
203-------------------------------------------------------
204This sf.net email is sponsored by:ThinkGeek
205Welcome to geek heaven.
206http://thinkgeek.com/sf
207_______________________________________________
208Nagios-devel mailing list
209Nagios-devel@lists.sourceforge.net
210https://lists.sourceforge.net/lists/listinfo/nagios-devel
diff --git a/contrib/check_arping.pl b/contrib/check_arping.pl
deleted file mode 100644
index c41c4a8..0000000
--- a/contrib/check_arping.pl
+++ /dev/null
@@ -1,120 +0,0 @@
1#! /usr/bin/perl -w
2#
3# check_arping.pl - Nagios plugin to check host status via ARP ping
4#
5# usage:
6# check_arping -H hostname -I interface -T timeout
7#
8#
9# Copyright (C) 2003 Kenny Root
10#
11# This program is free software; you can redistribute it and/or
12# modify it under the terms of the GNU General Public License
13# as published by the Free Software Foundation; either version 2
14# of the License, or (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program; if not, write to the Free Software
23# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24#
25#
26# Report bugs to: kenny@the-b.org, nagiosplug-help@lists.sf.net
27
28use POSIX;
29use strict;
30use lib "/usr/lib/nagios/plugins" ;
31use utils qw($TIMEOUT %ERRORS &print_revision &support);
32
33use Net::Arping;
34use Getopt::Long;
35
36my $PROGNAME = "check_arping";
37
38my($status, $state, $answer);
39my($opt_V, $opt_h, $opt_t, $opt_I, $opt_H);
40
41
42#Option checking
43$status = GetOptions(
44 "V|version" => \$opt_V,
45 "help" => \$opt_h,
46 "I|interface=s" => \$opt_I,
47 "H|host=s" => \$opt_H,
48 "t|timeout=i" => \$opt_t);
49
50if ($status == 0)
51{
52 print_help() ;
53 exit $ERRORS{'OK'};
54}
55
56
57if ($opt_V) {
58 print_revision($PROGNAME,'$Revision: 1112 $ ');
59 exit $ERRORS{'OK'};
60}
61
62if ($opt_h) {
63 print_help();
64 exit $ERRORS{'OK'};
65}
66
67if ($opt_t) {
68 if ($opt_t ne int($opt_t)) {
69 print "Timeout not in seconds!\n";
70 print_help();
71 exit $ERRORS{'OK'};
72 }
73 $opt_t = int($opt_t);
74} else {
75 $opt_t = 3;
76}
77
78if (! utils::is_hostname($opt_H)){
79 usage();
80 exit $ERRORS{"UNKNOWN"};
81}
82
83my $ping = Net::Arping->new();
84
85my $reply = $ping->arping(Host => $opt_H, Interface => $opt_I, Timeout => $opt_t);
86
87if ($reply eq "0") {
88 $state = "CRITICAL";
89 print "$state: no reply from $opt_H on interface $opt_I in $opt_t seconds.\n";
90 exit $ERRORS{$state};
91} else {
92 $state = "OK";
93 $answer = "replied with MAC address $reply";
94}
95
96print "ARPING $state - $answer\n";
97exit $ERRORS{$state};
98
99
100sub usage {
101 print "\nMissing arguments!\n";
102 print "\n";
103 print "check_arping -I <interface> -H <host IP> [-t <timeout>]\n";
104 print "\n\n";
105 support();
106 exit $ERRORS{"UNKNOWN"};
107}
108
109sub print_help {
110 print "check_arping pings hosts that normally wouldn't allow\n";
111 print "ICMP packets but are still on the local network.\n";
112 print "\nUsage:\n";
113 print " -H (--host) IP to query - (required)\n";
114 print " -I (--interface) Interface to use.\n";
115 print " -t (--timeout) Timeout in seconds.\n";
116 print " -V (--version) Plugin version\n";
117 print " -h (--help) usage help \n\n";
118 print_revision($PROGNAME, '$Revision: 1112 $');
119
120}
diff --git a/contrib/check_asterisk.pl b/contrib/check_asterisk.pl
deleted file mode 100644
index 179d367..0000000
--- a/contrib/check_asterisk.pl
+++ /dev/null
@@ -1,259 +0,0 @@
1#!/usr/bin/perl -w
2
3use strict;
4use IO::Socket;
5use Getopt::Long;
6$|=1;
7
8my (
9 $host, $username, $password, $verbose, $help, $command, $mode,
10 $ipaddr, $respaddr, $sendto, $msg, $recvfrom,
11 $version, $response, $message, $line,
12 $sock, $port, $reply,
13 $warning, $critical,
14 %warnval, %critval,
15 %channels,
16 $runmode,
17 $key,
18 $s,
19);
20my $stop = 0;
21my $mgr_port = 5038;
22my $iax_port = 4569;
23my $exitcode = 0;
24my $cause = "";
25
26my $iax_answer = 0;
27my $iax_maxlen = 1024;
28my $iax_timeout = 5;
29my $iax_src_call = "8000"; #8000 most siginificant bit is IAX packet type full ... required for a poke etc...
30my $iax_dst_call = "0000";
31my $iax_timestamp = "00000000";
32my $iax_outbound_seq = "00";
33my $iax_inbound_seq = "00";
34my $iax_type = "06"; #IAX_Control
35
36sub ok {
37 $s = shift;
38 $s =~ s/[\r\n]//g;
39 print "OK: $s\n";
40 exit(0);
41}
42
43sub warning {
44 $s = shift;
45 $s =~ s/[\r\n]//g;
46 print "WARNING: $s\n";
47 exit(1);
48}
49
50sub error {
51 $s = shift;
52 $s =~ s/[\r\n]//g;
53 print "ERROR: $s\n";
54 exit(2);
55}
56
57sub unknown {
58 $s = shift;
59 $s =~ s/[\r\n]//g;
60 print "UNKNOWN: $s\n";
61 exit(3);
62}
63
64sub syntax {
65 $s = shift;
66 unless ($s =~ m/Help:/) {
67 $s = "Error: (".$s.")" or $s = 'Unknown';
68 }
69 print "$s\n" unless ($help);
70 print "Syntax: $0 -m mgr -h <host> -u <username> -p <password> [-cwv]\n";
71 print "Syntax: $0 -m iax -h <host> [-v]\n";
72 print "* --host -h Host\n";
73 print "* --mode -m Mode - eithr 'mgr' or 'iax'\n";
74 print " --username -u Username\n";
75 print " --password -p Password\n";
76 print " --port -P n Port (if not using $mgr_port for manager or $iax_port for IAX)\n";
77 print " --warning xxx=n Return warning if > n channels of type xxx.\n";
78 print " --critical xxx=n Return critical if > n channels of type xxx.\n";
79 print " --verbose -v Verbose\n";
80 print " --help -h This help\n";
81 exit(3);
82}
83
84Getopt::Long::Configure('bundling');
85GetOptions
86 ("p=s" => \$password, "password=s" => \$password,
87 "u=s" => \$username, "username=s" => \$username,
88 "h=s" => \$host, "host=s" => \$host,
89 "P=i" => \$port, "port=i" => \$port,
90 "H" => \$help, "help" => \$help,
91 "v" => \$verbose, "verbose" => \$verbose,
92 "m=s" => \$mode, "mode=s" => \$mode,
93 "critical=s" => \$critical, "warning=s" => \$warning);
94
95syntax("Help:") if ($help);
96syntax("Missing host") unless (defined($host));
97syntax("Missing mode") unless (defined($mode));
98if ($mode =~ /^iax$/i) {
99 print "Running in IAX mode\n" if ($verbose);
100 $runmode = 1;
101} elsif ($mode =~ /^mgr$/i) {
102 print "Running in Manager mode\n" if ($verbose);
103 $runmode = 2;
104} else {
105 syntax("Unknown mode $mode")
106}
107
108##############################################################################
109
110if ($runmode == 2) {
111 $port = $mgr_port;
112 syntax("Missing username") unless (defined($username));
113 syntax("Missing password") unless (defined($password));
114 if (defined($warning)) {
115 foreach $s (split(/,/, $warning)) {
116 syntax("Warning value given, $s, is invalid")
117 unless ($s =~ /^(\w+)=(\d+)$/);
118 $warnval{$1} = $2;
119 print "Clear to give WARNING after $2 connections on $1\n" if ($verbose);
120 }
121 }
122 if (defined($critical)) {
123 foreach $s (split(/,/, $critical)) {
124 syntax("Critical value given, $s, is invalid")
125 unless ($s =~ /^(\w+)=(\d+)$/);
126 $critval{$1} = $2;
127 print "Clear to give CRITICAL after $2 connections on $1\n" if ($verbose);
128 }
129 }
130
131 print "Connecting to $host:$port\n" if ($verbose);
132 unless ($sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp')) {
133 print("Could not connect to asterisk server ".$host.":".$port."\n");
134 exit(2);
135 }
136 print "Connected to $host:$port\n" if ($verbose);
137 $version = <$sock>;
138 print $version if ($verbose);
139
140 print $sock "Action: Login\r\nUsername: $username\r\nSecret: $password\r\nEvents: off\r\n\r\n";
141 print "Action: Login\r\nUsername: $username\r\nSecret: $password\r\n\r\n" if ($verbose);
142 $response = <$sock>;
143 $message = <$sock>;
144 $s = <$sock>;
145 print $response.$message if ($verbose);
146 print $s if ($verbose);
147
148 exit(1) unless ($response =~ m/^Response:\s+(.*)$/i);
149 exit(1) unless ($1 =~ m/Success/i);
150
151 print $sock "Action: Status\r\n\r\n";
152 print "Action: Status\r\n\r\n" if ($verbose);
153
154 $response = <$sock>;
155 $message = <$sock>;
156 print $response.$message if ($verbose);
157
158 &unknown("Unknown answer $response (wanted Response: something)") unless ($response =~ m/^Response:\s+(.*)$/i);
159 &unknown("$response didn't say Success") unless ($1 =~ m/Success/i);
160 &unknown("Unknown answer $response (wanted Message: something)") unless ($message =~ m/^Message:\s+(.*)$/i);
161 &unknown("didn't understand message $message") unless ($1 =~ m/Channel status will follow/i);
162
163 $stop=0;
164 while (($stop == 0) && ($line = <$sock>)) {
165 print "$line" if ($verbose);
166 if ($line =~ m/Channel:\s+(\w+)\//) {
167 $channels{$1}++;
168 print "Found $1 channel\n" if ($verbose);
169 }
170 if ($line =~ m/Event:\s*StatusComplete/i) {
171 $stop++;
172 }
173 }
174
175# Log out
176 print $sock "Action: Logoff\r\n\r\n";
177
178 undef($s);
179 foreach $key (keys %channels) {
180 $s .= " " . $key . " (" . $channels{$key} . ")";
181 }
182
183 foreach $key (keys %critval) {
184 print "key = $key\n" if ($verbose);
185 if (defined($channels{$key}) && ($channels{$key} > $critval{$key})) {
186 $exitcode = 2;
187 $cause .= $channels{$key} . " $key channels detected. ";
188 }
189 }
190
191 if ($exitcode < 2) {
192 foreach $key (keys %warnval) {
193 print "key = $key\n" if ($verbose);
194 if (defined($channels{$key}) && ($channels{$key} > $warnval{$key})) {
195 $exitcode = 1;
196 $cause .= $channels{$key} . " $key channels detected. ";
197 }
198 }
199 }
200
201 if ($exitcode == 0) {
202 print "OK ";
203 } elsif ($exitcode == 1) {
204 print "WARNING ";
205 } elsif ($exitcode == 2) {
206 print "CRITICAL ";
207 } elsif ($exitcode > 2) {
208 print "UNKNOWN ";
209 }
210 if (defined($s)) {
211 $cause .= " Channels:$s";
212 } else {
213 $cause .= " (idle)";
214 }
215
216 print $cause;
217
218 print "\n" if ($verbose);
219
220 exit($exitcode);
221} elsif ($runmode == 1) {
222 $port = $iax_port;
223
224 socket(PING, PF_INET, SOCK_DGRAM, getprotobyname("udp"));
225
226 $msg = pack "H24", $iax_src_call . $iax_dst_call . $iax_timestamp .
227 $iax_outbound_seq . $iax_inbound_seq . $iax_type . $iax_type;
228
229 $ipaddr = inet_aton($host);
230 $sendto = sockaddr_in($port,$ipaddr);
231
232 send(PING, $msg, 0, $sendto) == length($msg) or die "cannot send to $host : $port : $!\n";
233
234 eval {
235 local $SIG{ALRM} = sub { die("alarm time out"); };
236 alarm $iax_timeout;
237
238 while (1) {
239 $recvfrom = recv(PING, $msg, $iax_maxlen, 0) or die "recv: $!";
240 ($port, $ipaddr) = sockaddr_in($recvfrom);
241 $respaddr = inet_ntoa($ipaddr);
242 $iax_answer++;
243 # print "Response from $respaddr : $port\n";
244 }
245
246 };
247
248 if ($iax_answer) {
249 if ($iax_answer == 1) {
250 $reply = "reply";
251 } else {
252 $reply = "replies";
253 }
254 &ok("Got $iax_answer $reply");
255 } else {
256 &error("Got no reply");
257 }
258}
259
diff --git a/contrib/check_axis.sh b/contrib/check_axis.sh
deleted file mode 100644
index 231d9da..0000000
--- a/contrib/check_axis.sh
+++ /dev/null
@@ -1,95 +0,0 @@
1#!/bin/sh
2
3box=$1
4port=$2
5usr=$3
6pass=$4
7
8if [ ! "$#" == "4" ]; then
9 echo -e "\nYou did not supply enough command line arguments. \nUsage: ./check_axis.sh <host> <port> <username> <password> \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"
10fi
11
12tempfile=/tmp/status-$box.tmp
13exit="3"
14
15ftp -in $box &>/dev/null <<EOF
16user $usr $pass
17passive
18prompt off
19lcd /tmp
20ascii
21get status $tempfile
22EOF
23
24if [ ! -e "$tempfile" ]; then
25 stdio="Status file could not be transferred from the Axis box." && rm -f $tempfile && echo $stdio && exit 2;
26fi
27
28lines=`cat $tempfile | grep -i $port`
29status=`echo $lines | awk '{ print $3 }'`
30if [ "$status" == "Printing" ]; then
31 bytes=`echo $lines | awk '{ print $4 }'`;
32 comments=`echo $lines | tr -d "
33" | awk '{ print $5 " " $6 }'`;
34else
35 comments=`echo $lines | tr -d "
36" | awk '{ print $4 " " $5 }'`;
37fi
38
39comma=`echo $comments | grep , | wc -l`
40if [ "$comma" -eq "1" ]; then
41 comments=`echo $comments | cut -d, -f1`
42fi
43
44
45if [ "$status" == "Available" ]; then
46 if [ "$comments" == "Paper out" ]; then
47 exit="1" && stdio="WARNING - Out of paper.";
48 elif [ "$comments" == " " ]; then
49 exit="0" && stdio="OK - Printer is available but returns no comments.";
50 elif [ "$comments" == "No error" ]; then
51 exit="0" && stdio="OK - No error.";
52 elif [ "$comments" == "Ready " ]; then
53 exit="0" && stdio="OK - Ready.";
54 elif [ "$comments" == "Off line" ]; then
55 exit="1" && stdio="WARNING - Printer is off line.";
56 elif [ "$comments" == "Out of" ]; then
57 exit="1" && stdio="WARNING - Out of paper.";
58 elif [ "$comments" == "Busy Out" ]; then
59 exit="1" && stdio="WARNING - Busy, out of paper.";
60 elif [ "$comments" == "Printer off-line" ]; then
61 exit="1" && stdio="WARNING - Printer is off line.";
62 elif [ "$comments" == "Printer fault" ]; then
63 exit="2" && stdio="CRITICAL - Printer fault.";
64 else
65 exit="3" && stdio="Comments: $comments";
66 fi
67elif [ "$status" == "Printing" ]; then
68 if [ "$comments" == "Printer busy" ]; then
69 exit="0" && stdio="OK - PRINTING. Bytes printed: $bytes.";
70 elif [ "$comments" == "No error" ]; then
71 exit="0" && stdio="OK - PRINTING. Bytes printed: $bytes.";
72 elif [ "$comments" == "Paper out" ]; then
73 exit="1" && stdio="WARNING - PRINTING. Out of paper.";
74 elif [ "$comments" == "Out of" ]; then
75 exit="1" && stdio="WARNING - PRINTING. Out of paper. Bytes printed: $bytes.";
76 elif [ "$comments" == "Busy Out" ]; then
77 exit="1" && stdio="WARNING - Busy, out of paper.";
78 elif [ "$comments" == "Ready " ]; then
79 exit="0" && stdio="OK - PRINTING. Bytes printed: $bytes.";
80 elif [ "$comments" == "Printer off-line" ]; then
81 exit="1" && stdio="WARNING - PRINTING. Printer is off line.";
82 elif [ "$comments" == "Busy " ]; then
83 exit="0" && stdio="OK - PRINTING. Busy. Bytes printed: $bytes.";
84 elif [ "$comments" == "Off line" ]; then
85 exit="1" && stdio="WARNING - PRINTING. Printer is off line.";
86 elif [ "$comments" == "Printer fault" ]; then
87 exit="2" && stdio="CRITICAL - PRINTING. Printer fault. Bytes printed: $bytes.";
88 else
89 exit="3" && stdio="Comments: $comments.";
90 fi
91fi
92
93rm -f $tempfile
94echo $stdio
95exit $exit
diff --git a/contrib/check_backup.pl b/contrib/check_backup.pl
deleted file mode 100644
index 703d242..0000000
--- a/contrib/check_backup.pl
+++ /dev/null
@@ -1,114 +0,0 @@
1#! /usr/bin/perl -wT
2
3# (c)2001 Patrick Greenwell, Stealthgeeks, LLC. (patrick@stealthgeeks.net)
4# Licensed under the GNU GPL
5# http://www.gnu.org/licenses/gpl.html
6
7# check_backup: Checks a directory to see if at least one file was
8# created within a specified period of time that is of equal to or greater
9# than a given size.
10
11# Version 1.0
12# Last Updated: 9/12/01
13
14
15BEGIN {
16 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
17 $runtimedir = $1;
18 $PROGNAME = $2;
19 }
20}
21
22require 5.004;
23use strict;
24use Getopt::Long;
25use vars qw($opt_H $opt_d $opt_s $opt_t $verbose $PROGNAME);
26use lib $main::runtimedir;
27use utils qw($TIMEOUT %ERRORS &print_revision &usage &support &is_error);
28
29sub help ();
30sub print_help ();
31sub print_usage ();
32sub version ();
33sub display_res($$);
34my ($filesize, $answer) = ();
35my $state = $ERRORS{'UNKNOWN'};
36
37# Directory to check.
38my $dir = "/backup/";
39
40# Time period(in seconds)
41my $within = "3600";
42
43# Minimum size of file (in bytes)
44my $minsize = "40000000";
45
46delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
47
48Getopt::Long::Configure('bundling', 'no_ignore_case');
49GetOptions
50 ("V|version" => \&version,
51 "h|help" => \&help,
52 "v|verbose" => \$verbose,
53 "d|directory=s" => \$opt_d,
54 "s|minsize=s" => \$opt_s,
55 "t|timeout=s" => \$opt_t,
56 );
57
58($opt_s) || ($opt_s = shift) || usage("Minimum File size not specified\n");
59usage("File size must be numeric value") unless ($opt_s =~ m/^[0-9]+$/);
60
61(($opt_t) && ($TIMEOUT = $opt_t)) || ($TIMEOUT = 120);
62usage("TIMEOUT must be numeric value") unless ($TIMEOUT =~ m/^[0-9]+$/);
63
64# Don't hang if there are timeout issues
65$SIG{'ALRM'} = sub {
66 print ("ERROR: No response from ftp server (alarm)\n");
67 exit $ERRORS{'UNKNOWN'};
68};
69alarm($TIMEOUT);
70
71# Do stuff
72
73my $time = time;
74
75opendir(THISDIR, "$dir") or die "Can't open directory! $!";
76my @allfiles = grep !/^\./, readdir THISDIR;
77closedir THISDIR;
78while (my $file = $dir . pop @allfiles){
79 my ($size, $mtime) = (stat($file))[7,9];
80 if (((my $a = ($time - $mtime)) <= $within) and ($size >= $opt_s)){
81 display_res("OK: File $file is <= $within and >=$opt_s bytes.\n","OK");
82 }
83}
84
85# If we got here nothing matched....
86display_res("CRITICAL: No files in $dir are <= $within and >= $minsize.", "CRITICAL");
87
88exit;
89
90sub print_usage () {
91 print "Usage: $PROGNAME -s <minimum file size in bytes> -t <timeout> \n";
92}
93
94sub print_help () {
95 print_revision($PROGNAME,'$ Revision: 1.0 $ ');
96 print_usage();
97 support();
98}
99
100sub version () {
101 print_revision($PROGNAME,'$ Revision: 1.0 $ ');
102 exit $ERRORS{'OK'};
103}
104
105sub help () {
106 print_help();
107 exit $ERRORS{'OK'};
108}
109
110sub display_res ($$) {
111 my ($answer, $state) = @_;
112 print $answer;
113 exit $ERRORS{$state};
114}
diff --git a/contrib/check_bgpstate.pl b/contrib/check_bgpstate.pl
deleted file mode 100644
index 645d750..0000000
--- a/contrib/check_bgpstate.pl
+++ /dev/null
@@ -1,215 +0,0 @@
1#!/usr/bin/perl -w
2#
3# check_bgpstate.pl - nagios plugin
4#
5# Copyright (C) 2000 Christoph Kron
6#
7# This program is free software; you can redistribute it and/or
8# modify it under the terms of the GNU General Public License
9# as published by the Free Software Foundation; either version 2
10# of the License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20#
21#
22# Report bugs to: ck@zet.net
23#
24# 11.01.2000 Version 1.0
25
26
27
28use strict;
29
30use Net::SNMP;
31use Getopt::Long;
32&Getopt::Long::config('auto_abbrev');
33
34
35# whois programm for RIPE database queries
36my $whois = '/usr/bin/whois';
37my $status;
38my $TIMEOUT = 30;
39
40# critical bgp sessions
41my %uplinks = ( 1273, 'Uplink ECRC',
42 1755, 'Uplink EBONE',
43 3300, 'Uplink AUCS'
44 );
45
46my %ERRORS = ('UNKNOWN' , '-1',
47 'OK' , '0',
48 'WARNING', '1',
49 'CRITICAL', '2');
50
51
52my %bgpPeerState = (
53 '1',"idle",
54 '2',"connect",
55 '3',"active",
56 '4',"opensent",
57 '5',"openconfirm",
58 '6',"established"
59 );
60my $state = "UNKNOWN";
61my $answer = "";
62my $snmpkey;
63my $snmpoid;
64my $key;
65my $community = "public";
66my $port = 161;
67my @snmpoids;
68my $snmpbgpPeerState = '1.3.6.1.2.1.15.3.1.2';
69my $snmpbgpPeerLocalAddr = '1.3.6.1.2.1.15.3.1.5';
70my $snmpbgpPeerRemoteAddr = '1.3.6.1.2.1.15.3.1.7';
71my $snmpbgpPeerRemoteAs = '1.3.6.1.2.1.15.3.1.9';
72my $hostname;
73my $session;
74my $error;
75my $response;
76my %bgpStatus;
77my $bgpestablished =0 ;
78my $bgpcritical =0;
79my $bgpdown =0;
80my $bgpidle =0;
81my $bgpmessage;
82my $asname;
83my $remoteas;
84my @output;
85
86sub usage {
87 printf "\nMissing arguments!\n";
88 printf "\n";
89 printf "Perl bgpstate plugin for Nagios\n";
90 printf "monitors all BGP sessions\n";
91 printf "usage: \n";
92 printf "check_bgpstate.pl -c <READCOMMUNITY> -p <PORT> <HOSTNAME>\n";
93 printf "Copyright (C) 2000 Christoph Kron\n";
94 printf "check_bgpstate.pl comes with ABSOLUTELY NO WARRANTY\n";
95 printf "This programm is licensed under the terms of the ";
96 printf "GNU General Public License\n(check source code for details)\n";
97 printf "\n\n";
98 exit $ERRORS{"UNKNOWN"};
99}
100
101# Just in case of problems, let's not hang Nagios
102$SIG{'ALRM'} = sub {
103 print ("ERROR: No snmp response from $hostname (alarm)\n");
104 exit $ERRORS{"UNKNOWN"};
105};
106alarm($TIMEOUT);
107
108
109$status = GetOptions("community=s",\$community,
110 "port=i",\$port);
111if ($status == 0)
112{
113 &usage;
114}
115
116 #shift;
117 $hostname = shift || &usage;
118
119
120push(@snmpoids, $snmpbgpPeerState);
121push(@snmpoids, $snmpbgpPeerLocalAddr);
122push(@snmpoids, $snmpbgpPeerRemoteAddr);
123push(@snmpoids, $snmpbgpPeerRemoteAs);
124
125foreach $snmpoid (@snmpoids) {
126
127 ($session, $error) = Net::SNMP->session(
128 -hostname => $hostname,
129 -community => $community,
130 -port => $port
131 );
132
133 if (!defined($session)) {
134 $state='UNKNOWN';
135 $answer=$error;
136 print ("$state: $answer");
137 exit $ERRORS{$state};
138 }
139
140 if (!defined($response = $session->get_table($snmpoid))) {
141 $answer=$session->error;
142 $session->close;
143 $state = 'CRITICAL';
144 print ("$state: $answer,$snmpkey");
145 exit $ERRORS{$state};
146 }
147
148 foreach $snmpkey (keys %{$response}) {
149 $snmpkey =~ m/.*\.(\d+\.\d+\.\d+\.\d+$)/;
150 $key = $1;
151# printf "debug: $snmpkey: $key -> $response->{$snmpkey}\n";
152 $bgpStatus{$key}{$snmpoid} = $response->{$snmpkey};
153 }
154 $session->close;
155}
156
157foreach $key (keys %bgpStatus) {
158 if ($bgpStatus{$key}{$snmpbgpPeerState} == 6 ) {
159 $bgpestablished++;
160 }
161 elsif ($bgpStatus{$key}{$snmpbgpPeerState} == 1 ) {
162 $bgpidle++;
163 }
164 else {
165 $bgpdown++ ;
166 if (exists($uplinks{$bgpStatus{$key}{$snmpbgpPeerRemoteAs}}) ) {
167 $bgpcritical++;
168 }
169 @output = `$whois -T aut-num AS$bgpStatus{$key}{$snmpbgpPeerRemoteAs}`;
170
171 $asname = "";
172 foreach (@output) {
173 if (m/as-name/) {
174 $asname = $_;
175 $asname =~ s/as-name://;
176 last;
177 }
178 if ( $asname =~ "" && m/descr/ ) {
179 $asname = $_;
180 $asname =~ s/descr://;
181 }
182 }
183 $asname =~ s/^\s*//;
184 $asname =~ s/\s*$//;
185 $bgpmessage .= sprintf("Peering with AS%s not established -> %s<BR>",
186 $bgpStatus{$key}{$snmpbgpPeerRemoteAs},
187 $asname);
188 }
189}
190
191
192 if ($bgpdown > 0) {
193 if ($bgpcritical > 0) {
194 $state = 'CRITICAL';
195 }
196 else {
197 $state = 'WARNING';
198 }
199 $answer = sprintf("host '%s', sessions up: %d, down: %d, shutdown: %d<BR>",
200 $hostname,
201 $bgpestablished,
202 $bgpdown, $bgpidle);
203 $answer = $answer . $bgpmessage . "\n";
204 }
205 else {
206 $state = 'OK';
207 $answer = sprintf("host '%s', sessions up: %d, down: %d, shutdown: %d\n",
208 $hostname,
209 $bgpestablished,
210 $bgpdown,$bgpidle);
211 }
212
213print ("$state: $answer");
214exit $ERRORS{$state};
215
diff --git a/contrib/check_breeze.pl b/contrib/check_breeze.pl
deleted file mode 100644
index bb83765..0000000
--- a/contrib/check_breeze.pl
+++ /dev/null
@@ -1,22 +0,0 @@
1#!/usr/bin/perl
2
3# Plugin to test signal strength on Breezecom wireless equipment
4# Contributed by Jeffrey Blank
5
6$Host=$ARGV[0];
7$sig_crit=$ARGV[1];
8$sig_warn=$ARGV[2];
9$sig=0;
10$sig = `snmpget $Host public .1.3.6.1.4.1.710.3.2.3.1.3.0`;
11@test=split(/ /,$sig);
12$sig=@test[2];
13$sig=int($sig);
14if ($sig>100){$sig=100}
15
16print "Signal Strength at: $sig%\n";
17if ($sig<$sig_crit)
18 {exit(2)}
19if ($sig<$sig_warn)
20 {exit(1)}
21
22exit(0);
diff --git a/contrib/check_cluster.c b/contrib/check_cluster.c
deleted file mode 100644
index 06519e6..0000000
--- a/contrib/check_cluster.c
+++ /dev/null
@@ -1,332 +0,0 @@
1/*****************************************************************************
2 *
3 * CHECK_CLUSTER.C - Host and Service Cluster Plugin for NetSaint
4 *
5 * Copyright (c) 2000 Ethan Galstad (netsaint@netsaint.org)
6 * License: GPL
7 * Last Modified: 07-08-2000
8 *
9 * License:
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 *****************************************************************************/
26
27
28#include <stdio.h>
29#include <stdlib.h>
30
31#define OK 0
32#define ERROR -1
33
34#define TRUE 1
35#define FALSE 0
36
37#define CHECK_SERVICES 1
38#define CHECK_HOSTS 2
39
40#define MAX_INPUT_BUFFER 1024
41
42#define STATE_OK 0
43#define STATE_WARNING 1
44#define STATE_CRITICAL 2
45#define STATE_UNKNOWN 3
46
47typedef struct clustermember_struct{
48 char *host_name;
49 char *svc_description;
50 struct clustermember_struct *next;
51 }clustermember;
52
53
54int check_cluster_status(void);
55int add_clustermember(char *,char *);
56void free_memory(void);
57
58clustermember *clustermember_list=NULL;
59
60int total_services_ok=0;
61int total_services_warning=0;
62int total_services_unknown=0;
63int total_services_critical=0;
64
65int total_hosts_up=0;
66int total_hosts_down=0;
67int total_hosts_unreachable=0;
68
69char status_log[MAX_INPUT_BUFFER]="";
70int warning_threshold=0;
71int critical_threshold=0;
72
73int check_type=CHECK_SERVICES;
74
75
76int main(int argc, char **argv){
77 char input_buffer[MAX_INPUT_BUFFER];
78 char *host_name;
79 char *svc_description;
80 int return_code=STATE_OK;
81 int error=FALSE;
82
83 if(argc!=5){
84
85 printf("Invalid arguments supplied\n");
86 printf("\n");
87
88 printf("Host/Service Cluster Plugin for NetSaint\n");
89 printf("Copyright (c) 2000 Ethan Galstad (netsaint@netsaint.org)\n");
90 printf("Last Modified: 07-08-2000\n");
91 printf("License: GPL\n");
92 printf("\n");
93 printf("Usage: %s <--service | --host> <status_log> <warn_threshold> <crit_threshold>\n",argv[0]);
94 printf("\n");
95 printf("Options:\n");
96 printf(" --service = Check service cluster status\n");
97 printf(" --host = Check host cluster status\n");
98 printf(" <status_log> = This is the location of the NetSaint status log\n");
99 printf(" <warn_threshold> = This is the number of hosts or services in\n");
100 printf(" the cluster that must be in a non-OK state\n");
101 printf(" in order to result in a warning status level\n");
102 printf(" <crit_threshold> = This is the number of hosts or services in\n");
103 printf(" the cluster that must be in a non-OK state\n");
104 printf(" in order to result in a critical status level\n");
105 printf("\n");
106 printf("Notes:\n");
107 printf("Members of the host or service cluster are read from STDIN.\n");
108 printf("One host or service can be specified per line, services must\n");
109 printf("be in the format of <host_name>;<svc_description>\n");
110 printf("\n");
111
112 return STATE_UNKNOWN;
113 }
114
115 /* see if we're checking a host or service clust */
116 if(!strcmp(argv[1],"--host"))
117 check_type=CHECK_HOSTS;
118 else
119 check_type=CHECK_SERVICES;
120
121 /* get the status log */
122 strncpy(status_log,argv[2],sizeof(status_log)-1);
123 status_log[sizeof(status_log)-1]='\x0';
124
125 /* get the warning and critical thresholds */
126 warning_threshold=atoi(argv[3]);
127 critical_threshold=atoi(argv[4]);
128
129
130 /* read all data from STDIN until there isn't anymore */
131 while(fgets(input_buffer,sizeof(input_buffer)-1,stdin)){
132
133 if(feof(stdin))
134 break;
135
136 /*strip(input_buffer);*/
137
138 if(!strcmp(input_buffer,""))
139 continue;
140
141 if(!strcmp(input_buffer,"\n"))
142 continue;
143
144 /* get the host name */
145 if(check_type==CHECK_SERVICES)
146 host_name=(char *)strtok(input_buffer,";");
147 else
148 host_name=(char *)strtok(input_buffer,"\n");
149 if(host_name==NULL || !strcmp(host_name,"")){
150 printf("Error: Host name is NULL!\n");
151 continue;
152 }
153
154 if(check_type==CHECK_SERVICES){
155
156 /* get the service description */
157 svc_description=(char *)strtok(NULL,"\n");
158 if(svc_description==NULL || !strcmp(svc_description,"")){
159 printf("Error: Service description is NULL!\n");
160 continue;
161 }
162 }
163
164 /* add the cluster member to the list in memory */
165 if(add_clustermember(host_name,svc_description)!=OK)
166 printf("Error: Could not add cluster member\n");
167#ifdef DEBUG
168 else
169 printf("Added cluster member\n");
170#endif
171 }
172
173
174 /* check the status of the cluster */
175 if(check_cluster_status()==OK){
176
177 if(check_type==CHECK_SERVICES){
178 if((total_services_warning+total_services_unknown+total_services_critical) >= critical_threshold)
179 return_code=STATE_CRITICAL;
180 else if((total_services_warning+total_services_unknown+total_services_critical) >= warning_threshold)
181 return_code=STATE_WARNING;
182 else
183 return_code=STATE_OK;
184
185 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);
186 }
187 else{
188 if((total_hosts_down+total_hosts_unreachable) >= critical_threshold)
189 return_code=STATE_CRITICAL;
190 else if((total_hosts_down+total_hosts_unreachable) >= warning_threshold)
191 return_code=STATE_WARNING;
192 else
193 return_code=STATE_OK;
194
195 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);
196 }
197 }
198 else
199 return_code=STATE_UNKNOWN;
200
201 free_memory();
202
203 return return_code;
204 }
205
206
207
208int add_clustermember(char *hst,char *svc){
209 clustermember *new_clustermember;
210
211 new_clustermember=(clustermember *)malloc(sizeof(clustermember));
212 if(new_clustermember==NULL)
213 return ERROR;
214
215 new_clustermember->host_name=NULL;
216 new_clustermember->svc_description=NULL;
217
218 if(hst!=NULL){
219 new_clustermember->host_name=(char *)malloc(strlen(hst)+1);
220 if(new_clustermember->host_name==NULL){
221 free(new_clustermember);
222 return ERROR;
223 }
224 strcpy(new_clustermember->host_name,hst);
225 }
226
227 if(svc!=NULL){
228 new_clustermember->svc_description=(char *)malloc(strlen(svc)+1);
229 if(new_clustermember->svc_description==NULL){
230 if(new_clustermember->host_name!=NULL)
231 free(new_clustermember->host_name);
232 free(new_clustermember);
233 return ERROR;
234 }
235 strcpy(new_clustermember->svc_description,svc);
236 }
237
238 new_clustermember->next=clustermember_list;
239 clustermember_list=new_clustermember;
240
241 return OK;
242 }
243
244
245void free_memory(void){
246 clustermember *this_clustermember;
247 clustermember *next_clustermember;
248
249 for(this_clustermember=clustermember_list;this_clustermember!=NULL;this_clustermember=next_clustermember){
250 next_clustermember=this_clustermember->next;
251 if(this_clustermember->host_name!=NULL)
252 free(this_clustermember->host_name);
253 if(this_clustermember->svc_description!=NULL)
254 free(this_clustermember->svc_description);
255 free(this_clustermember);
256 }
257
258 return;
259 }
260
261
262
263int check_cluster_status(void){
264 FILE *fp;
265 clustermember *temp_clustermember;
266 char input_buffer[MAX_INPUT_BUFFER];
267 char matching_entry[MAX_INPUT_BUFFER];
268
269 fp=fopen(status_log,"r");
270 if(fp==NULL){
271 printf("Error: Could not open status log '%s' for reading\n",status_log);
272 return ERROR;
273 }
274
275#ifdef DEBUG
276 for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){
277 if(check_type==CHECK_HOSTS)
278 printf("Cluster member: '%s'\n",temp_clustermember->host_name);
279 else
280 printf("Cluster member: '%s'/'%s'\n",temp_clustermember->host_name,temp_clustermember->svc_description);
281 }
282#endif
283
284 for(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp);!feof(fp);fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){
285
286 /* this is a host entry */
287 if(strstr(input_buffer,"] HOST;") && check_type==CHECK_HOSTS){
288
289 /* this this a match? */
290 for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){
291
292 snprintf(matching_entry,sizeof(matching_entry)-1,";%s;",temp_clustermember->host_name);
293
294 if(strstr(input_buffer,matching_entry)){
295 if(strstr(input_buffer,";DOWN;"))
296 total_hosts_down++;
297 else if(strstr(input_buffer,";UNREACHABLE;"))
298 total_hosts_unreachable++;
299 else if(strstr(input_buffer,";UP;"))
300 total_hosts_up++;
301 }
302 }
303
304 }
305
306 /* this is a service entry */
307 else if(strstr(input_buffer,"] SERVICE;") && check_type==CHECK_SERVICES){
308
309 /* this this a match? */
310 for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){
311
312 snprintf(matching_entry,sizeof(matching_entry)-1,";%s;%s;",temp_clustermember->host_name,temp_clustermember->svc_description);
313
314 if(strstr(input_buffer,matching_entry)){
315 if(strstr(input_buffer,";HOST DOWN;") || strstr(input_buffer,";UNREACHABLE;") || strstr(input_buffer,";CRITICAL;"))
316 total_services_critical++;
317 else if(strstr(input_buffer,";WARNING;"))
318 total_services_warning++;
319 else if(strstr(input_buffer,";UNKNOWN;"))
320 total_services_unknown++;
321 else if(strstr(input_buffer,";OK;") || strstr(input_buffer,";RECOVERY;"))
322 total_services_ok++;
323 }
324 }
325
326 }
327 }
328
329 fclose(fp);
330
331 return OK;
332 }
diff --git a/contrib/check_cluster2.README b/contrib/check_cluster2.README
deleted file mode 100644
index a014984..0000000
--- a/contrib/check_cluster2.README
+++ /dev/null
@@ -1,5 +0,0 @@
1check_cluster2 is now part of the core Nagios-Plugins distribution and has
2been renamed check_cluster. It will be installed automatically.
3
4The threshold format has changed and is not backward-compatible; be sure to
5understand 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 e60948d..0000000
--- a/contrib/check_cluster2.c
+++ /dev/null
@@ -1,232 +0,0 @@
1/*****************************************************************************
2 *
3 * CHECK_CLUSTER2.C - Host and Service Cluster Plugin for Nagios 2.x
4 *
5 * Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)
6 * License: GPL
7 * Last Modified: 03-11-2004
8 *
9 * License:
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 *****************************************************************************/
26
27
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31#include <unistd.h>
32#include <getopt.h>
33
34#define OK 0
35#define ERROR -1
36
37#define TRUE 1
38#define FALSE 0
39
40#define CHECK_SERVICES 1
41#define CHECK_HOSTS 2
42
43#define MAX_INPUT_BUFFER 1024
44
45#define STATE_OK 0
46#define STATE_WARNING 1
47#define STATE_CRITICAL 2
48#define STATE_UNKNOWN 3
49
50int total_services_ok=0;
51int total_services_warning=0;
52int total_services_unknown=0;
53int total_services_critical=0;
54
55int total_hosts_up=0;
56int total_hosts_down=0;
57int total_hosts_unreachable=0;
58
59int warning_threshold=1;
60int critical_threshold=1;
61
62int check_type=CHECK_SERVICES;
63
64char *data_vals=NULL;
65char *label=NULL;
66
67
68int process_arguments(int,char **);
69
70
71
72int main(int argc, char **argv){
73 char input_buffer[MAX_INPUT_BUFFER];
74 char *ptr;
75 int data_val;
76 int return_code=STATE_OK;
77 int error=FALSE;
78
79 if(process_arguments(argc,argv)==ERROR){
80
81 printf("Invalid arguments supplied\n");
82 printf("\n");
83
84 printf("Host/Service Cluster Plugin for Nagios 2\n");
85 printf("Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)\n");
86 printf("Last Modified: 03-11-2004\n");
87 printf("License: GPL\n");
88 printf("\n");
89 printf("Usage: %s (-s | -h) [-l label] [-w threshold] [-c threshold] [-d val1,val2,...,valn]\n",argv[0]);
90 printf("\n");
91 printf("Options:\n");
92 printf(" -s, --service = Check service cluster status\n");
93 printf(" -h, --host = Check host cluster status\n");
94 printf(" -l, --label = Optional prepended text output (i.e. \"Host cluster\")\n");
95 printf(" -w, --warning = Specifies the number of hosts or services in cluster that must be in\n");
96 printf(" a non-OK state in order to return a WARNING status level\n");
97 printf(" -c, --critical = Specifies the number of hosts or services in cluster that must be in\n");
98 printf(" a non-OK state in order to return a CRITICAL status level\n");
99 printf(" -d, --data = The status codes of the hosts or services in the cluster, separated\n");
100 printf(" by commas\n");
101 printf("\n");
102
103 return STATE_UNKNOWN;
104 }
105
106 /* check the data values */
107 for(ptr=strtok(data_vals,",");ptr!=NULL;ptr=strtok(NULL,",")){
108
109 data_val=atoi(ptr);
110
111 if(check_type==CHECK_SERVICES){
112 switch(data_val){
113 case 0:
114 total_services_ok++;
115 break;
116 case 1:
117 total_services_warning++;
118 break;
119 case 2:
120 total_services_critical++;
121 break;
122 case 3:
123 total_services_unknown++;
124 break;
125 default:
126 break;
127 }
128 }
129 else{
130 switch(data_val){
131 case 0:
132 total_hosts_up++;
133 break;
134 case 1:
135 total_hosts_down++;
136 break;
137 case 2:
138 total_hosts_unreachable++;
139 break;
140 default:
141 break;
142 }
143 }
144 }
145
146
147 /* return the status of the cluster */
148 if(check_type==CHECK_SERVICES){
149 if((total_services_warning+total_services_unknown+total_services_critical) >= critical_threshold)
150 return_code=STATE_CRITICAL;
151 else if((total_services_warning+total_services_unknown+total_services_critical) >= warning_threshold)
152 return_code=STATE_WARNING;
153 else
154 return_code=STATE_OK;
155 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);
156 }
157 else{
158 if((total_hosts_down+total_hosts_unreachable) >= critical_threshold)
159 return_code=STATE_CRITICAL;
160 else if((total_hosts_down+total_hosts_unreachable) >= warning_threshold)
161 return_code=STATE_WARNING;
162 else
163 return_code=STATE_OK;
164 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);
165 }
166
167 return return_code;
168 }
169
170
171
172int process_arguments(int argc, char **argv){
173 int c;
174 int option=0;
175 static struct option longopts[]={
176 {"data", required_argument,0,'d'},
177 {"warning", required_argument,0,'w'},
178 {"critical", required_argument,0,'c'},
179 {"label", required_argument,0,'l'},
180 {"host", no_argument, 0,'h'},
181 {"service", no_argument, 0,'s'},
182 {0,0,0,0}
183 };
184
185 /* no options were supplied */
186 if(argc<2)
187 return ERROR;
188
189 while(1){
190
191 c=getopt_long(argc,argv,"hsw:c:d:l:",longopts,&option);
192
193 if(c==-1 || c==EOF || c==1)
194 break;
195
196 switch(c){
197
198 case 'h': /* host cluster */
199 check_type=CHECK_HOSTS;
200 break;
201
202 case 's': /* service cluster */
203 check_type=CHECK_SERVICES;
204 break;
205
206 case 'w': /* warning threshold */
207 warning_threshold=atoi(optarg);
208 break;
209
210 case 'c': /* warning threshold */
211 critical_threshold=atoi(optarg);
212 break;
213
214 case 'd': /* data values */
215 data_vals=(char *)strdup(optarg);
216 break;
217
218 case 'l': /* text label */
219 label=(char *)strdup(optarg);
220 break;
221
222 default:
223 return ERROR;
224 break;
225 }
226 }
227
228 if(data_vals==NULL)
229 return ERROR;
230
231 return OK;
232 }
diff --git a/contrib/check_compaq_insight.pl b/contrib/check_compaq_insight.pl
deleted file mode 100644
index dfb0440..0000000
--- a/contrib/check_compaq_insight.pl
+++ /dev/null
@@ -1,296 +0,0 @@
1From mm@elabnet.de Mon Nov 18 09:59:04 2002
2Date: Mon, 18 Nov 2002 12:19:04 +0100
3From: Michael Markstaller <mm@elabnet.de>
4To: nagiosplug-devel@lists.sourceforge.net
5Subject: [Nagiosplug-devel] Submission: check_insight / checking Compaq
6 Insight Agent status
7
8Hi,
9
10I've been looking to check the status/health of Compaq Insight Agents on
11servers and found a spong plugin
12(http://spong.sourceforge.net/downloads/plugins/spong-network/check_insi
13ght) which I've slightly changed to work with Nagios.
14I have pretty no idea of perl at all, just wanted to make it work for
15me, so please don't shoot me for this copy-paste-code. I've tested some
16basic things, it seems to work at least to report a warning if smthg is
17degraded and OK of xcourse ;)
18I'm also quite unsure if this is the right way to submit, so I'll just
19try ;)
20There're some "unknown" components on all servers I've checked so far,
21if anybody has a documentation of what's exactly returned when getting
22the OID 1.3.6.1.4.1.232.11.2.10.1.0 (CPQHOST_MIB isn't very descriptive)
23I'd be happy to fix this.
24
25--- cut ---
26#!/usr/bin/perl
27#
28# (c)2002 Michael Markstaller, Elaborated Networks GmbH
29# send bug reports to <mm@elabnet.de>
30#
31# This program is free software; you can redistribute it and/or
32# modify it under the terms of the GNU General Public License
33# as published by the Free Software Foundation; either version 2
34# of the License, or (at your option) any later version.
35#
36# This program is distributed in the hope that it will be useful,
37# but WITHOUT ANY WARRANTY; without even the implied warranty
38# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# GNU General Public License for more details.
40#
41# you should have received a copy of the GNU General Public License
42# along with this program (or with Nagios); if not, write to the
43# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
44# Boston, MA 02111-1307, USA
45#
46#
47# Check Comapq Insight Management Agents Systems Status by SNMP
48# based on the spong-plugin check_insight from:
49#
50http://spong.sourceforge.net/downloads/plugins/spong-network/check_insig
51ht
52#
53# Usage:
54# check_insight -H <host> -C community
55#
56
57use Net::SNMP;
58use Getopt::Long;
59Getopt::Long::Configure('bundling');
60
61$version=0.01;
62
63my %ERRORS = ('UNKNOWN' , '-1',
64 'OK' , '0',
65 'WARNING', '1',
66 'CRITICAL', '2');
67
68
69#
70# some default values
71#
72$TIMEOUT=15;
73
74#
75# get command line options the regular way
76#
77GetOptions
78 ("V" => \$opt_V, "version" => \$opt_V,
79 "h" => \$opt_h, "help" => \$opt_h,
80 "v" => \$verbose, "verbose" => \$verbose,
81 "H=s" => \$opt_H, "hostname=s" => \$opt_H,
82 "C=s" => \$opt_C, "community=s" => \$opt_C);
83
84#
85# handle the verbose stuff first
86#
87if ($opt_V) {
88 print "\n";
89 print "check_insight nagios plugin version $version\n";
90 print "\n";
91 print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You
92may redistribute\n";
93 print "copies of the plugins under the terms of the GNU General
94Public License.\n";
95 print "For more information about these matters, see the file
96named COPYING.\n";
97 print "\n";
98 print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n";
99 print "\n";
100 print "\n";
101 exit $ERRORS{'UNKNOWN'};
102}
103
104if ($opt_h) {
105 print_help();
106 exit $ERRORS{'UNKNOWN'};
107}
108
109#
110# now get options the weired way and set the defaults
111# if nothing else is provided
112#
113$opt_H = shift unless ($opt_H);
114print_usage() unless ($opt_H);
115
116#
117# dont let us wait forever...
118#
119$SIG{'ALRM'} = sub {
120 print ("ERROR: No response from server (alarm)\n");
121 exit $ERRORS{"UNKNOWN"};
122};
123alarm($TIMEOUT);
124
125
126#
127# now we set things up for the real work
128# and fire up the request
129#
130
131########################################################################
132########
133my ($host) = ($opt_H);
134my ($color, $summary, $message ) = ( "green", "", "" );
135($opt_C) || ($opt_C = shift) || ($opt_C = "public");
136my ($community) = $opt_C;
137
138# We use some look up tables for checking some config options.
139my (@State) = ("Not Available", "Other", "OK", "Degraded", "Failed");
140
141my (@MIBName) = ("", "Std", "Unknown", "Array",
142 "Netware", "SCSI", "Health","Unknown",
143 "Store", "SM2", "Thresh", "OS", "UPS",
144 "Unknown", "IDE", "Clusters", "Fibre",
145 "MIB", "NIC");
146
147# These are the positions within the table to actually look at.
148my (@MIBs) = (1, 2, 3, 5, 6, 10, 11, 14, 18);
149
150my ($oid) = "1.3.6.1.4.1.232.11.2.10.1.0"; # SysArray
151
152# Open the connection.
153my ($session, $error) = Net::SNMP->session(Hostname => $host,
154 Community => $community);
155
156# If we can't open a connection, just return red straight away.
157if (! defined $session) {
158 print ("ERROR: Unable to contact server '$opt_H'\n");
159 exit $ERRORS{"UNKNOWN"};
160}
161
162
163$session->translate;
164my ($response) = $session->get_request($oid);
165
166 if (!defined $response) {
167 # If there's no response, something screwy is going on, give up.
168 $summary = $session->error;
169 print ("ERROR: $summary\n");
170 exit $ERRORS{"UNKNOWN"};
171 $session->close;
172 } else {
173 $session->close;
174
175 # I'm not convinced that this is the easiest way to go about this,
176this is
177 # from some code which I've inherited and I've modified for use in
178here.
179 # Hi George!
180 %h = %$response;
181 my ($d) = $h{$oid};
182
183 my (@list) = ();
184
185 # Gobble the first two char's.
186 $d = substr $d,2;
187
188 while (length($d) > 0) {
189 my ($v) = substr($d,0,2);
190 $v = hex($v);
191 $d = substr $d,2;
192 push @list, $v;
193 }
194
195 # Value in $MIBs[1] is the overall status of the machine...
196 my ($cond) = $MIBs[1];
197 $message .= "Status: $State[$cond] ";
198
199 foreach my $v (@MIBs) {
200 $cond = $list[($v*4)+1]; # A little bit of magic.
201
202 # We only bother printing the status out if it's actually
203available,
204 # as if it's N/A or Unknown then it's probably because the machine
205 # isn't available.
206 $message .= "$MIBName[$v]: $State[$cond] " if $cond > 1;
207 next if $cond < 2;
208
209 # What follows is some trickery to try and not to override a
210previous
211 # message at the same or lower color.
212 if ($cond == 4) {
213 if ($color ne 'red') {
214 $color = 'red';
215 $summary = "$MIBName[$v] is failed";
216 }
217 } elsif ($cond == 3) {
218 if ($color ne 'red') {
219 $color = 'yellow';
220 $summary = "$MIBName[$v] is degraded" if $summary eq "";
221 }
222 } elsif ($cond < 2) {
223 if ($color eq 'green') {
224 $color = 'yellow';
225 $summary = "$MIBName[$v] is unknown ($cond)" if $summary eq
226"";
227 }
228 }
229 }
230 }
231
232 $summary = "Ok" if $summary eq "";
233
234# return ($color, $summary, $message);
235
236if ($color eq 'red') {
237 print ("red Output: $message\n");
238 exit $ERRORS{"CRITICAL"};
239 } elsif ($color eq 'yellow') {
240 print ("$summary $message\n");
241 exit $ERRORS{"WARNING"};
242 } elsif ($color eq 'green') {
243 print ("$message\n");
244 exit $ERRORS{"OK"};
245}
246
247
248sub print_usage () {
249 print "Usage: $0 -H <host> -C <community> \n"; }
250
251sub print_help () {
252 print "\n";
253 print "\n";
254 print "check_insight nagios plugin version $version\n";
255 print "\n";
256 print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You
257may redistribute\n";
258 print "copies of the plugins under the terms of the GNU General
259Public License.\n";
260 print "For more information about these matters, see the file
261named COPYING.\n";
262 print "\n";
263 print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n";
264 print "\n";
265 print "\n";
266 print "This plugin checks the Compaq Insight Management agents
267system status via SNMP on the specified host.\n";
268 print "\n";
269 print "\n";
270 print_usage();
271 print "\n";
272 print "Options:\n";
273 print " -H, --hostname=ADDRESS\n";
274 print " host name argument for server.\n";
275 print " -C, --community=STRING\n";
276 print " SNMP Read-community string.\n";
277 print " -h, --help\n";
278 print " print detailed help screen.\n";
279 print " -V, --version\n";
280 print " print version information.\n";
281 print "\n";
282 print "\n";
283}
284--- cut ---
285
286Michael
287
288
289-------------------------------------------------------
290This sf.net email is sponsored by: To learn the basics of securing
291your web site with SSL, click here to get a FREE TRIAL of a Thawte
292Server Certificate: http://www.gothawte.com/rd524.html
293_______________________________________________
294Nagiosplug-devel mailing list
295Nagiosplug-devel@lists.sourceforge.net
296https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel
diff --git a/contrib/check_cpqarray.c b/contrib/check_cpqarray.c
deleted file mode 100644
index badffeb..0000000
--- a/contrib/check_cpqarray.c
+++ /dev/null
@@ -1,430 +0,0 @@
1/*
2 check_cpqarray, an extension for Netsaint / Nagios to check the
3 status of a Compaq SmartArray controller from the commandline.
4 Copyright (C) 2003 Guenther Mair
5
6 based on the work and using main parts of
7
8 CpqArray Deamon, a program to monitor and remotely configure a
9 SmartArray controller.
10 Copyright (C) 1999 Hugo Trippaers
11
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26
27#include <unistd.h>
28#include <sys/ioctl.h>
29#include <sys/utsname.h>
30#include <stdio.h>
31#include <fcntl.h>
32#include <string.h>
33#include <errno.h>
34
35#include "/usr/src/linux/drivers/block/ida_ioctl.h"
36#include "/usr/src/linux/drivers/block/ida_cmd.h"
37#include "/usr/src/linux/drivers/block/cpqarray.h"
38
39
40const char *controllers[] =
41{
42 "/dev/ida/c0d0",
43 "/dev/ida/c1d0",
44 "/dev/ida/c2d0",
45 "/dev/ida/c3d0",
46 "/dev/ida/c4d0",
47 "/dev/ida/c5d0",
48 "/dev/ida/c6d0",
49 "/dev/ida/c7d0"
50};
51
52const char *statusstr[] = {
53 "Logical drive /dev/ida/c%dd%d: OK\n",
54 "Logical drive /dev/ida/c%dd%d: FAILED\n",
55 "Logical drive /dev/ida/c%dd%d: not configured.\n",
56 "Logical drive /dev/ida/c%dd%d: using interim recovery mode, %3.2f%% done.\n",
57 "Logical drive /dev/ida/c%dd%d: ready for recovery operation.\n",
58 "Logical drive /dev/ida/c%dd%d: is currently recovering, %3.2f%% done.\n",
59 "Wrong physical drive was replaced.\n",
60 "A physical drive is not properly connected.\n",
61 "Hardware is overheating.\n",
62 "Hardware has overheated.\n",
63 "Logical drive /dev/ida/c%dd%d: currently expanding, %3.2f%% done.\n",
64 "Logical drive /dev/ida/c%dd%d: not yet available.\n",
65 "Logical drive /dev/ida/c%dd%d: queued for expansion.\n",
66};
67
68extern char *optarg;
69extern int optind, opterr, optopt;
70
71int ctrls_found_num;
72int exit_code = 0;
73struct controller ctrls_found[8];
74
75#define DEBUG(x) fprintf(stderr, x)
76
77struct opts
78{
79 char debug;
80};
81
82struct slog_disk
83{
84 int status;
85 float pvalue;
86};
87
88struct controller
89{
90 char ctrl_devicename[20];
91 int num_logd_found;
92 struct slog_disk log_disk[16];
93};
94
95
96
97int status_check (struct opts opts)
98{
99 int devicefd;
100 int ctrl_cntr;
101 int logd_cntr;
102 ida_ioctl_t io, io2;
103 int status, nr_blks, blks_tr;
104 float pvalue;
105 int counter;
106
107 for ( ctrl_cntr=0;
108 ctrl_cntr < ctrls_found_num;
109 ctrl_cntr++) {
110
111 devicefd = open (controllers[ctrl_cntr], O_RDONLY);
112
113 for ( logd_cntr=0;
114 logd_cntr < ctrls_found[ctrl_cntr].num_logd_found;
115 logd_cntr++) {
116
117 memset (&io, 0, sizeof (io));
118
119 io.cmd = SENSE_LOG_DRV_STAT;
120 io.unit = logd_cntr | UNITVALID;
121
122 if (ioctl (devicefd, IDAPASSTHRU, &io) < 0)
123 {
124 perror ("SENSE_LOG_DRV_STAT ioctl");
125 return 0;
126 }
127
128 status=io.c.sense_log_drv_stat.status;
129
130 if ((status == 3) || (status == 5) || (status == 7)) {
131 /* is a progress indicator required?
132 */
133 memset (&io2, 0, sizeof (io));
134
135 io2.cmd = ID_LOG_DRV;
136 io2.unit = logd_cntr | UNITVALID;
137
138 if (ioctl (devicefd, IDAPASSTHRU, &io2) < 0)
139 {
140 perror ("ID_LOG_DRV ioctl");
141 /* return 0; no return this isn't fatal for now */
142 }
143 else
144 {
145 nr_blks = io2.c.id_log_drv.nr_blks;
146 blks_tr = io.c.sense_log_drv_stat.blks_to_recover;
147
148 pvalue = ((float)(nr_blks - blks_tr)/(float)nr_blks) * 100;
149 }
150 }
151 else {
152 pvalue = 0.0;
153 }
154
155 if (opts.debug) {
156 fprintf(stdout, "DEBUG: Status of controller %d unit %d is %d\n",
157 ctrl_cntr, logd_cntr, status);
158 fprintf(stdout, "DEBUG: ");
159 fprintf(stdout, statusstr[status],
160 ctrl_cntr, logd_cntr, pvalue);
161 fprintf(stdout, "\n");
162 }
163
164 printf(statusstr[status], ctrl_cntr, logd_cntr, pvalue);
165
166 switch(status)
167 {
168 case 1:
169 case 2:
170 case 6:
171 case 7:
172 case 9:
173 /* CRITICAL */
174 exit_code = 2;
175 break;
176 case 3:
177 case 4:
178 case 5:
179 case 8:
180 case 10:
181 case 11:
182 case 12:
183 /* WARNING (only if not yet at CRITICAL LEVEL) */
184 if (exit_code < 2) exit_code = 1;
185 break;
186 case 0:
187 default:
188 /* do nothing */
189 break;
190 }
191
192 ctrls_found[ctrl_cntr].log_disk[logd_cntr].pvalue = pvalue;
193 ctrls_found[ctrl_cntr].log_disk[logd_cntr].status = status;
194 }
195 close (devicefd);
196 }
197
198 return 1;
199}
200
201int discover_controllers (struct opts opts)
202{
203 int cntr;
204 int foundone = 0;
205
206 for (cntr = 0; cntr < 8; cntr++)
207 {
208 /* does this device exist ? */
209 if ((access (controllers[cntr], R_OK | F_OK)) == 0)
210 {
211 /* it does :) */
212 if (interrogate_controller (opts, cntr))
213 {
214 foundone = 1;
215 if (opts.debug)
216 fprintf (stderr, "DEBUG: %s is a existing controller\n",
217 controllers[cntr]);
218 }
219 }
220 else if (opts.debug)
221 {
222 fprintf (stderr, "DEBUG: Device %s could not be opened\n", controllers[cntr]);
223 perror ("DEBUG: reason");
224 }
225 }
226 return foundone;
227}
228
229void boardid2str (unsigned long board_id, char *name)
230{
231 switch (board_id)
232 {
233 case 0x0040110E: /* IDA */
234 strcpy (name, "Compaq IDA");
235 break;
236 case 0x0140110E: /* IDA-2 */
237 strcpy (name, "Compaq IDA-2");
238 break;
239 case 0x1040110E: /* IAES */
240 strcpy (name, "Compaq IAES");
241 break;
242 case 0x2040110E: /* SMART */
243 strcpy (name, "Compaq SMART");
244 break;
245 case 0x3040110E: /* SMART-2/E */
246 strcpy (name, "Compaq SMART-2/E");
247 break;
248 case 0x40300E11: /* SMART-2/P or SMART-2DH */
249 strcpy (name, "Compaq SMART-2/P (2DH)");
250 break;
251 case 0x40310E11: /* SMART-2SL */
252 strcpy (name, "Compaq SMART-2SL");
253 break;
254 case 0x40320E11: /* SMART-3200 */
255 strcpy (name, "Compaq SMART-3200");
256 break;
257 case 0x40330E11: /* SMART-3100ES */
258 strcpy (name, "Compaq SMART-3100ES");
259 break;
260 case 0x40340E11: /* SMART-221 */
261 strcpy (name, "Compaq SMART-221");
262 break;
263 case 0x40400E11: /* Integrated Array */
264 strcpy (name, "Compaq Integrated Array");
265 break;
266 case 0x40500E11: /* Smart Array 4200 */
267 strcpy (name, "Compaq Smart Array 4200");
268 break;
269 case 0x40510E11: /* Smart Array 4250ES */
270 strcpy (name, "Compaq Smart Array 4250ES");
271 break;
272 case 0x40580E11: /* Smart Array 431 */
273 strcpy (name, "Compaq Smart Array 431");
274 break;
275 default:
276 /*
277 * Well, its a SMART-2 or better, don't know which
278 * kind.
279 */
280 strcpy (name, "Unknown Controller Type");
281 }
282}
283
284int interrogate_controller (struct opts opts, int contrnum)
285{
286 int devicefd;
287 ida_ioctl_t io;
288 char buffer[30];
289 int foundone = 0;
290 int cntr;
291
292 devicefd = open (controllers[contrnum], O_RDONLY);
293 /* no checks, did that before */
294
295 /* clear io */
296 memset (&io, 0, sizeof (io));
297
298 io.cmd = ID_CTLR;
299
300 if (ioctl (devicefd, IDAPASSTHRU, &io) < 0)
301 {
302 if (opts.debug) perror ("DEBUG: ioctl");
303 return 0;
304 }
305
306 boardid2str (io.c.id_ctlr.board_id, buffer);
307
308 strncpy (ctrls_found[ctrls_found_num].ctrl_devicename,
309 buffer, 20);
310
311 ctrls_found[ctrls_found_num].num_logd_found = 0;
312
313 for (cntr = 0; cntr < io.c.id_ctlr.nr_drvs; cntr++)
314 {
315 if (interrogate_logical (opts, devicefd, cntr))
316 {
317 /* logical drive found, this could be used later one */
318 foundone = 1;
319 }
320 }
321
322 switch (ctrls_found[ctrls_found_num].num_logd_found)
323 {
324 case 0:
325 printf("Found a %s with no logical drives.\n", buffer);
326 break;
327 case 1:
328 printf("Found a %s with one Logical drive.\n", buffer,
329 ctrls_found[ctrls_found_num].num_logd_found);
330 break;
331 default:
332 printf("Found a %s with %d Logical drives.\n", buffer,
333 ctrls_found[ctrls_found_num].num_logd_found);
334 break;
335 }
336
337 ctrls_found_num++;
338
339 close (devicefd);
340 return 1;
341}
342
343int interrogate_logical (struct opts opts, int devicefd, int unit_nr)
344{
345 ida_ioctl_t io;
346 ida_ioctl_t io2;
347 int nr_blks, blks_tr;
348
349 if (opts.debug) printf ("DEBUG: interrogating unit %d\n", unit_nr);
350
351 memset (&io, 0, sizeof (io));
352
353 io.cmd = ID_LOG_DRV;
354 io.unit = unit_nr | UNITVALID;
355
356 if (ioctl (devicefd, IDAPASSTHRU, &io) < 0)
357 {
358 perror ("FATAL: ID_LOG_DRV ioctl");
359 return 0;
360 }
361
362 memset (&io2, 0, sizeof (io2));
363
364 io2.cmd = SENSE_LOG_DRV_STAT;
365 io2.unit = unit_nr | UNITVALID;
366
367 if (ioctl (devicefd, IDAPASSTHRU, &io2) < 0)
368 {
369 perror ("FATAL: SENSE_LOG_DRV_STAT ioctl");
370 return 0;
371 }
372
373 ctrls_found[ctrls_found_num].num_logd_found++;
374 /* ctrls_found[ctrls_found_num].log_disk[unit_nr].status =
375 * io2.c.sense_log_drv_stat.status;
376
377 * nr_blks = io2.c.id_log_drv.nr_blks;
378 * blks_tr = io.c.sense_log_drv_stat.blks_to_recover;
379 * ctrls_found[ctrls_found_num].log_disk[unit_nr].pvalue =
380 * ((float)(nr_blks - blks_tr)/(float)nr_blks) * 100;
381 */
382 ctrls_found[ctrls_found_num].log_disk[unit_nr].status = 0;
383 ctrls_found[ctrls_found_num].log_disk[unit_nr].pvalue = 0;
384
385 return 1;
386}
387
388
389void print_usage()
390{
391 printf("cpqarrayd [options]\n");
392 printf(" -h prints this text\n");
393 printf(" -d enables debugging\n");
394}
395
396
397int main(int argc, char *argv[])
398{
399 char option;
400 struct opts opts; /* commandline options */
401
402 memset(&opts, 0, sizeof(struct opts));
403
404 /* check options */
405 while ((option = getopt (argc, argv, "dh:")) != EOF)
406 {
407 switch (option)
408 {
409 case 'd':
410 opts.debug = 1;
411 break;
412 case '?':
413 case 'h':
414 default:
415 print_usage();
416 exit(0);
417 break;
418 }
419 }
420
421 /* Check for existance of array controllers */
422 if (!discover_controllers(opts)) {
423 printf("No array controller found!\n\n");
424 exit(1);
425 }
426
427 status_check(opts);
428
429 return exit_code;
430}
diff --git a/contrib/check_digitemp.pl b/contrib/check_digitemp.pl
deleted file mode 100755
index d2b40a1..0000000
--- a/contrib/check_digitemp.pl
+++ /dev/null
@@ -1,252 +0,0 @@
1#!/usr/bin/perl -w
2
3# check_digitemp.pl Copyright (C) 2002 by Brian C. Lane <bcl@brianlane.com>
4#
5# This is a NetSaint plugin script to check the temperature on a local
6# machine. Remote usage may be possible with SSH
7#
8# Permission is hereby granted, free of charge, to any person obtaining a copy
9# of this software and associated documentation files (the "Software"), to
10# deal in the Software without restriction, including without limitation the
11# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12# sell copies of the Software, and to permit persons to whom the Software is
13# furnished to do so, subject to the following conditions:
14#
15# The above copyright notice and this permission notice shall be included in
16# all copies or substantial portions of the Software.
17#
18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24# IN THE SOFTWARE.
25#
26# ===========================================================================
27# Howto Install in NetSaint (tested with v0.0.7)
28#
29# 1. Copy this script to /usr/local/netsaint/libexec/ or wherever you have
30# placed your NetSaint plugins
31#
32# 2. Create a digitemp config file in /usr/local/netsaint/etc/
33# eg. digitemp -i -s/dev/ttyS0 -c /usr/local/netsaint/etc/digitemp.conf
34#
35# 3. Make sure that the webserver user has permission to access the serial
36# port being used.
37#
38# 4. Add a command to /usr/local/netsaint/etc/commands.cfg like this:
39# command[check-temp]=$USER1$/check_digitemp.pl -w $ARG1$ -c $ARG2$ \
40# -t $ARG3$ -f $ARG4$
41# (fold into one line)
42#
43# 5. Tell NetSaint to monitor the temperature by adding a service line like
44# this to your hosts.cfg file:
45# service[kermit]=Temperature;0;24x7;3;5;1;home-admins;120;24x7;1;1;1;; \
46# check-temp!65!75!1!/usr/local/netsaint/etc/digitemp.conf
47# (fold into one line)
48# 65 is the warning temperature
49# 75 is the critical temperature
50# 1 is the sensor # (as reported by digitemp -a) to monitor
51# digitemp.conf is the path to the config file
52#
53# 6. If you use Centigrade instead of Fahrenheit, change the commands.cfg
54# line to include the -C argument. You can then pass temperature limits in
55# Centigrade in the service line.
56#
57# ===========================================================================
58# Howto Install in Nagios (tested with v1.0b4)
59#
60# 1. Copy this script to /usr/local/nagios/libexec/ or wherever you have
61# placed your Nagios plugins
62#
63# 2. Create a digitemp config file in /usr/local/nagios/etc/
64# eg. digitemp -i -s/dev/ttyS0 -c /usr/local/nagios/etc/digitemp.conf
65#
66# 3. Make sure that the webserver user has permission to access the serial
67# port being used.
68#
69# 4. Add a command to /usr/local/nagios/etc/checkcommands.cfg like this:
70#
71# #DigiTemp temperature check command
72# define command{
73# command_name check_temperature
74# command_line $USER1$/check_digitemp.pl -w $ARG1$ -c $ARG2$ \
75# -t $ARG3$ -f $ARG4$
76# (fold above into one line)
77# }
78#
79# 5. Tell NetSaint to monitor the temperature by adding a service line like
80# this to your service.cfg file:
81#
82# #DigiTemp Temperature check Service definition
83# define service{
84# use generic-service
85# host_name kermit
86# service_description Temperature
87# is_volatile 0
88# check_period 24x7
89# max_check_attempts 3
90# normal_check_interval 5
91# retry_check_interval 2
92# contact_groups home-admins
93# notification_interval 240
94# notification_period 24x7
95# notification_options w,u,c,r
96# check_command check_temperature!65!75!1! \
97# /usr/local/nagios/etc/digitemp.conf
98# (fold into one line)
99# }
100#
101# 65 is the warning temperature
102# 75 is the critical temperature
103# 1 is the sensor # (as reported by digitemp -a) to monitor
104# digitemp.conf is the path to the config file
105#
106# 6. If you use Centigrade instead of Fahrenheit, change the checkcommands.cfg
107# line to include the -C argument. You can then pass temperature limits in
108# Centigrade in the service line.
109#
110# ===========================================================================
111
112# Modules to use
113use strict;
114use Getopt::Std;
115
116# Define all our variable usage
117use vars qw($opt_c $opt_f $opt_t $opt_w $opt_F $opt_C
118 $temperature $conf_file $sensor $temp_fmt
119 $crit_level $warn_level $null
120 %exit_codes
121 $percent $fmt_pct
122 $verb_err $command_line);
123
124
125# Predefined exit codes for NetSaint
126%exit_codes = ('UNKNOWN' ,-1,
127 'OK' , 0,
128 'WARNING' , 1,
129 'CRITICAL', 2,);
130
131# Default to Fahrenheit input and result (use -C to change this)
132$temp_fmt = 3;
133
134
135# Get the options
136if ($#ARGV le 0)
137{
138 &usage;
139} else {
140 getopts('f:t:FCc:w:');
141}
142
143# Shortcircuit the switches
144if (!$opt_w or $opt_w == 0 or !$opt_c or $opt_c == 0)
145{
146 print "*** You must define WARN and CRITICAL levels!";
147 &usage;
148}
149
150# Check if levels are sane
151if ($opt_w >= $opt_c)
152{
153 print "*** WARN level must not be greater than CRITICAL when checking temperature!";
154 &usage;
155}
156
157
158$warn_level = $opt_w;
159$crit_level = $opt_c;
160
161# Default sensor to read is #0
162if(!$opt_t)
163{
164 $sensor = 0;
165} else {
166 $sensor = $opt_t;
167}
168
169# Default config file is /etc/digitemp.conf
170if(!$opt_f)
171{
172 $conf_file = "/etc/digitemp.conf";
173} else {
174 $conf_file = $opt_f;
175}
176
177# Check for config file
178if( !-f $conf_file ) {
179 print "*** You must have a digitemp.conf file\n";
180 &usage;
181}
182
183
184if($opt_C)
185{
186 $temp_fmt = 2;
187}
188
189# Read the output from digitemp
190# Output in form 0\troom\tattic\tdrink
191open( DIGITEMP, "/usr/local/bin/digitemp -c $conf_file -t $sensor -q -o $temp_fmt |" );
192
193# Process the output from the command
194while( <DIGITEMP> )
195{
196# print "$_\n";
197 chomp;
198
199 if( $_ =~ /^nanosleep/i )
200 {
201 print "Error reading sensor #$sensor\n";
202 close(DIGITEMP);
203 exit $exit_codes{'UNKNOWN'};
204 } else {
205 # Check for an error from digitemp, and report it instead
206 if( $_ =~ /^Error.*/i ) {
207 print $_;
208 close(DIGITEMP);
209 exit $exit_codes{'UNKNOWN'};
210 } else {
211 ($null,$temperature) = split(/\t/);
212 }
213 }
214}
215close( DIGITEMP );
216
217if( $temperature and $temperature >= $crit_level )
218{
219 print "Temperature CRITICAL - Sensor #$sensor = $temperature ";
220 if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; }
221 exit $exit_codes{'CRITICAL'};
222} elsif ($temperature and $temperature >= $warn_level ) {
223 print "Temperature WARNING - Sensor #$sensor = $temperature ";
224 if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; }
225 exit $exit_codes{'WARNING'};
226} elsif( $temperature ) {
227 print "Temperature OK - Sensor #$sensor = $temperature ";
228 if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; }
229 exit $exit_codes{'OK'};
230} else {
231 print "Error parsing result for sensor #$sensor\n";
232 exit $exit_codes{'UNKNOWN'};
233}
234
235# Show usage
236sub usage()
237{
238 print "\ncheck_digitemp.pl v1.0 - NetSaint Plugin\n";
239 print "Copyright 2002 by Brian C. Lane <bcl\@brianlane.com>\n";
240 print "See source for License\n";
241 print "usage:\n";
242 print " check_digitemp.pl -t <sensor> -f <config file> -w <warnlevel> -c <critlevel>\n\n";
243 print "options:\n";
244 print " -f DigiTemp Config File\n";
245 print " -t DigiTemp Sensor #\n";
246 print " -F Temperature in Fahrenheit\n";
247 print " -C Temperature in Centigrade\n";
248 print " -w temperature temperature >= to warn\n";
249 print " -c temperature temperature >= when critical\n";
250
251 exit $exit_codes{'UNKNOWN'};
252}
diff --git a/contrib/check_dlswcircuit.pl b/contrib/check_dlswcircuit.pl
deleted file mode 100755
index f6ef931..0000000
--- a/contrib/check_dlswcircuit.pl
+++ /dev/null
@@ -1,221 +0,0 @@
1#!/usr/bin/perl -w
2#
3# check_dlswcircuit.pl - nagios plugin
4#
5# Checks if a Cisco Dlsw circuit is connected.
6#
7#
8# Copyright (C) 2000 Carsten Foss & Christoph Kron
9#
10# Basically this is an adapted version of Christoph Kron's (ck@zet.net) check_ifoperstatus.pl plugin.
11# most of the thanks should go to him.
12#
13# This program is free software; you can redistribute it and/or
14# modify it under the terms of the GNU General Public License
15# as published by the Free Software Foundation; either version 2
16# of the License, or (at your option) any later version.
17#
18# This program is distributed in the hope that it will be useful,
19# but WITHOUT ANY WARRANTY; without even the implied warranty of
20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21# GNU General Public License for more details.
22#
23# You should have received a copy of the GNU General Public License
24# along with this program; if not, write to the Free Software
25# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26#
27# Arguments : -s <SourceMac> -d <DestMac> -c <READCOMMUNITY> -p <PORT> <HOSTNAME or IP-Addr>
28# -
29# 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)
30#
31# 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
32#
33# Sample host.cfg entry :
34#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
35# remember to add the service to commands.cfg , something like this:
36# command[check_dlswcircuit]=$USER1$/check_dlswcircuit.pl $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$
37#
38# Report bugs to: cfo@dmdata.dk
39#
40# 11.03.2000 Version 1.0
41
42use strict;
43
44use Net::SNMP;
45use Getopt::Long;
46&Getopt::Long::config('auto_abbrev');
47
48
49my $status;
50my $TIMEOUT = 15;
51
52my %ERRORS = ('UNKNOWN' , '-1',
53 'OK' , '0',
54 'WARNING', '1',
55 'CRITICAL', '2');
56
57my %dlswCircuitStatus = (
58 '1','disconnected',
59 '2','circuitStart',
60 '3','resolvePending',
61 '4','circuitPending',
62 '5','circuitEstablished',
63 '6','connectPending',
64 '7','contactPending',
65 '8','connected',
66 '9','disconnectPending',
67 '10','haltPending',
68 '11','haltPendingNoack',
69 '13','circuitRestart',
70 '14','restartPending');
71
72my $state = "UNKNOWN";
73my $answer = "";
74my $smac = "";
75my $dmac = "";
76my $community = "public";
77my $port = 161;
78#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
79my $enterpriseOid = "1.3.6.1.4.1";
80my $ciscoDlswCircuitOid = ".9.10.9.1.5.2.1.17.";
81my $unknownOid = "6.";
82my $smacOid = "";
83my $dmacOid = "";
84my $tmpOid = "";
85my @tmparg;
86my $snmpoid;
87my @snmpoids;
88my $hostname;
89my $session;
90my $error;
91my $response;
92my $p = "";
93my $q = "";
94
95sub usage {
96 printf "\nMissing arguments!\n";
97 printf "\n";
98 printf "Perl Check Cisco Dlsw Circuit State plugin for Nagios\n";
99 printf "checks operational status of specified DLSW Circuit\n";
100 printf "usage: \n";
101 printf "check_dlswcircuit.pl -s <SourceMac> -d <DestMac> -c <READCOMMUNITY> -p <PORT> <HOSTNAME>";
102 printf "\nCopyright (C) 2000 Carsten Foss\n";
103 printf "check_dlswcircuit.pl comes with ABSOLUTELY NO WARRANTY\n";
104 printf "This programm is licensed under the terms of the ";
105 printf "GNU General Public License\n(check source code for details)\n";
106 printf "\n\n";
107 exit $ERRORS{"UNKNOWN"};
108}
109
110# Just in case of problems, let's not hang Nagios
111$SIG{'ALRM'} = sub {
112 print ("ERROR: No snmp response from $hostname (alarm)\n");
113 exit $ERRORS{"UNKNOWN"};
114};
115alarm($TIMEOUT);
116
117
118$status = GetOptions("sourcemac=s",\$smac,"destmac=s",\$dmac,
119 "community=s",\$community,
120 "port=i",\$port);
121if ($status == 0)
122{
123 &usage;
124}
125
126#
127#Convert Source Mac & Sap
128#
129 @tmparg = split(/\./,$smac);
130 #print "-$smac-\n";
131 #print "@tmparg\n";
132 #print "$#tmparg\n";
133 if($#tmparg != 6)
134 {
135 print "SourceMac/Sap format $smac not valid\n";
136 &usage;
137 }
138 while($p = shift @tmparg)
139 {
140 $q = hex($p);
141 $smacOid = $smacOid.$q;
142 $smacOid = $smacOid.'.';
143 }
144
145 #print "@tmparg1\n";
146 #print "$smacOid\n";
147
148#
149#Convert Dest Mac & Sap
150#
151 @tmparg = split(/\./,$dmac);
152 #print "-$dmac-\n";
153 #print "@tmparg\n";
154 #print "$#tmparg\n";
155 if($#tmparg != 6)
156 {
157 print "DestMac/Sap format $dmac not valid\n";
158 &usage;
159 }
160
161 while($p = shift @tmparg)
162 {
163 $q = hex($p);
164 $dmacOid = $dmacOid.$q;
165 $dmacOid = $dmacOid.'.';
166 }
167# Remove Trailing Dot
168 $dmacOid = substr($dmacOid,0,length($dmacOid)-1);
169
170
171 #print "@tmparg1\n";
172 #print "$dmacOid\n";
173#Build the Dlsw Oic to use
174 $snmpoid = $enterpriseOid.$ciscoDlswCircuitOid.$unknownOid.$smacOid.$unknownOid.$dmacOid ;
175 #print "$snmpoid\n";
176
177 #shift;
178 $hostname = shift || &usage;
179
180 ($session, $error) = Net::SNMP->session(
181 -hostname => $hostname,
182 -community => $community,
183 -port => $port
184 );
185
186 if (!defined($session)) {
187 $state='UNKNOWN';
188 $answer=$error;
189 print ("$state: $answer");
190 exit $ERRORS{$state};
191 }
192
193 push(@snmpoids,$snmpoid);
194 #push(@snmpoids,$snmpLocIfDescr);
195
196 if (!defined($response = $session->get_request(@snmpoids))) {
197 $answer=$session->error;
198 $session->close;
199 $state = 'CRITICAL';
200 print ("$state: $answer,$community,$smac - $dmac");
201 exit $ERRORS{$state};
202 }
203
204 $answer = sprintf("dlsw circuit %s - %s at host '%s',is %s\n",
205 $smac,
206 $dmac,
207 $hostname,
208 $dlswCircuitStatus{$response->{$snmpoid}}
209 );
210
211 $session->close;
212
213 if ( $response->{$snmpoid} == 8 ) {
214 $state = 'OK';
215 }
216 else {
217 $state = 'CRITICAL';
218 }
219
220print ("$state: $answer");
221exit $ERRORS{$state};
diff --git a/contrib/check_dns_random.pl b/contrib/check_dns_random.pl
deleted file mode 100644
index 4bed412..0000000
--- a/contrib/check_dns_random.pl
+++ /dev/null
@@ -1,74 +0,0 @@
1#!/usr/bin/perl
2# ------------------------------------------------------------------------------
3# File Name: check_dns_random.pl
4# Author: Richard Mayhew - South Africa
5# Date: 2000/01/26
6# Version: 1.0
7# Description: This script will check to see if dns resolves hosts
8# randomly from a list using the check_dns plugin.
9# Email: netsaint@splash.co.za
10# ------------------------------------------------------------------------------
11# Copyright 1999 (c) Richard Mayhew
12# Credits go to Ethan Galstad for coding Nagios
13# If any changes are made to this script, please mail me a copy of the
14# changes :)
15# License GPL
16# ------------------------------------------------------------------------------
17# Date Author Reason
18# ---- ------ ------
19# 1999/09/26 RM Creation
20# ------------------------------------------------------------------------------
21
22# -----------------------------------------------------------------[ Require ]--
23require 5.004;
24
25# --------------------------------------------------------------------[ Uses ]--
26use Socket;
27use strict;
28
29# --------------------------------------------------------------[ Enviroment ]--
30$ENV{PATH} = "/bin";
31$ENV{BASH_ENV} = "";
32$|=1;
33
34my $host = shift || &usage;
35
36my $domainfile = "/usr/local/nagios/etc/domains.list";
37my $wc = `/usr/bin/wc -l $domainfile`;
38my $check = "/usr/local/nagios/libexec/check_dns";
39my $x = 0;
40my $srv_file = "";
41my $z = "";
42my $y = "";
43
44open(DOMAIN,"<$domainfile") or die "Error Opening $domainfile File!\n";
45 while (<DOMAIN>) {
46 $srv_file .= $_;
47}
48 close(DOMAIN);
49 my @data = split(/\n/,$srv_file);
50
51chomp $wc;
52$wc =~ s/ //g;
53$wc =~ s/domains//g;
54
55$x = rand $wc;
56($z,$y) = split(/\./,$x);
57
58system($check, $data[$z], $host);
59exit ($? / 256);
60
61sub usage
62{
63 print "Minimum arguments not supplied!\n";
64 print "\n";
65 print "Perl Check Random DNS plugin for Nagios\n";
66 print "Copyright (c) 2000 Richard Mayhew\n";
67 print "\n";
68 print "Usage: check_dns_random.pl <host>\n";
69 print "\n";
70 print "<host> = DNS server you would like to query.\n";
71 exit -1;
72
73}
74
diff --git a/contrib/check_email_loop.pl b/contrib/check_email_loop.pl
deleted file mode 100644
index 1b02ea3..0000000
--- a/contrib/check_email_loop.pl
+++ /dev/null
@@ -1,309 +0,0 @@
1#!/usr/bin/perl -w
2#
3# $Id: check_email_loop.pl 1290 2005-11-29 23:21:06Z harpermann $
4#
5# (c)2000 Benjamin Schmid, blueshift@gmx.net (emergency use only ;-)
6# Copyleft by GNU GPL
7#
8#
9# check_email_loop Nagios Plugin
10#
11# This script sends a mail with a specific id in the subject via
12# an given smtp-server to a given email-adress. When the script
13# is run again, it checks for this Email (with its unique id) on
14# a given pop3 account and send another mail.
15#
16#
17# Example: check_email_loop.pl -poph=mypop -popu=user -pa=password
18# -smtph=mailer -from=returnadress@yoursite.com
19# -to=remaileradress@friend.com -pendc=2 -lostc=0
20#
21# This example will send eacht time this check is executed a new
22# mail to remaileradress@friend.com using the SMTP-Host mailer.
23# Then it looks for any back-forwarded mails in the POP3 host
24# mypop. In this Configuration CRITICAL state will be reached if
25# more than 2 Mails are pending (meaning that they did not came
26# back till now) or if a mails got lost (meaning a mail, that was
27# send later came back prior to another mail).
28#
29# Michael Markstaller, mm@elabnet.de various changes/additions
30# MM 021003: fixed some unquoted strings
31# MM 021116: fixed/added pendwarn/lostwarn
32# MM 030515: added deleting of orphaned check-emails
33# changed to use "top" instead of get to minimize traffic (required changing match-string from "Subject: Email-ping [" to "Email-Ping ["
34
35use Net::POP3;
36use Net::SMTP;
37use strict;
38use Getopt::Long;
39&Getopt::Long::config('auto_abbrev');
40
41# ----------------------------------------
42
43my $TIMEOUT = 120;
44my %ERRORS = ('OK' , '0',
45 'WARNING', '1',
46 'CRITICAL', '2');
47 'UNKNOWN' , '3');
48
49my $state = "UNKNOWN";
50my ($sender,$receiver, $pophost, $popuser, $poppasswd, $smtphost,$keeporphaned);
51my ($poptimeout,$smtptimeout,$pinginterval,$maxmsg)=(60,60,5,50);
52my ($lostwarn, $lostcrit,$pendwarn, $pendcrit,$debug);
53$debug = 0;
54
55# Internal Vars
56my ($pop,$msgcount,@msglines,$statinfo,@messageids,$newestid);
57my (%other_smtp_opts);
58my ($matchcount,$statfile) = (0,"check_email_loop.stat");
59
60# Subs declaration
61sub usage;
62sub messagematchs;
63sub nsexit;
64
65# Just in case of problems, let's not hang Nagios
66$SIG{'ALRM'} = sub {
67 print ("ERROR: $0 Time-Out $TIMEOUT s \n");
68 exit $ERRORS{"UNKNOWN"};
69};
70alarm($TIMEOUT);
71
72
73# Evaluate Command Line Parameters
74my $status = GetOptions(
75 "from=s",\$sender,
76 "to=s",\$receiver,
77 "debug", \$debug,
78 "pophost=s",\$pophost,
79 "popuser=s",\$popuser,
80 "passwd=s",\$poppasswd,
81 "poptimeout=i",\$poptimeout,
82 "smtphost=s",\$smtphost,
83 "smtptimeout=i",\$smtptimeout,
84 "statfile=s",\$statfile,
85 "interval=i",\$pinginterval,
86 "lostwarn=i",\$lostwarn,
87 "lostcrit=i",\$lostcrit,
88 "pendwarn=i",\$pendwarn,
89 "pendcrit=i",\$pendcrit,
90 "maxmsg=i",\$maxmsg,
91 "keeporphaned=s",\$keeporphaned,
92 );
93usage() if ($status == 0 || ! ($pophost && $popuser && $poppasswd &&
94 $smtphost && $receiver && $sender ));
95
96# Try to read the ids of the last send emails out of statfile
97if (open STATF, "$statfile") {
98 @messageids = <STATF>;
99 chomp @messageids;
100 close STATF;
101}
102
103# Try to open statfile for writing
104if (!open STATF, ">$statfile") {
105 nsexit("Failed to open mail-ID database $statfile for writing",'CRITICAL');
106}
107
108# Ok - check if it's time to release another mail
109
110# ...
111
112# creating new serial id
113my $serial = time();
114$serial = "ID#" . $serial . "#$$";
115
116
117# sending new ping email
118%other_smtp_opts=();
119if ( $debug == 1 ) {
120 $other_smtp_opts{'Debug'} = 1;
121}
122
123my $smtp = Net::SMTP->new($smtphost,Timeout=>$smtptimeout, %other_smtp_opts)
124 || nsexit("SMTP connect timeout ($smtptimeout s)",'CRITICAL');
125($smtp->mail($sender) &&
126 $smtp->to($receiver) &&
127 $smtp->data() &&
128 $smtp->datasend("To: $receiver\nSubject: E-Mail Ping [$serial]\n\n".
129 "This is an automatically sent E-Mail.\n".
130 "It is not intended for a human reader.\n\n".
131 "Serial No: $serial\n") &&
132 $smtp->dataend() &&
133 $smtp->quit
134 ) || nsexit("Error delivering message",'CRITICAL');
135
136# no the interessting part: let's if they are receiving ;-)
137
138$pop = Net::POP3->new( $pophost,
139 Timeout=>$poptimeout)
140 || nsexit("POP3 connect timeout (>$poptimeout s, host: $pophost)",'CRITICAL');
141
142$msgcount=$pop->login($popuser,$poppasswd);
143
144$statinfo="$msgcount mails on POP3";
145
146nsexit("POP3 login failed (user:$popuser)",'CRITICAL') if (!defined($msgcount));
147
148# Check if more than maxmsg mails in pop3-box
149nsexit(">$maxmsg Mails ($msgcount Mails on POP3); Please delete !",'WARNING') if ($msgcount > $maxmsg);
150
151my ($mid, $nid);
152# Count messages, that we are looking 4:
153while ($msgcount > 0) {
154 @msglines = @{$pop->top($msgcount,1)};
155 for (my $i=0; $i < scalar @messageids; $i++) {
156 if (messagematchsid(\@msglines,$messageids[$i])) {
157 $matchcount++;
158 # newest received mail than the others, ok remeber id.
159 if (!defined $newestid) {
160 $newestid = $messageids[$i];
161 } else {
162 $messageids[$i] =~ /\#(\d+)\#/;
163 $mid = $1;
164 $newestid =~ /\#(\d+)\#/;
165 $nid = $1;
166 if ($mid > $nid) {
167 $newestid = $messageids[$i];
168 }
169 }
170 $pop->delete($msgcount); # remove E-Mail from POP3 server
171 splice @messageids, $i, 1;# remove id from List
172 last; # stop looking in list
173 }
174 }
175 # Delete orphaned Email-ping msg
176 my @msgsubject = grep /^Subject/, @msglines;
177 chomp @msgsubject;
178 # Scan Subject if email is an Email-Ping. In fact we match and delete also successfully retrieved messages here again.
179 if (!defined $keeporphaned && $msgsubject[0] =~ /E-Mail Ping \[/) {
180 $pop->delete($msgcount); # remove E-Mail from POP3 server
181 }
182
183 $msgcount--;
184}
185
186$pop->quit(); # necessary for pop3 deletion!
187
188# traverse through the message list and mark the lost mails
189# that mean mails that are older than the last received mail.
190if (defined $newestid) {
191 $newestid =~ /\#(\d+)\#/;
192 $newestid = $1;
193 for (my $i=0; $i < scalar @messageids; $i++) {
194 $messageids[$i] =~ /\#(\d+)\#/;
195 my $akid = $1;
196 if ($akid < $newestid) {
197 $messageids[$i] =~ s/^ID/LI/; # mark lost
198 }
199 }
200}
201
202# Write list to id-Database
203foreach my $id (@messageids) {
204 print STATF "$id\n";
205}
206print STATF "$serial\n"; # remember send mail of this session
207close STATF;
208
209# ok - count lost and pending mails;
210my @tmp = grep /^ID/, @messageids;
211my $pendingm = scalar @tmp;
212@tmp = grep /^LI/, @messageids;
213my $lostm = scalar @tmp;
214
215# Evaluate the Warnin/Crit-Levels
216if (defined $pendwarn && $pendingm > $pendwarn) { $state = 'WARNING'; }
217if (defined $lostwarn && $lostm > $lostwarn) { $state = 'WARNING'; }
218if (defined $pendcrit && $pendingm > $pendcrit) { $state = 'CRITICAL'; }
219if (defined $lostcrit && $lostm > $lostcrit) { $state = 'CRITICAL'; }
220
221if ((defined $pendwarn || defined $pendcrit || defined $lostwarn
222 || defined $lostcrit) && ($state eq 'UNKNOWN')) {$state='OK';}
223
224
225# Append Status info
226$statinfo = $statinfo . ", $matchcount mail(s) came back,".
227 " $pendingm pending, $lostm lost.";
228
229# Exit in a Nagios-compliant way
230nsexit($statinfo);
231
232# ----------------------------------------------------------------------
233
234sub usage {
235 print "check_email_loop 1.1 Nagios Plugin - Real check of a E-Mail system\n";
236 print "=" x 75,"\nERROR: Missing or wrong arguments!\n","=" x 75,"\n";
237 print "This script sends a mail with a specific id in the subject via an given\n";
238 print "smtp-server to a given email-adress. When the script is run again, it checks\n";
239 print "for this Email (with its unique id) on a given pop3 account and sends \n";
240 print "another mail.\n";
241 print "\nThe following options are available:\n";
242 print " -from=text email adress of send (for mail returnr on errors)\n";
243 print " -to=text email adress to which the mails should send to\n";
244 print " -pophost=text IP or name of the POP3-host to be checked\n";
245 print " -popuser=text Username of the POP3-account\n";
246 print " -passwd=text Password for the POP3-user\n";
247 print " -poptimeout=num Timeout in seconds for the POP3-server\n";
248 print " -smtphost=text IP oder name of the SMTP host\n";
249 print " -smtptimeout=num Timeout in seconds for the SMTP-server\n";
250 print " -statfile=text File to save ids of messages ($statfile)\n";
251 print " -interval=num Time (in minutes) that must pass by before sending\n";
252 print " another Ping-mail (gibe a new try);\n";
253 print " -lostwarn=num WARNING-state if more than num lost emails\n";
254 print " -lostcrit=num CRITICAL \n";
255 print " -pendwarn=num WARNING-state if more than num pending emails\n";
256 print " -pendcrit=num CRITICAL \n";
257 print " -maxmsg=num WARNING if more than num emails on POP3 (default 50)\n";
258 print " -keeporphaned Set this to NOT delete orphaned E-Mail Ping msg from POP3\n";
259 print " -debug send SMTP tranaction info to stderr\n\n";
260 print " Options may abbreviated!\n";
261 print " LOST mails are mails, being sent before the last mail arrived back.\n";
262 print " PENDING mails are those, which are not. (supposed to be on the way)\n";
263 print "\nExample: \n";
264 print " $0 -poph=host -pa=pw -popu=popts -smtph=host -from=root\@me.com\n ";
265 print " -to=remailer\@testxy.com -lostc=0 -pendc=2\n";
266 print "\nCopyleft 19.10.2000, Benjamin Schmid / 2003 Michael Markstaller, mm\@elabnet.de\n";
267 print "This script comes with ABSOLUTELY NO WARRANTY\n";
268 print "This programm is licensed under the terms of the ";
269 print "GNU General Public License\n\n";
270 exit $ERRORS{"UNKNOWN"};
271}
272
273# ---------------------------------------------------------------------
274
275sub nsexit {
276 my ($msg,$code) = @_;
277 $code=$state if (!defined $code);
278 print "$code: $msg\n" if (defined $msg);
279 exit $ERRORS{$code};
280}
281
282# ---------------------------------------------------------------------
283
284sub messagematchsid {
285 my ($mailref,$id) = (@_);
286 my (@tmp);
287 my $match = 0;
288
289 # ID
290 $id =~ s/^LI/ID/; # evtl. remove lost mail mark
291 @tmp = grep /E-Mail Ping \[/, @$mailref;
292 chomp @tmp;
293 if (($tmp[0] =~ /$id/))
294 { $match = 1; }
295
296 # Sender:
297# @tmp = grep /^From:\s+/, @$mailref;
298# if (@tmp && $sender ne "")
299# { $match = $match && ($tmp[0]=~/$sender/); }
300
301 # Receiver:
302# @tmp = grep /^To: /, @$mailref;
303# if (@tmp && $receiver ne "")
304# { $match = $match && ($tmp[0]=~/$receiver/); }
305
306 return $match;
307}
308
309# ---------------------------------------------------------------------
diff --git a/contrib/check_fan_cpq_present b/contrib/check_fan_cpq_present
deleted file mode 100644
index 0bd1390..0000000
--- a/contrib/check_fan_cpq_present
+++ /dev/null
@@ -1,133 +0,0 @@
1#!/usr/bin/perl
2#
3#
4# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical]
5#
6# NetSaint host script to get the disk usage from NT snmp
7#
8# Changes and Modifications
9# =========================
10# 3-Aug-2000 - Xavier Dusart
11# Created
12# 2003 - Rainer Duffner
13
14BEGIN {
15 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
16 $runtimedir = $1;
17 $PROGNAME = $2;
18 }
19}
20
21
22
23require 5.004;
24use POSIX;
25#use strict;
26use Getopt::Std ;
27use BER;
28require 'SNMP_Session.pm';
29use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME);
30use lib $main::runtimedir;
31use utils qw($TIMEOUT %ERRORS &print_revision &usage &support);
32use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED);
33
34delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
35
36getopts('H:p:C:f:hV') ;
37
38my $ip_address=undef ;
39
40if ($opt_h) {&help();}
41
42if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA
43-Z0-9]*)*)$/) {
44 $ip_address = $opt_H ;
45 }
46else {
47 usage();
48 print "IP-Address format wrong\n";
49 exit $ERRORS{'UNKNOWN'};
50 }
51
52#if ($opt_p =~ m/^[0-9]
53
54my $port = $opt_p;
55
56my $community = $opt_C;
57
58my $fan = $opt_f ;
59
60#my $err_counter=0 ;
61#my $err_status="";
62
63 my $fan_locale_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,3,0,$fan );
64# not used for the moment - gives no usable output
65# if reused, enter at end of list to avoid renumbering !
66 my $fan_present_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,4,0,$fan );
67 my $fan_speed_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,6,0,$fan );
68 my $fan_condition_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,9,0,$fan );
69 my $count=1 ;
70 my $label ;
71 my @r_array=();
72 my $q ;
73 my $diff ;
74 $warning=$warning/100 ;
75 $crititcal=$critical/100 ;
76
77
78# get temperature, temperature_threshold bfore shutdown
79 my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
80
81 if ($session->get_request_response ($fan_present_oid, $fan_locale_oid, $fan_speed_oid, $fan_condition_oid )) {
82 (my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
83 while ($bindings ne '') {
84 ($binding, $bindings) = &decode_sequence ($bindings) ;
85 ($oid,$value) = &decode_by_template ($binding,"%O%@");
86 $r_array[$count]=&pretty_print($value);
87 $count++;
88 }
89 } else {
90 print "No response from agent\n";
91 exit $ERRORS{'CRITICAL'};
92 }
93 $result_fan_present= $r_array[1];
94 $result_fan_locale= $r_array[2];
95 $result_fan_speed= $r_array[3];
96 $result_fan_condition=$r_array[4];
97
98
99 if ( $result_fan_present != 3 || $result_fan_speed !=2 ) {
100 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" ;
101 exit $ERRORS{'CRITICAL'} ;
102 }
103 else {
104 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" ;
105 exit $ERRORS{'OK'} ;
106 }
107
108
109sub print_usage () {
110 print "Usage: $PROGNAME -H <host> -p <port> -C <community> -f <fannumber>\n";
111 }
112
113sub print_help () {
114 print_revision($PROGNAME,'$Revision: 1113 $\n ');
115 print "Copyright (c) 2003 Rainer Duffner\n ";
116 print_usage();
117 print "\n";
118 print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
119 print "<port> = SNMP-Port (normaly 161)\n";
120 print "<community> = SNMP v1 community\n";
121 print "<fannumber> = Fannumber (1, 2, 3 etc.)\n";
122 }
123
124sub version () {
125 print_revision($PROGNAME,'$Revision: 1113 $ ');
126 exit $ERRORS{'OK'};
127}
128
129sub help () {
130 print_help();
131 exit $ERRORS{'OK'};
132}
133
diff --git a/contrib/check_fan_fsc_present b/contrib/check_fan_fsc_present
deleted file mode 100644
index 19f8e7f..0000000
--- a/contrib/check_fan_fsc_present
+++ /dev/null
@@ -1,135 +0,0 @@
1#!/usr/bin/perl
2#
3#
4# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical]
5#
6# NetSaint host script to get the disk usage from NT snmp
7#
8# Changes and Modifications
9# =========================
10# 3-Aug-2000 - Xavier Dusart
11# Created
12# 2003 - Rainer Duffner
13
14BEGIN {
15 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
16 $runtimedir = $1;
17 $PROGNAME = $2;
18 }
19}
20
21
22
23require 5.004;
24use POSIX;
25#use strict;
26use Getopt::Std ;
27use BER;
28require 'SNMP_Session.pm';
29use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME);
30use lib $main::runtimedir;
31use utils qw($TIMEOUT %ERRORS &print_revision &usage &support);
32use snmputil qw(%FSC_LOCALE %FSC_FAN_STATUS);
33
34delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
35
36getopts('H:p:C:f:hV') ;
37
38my $ip_address=undef ;
39
40if ($opt_h) {&help();}
41
42if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA
43-Z0-9]*)*)$/) {
44 $ip_address = $opt_H ;
45 }
46else {
47 usage();
48 print "IP-Address format wrong\n";
49 exit $ERRORS{'UNKNOWN'};
50 }
51
52#if ($opt_p =~ m/^[0-9]
53
54my $port = $opt_p;
55
56my $community = $opt_C;
57
58my $fan = $opt_f ;
59
60#my $err_counter=0 ;
61#my $err_status="";
62
63 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 );
64# not used for the moment - gives no usable output
65# if reused, enter at end of list to avoid renumbering !
66 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 );
67 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 );
68 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 );
69 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 );
70 my $count=1 ;
71 my $label ;
72 my @r_array=();
73 my $q ;
74 my $diff ;
75 $warning=$warning/100 ;
76 $crititcal=$critical/100 ;
77
78
79# get temperature, temperature_threshold bfore shutdown
80 my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
81
82 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 )) {
83 (my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
84 while ($bindings ne '') {
85 ($binding, $bindings) = &decode_sequence ($bindings) ;
86 ($oid,$value) = &decode_by_template ($binding,"%O%@");
87 $r_array[$count]=&pretty_print($value);
88 $count++;
89 }
90 } else {
91 print "No response from agent\n";
92 exit $ERRORS{'CRITICAL'};
93 }
94 $result_fan_locale= $r_array[1];
95 $result_fan_cur_speed= $r_array[2];
96 $result_fan_nom_max_speed= $r_array[3];
97 $result_fan_cur_max_speed= $r_array[4];
98 $result_fan_condition=$r_array[5];
99
100
101 if ( $result_fan_condition != "3" ) {
102 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" ;
103 exit $ERRORS{'CRITICAL'} ;
104 }
105 else {
106 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" ;
107 exit $ERRORS{'OK'} ;
108 }
109
110
111sub print_usage () {
112 print "Usage: $PROGNAME -H <host> -p <port> -C <community> -f <fannumber>\n";
113 }
114
115sub print_help () {
116 print_revision($PROGNAME,'$Revision: 1113 $\n ');
117 print "Copyright (c) 2003 Rainer Duffner\n ";
118 print_usage();
119 print "\n";
120 print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
121 print "<port> = SNMP-Port (normaly 161)\n";
122 print "<community> = SNMP v1 community\n";
123 print "<fannumber> = Fannumber (1, 2, 3 etc.)\n";
124 }
125
126sub version () {
127 print_revision($PROGNAME,'$Revision: 1113 $ ');
128 exit $ERRORS{'OK'};
129}
130
131sub help () {
132 print_help();
133 exit $ERRORS{'OK'};
134}
135
diff --git a/contrib/check_flexlm.pl b/contrib/check_flexlm.pl
deleted file mode 100644
index 8fa0e33..0000000
--- a/contrib/check_flexlm.pl
+++ /dev/null
@@ -1,82 +0,0 @@
1#!/usr/local/bin/perl
2#
3# usage:
4# check_flexlm.pl license_file
5#
6# Check available flexlm license managers.
7# Use lmstat to check the status of the license server
8# described by the license file given as argument.
9# Check and interpret the output of lmstat
10# and create returncodes and output.
11#
12# Contrary to the nagios concept, this script takes
13# a file, not a hostname as an argument and returns
14# the status of hosts and services described in that
15# file. Use these hosts.cfg entries as an example
16#
17#host[anchor]=any host will do;some.address.com;;check-host-alive;3;120;24x7;1;1;1;
18#service[anchor]=yodel;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yodel_lic
19#service[anchor]=yeehaw;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yeehaw_lic
20#command[check_flexlm]=/some/path/libexec/check_flexlm.pl $ARG1$
21#
22# Notes:
23# - you need the lmstat utility which comes with flexlm.
24# - set the correct path in the variable $lmstat.
25#
26# initial version: 9-10-99 Ernst-Dieter Martin edmt@infineon.com
27# current status: looks like working
28#
29# Copyright Notice: Do as you please, credit me, but don't blame me
30#
31
32# Just in case of problems, let's not hang Nagios
33$SIG{'ALRM'} = sub {
34 print "No Answer from Client\n";
35 exit 2;
36};
37alarm(20);
38
39$lmstat = "/opt/lic/sw/cadadm/default/bin/lmstat";
40
41$licfile = shift;
42
43#print "$licfile \n";
44
45open CMD,"$lmstat -c $licfile |";
46
47$serverup = 0;
48
49while ( <CMD> ) {
50 if ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*)/ ) {
51 $ls1 = $1;
52 $ls2 = $2;
53 $ls3 = $3;
54 $lf1 = $lf2 = $lf3 = 0;
55 $servers = 3;
56 } elsif ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*)/ ) {
57 $ls1 = $1;
58 $ls2 = $ls3 = "";
59 $lf1 = $lf2 = $lf3 = 0;
60 $servers = 1;
61 } elsif ( / *$ls1: license server UP/ ) {
62 print "$ls1 UP, ";
63 $lf1 = 1
64 } elsif ( / *$ls2: license server UP/ ) {
65 print "$ls2 UP, ";
66 $lf2 = 1
67 } elsif ( / *$ls3: license server UP/ ) {
68 print "$ls3 UP, ";
69 $lf3 = 1
70 } elsif ( / *([^:]*: UP .*)/ ) {
71 print " license server for $1\n";
72 $serverup = 1;
73 }
74}
75if ( $serverup == 0 ) {
76 print " license server not running\n";
77 exit 2;
78}
79
80exit 0 if ( $servers == $lf1 + $lf2 + $lf3 );
81exit 1 if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 );
82exit 2;
diff --git a/contrib/check_frontpage b/contrib/check_frontpage
deleted file mode 100644
index 21c5267..0000000
--- a/contrib/check_frontpage
+++ /dev/null
@@ -1,151 +0,0 @@
1#! /usr/bin/perl -w
2#
3# $Id: check_frontpage 1112 2005-01-27 04:46:08Z stanleyhopcroft $
4#
5# Check that FrontPage extensions appear to be working on a specified host.
6# Currently only checks that the hit counter is not returning an error.
7#
8# Probably not a good idea to use this on a host that someone's counting
9# the hits on, so create a separate vhost for frontpage extensions testing,
10# or just install the extensions on the default/root host for your server, and
11# point it against that hostname, running it against all vhosts on a server is
12# probably rather wasteful.
13#
14# Kev Green, oRe Net (http://www.orenet.co.uk/).
15
16
17use strict;
18use lib "/usr/lib/nagios/plugins";
19use utils qw($TIMEOUT %ERRORS &print_revision &support);
20use vars qw($PROGNAME);
21use Getopt::Long;
22use LWP;
23use vars qw($opt_V $opt_h $verbose $opt_w $opt_c $opt_H);
24my ($tt,$url,$response,$stime, $etime,$warning,$critical,$mimetype,$failtype,$temp,$message);
25my $rt = 0;
26
27$PROGNAME = "check_frontpage";
28sub print_help ();
29sub print_usage ();
30
31$ENV{'PATH'}='';
32$ENV{'BASH_ENV'}='';
33$ENV{'ENV'}='';
34
35Getopt::Long::Configure('bundling');
36GetOptions
37 ("V" => \$opt_V, "version" => \$opt_V,
38 "h" => \$opt_h, "help" => \$opt_h,
39 "v" => \$verbose, "verbose" => \$verbose,
40 "w=s" => \$opt_w, "warning=s" => \$opt_w,
41 "c=s" => \$opt_c, "critical=s" => \$opt_c,
42 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
43
44if ($opt_V) {
45 print_revision($PROGNAME,'$Revision: 1112 $'); #'
46 exit $ERRORS{'OK'};
47}
48
49if ($opt_h) {
50 print_help();
51 exit $ERRORS{'OK'};
52}
53
54$opt_H = shift unless ($opt_H);
55print_usage() unless $opt_H;
56my $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]+)*)$/);
57print_usage() unless $host;
58
59($opt_c) || ($opt_c = shift) || ($opt_c = 120);
60if ($opt_c =~ /([0-9]+)/) {
61 $critical = $1;
62} else {
63 $critical = 10;
64}
65
66($opt_w) || ($opt_w = shift) || ($opt_w = 60);
67if ($opt_w =~ /([0-9]+)/) {
68 $warning = $1;
69} else {
70 $warning = 5;
71}
72
73# Guts go here, once we're through argument parsing and have warning and
74# critical thresholds.
75my $browser = LWP::UserAgent->new;
76
77my @urls = (
78 # This is the "Hit Counter", which continues to work if frontpage extensions
79 # are 'uninstall'ed from the site, but not when they are 'fulluninstall'ed.
80 {
81 url => "_vti_bin/fpcount.exe?Page=_borders/right.htm|Image=4",
82 mimetype => "image/gif",
83 message => "None, or broken frontpage extensions on server, or virtual site 'fulluninstall'ed?",
84 failtype => "CRITICAL"
85 },
86 # This is the "FrontPage Configuration Information" file, which is removed
87 # when you 'uninstall' the extensions from a site.
88 {
89 url => "_vti_inf.html",
90 mimetype => "text/html",
91 message => "Someone 'uninstall'ed extensions on virtual site?",
92 failtype => "WARNING"
93 }
94);
95
96print "FRONTPAGE: ";
97
98foreach $temp (@urls) {
99 $url = $temp->{'url'};
100 $mimetype = $temp->{'mimetype'};
101 $failtype = $temp->{'failtype'};
102 $message = $temp->{'message'};
103 $stime = time();
104 $response=$browser->get("http://".$host."/".$url);
105 $etime = time();
106 $tt = $etime - $stime;
107
108# If we got a server error, or unknown output type, report back as critical.
109 if ($response->status_line !~ "^200") {
110 print $message." (".$response->status_line.")\r\n";
111 exit $ERRORS{$failtype};
112 } elsif ($response->content_type !~ $mimetype) {
113 print $message." (Wrong Content-type: ".$response->content_type.")\r\n";
114 exit $ERRORS{$failtype};
115 } else {
116 # Because we're dealing with multiple URL's
117 $rt += $tt;
118 }
119
120# Decide if the response time was critical or not.
121#
122 if ($rt > $critical) {
123 print "Response time ".$rt." over critical threshold ".$critical."\r\n";
124 exit($ERRORS{'CRITICAL'});
125 } elsif ($rt > $warning) {
126 print "Response time ".$rt." over warning threshold ".$warning."\r\n";
127 exit($ERRORS{'WARNING'});
128 }
129}
130printf(" %s - %s second response time, ",$response->status_line, $rt);
131
132# If all the required URL's give the right responses quick enough, then we
133# should be okay.
134exit($ERRORS{'OK'});
135
136sub print_usage () {
137 print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n";
138 exit;
139}
140
141sub print_help () {
142 print_revision($PROGNAME,'$Revision: 1112 $');
143 print "Copyright (c) 2003 Kev Green\n";
144 print "\n";
145 print "FrontPage remains a copyright/trademark of Microsoft Corporation.\n";
146 print_usage();
147 print "\n";
148 print "<warn> = Unknown.\n";
149 print "<crit> = Server error from FrontPage extensions.\n\n";
150 support();
151}
diff --git a/contrib/check_hltherm.c b/contrib/check_hltherm.c
deleted file mode 100644
index 85c989f..0000000
--- a/contrib/check_hltherm.c
+++ /dev/null
@@ -1,209 +0,0 @@
1/******************************************************************************************
2 *
3 * CHECK_HLTHERM.C
4 *
5 * Program: Hot Little Therm temperature plugin for Nagios
6 * License: GPL
7 * Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org)
8 *
9 * Last Modified: 02-28-2002
10 *
11 * Command line: check_hltherm <probe> <wtemp> <ctemp> [-l label] [-s scale] [-lower]
12 *
13 * Description:
14 *
15 * This plugin checks the temperature of a given temperature probe on a
16 * Hot Little Therm digital thermometer. The plugin uses the 'therm' utility
17 * that is included with the HLT software to check the probe temperature. Both
18 * the HLT digital thermometer and software are produced by Spiderplant. See
19 * their website at http://www.spiderplant.com/hlt for more information.
20 *
21 *****************************************************************************************/
22
23#include "config.h"
24#include "common.h"
25#include "popen.h"
26
27#define DEFAULT_TIMEOUT 10 /* default timeout in seconds */
28
29#define HLTHERM_COMMAND "/usr/local/bin/therm" /* this should be moved out to the configure script */
30
31
32static void timeout_alarm_handler(int); /* author must provide */
33int process_arguments(int, char **);
34
35int timeout_interval=DEFAULT_TIMEOUT;
36
37double wtemp=0.0L;
38double ctemp=0.0L;
39
40int check_lower_temps=FALSE;
41
42char probe[MAX_INPUT_BUFFER]="";
43char label[MAX_INPUT_BUFFER]="Temperature";
44char scale[MAX_INPUT_BUFFER]="Degrees";
45
46FILE *fp;
47
48
49int main(int argc, char **argv){
50 int result=STATE_OK;
51 char command[MAX_INPUT_BUFFER];
52 double temp=0.0L;
53 char input_buffer[MAX_INPUT_BUFFER];
54 int found=0;
55
56 /* process command line arguments */
57 result=process_arguments(argc,argv);
58
59 /* display usage if there was a problem */
60 if(result==ERROR){
61 printf("Incorrect arguments supplied\n");
62 printf("\n");
63 printf("Hot Little Therm temperature plugin for Nagios\n");
64 printf("Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org)\n");
65 printf("Last Modified: 02-28-2002\n");
66 printf("License: GPL\n");
67 printf("\n");
68 printf("Usage: %s <probe> <wtemp> <ctemp> [-l label] [-s scale] [-lower]\n",argv[0]);
69 printf("\n");
70 printf("Options:\n");
71 printf(" <wtemp> = Temperature necessary to result in a WARNING state\n");
72 printf(" <ctemp> = Temperature necessary to result in a CRITICAL state\n");
73 printf(" [label] = A descriptive label for the probe. Example: \"Outside Temp\"\n");
74 printf(" [scale] = A descriptive label for the temperature scale. Example: \"Celsius\"\n");
75 printf(" [-lower] = Evaluate temperatures with lower values being more critical\n");
76 printf("\n");
77 printf("This plugin checks the temperature of a given temperature probe on a\n");
78 printf("Hot Little Therm digital thermometer. The plugin uses the 'therm' utility\n");
79 printf("included with the HLT software to check the probe temperature. Both the\n");
80 printf("HLT digital thermometer and software are produced by Spiderplant. See\n");
81 printf("their website at http://www.spiderplant.com/hlt for more information.\n");
82 printf("\n");
83 return STATE_UNKNOWN;
84 }
85
86
87 result=STATE_OK;
88
89 /* Set signal handling and alarm */
90 if(signal(SIGALRM,timeout_alarm_handler)==SIG_ERR){
91 printf("Cannot catch SIGALRM");
92 return STATE_UNKNOWN;
93 }
94
95 /* handle timeouts gracefully */
96 alarm(timeout_interval);
97
98 /* create the command line we're going to use */
99 snprintf(command,sizeof(command),"%s %s",HLTHERM_COMMAND,probe);
100 command[sizeof(command)-1]='\x0';
101
102 /* run the command to check the temperature on the probe */
103 fp=spopen(command);
104 if(fp==NULL){
105 printf("Could not open pipe: %s\n",command);
106 return STATE_UNKNOWN;
107 }
108
109 if(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){
110 found=1;
111 temp=(double)atof(input_buffer);
112 }
113
114 /* close the pipe */
115 spclose(fp);
116
117 if(result==STATE_OK){
118
119 if(found==0){
120 printf("Therm problem - Could not read program output\n");
121 result=STATE_CRITICAL;
122 }
123 else{
124 if(check_lower_temps==TRUE){
125 if(temp<=ctemp)
126 result=STATE_CRITICAL;
127 else if(temp<=wtemp)
128 result=STATE_WARNING;
129 }
130 else{
131 if(temp>=ctemp)
132 result=STATE_CRITICAL;
133 else if(temp>=wtemp)
134 result=STATE_WARNING;
135 }
136
137 printf("Therm %s: %s = %2.1f %s\n",(result==STATE_OK)?"ok":"problem",label,temp,scale);
138 }
139 }
140
141 return result;
142 }
143
144
145/* process command-line arguments */
146int process_arguments(int argc, char **argv){
147 int x;
148
149 /* not enough options were supplied */
150 if(argc<4)
151 return ERROR;
152
153 /* first option is always the probe name */
154 strncpy(probe,argv[1],sizeof(probe)-1);
155 probe[sizeof(probe)-1]='\x0';
156
157 /* 2nd and 3rd options are temperature thresholds */
158 wtemp=(double)atof(argv[2]);
159 ctemp=(double)atof(argv[3]);
160
161 /* process all remaining arguments */
162 for(x=5;x<=argc;x++){
163
164 /* we got the lower temperature option */
165 if(!strcmp(argv[x-1],"-lower"))
166 check_lower_temps=TRUE;
167
168 /* we got the label */
169 else if(!strcmp(argv[x-1],"-l")){
170 if(x<argc){
171 strncpy(label,argv[x],sizeof(label));
172 label[sizeof(label)-1]='\x0';
173 x++;
174 }
175 else
176 return ERROR;
177 }
178
179 /* we got the scale */
180 else if(!strcmp(argv[x-1],"-s")){
181 if(x<argc){
182 strncpy(scale,argv[x],sizeof(scale));
183 scale[sizeof(scale)-1]='\x0';
184 x++;
185 }
186 else
187 return ERROR;
188 }
189
190 /* else we got something else... */
191 else
192 return ERROR;
193 }
194
195 return OK;
196 }
197
198
199
200/* handle timeouts gracefully... */
201static void timeout_alarm_handler(int signo){
202
203 if(signo==SIGALRM){
204
205 kill(childpid[fileno(fp)],SIGKILL);
206 printf("Therm problem - Check timed out after %d seconds\n",timeout_interval);
207 exit(STATE_CRITICAL);
208 }
209 }
diff --git a/contrib/check_hprsc.pl b/contrib/check_hprsc.pl
deleted file mode 100755
index 7a85650..0000000
--- a/contrib/check_hprsc.pl
+++ /dev/null
@@ -1,221 +0,0 @@
1#!/usr/bin/perl -wT
2#
3# Copyright (c) 2000 Hugo Gayosso
4#
5# Description:
6# Nagios plug-in that monitors the resources on an HP-UX machine
7# by querying the SNMP daemon
8#
9# License: General Public License (GPL)
10# http://www.gnu.org/copyleft/gpl.txt
11#
12# ChangeLog
13#
14
15# Requirements: Perl 5.005 or higher
16
17# Variable initialization
18$ENV{'PATH'}="";
19$ENV{'ENV'}="";
20$ENV{'BASH_ENV'}="";
21
22
23if (-e "/usr/bin/snmpwalk") {
24 $snmpwalk = "/usr/bin/snmpwalk";
25} elsif (-e "/usr/local/bin/snmpwalk") {
26 $snmpwalk = "/usr/local/bin/snmpwalk";
27}
28
29
30# HP-UX SNMP OIDs
31$filesystemID1_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.1";
32$mounted_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.3";
33$totalspace_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.4";
34$freespace_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.6";
35$path_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.10";
36$cpu_5min_OID = ".1.3.6.1.4.1.11.2.3.1.1.4";
37
38use Getopt::Long;
39
40GetOptions( "check-filesystem" => \$chk_fs,
41 "show-filesystems" => \$show_fs,
42 "check-filesystemID" => \$chk_fsid,
43 "check-cpu" => \$chk_cpu,
44 "host=s" => \$target_host,
45 "community=s" => \$target_community,
46 "filesystemID1=i" => \$fsid1_opt,
47 "filesystem=s" => \$fs_opt,
48 "protocol:s" => \$proto_opt,
49 "warning=i" => \$warning_opt,
50 "critical=i" => \$critical_opt);
51
52$proto_opt = 1
53 unless $proto_opt == 1 ||
54 $proto_opt == '2c' ||
55 $proto_opt == 3;
56
57if ($chk_fs) {
58 walk_data($snmpwalk, $target_host, $target_community, $mounted_OID,$proto_opt );
59 walk_data($snmpwalk, $target_host, $target_community, $totalspace_OID,$proto_opt );
60 walk_data($snmpwalk, $target_host, $target_community, $freespace_OID,$proto_opt ); check_filesystem($fs_opt, $warning_opt, $critical_opt);
61} elsif ($show_fs) {
62 walk_data($snmpwalk, $target_host, $target_community, $filesystemID1_OID,$proto_opt);
63 walk_data($snmpwalk, $target_host, $target_community, $mounted_OID,$proto_opt );
64 walk_data($snmpwalk, $target_host, $target_community, $path_OID,$proto_opt);
65 show_filesystem();
66} elsif ($chk_fsid){
67 $totalspace_fsID_OID = "$totalspace_OID.$fsid1_opt";
68 $freespace_fsID_OID = "$freespace_OID.$fsid1_opt";
69 walk_data($snmpwalk, $target_host, $target_community, $totalspace_fsID_OID,$proto_opt);
70 walk_data($snmpwalk, $target_host, $target_community, $freespace_fsID_OID,$proto_opt);
71 check_filesystemID1($fsid1_opt, $warning_opt, $critical_opt);
72} elsif ($chk_cpu) {
73 get_cpu_load($snmpwalk, $target_host, $target_community, $cpu_5min_OID,$proto_opt);
74 check_cpu_5min($cpu, $warning_opt, $critical_opt);
75} else {
76 print "\n\nUsage:\n";
77 print "Checking 5-min CPU Load:\n";
78 print " $0 --check-cpu -warning <threshold> --critical <threshold> --host <yourhost> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
79 print "Checking local filesystem mounted on a host:\n";
80 print " $0 --show-filesystems --host <hostname> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
81 print "Checking by filesystem name:\n";
82 print " $0 --check-filesystem --filesystem </dev/vg00/lvol1> --warning <% used space> --critical <% used space> --host <hostname> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
83 print "Checking by filesystem ID:\n";
84 print " $0 --check-filesystemID --filesystemID <filesystemID1> --warning <% used space> --critical <% used space> --host <hostname> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n";
85}
86
87sub get_cpu_load {
88 my ($snmpwalk, $target_host, $target_community, $OID,$vers) = @_;
89 die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|"));
90
91 if ($pid) { # parent
92 while (<SNMPWALK>) {
93 my @snmpdata = split(/:/,$_);
94 $cpu = $snmpdata[1]/100;
95 }
96 close(SNMPWALK) or warn "kid exited $?";
97 } else { # child
98 exec($snmpwalk,'-c',$target_community,'-v',$vers,$target_host,$OID) or die "can't exec program: $!";
99 }
100}
101
102sub walk_data {
103#This function queries the SNMP daemon for the specific OID
104 my ($snmpwalk, $target_host, $target_community, $OID,$vers) = @_;
105
106 die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|"));
107
108 if ($pid) { # parent
109 while (<SNMPWALK>) {
110 $output = $_;
111 sort_walk_data($output);
112 }
113 close(SNMPWALK) or warn "kid exited $?";
114 } else { # child
115 exec($snmpwalk,'-c',$target_community,'-v',$vers,$target_host,$OID) or die "can't exec program: $!";
116 }
117}
118
119sub sort_walk_data {
120 my ($snmp_data) = @_;
121 @fields = split(/\./,$snmp_data);
122 $item = $fields[8];
123 $filesystemID1 = $fields[9];
124 @fields2 = split(/=/,$fields[10]);
125# $filesystemID2 = $fields2[0];
126 $value = $fields2[1];
127 chomp($value);
128 if ($value =~ /"/) {
129 @fields3 = split(/"/,$value);
130 $value = $fields3[1];
131 }
132 if ($item == 3) {
133 $mounted{$filesystemID1} = "$value";
134 } elsif ($item == 4) {
135 $totalspace{$filesystemID1} = "$value";
136 } elsif ($item == 6) {
137 $freespace{$filesystemID1} = "$value";
138 } elsif ($item == 10) {
139 $filesystempath{$filesystemID1} = "$value";
140 }
141}
142
143sub show_filesystem {
144 print "\n\nfilesystemID1\tmounted filesystem\tfilesystem path\n";
145 foreach $element (keys %mounted) {
146 print "$element\t$mounted{$element}\t\t$filesystempath{$element}\n";
147 }
148 print "\n\n";
149}
150
151sub check_filesystem {
152
153# Warning = percentage of used space >= $warning and < $critical
154# Critical = percentage of used space > $warning and >= $critical
155# OK = percentage of used space < $warning and < $critical
156
157 my ($mounted_filesystem, $warning, $critical) = @_;
158 foreach $element (keys %mounted) {
159 if ($mounted{$element} eq $mounted_filesystem) {
160 my $warning_result = $totalspace{$element}*(100-$warning)/100;
161 my $critical_result = $totalspace{$element}*(100-$critical)/100;
162 my $result_percent = $freespace{$element}*100/$totalspace{$element};
163 if (($freespace{$element} <= $warning_result) && ($freespace{$element} > $critical_result)) {
164 printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
165 exit 1;
166 } elsif ($freespace{$element} <= $critical_result) {
167 printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
168 exit 2;
169 } else {
170 printf "Disk ok - %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
171 exit 0;
172 }
173 }
174 }
175 print "$mounted_filesystem doesn't exist in $target_host\n\n";
176 exit -1;
177}
178
179sub check_filesystemID1{
180# Warning = percentage of used space >= $warning and < $critical
181# Critical = percentage of used space > $warning and >= $critical
182# OK = percentage of used space < $warning and < $critical
183
184 my ($fsid1, $warning, $critical) = @_;
185 foreach $element (keys %totalspace) {
186 if ($element eq $fsid1) {
187 my $warning_result = $totalspace{$element}*(100-$warning)/100;
188 my $critical_result = $totalspace{$element}*(100-$critical)/100;
189 my $result_percent = $freespace{$element}*100/$totalspace{$element};
190 if (($freespace{$element} <= $warning_result) && ($freespace{$element} >= $critical_result)) {
191 printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
192 exit 1;
193 } elsif ($freespace{$element} <= $critical_result) {
194 printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
195 exit 2;
196 } else {
197 printf "Disk ok - %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%";
198 exit 0;
199 }
200 }
201 }
202 print "$fsid1 doesn't exist in $target_host\n\n";
203 exit -1;
204}
205
206sub check_cpu_5min {
207 my ($cpu, $warn, $crit) = @_;
208 if ($cpu >= $crit) {
209 print "Critical- 5-min load: $cpu\n";
210 exit 2;
211 } elsif ($cpu >= $warn) {
212 print "Warning - 5-min load: $cpu\n";
213 exit 1;
214 } else {
215 print "Load ok - 5-min load: $cpu\n";
216 exit 0;
217 }
218}
219
220
221
diff --git a/contrib/check_hw.sh b/contrib/check_hw.sh
deleted file mode 100644
index 9d3b574..0000000
--- a/contrib/check_hw.sh
+++ /dev/null
@@ -1,66 +0,0 @@
1#! /bin/sh
2#
3# Tested on SuSE 9.1 Professional with the hwinfo-8.62-0.2 package installed.
4#
5# Before you can run this plugin, you must do:
6# /usr/sbin/hwinfo --short > /etc/hw.original
7# add to cron job:
8# /usr/sbin/hwinfo --short > /etc/hw.current
9# /usr/bin/diff /etc/hw.original /etc/hw.current > /tmp/hw.check
10#
11#
12# Rok Debevc -- rok.debevc@agenda.si
13#
14#
15PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
16
17PROGNAME=`basename $0`
18PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
19REVISION=`echo '$Revision: 939 $' | sed -e 's/[^0-9.]//g'`
20
21. $PROGPATH/utils.sh
22
23
24print_usage() {
25 echo "Usage: $PROGNAME"
26}
27
28print_help() {
29 print_revision $PROGNAME $REVISION
30 echo ""
31 print_usage
32 echo ""
33 echo "This plugin checks hardware changes."
34 echo ""
35 support
36 exit 0
37}
38
39case "$1" in
40 --help)
41 print_help
42 exit 0
43 ;;
44 -h)
45 print_help
46 exit 0
47 ;;
48 --version)
49 print_revision $PROGNAME $REVISION
50 exit 0
51 ;;
52 -V)
53 print_revision $PROGNAME $REVISION
54 exit 0
55 ;;
56 *)
57 if `du /tmp/hw.check | cut -c 1|grep "^[0]" > /dev/null` ; then
58 echo No hardware is changed
59 exit 0
60 else
61 echo ***hardware is changed*** look into /tmp/hw.check
62 exit 2
63 fi
64 ;;
65esac
66
diff --git a/contrib/check_ica_master_browser.pl b/contrib/check_ica_master_browser.pl
deleted file mode 100755
index 922e718..0000000
--- a/contrib/check_ica_master_browser.pl
+++ /dev/null
@@ -1,228 +0,0 @@
1#!/usr/bin/perl -w
2
3# $Id: check_ica_master_browser.pl 1099 2005-01-25 09:09:33Z stanleyhopcroft $
4
5# Revision 1.1 2005/01/25 09:09:33 stanleyhopcroft
6# New plugin - checks that ICA master browser is what it should be (important for firewalled dialup)
7#
8
9use strict ;
10
11use IO::Socket;
12use IO::Select;
13use Getopt::Long ;
14
15use lib qw(/usr/local/nagios/libexec) ;
16use utils qw(%ERRORS &print_revision &support &usage);
17use packet_utils qw(&pdump &tethereal) ;
18
19my $PROGNAME = 'check_ica_master_browser' ;
20
21# You might have to change this...
22
23my $PACKET_TIMEOUT = 1;
24 # Number of seconds to wait for further UDP packets
25my $TEST_COUNT = 2;
26 # Number of datagrams sent without reply
27my $BUFFER_SIZE = 1500;
28 # buffer size used for 'recv' calls.
29my $ICA_PORT = 1604;
30 # what port ICA runs on. Unlikely to change.
31
32# End user config.
33
34my ($debug, $preferred_master, $bcast_addr, $ica_browser, $timeout) ;
35
36Getopt::Long::Configure('bundling', 'no_ignore_case');
37GetOptions
38 ("V|version" => \&version,
39 "h|help" => \&help,
40 "v|verbose" => \$debug,
41 "B|broadcast_addr:s" => \$bcast_addr,
42 "I|ica_browser:s" => \$ica_browser,
43 "P|preferred_master:s" => \$preferred_master,
44 "T|Packet_timeout:i" => \$timeout,
45) ;
46
47
48my $broadcast_addr = $1 if $bcast_addr and $bcast_addr =~ m#(\d+\.\d+\.\d+\.\d+)# ;
49usage("Invalid broadcast address: $bcast_addr")
50 if $bcast_addr and not defined($broadcast_addr) ;
51
52usage("You must provide either the name of an ICA browser or the broadcast address of the subnet containing them\n")
53 unless ($ica_browser or $broadcast_addr) ;
54
55usage("You must provide the name or address of a preferred ICA master browser\n")
56 unless ($preferred_master) ;
57
58my $preferred_master_n = $preferred_master =~ m#(\d+\.\d+\.\d+\.\d+)#
59 ? $preferred_master
60 : inet_ntoa(scalar gethostbyname($preferred_master)) ;
61
62my $Timeout = $timeout || $PACKET_TIMEOUT ;
63
64 # Definitions of query strings. Change at your own risk :)
65 # this info was gathered with tcpdump whilst trying to use an ICA client,
66 # so I'm not 100% sure of what each value is.
67
68my $bcast_helo = &tethereal(<<'End_of_Tethereal_trace', '1e') ;
690020 ff ff 04 d6 06 44 00 26 4a 76 1e 00 01 30 02 fd .....D.&Jv...0..
700030 a8 e3 00 02 f5 95 9f f5 30 07 00 00 00 00 00 00 ........0.......
710040 00 00 00 00 00 00 01 00 ........
72End_of_Tethereal_trace
73
74my $direct_helo = &tethereal(<<'End_of_Tethereal_trace', '20') ;
750020 64 17 05 0f 06 44 00 28 ab b5 20 00 01 30 02 fd d....D.(.. ..0..
760030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
770040 00 00 00 00 00 00 00 00 00 00 ........
78End_of_Tethereal_trace
79
80my $Udp = IO::Socket::INET->new( Proto => 'udp' )
81 || die "Socket failure: $!";
82
83 # select is here to allow us to set timeouts on the connections. Otherwise they
84 # just 'stop' until a server appears.
85
86my $select = IO::Select->new($Udp)
87 || die "Select failure: $!";
88
89$Udp->sockopt(SO_BROADCAST, 1 );
90
91my ($remote_host, $buff, $destination, $raddr, $rport, $rhost, @remote_response);
92my ($query_message, $send_addr, $this_test) ;
93
94$buff = '';
95$this_test = 0;
96
97 # If there is no response to the first helo packet it will be resent
98 # up to $TEST_COUNT (see at the top).
99
100$query_message = $broadcast_addr ? $bcast_helo : $direct_helo ;
101$destination = $broadcast_addr ? $broadcast_addr: $ica_browser ;
102$send_addr = sockaddr_in($ICA_PORT, inet_aton($destination) ) ;
103
104while ( ++$this_test <= $TEST_COUNT && !$buff ) {
105
106 print "Sending helo datagram. datagram number: ", $this_test, "\n"
107 if $debug ;
108
109 print "Querying $destination for master browser\n"
110 if $debug ;
111 &pdump($query_message)
112 if $debug ;
113 $Udp->send($query_message, 0, $send_addr );
114 if ( $select->can_read($Timeout) ) {
115 $remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 );
116 }
117
118 last
119 if $buff ;
120 sleep 1 ;
121
122}
123
124 # Ok we've looped several times, looking for a response. If we don't have one
125 # yet, we simply mark the whole lot as being unavailable.
126
127unless ( $buff ) {
128 print "Failed. No response to helo datagram (master browser query) from $destination.\n" ;
129 exit $ERRORS{CRITICAL} ;
130}
131
132($rport, $raddr) = sockaddr_in( $remote_host );
133$rhost = gethostbyaddr( $raddr, AF_INET );
134my @tmpbuf = unpack('C*', $buff );
135if ( $debug ) {
136 print "$rhost:$rport responded with: ",length($buff), " bytes\n";
137 &pdump($buff) ;
138}
139
140 # Now we have a response, then we need to figure out the master browser, and
141 # query it for published applications...
142
143my $master_browser = join '.', @tmpbuf[32..35] ;
144my ($master_browser_a) = gethostbyaddr(inet_aton($master_browser), AF_INET) =~ /^(\w+?)\./ ;
145
146 # Ok should probably error check this, because it's remotely possible
147 # that a server response might be completely wrong...
148
149print "Master browser = $master_browser_a/$master_browser\n"
150 if $debug ;
151
152$send_addr = sockaddr_in($ICA_PORT, inet_aton($master_browser));
153
154my $subject_clause = $bcast_addr ? "of the \"$destination\" subnet" : "known to ICA server \"$destination\"" ;
155
156if ( $master_browser eq $preferred_master_n ) {
157 print "Preferred master browser \"$preferred_master\" __is__ the master browser (\"$master_browser_a/$master_browser\") $subject_clause.\n" ;
158 exit $ERRORS{OK} ;
159} else {
160 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" ;
161 exit $ERRORS{CRITICAL} ;
162}
163
164close $Udp;
165
166
167sub print_usage () {
168 print "Usage: $PROGNAME (-B <broadcast_address>| -I <citrix_server>) - P <preferred_master_browser>" ;
169}
170
171sub print_help () {
172 print_revision($PROGNAME,'$Revision: 1099 $ ');
173 print "Copyright (c) 2002 Ed Rolison/Tom De Blende/S Hopcroft
174
175Perl Check Citrix Master Browser plugin for Nagios.
176
177Returns OK if the Citrix master browser is that given by the -P option.
178
179The plugin works by
180 If the -B option is specified, sends a broadcast helo to find the address of the Citrix master browser in the specified subnet.
181 return critical if there is no reply;
182 Else if the -I option is specified
183 send a direct helo to the specified server until there is a response (containing the address of the Citrix master browser)
184
185
186 return Critical if the response does not contain the address of the 'preferred master browser' (-P option).
187 return OK
188
189 How ICA Clients Use the Master ICA Browser.
190
191Citrix ICA Clients must locate the master browser to get the address of a server or published application.
192
193The Citrix ICA Client can locate the master browser by sending out broadcast packets, or,
194if the address of a Citrix server is specified in the Citrix ICA Client or in an ICA file,
195the ICA Client locates the master browser by sending directed packets to the specified address.
196The ICA Client requests the address of the ICA master browser from the Citrix server.
197
198";
199 print_usage();
200 print '
201-B, --broadcast_address:STRING
202 The broadcast address that should contain Citrix master browser. This option takes precedence over -I.
203-I, --ica_browser:STRING
204 Optional name or address of an ICA server that could be the master browser (used when broadcast not possible).
205-P, --preferred_master:STRING
206 Name or address of the ICA server that _should_ be the master browser.
207 Required.
208-T, --packet-timeout:INTEGER
209 Time to wait for UDP packets (default 1 sec).
210-v, --verbose
211 Debugging output.
212-h, --help
213 This stuff.
214
215';
216 support();
217}
218
219sub version () {
220 print_revision($PROGNAME,'$Revision: 1099 $ ');
221 exit $ERRORS{'OK'};
222}
223
224sub help () {
225 print_help();
226 exit $ERRORS{'OK'};
227}
228
diff --git a/contrib/check_ica_metaframe_pub_apps.pl b/contrib/check_ica_metaframe_pub_apps.pl
deleted file mode 100755
index 0edbdca..0000000
--- a/contrib/check_ica_metaframe_pub_apps.pl
+++ /dev/null
@@ -1,381 +0,0 @@
1#!/usr/bin/perl -w
2
3# $Id: check_ica_metaframe_pub_apps.pl 1098 2005-01-25 09:07:39Z stanleyhopcroft $
4
5# Revision 1.1 2005/01/25 09:07:39 stanleyhopcroft
6# Replacement (structured name mainly) for check_citrix: check of ICA browse service
7#
8# Revision 1.1 2005-01-25 17:00:24+11 anwsmh
9# Initial revision
10#
11
12use strict ;
13
14use IO::Socket;
15use IO::Select;
16use Getopt::Long ;
17
18my ($bcast_addr, $timeout, $debug, @citrix_servers, $crit_pub_apps, $warn_pub_apps, $long_list) ;
19
20use lib qw(/usr/local/nagios/libexec) ;
21use utils qw(%ERRORS &print_revision &support &usage) ;
22use packet_utils qw(&pdump &tethereal) ;
23
24my $PROGNAME = 'check_ica_metaframe_pub_apps' ;
25
26sub print_help ();
27sub print_usage ();
28sub help ();
29sub version ();
30
31 # You might have to change this...
32
33my $PACKET_TIMEOUT = 1;
34 # Number of seconds to wait for further UDP packets
35my $TEST_COUNT = 2;
36# Number of datagrams sent without reply
37my $BUFFER_SIZE = 1500;
38 # buffer size used for 'recv' calls.
39my $LONG_LIST = 0 ;
40 # this is for if you have many published applications.
41 # if you set it, it won't do any harm, but may slow the test
42 # down a little. (Since it does a 'recv' twice instead of
43 # once and therefore may have to wait for a timeout).
44my $ICA_PORT = 1604;
45 # what port ICA runs on. Unlikely to change.
46
47Getopt::Long::Configure('bundling', 'no_ignore_case');
48GetOptions
49 ("V|version" => \&version,
50 "h|help" => \&help,
51 "v|verbose" => \$debug,
52 "B|broadcast_addr:s" => \$bcast_addr,
53 "C|citrix_servers:s" => \@citrix_servers,
54 "L|long_list" => \$long_list,
55 "P|crit_pub_apps:s" => \$crit_pub_apps,
56 "T|Packet_timeout:i" => \$timeout,
57 "W|warn_pub_apps:s" => \$warn_pub_apps,
58) ;
59
60
61my $broadcast_addr = $1 if $bcast_addr and $bcast_addr =~ m#(\d+\.\d+\.\d+\.\d+)# ;
62usage("Invalid broadcast address: $bcast_addr\n")
63 if $bcast_addr and not defined($broadcast_addr) ;
64
65usage("You must provide either the names of citrix servers or the broadcast address of the subnet containing them\n")
66 unless (@citrix_servers or $broadcast_addr) ;
67
68my @target = defined $broadcast_addr ? ($broadcast_addr) : @citrix_servers ;
69
70usage("You must provide the names of the published applications that the Citrix browser should be advertising\n")
71 unless $crit_pub_apps or $warn_pub_apps ;
72
73my $Timeout = $timeout
74 if defined $timeout ;
75$Timeout = $PACKET_TIMEOUT
76 unless defined $Timeout ;
77$long_list = $LONG_LIST
78 unless defined $long_list ;
79
80my @crit_pub_apps = $crit_pub_apps ? split(/,/, $crit_pub_apps) : () ;
81my @warn_pub_apps = $warn_pub_apps ? split(/,/, $warn_pub_apps) : () ;
82
83 # Definitions of query strings. Change at your own risk :)
84 # this info was gathered with tcpdump whilst trying to use an ICA client,
85 # so I'm not 100% sure of what each value is.
86
87my $bcast_helo = &tethereal(<<'End_of_Tethereal_trace', '1e') ;
880020 ff ff 04 d6 06 44 00 26 4a 76 1e 00 01 30 02 fd .....D.&Jv...0..
890030 a8 e3 00 02 f5 95 9f f5 30 07 00 00 00 00 00 00 ........0.......
900040 00 00 00 00 00 00 01 00 .......
91End_of_Tethereal_trace
92
93my $bcast_query_app = &tethereal(<<'End_of_Tethereal_trace', '24') ;
940020 64 17 04 50 06 44 00 2c 85 6a 24 00 01 32 02 fd d..P.D.,.j$..2..
950030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
960040 00 00 00 00 00 00 21 00 02 00 00 00 00 00 ......!......
97End_of_Tethereal_trace
98
99my $direct_helo = &tethereal(<<'End_of_Tethereal_trace', '20') ;
1000020 64 17 05 0f 06 44 00 28 ab b5 20 00 01 30 02 fd d....D.(.. ..0..
1010030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
1020040 00 00 00 00 00 00 00 00 00 00 .........
103End_of_Tethereal_trace
104
105my $direct_query_app = &tethereal(<<'End_of_Tethereal_trace', '2c') ;
1060020 64 17 05 10 06 44 00 34 7a 9a 2c 00 02 32 02 fd d....D.4z.,..2..
1070030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
1080040 00 00 00 00 00 00 21 00 02 00 01 00 00 00 00 00 ......!.........
1090050 00 00 00 00 00 00 ......
110End_of_Tethereal_trace
111
112my $Udp = IO::Socket::INET->new( Proto => 'udp' )
113 || die "Socket failure: $!";
114
115 # Select is here to allow us to set timeouts on the connections.
116 # Otherwise they just 'stop' until a server appears.
117
118my $select = IO::Select->new($Udp)
119 || die "Select failure: $!";
120 # Helo needs to be broadcastt, but query does not.
121$Udp->sockopt(SO_BROADCAST, 1 );
122
123my ($remote_host, $buff, $buff2, $raddr, $rport, $rhost, @remote_response);
124my ($query_message, $send_addr, $this_test) ;
125
126$buff = $buff2 = '';
127$this_test = 0;
128
129 # If there is no response to the first helo packet it will be resent
130 # up to TEST_COUNT (see at the top).
131
132while ( ++$this_test <= $TEST_COUNT && !$buff ) {
133
134 print "Sending helo datagram. datagram number: ", $this_test, "\n"
135 if $debug ;
136
137 # If we have multiple targets, we probe each of them until we get a
138 # response...
139
140 foreach my $destination (@target) {
141 $query_message = $broadcast_addr ? $bcast_helo : $direct_helo ;
142 print "Querying $destination for master browser\n"
143 if $debug ;
144 $send_addr = sockaddr_in($ICA_PORT, inet_aton($destination) );
145 &pdump($query_message)
146 if $debug ;
147 $Udp->send($query_message, 0, $send_addr );
148 if ( $select->can_read($Timeout) ) {
149 $remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 );
150 }
151
152 last
153 if $buff ;
154 sleep 1 ;
155
156 }
157}
158
159 # Ok we've looped several times, looking for a response. If we don't have one
160 # yet, we simply mark the whole lot as being unavailable.
161
162unless ( $buff ) {
163 print "Failed. No response to helo datagram (master browser query) from ", $broadcast_addr ? $broadcast_addr : "@citrix_servers", ".\n" ;
164 exit $ERRORS{CRITICAL} ;
165}
166
167($rport, $raddr) = sockaddr_in( $remote_host );
168$rhost = gethostbyaddr( $raddr, AF_INET );
169my @tmpbuf = unpack('C*', $buff );
170if ( $debug ) {
171 print "$rhost:$rport responded with: ", length($buff), " bytes\n";
172 &pdump($buff) ;
173}
174
175 # Now we have a response, then we need to figure out the master browser, and
176 # query it for published applications...
177
178my $master_browser = join '.', @tmpbuf[32..35] ;
179
180 # Ok should probably error check this, because it's remotely possible
181 # that a server response might be completely wrong...
182
183print "Master browser = $master_browser\n"
184 if $debug ;
185
186$send_addr = sockaddr_in($ICA_PORT, inet_aton($master_browser));
187
188if ( $broadcast_addr ) {
189 print "using broadcast query\n"
190 if $debug ;
191 $query_message = $bcast_query_app;
192} else {
193 print "using directed query\n"
194 if $debug ;
195 $query_message = $direct_query_app;
196}
197
198 # Now we send the appropriate query string, to the master browser we've found.
199
200$buff = '';
201$this_test = 0 ;
202
203print "Querying master browser for published application list\n"
204 if $debug ;
205
206while ( ++$this_test <= $TEST_COUNT && !$buff ) {
207 print "Sending application query datagram. datagram number: ", $this_test, "\n"
208 if $debug ;
209 &pdump($query_message)
210 if $debug ;
211 $Udp->send($query_message, 0, $send_addr);
212
213 if ( $select->can_read($Timeout) ) {
214 $remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 );
215 # $buff = substr($buff, 32) ;
216 # Hope that ICA preamble is first 32 bytes
217 }
218
219 # Long application lists are delivered in multiple packets
220
221 my $buff2 = '' ;
222 while ( $long_list && $select->can_read($Timeout) ) {
223 $remote_host = $Udp->recv($buff2, $BUFFER_SIZE, 0);
224 $buff .= $buff2
225 if $buff2 ;
226 # $buff .= substr($buff2, 32) if $buff2 ;
227 # Hope that ICA preamble is first 32 bytes
228 }
229
230 last if $buff ;
231 sleep 1 ;
232
233}
234
235unless ( $buff ) {
236 print "Failed. No response to application query datagram from ", $master_browser, ".\n" ;
237 exit $ERRORS{CRITICAL} ;
238}
239
240 # we got a response from a couple of retries of the app query
241
242($rport, $raddr) = sockaddr_in ( $remote_host );
243$rhost = gethostbyaddr ( $raddr, AF_INET );
244if ( $debug ) {
245 print "$rhost:$rport responded to app query with: ", length($buff), " bytes\n";
246 &pdump($buff) ;
247}
248
249my $app_list = $buff ;
250 # delete nulls in unicode
251 # but only if there is unicode (usually from
252 # broadcast query)
253
254$app_list =~ s/(?:(\w| |-)\x00)/$1/g
255 if $app_list =~ /(?:(?:(?:\w| |-)\x00){3,})/ ;
256 # FIXME an application name is
257 # 3 or more unicoded characters
258
259 # FIXME locale
260 # extract null terminated strings
261
262my (@clean_app_list, $clean_app_list) ;
263$clean_app_list = join(',', @clean_app_list = $app_list =~ m#([A-Za-z](?:\w| |-|[ÄÖÜäöüß])+?(?=\x00))#g ) ;
264
265 # patch for German umlauts et al from Herr Mike Gerber.
266
267 # $clean_app_list = join(',', @clean_app_list = $app_list =~ m#([A-Z](?:\w| |-)+?(?=\x00))#g ) ;
268
269 # FIXME everyones apps don't start with caps
270
271print qq(Received list of applications: "$clean_app_list".\n)
272 if $debug ;
273
274if ( scalar @crit_pub_apps and my @missing = &simple_diff(\@clean_app_list, \@crit_pub_apps) ) {
275 print qq(Failed. "@missing" not found in list of published applications),
276 qq(" $clean_app_list" from master browser "$master_browser".\n) ;
277 exit $ERRORS{CRITICAL} ;
278}
279
280if ( my @missing = &simple_diff(\@clean_app_list, \@warn_pub_apps) ) {
281 print qq(Warning. "@missing" not found in list of published applications),
282 qq(" $clean_app_list" from master browser "$master_browser".\n) ;
283 exit $ERRORS{WARNING} ;
284}
285
286my @x = (@crit_pub_apps, @warn_pub_apps) ;
287my $blah = ( scalar(@x) == 1
288 ? 'the published application "' . join(',', @x) . '" is available'
289 : 'the published applications "' . join(',', @x) . '" are available' ) ;
290
291print qq(Ok. Citrix master browser "$master_browser" reported that $blah.\n) ;
292exit $ERRORS{OK} ;
293
294 # sleep $Timeout;
295 # because otherwise we can get responses from
296 # the WRONG servers. DOH
297close $Udp;
298
299
300sub print_usage () {
301 print "Usage: $PROGNAME (-B <broadcast_address>| -C <citrix_server>..) -W <pub_app1,pub_app2..> -P <pub_app1,pub_app2,>\n";
302}
303
304sub print_help () {
305 print_revision($PROGNAME,'$Revision: 1098 $ ');
306 print "Copyright (c) 2002 Ed Rolison/Tom De Blende/S Hopcroft
307
308Perl Check Citrix plugin for Nagios.
309
310Returns OK if the Citrix master browser returns a 'published application' list that contain names specified by the -W or -P options
311
312The plugin works by
313 If the -B option is specified, sending a broadcast helo to find the address of the Citrix master browser in the specified subnet.
314 return critical if there is no reply;
315 Else if the -C option is specified
316 send a direct helo to the specified server until there is a response (containing the address of the Citrix master browser)
317
318 Query the master browser (using a 'broadcast published applications query ' if -B) and compare the published applications returned
319 to those specified by -W and -P options
320
321 return Critical if the published applications specified by -P is not a subset of the query responses;
322 return Warning if the published applications specified by -W is not a subset of the query responses;
323 return OK
324
325";
326 print_usage();
327 print '
328-B, --broadcast_address=STRING
329 The broadcast address that should contain Citrix master browser. This option takes precedence over -C.
330-C, --citrix_server:STRING
331 Optional __name(s)__ of Citrix servers that could be the master browser (used when broadcast not possible).
332-L, --long_list
333 Set this if you have heaps of published applications (ie more than will fit in _one_ UDP packet)
334-P, --crit_published_app=STRING
335 Optional comma separated list of published application that must be in the response from the master browser.
336 Check returns critical otherwise.
337-T, --packet-timeout:INTEGER
338 Time to wait for UDP packets (default 1 sec).
339-W, --warn_published_app=STRING
340 Optional comma separated list of published application that should be in the response from the master browser.
341 Check returns warning otherwise.
342-v, --verbose
343 Debugging output.
344-h, --help
345 This stuff.
346
347';
348 support();
349}
350
351sub version () {
352 print_revision($PROGNAME,'$Revision: 1098 $ ');
353 exit $ERRORS{'OK'};
354}
355
356sub help () {
357 print_help();
358 exit $ERRORS{'OK'};
359}
360
361
362sub simple_diff {
363
364my ( $a_list, $b_list) = @_ ;
365
366 # simple set difference 'Recipe 4.7 Perl Cookbook', Christiansen and Torkington
367
368 my (%seen, @missing) ;
369
370 @seen{@$a_list} = () ;
371
372 foreach my $item (@$b_list) {
373 push @missing, $item
374 unless exists $seen{$item} ;
375 }
376
377 @missing ;
378}
379
380
381
diff --git a/contrib/check_ica_program_neigbourhood.pl b/contrib/check_ica_program_neigbourhood.pl
deleted file mode 100755
index 1f0fb45..0000000
--- a/contrib/check_ica_program_neigbourhood.pl
+++ /dev/null
@@ -1,618 +0,0 @@
1#!/usr/bin/perl -w
2
3# $Id: check_ica_program_neigbourhood.pl 1097 2005-01-25 09:05:53Z stanleyhopcroft $
4
5# Revision 1.1 2005/01/25 09:05:53 stanleyhopcroft
6# New plugin to check Citrix Metaframe XP "Program Neighbourhood"
7#
8# Revision 1.1 2005-01-25 16:50:30+11 anwsmh
9# Initial revision
10#
11
12use strict ;
13
14use Getopt::Long;
15
16use utils qw($TIMEOUT %ERRORS &print_revision &support);
17use LWP 5.65 ;
18use XML::Parser ;
19
20my $PROGNAME = 'check_program_neigbourhood' ;
21my ($debug, $xml_debug, $pn_server, $pub_apps, $app_servers, $server_farm, $usage) ;
22
23Getopt::Long::Configure('bundling', 'no_ignore_case') ;
24GetOptions
25 ("V|version" => \&version,
26 "A|published_app:s" => \$pub_apps,
27 "h|help" => \&help,
28 'usage|?' => \&usage,
29 "F|server_farm=s" => \$server_farm,
30 "P|pn_server=s" => \$pn_server,
31 "S|app_server=s" => \$app_servers,
32 "v|verbose" => \$debug,
33 "x|xml_debug" => \$xml_debug,
34) ;
35
36$pn_server || do {
37 print "Name or IP Address of _one_ Program Neighbourhood server is required.\n" ;
38 &print_usage ;
39 exit $ERRORS{UNKNOWN} ;
40} ;
41
42$pub_apps ||= 'Word 2003' ;
43$pub_apps =~ s/["']//g ;
44my @pub_apps = split /,\s*/, $pub_apps ;
45
46my @app_servers = split /,\s*/, $app_servers ;
47
48@app_servers || do {
49 print "IP Address of _each_ Application server in the Metaframe Citrix XP server farm is required.\n" ;
50 &print_usage ;
51 exit $ERRORS{UNKNOWN} ;
52} ;
53
54my @non_ip_addresses = grep ! /\d+\.\d+\.\d+\.\d+/, @app_servers ;
55
56scalar(@non_ip_addresses) && do {
57 print qq(Application servers must be specified by IP Address (not name): "@non_ip_addresses".\n) ;
58 &print_usage ;
59 exit $ERRORS{UNKNOWN} ;
60} ;
61
62$server_farm || do {
63 print "Name of Citrix Metaframe XP server farm is required.\n" ;
64 &print_usage ;
65 exit $ERRORS{UNKNOWN} ;
66} ;
67
68my %xml_tag = () ;
69my @tag_stack = () ;
70
71my $xml_p = new XML::Parser(Handlers => {Start => \&handle_start,
72 End => sub { pop @tag_stack },
73 Char => \&handle_char}) ;
74
75# values required by Metaframe XP that don't appear to matter too much
76
77my $client_host = 'Nagios server (http://www.Nagios.ORG)' ;
78my $user_name = 'nagios' ;
79my $domain = 'Nagios_Uber_Alles' ;
80
81# end values required by Metaframe XP
82
83my $nilpotent_req = <<'EOR' ;
84<?xml version="1.0" encoding="ISO-8859-1"?>
85<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"><NFuseProtocol version="1.1">
86 <RequestProtocolInfo>
87 <ServerAddress addresstype="dns-port" />
88 </RequestProtocolInfo>
89</NFuseProtocol>
90EOR
91
92my $server_farm_req = <<'EOR' ;
93<?xml version="1.0" encoding="ISO-8859-1"?>
94<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
95<NFuseProtocol version="1.1">
96 <RequestServerFarmData>
97 <Nil />
98 </RequestServerFarmData>
99</NFuseProtocol>
100EOR
101
102my $spec_server_farm_req = <<EOR ;
103<?xml version="1.0" encoding="ISO-8859-1"?>
104<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
105<NFuseProtocol version="1.1">
106 <RequestAddress>
107 <Name>
108 <UnspecifiedName>$server_farm*</UnspecifiedName>
109 </Name>
110 <ClientName>$client_host</ClientName>
111 <ClientAddress addresstype="dns-port" />
112 <ServerAddress addresstype="dns-port" />
113 <Flags />
114 <Credentials>
115 <UserName>$user_name</UserName>
116 <Domain>$domain</Domain>
117 </Credentials>
118 </RequestAddress>
119</NFuseProtocol>
120EOR
121
122my $app_req = <<EOR ;
123<?xml version="1.0" encoding="ISO-8859-1"?>
124<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
125<NFuseProtocol version="1.1">
126 <RequestAddress>
127 <Name>
128 <UnspecifiedName>PUBLISHED_APP_ENCODED</UnspecifiedName>
129 </Name>
130 <ClientName>Nagios_Service_Check</ClientName>
131 <ClientAddress addresstype="dns-port"/>
132 <ServerAddress addresstype="dns-port" />
133 <Flags />
134 <Credentials>
135 <UserName>$PROGNAME</UserName>
136 <Domain>$domain</Domain>
137 </Credentials>
138 </RequestAddress>
139</NFuseProtocol>
140EOR
141
142my $ua = LWP::UserAgent->new ;
143my $req = HTTP::Request->new('POST', "http://$pn_server/scripts/WPnBr.dll") ;
144 $req->content_type('text/xml') ;
145
146my $svr ;
147
148my @pubapp_encoded = map { my $x = $_ ; $x =~ s/(\W)/'&#' . ord($1) . ';'/eg; $x } @pub_apps ;
149
150my $error_tag_cr = sub { ! exists($xml_tag{ErrorId}) } ;
151
152my @app_reqs = (
153 # { Content => url, Ok => ok_condition, Seq => \d+ }
154
155 { Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 0 },
156 { Content => $server_farm_req, Ok => sub {
157 ! exists($xml_tag{ErrorId}) &&
158 exists( $xml_tag{ServerFarmName}) &&
159 defined($xml_tag{ServerFarmName}) &&
160 $xml_tag{ServerFarmName} eq $server_farm
161 }, Seq => 2 },
162 { Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 4 },
163 { Content => $spec_server_farm_req, Ok => sub {
164 ! exists($xml_tag{ErrorId}) &&
165 exists( $xml_tag{ServerAddress}) &&
166 defined($xml_tag{ServerAddress}) &&
167 $xml_tag{ServerAddress} =~ /\d+\.\d+\.\d+\.\d+:\d+/
168 }, Seq => 6 },
169 { Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 8 },
170 { Content => $app_req, Ok => sub {
171 ! exists($xml_tag{ErrorId}) &&
172 exists( $xml_tag{ServerAddress}) &&
173 defined($xml_tag{ServerAddress}) &&
174 (($svr) = split(/:/, $xml_tag{ServerAddress})) &&
175 defined($svr) &&
176 scalar(grep $_ eq $svr, @app_servers)
177 }, Seq => 10 }
178) ;
179
180my $app_location ;
181
182foreach my $pub_app (@pub_apps) {
183
184 my $pubapp_enc = shift @pubapp_encoded ;
185 my $app_req_tmp = $app_reqs[5]{Content} ;
186 $app_reqs[5]{Content} =~ s/PUBLISHED_APP_ENCODED/$pubapp_enc/ ;
187
188 foreach (@app_reqs) {
189
190 $req->content($_->{Content}) ;
191
192 $debug && print STDERR "App: $pub_app Seq: $_->{Seq}\n", $req->as_string, "\n" ;
193
194 my $resp = $ua->request($req) ;
195
196 $debug && print STDERR "App: $pub_app Seq: ", $_->{Seq} + 1, "\n", $resp->as_string, "\n" ;
197
198 $resp->is_error && do {
199 my $err = $resp->as_string ;
200 $err =~ s/\n//g ;
201 &outahere(qq(Failed. HTTP error finding $pub_app at seq $_->{Seq}: "$err")) ;
202 } ;
203 my $xml = $resp->content ;
204
205 my $xml_disp ;
206 ($xml_disp = $xml) =~ s/\n//g ;
207 $xml_disp =~ s/ \s+/ /g ;
208
209 &outahere($resp->as_string)
210 unless $xml ;
211
212 my ($xml_ok, $whine) = &valid_xml($xml_p, $xml) ;
213
214 $xml_ok || &outahere(qq(Failed. Bad XML finding $pub_app at eq $_->{Seq} in "$xml_disp".)) ;
215
216 &{$_->{Ok}} || &outahere(qq(Failed. \"\&\$_->{Ok}\" false finding $pub_app at seq $_->{Seq} in "$xml_disp".)) ;
217
218 # Ugly but alternative is $_->{Ok}->().
219 # eval $_->{Ok} where $_->{Ok} is an
220 # expression returning a bool is possible. but
221 # sub { } prevent recompilation.
222
223 }
224
225 $app_reqs[5]{Content} = $app_req_tmp ;
226
227 $app_location .= qq("$pub_app" => $svr, ) ;
228
229}
230
231substr($app_location, -2, 2) = '' ;
232print qq(Ok. Citrix XML service located all published apps $app_location.\n) ;
233exit $ERRORS{'OK'} ;
234
235sub outahere {
236 print "Citrix XML service $_[0]\n" ;
237 exit $ERRORS{CRITICAL} ;
238}
239
240sub valid_xml {
241 my ($p, $input) = @_ ;
242
243 %xml_tag = () ;
244 @tag_stack = () ;
245
246 eval {
247 $p->parse($input)
248 } ;
249
250 return (0, qq(XML::Parser->parse failed: Bad XML in "$input".!))
251 if $@ ;
252
253 if ( $xml_debug ) {
254 print STDERR pack('A4 A30 A40', ' ', $_, qq(-> "$xml_tag{$_}")), "\n"
255 foreach (keys %xml_tag)
256 }
257
258 return (1, 'valid xml')
259
260}
261
262
263sub handle_start {
264 push @tag_stack, $_[1] ;
265
266 $xml_debug && print STDERR pack('A8 A30 A40', ' ', 'handle_start - tag', " -> '$_[1]'"), "\n" ;
267 $xml_debug && print STDERR pack('A8 A30 A60', ' ', 'handle_start - @tag_stack', " -> (@tag_stack)"), "\n" ;
268}
269
270sub handle_char {
271 my $text = $_[1] ;
272
273 !($text =~ /\S/ || $text =~ /^[ \t]$/) && return ;
274
275 $text =~ s/\n//g ;
276
277 my $tag = $tag_stack[-1] ;
278
279 $xml_debug && print STDERR pack('A8 A30 A30', ' ', 'handle_char - tag', " -> '$tag'"), "\n" ;
280 $xml_debug && print STDERR pack('A8 A30 A40', ' ', 'handle_char - text', " -> '$text'"), "\n" ;
281
282 $xml_tag{$tag} .= $text ;
283
284}
285
286
287sub print_help() {
288
289# 1 2 3 4 5 6 7 8
290#12345678901234567890123456789012345678901234567890123456789012345678901234567890
291
292 print_revision($PROGNAME,'$Revision: 1097 $ ');
293
294my $help = <<EOHELP ;
295Copyright (c) 2004 Karl DeBisschop/S Hopcroft
296
297$PROGNAME -P <pn_server> -S <svr1,svr2,..> -A <app1,app2,..>
298 -F <Farm> [-v -x -h -V]
299
300Check the Citrix Metaframe XP service by completing an HTTP dialogue with a Program
301Neigbourhood server (pn_server) that returns an ICA server in the named Server farm
302hosting the specified applications (an ICA server in a farm which runs some MS app).
303EOHELP
304
305 print $help ;
306 print "\n";
307 print "\n";
308 print_usage();
309 print "\n";
310 support();
311}
312
313sub print_usage () {
314
315# 1 2 3 4 5 6 7 8
316#12345678901234567890123456789012345678901234567890123456789012345678901234567890
317
318my $usage = <<EOUSAGE ;
319$PROGNAME
320[-P | --pn_server] The name or address of the Citrix Metaframe XP
321 Program Neigbourhood server (required).
322[-A | --pub_apps] The name or names of an application published by the
323 server farm (default 'Word 2003').
324[-F | --server_farm] The name of a Citrix Metaframe XP server farm. (required)
325[-S | --app_servers] The _IP addresses_ of _all_ of the Farms ICA servers expected
326 to host the published application.
327 Enter as a comma separated string eg 'Srv1, Svr2, ..,Srvn'.
328 Since the PN servers round-robin the app servers to the clients,
329 _all_ the server farm addresses must be specified or the check
330 will fail (required).
331[-v | --verbose]
332[-h | --help]
333[-x | --xml_debug]
334[-V | --version]
335EOUSAGE
336
337 print $usage ;
338
339}
340
341sub usage {
342 &print_usage ;
343 exit $ERRORS{'OK'} ;
344}
345
346sub version () {
347 print_revision($PROGNAME,'$Revision: 1097 $ ');
348 exit $ERRORS{'OK'};
349}
350
351sub help () {
352 print_help();
353 exit $ERRORS{'OK'};
354}
355
356=begin comment
357
358This is the set of requests and responses transmitted between a Citrix Metaframe XP Program Neigbourhood (PN) client and a PN server.
359
360This dialogue was captured by and reconstructed from tcpdump.
361
362Citrix are not well known for documenting their protocols although the DTD may be informative. Note that the pair(s) 0 and 1, 4 and 5, ...
363do not appear to do anything.
364
365req 0
366POST /scripts/WPnBr.dll HTTP/1.1
367Content-type: text/xml
368Host: 10.1.2.2:80
369Content-Length: 220
370Connection: Keep-Alive
371
372
373<?xml version="1.0" encoding="ISO-8859-1"?>
374<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
375<NFuseProtocol version="1.1"><RequestProtocolInfo><ServerAddress addresstype="dns-port" /></RequestProtocolInfo></NFuseProtocol>
376
377HTTP/1.1 100 Continue
378Server: Citrix Web PN Server
379Date: Thu, 30 Sep 2004 00:12:40 GMT
380
381
382resp 1
383HTTP/1.1 200 OK
384Server: Citrix Web PN Server
385Date: Thu, 30 Sep 2004 00:12:40 GMT
386Content-type: text/xml
387Content-length: 253
388
389
390<?xml version="1.0" encoding="ISO-8859-1" ?>
391<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
392<NFuseProtocol version="1.1">
393 <ResponseProtocolInfo>
394 <ServerAddress addresstype="no-change"></ServerAddress>
395 </ResponseProtocolInfo>
396</NFuseProtocol>
397
398req 2
399POST /scripts/WPnBr.dll HTTP/1.1
400Content-type: text/xml
401Host: 10.1.2.2:80
402Content-Length: 191
403Connection: Keep-Alive
404
405
406<?xml version="1.0" encoding="ISO-8859-1"?>
407<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
408<NFuseProtocol version="1.1"><RequestServerFarmData><Nil /></RequestServerFarmData></NFuseProtocol>
409
410HTTP/1.1 100 Continue
411Server: Citrix Web PN Server
412Date: Thu, 30 Sep 2004 00:12:40 GMT
413
414
415resp 3
416HTTP/1.1 200 OK
417Server: Citrix Web PN Server
418Date: Thu, 30 Sep 2004 00:12:40 GMT
419Content-type: text/xml
420Content-length: 293
421
422
423<?xml version="1.0" encoding="ISO-8859-1" ?>
424<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
425<NFuseProtocol version="1.1">
426 <ResponseServerFarmData>
427 <ServerFarmData>
428 <ServerFarmName>FOOFARM01</ServerFarmName>
429 </ServerFarmData>
430 </ResponseServerFarmData>
431</NFuseProtocol>
432
433req 4
434POST /scripts/WPnBr.dll HTTP/1.1
435Content-type: text/xml
436Host: 10.1.2.2:80
437Content-Length: 220
438Connection: Keep-Alive
439
440
441<?xml version="1.0" encoding="ISO-8859-1"?>
442<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
443<NFuseProtocol version="1.1"><RequestProtocolInfo><ServerAddress addresstype="dns-port" /></RequestProtocolInfo></NFuseProtocol>
444
445HTTP/1.1 100 Continue
446Server: Citrix Web PN Server
447Date: Thu, 30 Sep 2004 00:12:55 GMT
448
449
450resp 5
451HTTP/1.1 200 OK
452Server: Citrix Web PN Server
453Date: Thu, 30 Sep 2004 00:12:55 GMT
454Content-type: text/xml
455Content-length: 253
456
457
458<?xml version="1.0" encoding="ISO-8859-1" ?>
459<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
460<NFuseProtocol version="1.1">
461 <ResponseProtocolInfo>
462 <ServerAddress addresstype="no-change"></ServerAddress>
463 </ResponseProtocolInfo>
464</NFuseProtocol>
465
466req 6
467POST /scripts/WPnBr.dll HTTP/1.1
468Content-type: text/xml
469Host: 10.1.2.2:80
470Content-Length: 442
471Connection: Keep-Alive
472
473
474<?xml version="1.0" encoding="ISO-8859-1"?>
475<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
476<NFuseProtocol version="1.1">
477<RequestAddress><Name>i
478 <UnspecifiedName>FOOFARM01*</UnspecifiedName>
479 </Name><ClientName>WS09535</ClientName>
480 <ClientAddress addresstype="dns-port" />
481 <ServerAddress addresstype="dns-port" />
482 <Flags />
483 <Credentials>
484 <UserName>foo-user</UserName>
485 <Domain>some-domain</Domain>
486 </Credentials>
487</RequestAddress></NFuseProtocol>
488
489HTTP/1.1 100 Continue
490Server: Citrix Web PN Server
491Date: Thu, 30 Sep 2004 00:12:56 GMT
492
493
494resp 7
495HTTP/1.1 200 OK
496Server: Citrix Web PN Server
497Date: Thu, 30 Sep 2004 00:12:56 GMT
498Content-type: text/xml
499Content-length: 507
500
501
502<?xml version="1.0" encoding="ISO-8859-1" ?>
503<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
504<NFuseProtocol version="1.1">
505 <ResponseAddress>
506 <ServerAddress addresstype="dot-port">10.1.2.2:1494</ServerAddress>
507 <ServerType>win32</ServerType>
508 <ConnectionType>tcp</ConnectionType>
509 <ClientType>ica30</ClientType>
510 <TicketTag>10.1.2.2</TicketTag>
511 <SSLRelayAddress addresstype="dns-port">ica_svr01.some.domain:443</SSLRelayAddress>
512 </ResponseAddress>
513</NFuseProtocol>
514
515req 8
516POST /scripts/WPnBr.dll HTTP/1.1
517Content-type: text/xml
518Host: 10.1.2.2:80
519Content-Length: 220
520Connection: Keep-Alive
521
522
523<?xml version="1.0" encoding="ISO-8859-1"?>
524<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
525<NFuseProtocol version="1.1"><RequestProtocolInfo><ServerAddress addresstype="dns-port" /></RequestProtocolInfo></NFuseProtocol>
526
527HTTP/1.1 100 Continue
528Server: Citrix Web PN Server
529Date: Thu, 30 Sep 2004 00:13:29 GMT
530
531
532resp 9
533HTTP/1.1 200 OK
534Server: Citrix Web PN Server
535Date: Thu, 30 Sep 2004 00:13:29 GMT
536Content-type: text/xml
537Content-length: 253
538
539
540<?xml version="1.0" encoding="ISO-8859-1" ?>
541<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
542<NFuseProtocol version="1.1">
543 <ResponseProtocolInfo>
544 <ServerAddress addresstype="no-change"></ServerAddress>
545 </ResponseProtocolInfo>
546</NFuseProtocol>
547
548req 10
549POST /scripts/WPnBr.dll HTTP/1.1
550Content-type: text/xml
551Host: 10.1.2.2:80
552Content-Length: 446
553Connection: Keep-Alive
554
555
556<?xml version="1.0" encoding="ISO-8859-1"?>
557<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
558<NFuseProtocol version="1.1">
559<RequestAddress>i
560 <Name>
561 <UnspecifiedName>EXCEL#32;2003</UnspecifiedName>
562 </Name>
563 <ClientName>WS09535</ClientName>
564 <ClientAddress addresstype="dns-port" />
565 <ServerAddress addresstype="dns-port" />
566 <Flags />
567 <Credentials><UserName>foo-user</UserName>
568 <Domain>some-domain</Domain>
569 </Credentials>
570</RequestAddress>i
571</NFuseProtocol>
572
573HTTP/1.1 100 Continue
574Server: Citrix Web PN Server
575Date: Thu, 30 Sep 2004 00:13:29 GMT
576
577
578resp 11
579HTTP/1.1 200 OK
580Server: Citrix Web PN Server
581Date: Thu, 30 Sep 2004 00:13:29 GMT
582Content-type: text/xml
583Content-length: 509
584
585
586<?xml version="1.0" encoding="ISO-8859-1" ?>
587<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
588<NFuseProtocol version="1.1">
589 <ResponseAddress>
590 <ServerAddress addresstype="dot-port">10.1.2.14:1494</ServerAddress>
591 <ServerType>win32</ServerType>
592 <ConnectionType>tcp</ConnectionType>
593 <ClientType>ica30</ClientType>
594 <TicketTag>10.1.2.14</TicketTag>
595 <SSLRelayAddress addresstype="dns-port">ica_svr02.some.domain:443</SSLRelayAddress>
596 </ResponseAddress>
597</NFuseProtocol>
598
599** One sees this XML on an error (there may well be other error XML also, but I haven't seen it) **
600
601<?xml version="1.0" encoding="ISO-8859-1" ?>
602<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd">
603<NFuseProtocol version="1.1">
604 <ResponseAddress>
605 <ErrorId>unspecified</ErrorId>
606 <BrowserError>0x0000000E</BrowserError>
607 </ResponseAddress>
608</NFuseProtocol>
609
610
611=end comment
612
613=cut
614
615
616# You never know when you may be embedded ...
617
618
diff --git a/contrib/check_inodes-freebsd.pl b/contrib/check_inodes-freebsd.pl
deleted file mode 100644
index d66e5e3..0000000
--- a/contrib/check_inodes-freebsd.pl
+++ /dev/null
@@ -1,127 +0,0 @@
1#!/usr/bin/perl
2
3# check_inodes.pl for FreeBSD
4# Designed on FreeBSD 4.6 (although this should not matter)
5# parses df output, splits, and then takes variables
6# df.pl -f mountpoint -w warningnumber -c critical number
7# USE NUMBERS AND NOT PERCENTS FOR wanring and critical values
8# -h is help
9# -v is version
10# Mountpoints:
11# like / or /usr or /var (whatever you mount drives NOT the device names)
12# Andrew Ryder - 20020804 - atr@mrcoffee.org
13
14
15use strict;
16use Getopt::Long;
17use vars qw($opt_V $opt_h $opt_w $opt_c $opt_f $verbose $PROGNAME);
18use lib "/usr/local/libexec/nagios" ;
19use utils qw($TIMEOUT %ERRORS &print_revision &support);
20
21my $df = "/bin/df";
22my $grep = "/usr/bin/grep";
23
24$PROGNAME="df.pl";
25
26sub print_help ();
27sub print_usage ();
28
29
30$ENV{'PATH'}='';
31$ENV{'BASH_ENV'}='';
32$ENV{'ENV'}='';
33
34Getopt::Long::Configure('bundling');
35GetOptions
36 ("V" => \$opt_V, "version" => \$opt_V,
37 "h" => \$opt_h, "help" => \$opt_h,
38 "w=s" => \$opt_w, "warning=s" => \$opt_w,
39 "c=s" => \$opt_c, "critical=s" => \$opt_c,
40 "f=s" => \$opt_f, "filesystem=s" => \$opt_f);
41
42
43if ($opt_V) {
44 print_revision($PROGNAME,'$Revision: 72 $ ');
45 exit $ERRORS{'OK'};
46}
47
48if ($opt_h) {
49 print_help();
50 exit $ERRORS{'OK'};
51}
52
53($opt_w) || ($opt_w = shift) || ($opt_w = 50);
54my $warning = $1 if ($opt_w =~ /([0-9]+)/);
55
56($opt_c) || ($opt_c = shift) || ($opt_c = 75);
57my $critical = $1 if ($opt_c =~ /([0-9]+)/);
58
59if ($opt_c < $opt_w) {
60 print "Critical offset should be larger than warning offset\n";
61 print_usage();
62 exit $ERRORS{"UNKNOWN"};
63}
64
65($opt_f) || ($opt_f = "/");
66
67
68unless (-e $df) {
69 print "UNKNOWN: $df is not where df is\n";
70 exit $ERRORS{'UNKNOWN'};
71 }
72
73unless (-e $grep) {
74 print "UNKNOWN: $grep is not where grep is\n";
75 exit $ERRORS{'UNKNOWN'};
76 }
77
78unless (-d $opt_f) {
79 print "UNKNOWN: $opt_f is not a mount point\n";
80 exit $ERRORS{'UNKNOWN'};
81 }
82
83
84my $state = $ERRORS{'UNKNOWN'};
85my $answer;
86
87open(DF, "$df -i $opt_f| $grep -v Filesystem |");
88
89while (<DF>) {
90
91 my ($fs,$onek,$used,$avail,$capacity,$iused,$ifree,$ipercent,$mounted) = split;
92 $ipercent =~ s/%//s;
93
94 if ($ipercent > $opt_w) {
95 $state = $ERRORS{'WARNING'};
96 $answer = "WARNING: $ipercent percent inodes free on $opt_f\n";
97 } elsif ($ipercent > $opt_w) {
98 $state = $ERRORS{'CRITCAL'};
99 $answer = "CRITICAL: $ipercent percent inodes free on $opt_f\n";
100 } elsif ($ipercent < $opt_w) {
101 $state = $ERRORS{'OK'};
102 $answer = "OK: $ipercent percent inodes free on $opt_f\n";
103 }
104}
105
106close(DF);
107
108print "$answer";
109exit $state;
110
111sub print_usage () {
112 print "Usage: $PROGNAME <filesystem> [-w <warn>] [-c <crit>]\n";
113 print "Example: $PROGNAME /dev/ad0s1a -w 50 -c 75\n";
114}
115
116sub print_help () {
117 print_revision($PROGNAME,'$Revision: 72 $');
118 print "Copyright (c) 2002 Andrew Ryder\n";
119 print "\n";
120 print_usage();
121 print "\n";
122 print "<warn> = Inode Percent at which a warning message is returned. Defaults to 50.\n";
123 print "<crit> = Inode Percent at which a critical message is returned..\n Defaults to 75.\n\n";
124 support();
125}
126
127
diff --git a/contrib/check_inodes.pl b/contrib/check_inodes.pl
deleted file mode 100755
index 5767878..0000000
--- a/contrib/check_inodes.pl
+++ /dev/null
@@ -1,69 +0,0 @@
1#!/usr/bin/perl
2##############################################################################
3# This plugin uses df to gather filesystem statistics and check the percent #
4# used of inodes. I've put a switch in here since i've got both aix and #
5# linux systems...adjust for your syntax's results. #
6# Note: the percentages passed in MUST NOT have % after them #
7# No warranty is either implied, nor expressed herein. #
8# #
9##############################################################################
10
11$filesystem = $ARGV[0];
12$warnpercent = $ARGV[1];
13$critpercent = $ARGV[2];
14
15#------Find out what kind of syntax to expect
16$systype=`uname`;
17chomp($systype);
18
19#------Make sure we got called with the right number of arguments
20#------you could also put a check in here to make sure critical level is
21#------greater than warning...but what the heck.
22die "Usage: check_inodes filesystem warnpercent critpercent" unless @ARGV;
23
24if ($#ARGV < 2) {
25 die "Usage: check_inodes filesystem warnpercent critpercent";
26}#end if
27
28#------This gets the data from the df command
29$inputline = `df -i $filesystem|grep -v "Filesystem"`;
30
31#------replaces all spaces with a single :, that way we can use split
32$inputline =~ y/ /:/s;
33
34#------different oses give back different sets of columns from the df -i
35#------(at least mine do). This way I can use this plugin on all my hosts
36#------if neither of these work, add your own in, or if you've got one that
37#------just flat out reports something different...well...perl is your friend.
38SWITCH: {
39 if ($systype eq "Linux") {
40 ($fs,$inodes,$iused,$ifree,$ipercent,$mntpt) = split(/:/,$inputline);
41 last SWITCH;
42 }#end if
43 if ($systype eq "AIX") {
44 ($fs,$blks,$free,$percentused,$iused,$ipercent,$mntpt) = split(/:/,$inputline);
45 last SWITCH;
46 }#end if
47}#end switch
48
49#------First we check for critical, since that is, by definition and convention
50#------going to exceed the warning threshold
51$ipercent =~ y/%//ds;
52
53if ($ipercent > $critpercent) {
54 print "CRITICAL: $filesystem inode use exceeds critical threshold $critpercent ($ipercent)";
55 exit 1;
56}# end if
57
58#------Next we check the warning threshold
59if ($ipercent > $warnpercent) {
60 print "WARNING: $filesystem inode use exceeds warning threshold $warnpercent ($ipercent)";
61 exit 2;
62}# end if
63
64
65#------thanks to the magic of procedural programming, we figure if we got here,
66#------everything MUST be fine.
67print "$filesystem inode use within limits ($ipercent)";
68exit 0;
69
diff --git a/contrib/check_ipxping.c b/contrib/check_ipxping.c
deleted file mode 100644
index 937b921..0000000
--- a/contrib/check_ipxping.c
+++ /dev/null
@@ -1,201 +0,0 @@
1/******************************************************************************************
2 *
3 * CHECK_IPXPING.C
4 *
5 * Program: IPX ping plugin for Nagios
6 * License: GPL
7 * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
8 *
9 * Last Modified: 09-24-1999
10 *
11 * Command line: CHECK_IPXPING <dest_network> <dest_address> <wrtt> <crtt>
12 *
13 * Description:
14 *
15 * This plugin will use the /usr/bin/ipxping command to ping the specified host using the
16 * IPX protocol. Note: Linux users must have IPX support compiled into the kernerl and
17 * must have IPX configured correctly in order for this plugin to work.
18 * If the round trip time value is above the <wrtt> level, a STATE_WARNING is
19 * returned. If it exceeds the <crtt> level, a STATE_CRITICAL is returned.
20 *
21 *
22 *
23 * IMPORTANT!!
24 *
25 * This plugin will only work with the ipxping command that has been ported to Linux.
26 * The version for Sun takes different command line arguments and differs in its output.
27 *
28 *****************************************************************************************/
29
30#include "config.h"
31#include "common.h"
32#include "netutils.h"
33#include "popen.h"
34
35/* this should be moved out to the configure script! */
36#define IPXPING_COMMAND "/tmp/ipxping/ipxping"
37
38/* these should be moved to the common header file */
39#define MAX_IPXNET_ADDRESS_LENGTH 12
40#define MAX_IPXHOST_ADDRESS_LENGTH 18
41
42int socket_timeout=DEFAULT_SOCKET_TIMEOUT;
43char dest_network[MAX_IPXNET_ADDRESS_LENGTH];
44char dest_address[MAX_IPXHOST_ADDRESS_LENGTH];
45int wrtt;
46int crtt;
47
48int process_arguments(int,char **);
49
50FILE * spopen(const char *);
51int spclose(FILE *);
52
53int main(int argc, char **argv){
54 char command_line[MAX_INPUT_BUFFER];
55 int rtt;
56 int bytes_returned;
57 int result=STATE_OK;
58 FILE *fp;
59 char input_buffer[MAX_INPUT_BUFFER];
60 char *substr;
61 int current_line;
62
63 if(process_arguments(argc,argv)!=OK){
64 printf("Incorrect arguments supplied\n");
65 printf("\n");
66 printf("IPX ping plugin for Nagios\n");
67 printf("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n");
68 printf("Last Modified: 09-24-1999\n");
69 printf("License: GPL\n");
70 printf("\n");
71 printf("Usage: %s <dest_network> <dest_address> <wrtt> <crtt> [-to to_sec]\n",argv[0]);
72 printf("\n");
73 printf("Options:\n");
74 printf(" <dest_network> = IPX network that the remote host lies on. (Hex Format - 00:00:00:00)\n");
75 printf(" <dest_address> = MAC address of the remote host. (Hex Format - 00:00:00:00:00:00)\n");
76 printf(" <wrtt> = Round trip time in milliseconds necessary to result in a WARNING state\n");
77 printf(" <crtt> = Round trip time in milliseconds necessary to result in a CRITICAL state\n");
78 printf(" [to_sec] = Seconds before we should timeout waiting for ping result. Default = %d sec\n",DEFAULT_SOCKET_TIMEOUT);
79 printf("\n");
80 printf("Notes:\n");
81 printf("This plugin will use the /usr/bin/ipxping command to ping the specified host using\n");
82 printf("the IPX protocol. IPX support must be compiled into the kernel and your host must\n");
83 printf("be correctly configured to use IPX before this plugin will work! An RPM package of\n");
84 printf("the ipxping binary can be found at...\n");
85 printf("http://www.rpmfind.net/linux/RPM/contrib/libc5/i386/ipxping-0.0-2.i386.shtml\n");
86 printf("\n");
87 return STATE_UNKNOWN;
88 }
89
90 /* create the command line to use... */
91 sprintf(command_line,"%s %s %s",IPXPING_COMMAND,dest_network,dest_address);
92
93 /* initialize alarm signal handling */
94 signal(SIGALRM,socket_timeout_alarm_handler);
95
96 /* set socket timeout */
97 alarm(socket_timeout);
98
99 /* run the command */
100 fp = spopen(command_line);
101 if(fp==NULL){
102 printf("Unable to open pipe: %s",command_line);
103 return STATE_UNKNOWN;
104 }
105
106 current_line=0;
107 while(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){
108
109 current_line++;
110
111 /* skip the first line of the output */
112 if(current_line==1)
113 continue;
114
115 /* we didn't get the "is alive" */
116 if(current_line==2 && !strstr(input_buffer,"is alive"))
117 result=STATE_CRITICAL;
118
119 /* get the round trip time */
120 if(current_line==3){
121 substr=strtok(input_buffer,":");
122 substr=strtok(NULL,"\n");
123 rtt=atoi(substr);
124 }
125
126 /* get the number of bytes returned */
127 if(current_line==4 && strstr(input_buffer,"bytes returned")){
128 bytes_returned=atoi(input_buffer);
129 }
130 }
131
132 /* close the pipe */
133 spclose(fp);
134
135 /* reset the alarm */
136 alarm(0);
137
138 if(current_line==1 || result==STATE_CRITICAL)
139 printf("IPX Ping problem - No response from host\n");
140 else{
141
142 if(rtt>crtt)
143 result=STATE_CRITICAL;
144 else if(rtt>wrtt)
145 result=STATE_WARNING;
146
147 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);
148 }
149
150
151 return result;
152 }
153
154
155
156/* process all arguments passed on the command line */
157int process_arguments(int argc, char **argv){
158 int x;
159
160 /* no options were supplied */
161 if(argc<5)
162 return ERROR;
163
164 /* get the destination network address */
165 strncpy(dest_network,argv[1],sizeof(dest_network)-1);
166 dest_network[sizeof(dest_network)-1]='\x0';
167
168 /* get the destination host address */
169 strncpy(dest_address,argv[2],sizeof(dest_address)-1);
170 dest_address[sizeof(dest_address)-1]='\x0';
171
172 /* get the round trip time variables */
173 wrtt=atoi(argv[3]);
174 crtt=atoi(argv[4]);
175
176 /* process remaining arguments */
177 for(x=6;x<=argc;x++){
178
179 /* we got the timeout to use */
180 if(!strcmp(argv[x-1],"-to")){
181 if(x<argc){
182 socket_timeout=atoi(argv[x]);
183 if(socket_timeout<=0)
184 return ERROR;
185 x++;
186 }
187 else
188 return ERROR;
189 }
190
191 /* else we got something else... */
192 else
193 return ERROR;
194 }
195
196 return OK;
197 }
198
199
200
201
diff --git a/contrib/check_javaproc.pl b/contrib/check_javaproc.pl
deleted file mode 100644
index b68764e..0000000
--- a/contrib/check_javaproc.pl
+++ /dev/null
@@ -1,278 +0,0 @@
1#!/usr/bin/perl -w
2
3#
4# Author: Wim Rijnders, 17-10-2002
5#
6# Description:
7# -----------
8#
9# Nagios host script to check if any specified java processes are running.
10#
11# Implementation Notes:
12# ---------------------
13#
14# check_disk_smb was used as a starting point, since it was written in perl.
15#
16# This script has been created and tested on Linux RH 7.1.
17#
18# I tried OS-X Darwin (BSD), but the ps command works differently.
19# Notably, you can't get a combined list of child processes. The best approach
20# appears to be to use 'ps -wwaxo command' combined with 'ps -M' (or suchlike)
21#
22########################################################################
23####
24
25require 5.004;
26use POSIX;
27use strict;
28use Getopt::Long;
29use vars qw($opt_w $opt_c $verbose $classname);
30use vars qw($PROGNAME);
31use lib "utils.pm" ;
32use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
33
34$PROGNAME="check_javaprocs";
35sub getJavaList ();
36sub check_ranges ($ $ $ $);
37
38Getopt::Long::Configure('bundling', 'no_ignore_case');
39GetOptions
40 ("V|version" => \&version,
41 "h|help" => \&help,
42 "v|verbose" => \$verbose,
43 "w|warning=s" => \$opt_w,
44 "c|critical=s" => \$opt_c,
45 "n|name=s" => \$classname
46 );
47
48
49my $state = 'OK';
50my $min_warn = undef
51my $max_warn = undef;
52my $min_crit = undef;
53my $max_crit = undef;
54
55
56($opt_w) || ($opt_w = shift);
57check_ranges($opt_w,\$min_warn, \$max_warn, "warning");
58($opt_c) || ($opt_c = shift);
59check_ranges($opt_c,\$min_crit, \$max_crit, "critical");
60
61
62#
63# Determine # of running processes for the java programs that interest us.
64#
65my @javalist = getJavaList();
66
67my $total = 0;
68my $msgout = "";
69my @fields;
70
71if ( defined $classname ) {
72
73 #filter out a single java process based on class name
74 foreach (@javalist) {
75 @fields = split(/\s+/, $_);
76 $total = $fields[-1] and last if $classname eq $fields[0];
77 }
78 $msgout .= "$total processes for $classname\n";
79} else {
80 #Handle all java processes
81 $msgout .= "\n";
82 foreach (@javalist) {
83 @fields = split(/\s+/, $_);
84
85 $total += $fields[-1];
86 $msgout .= " $fields[-1] processes for ";
87 $msgout .= (scalar @fields > 1)? $fields[0] : "unknown" ;
88 $msgout .= "\n";
89 }
90 my $msgtotal = "$total java processes for ". scalar @javalist . " applications";
91
92 if ( defined $verbose ) {
93 $msgout = $msgtotal . $msgout;
94 } else {
95 $msgout = $msgtotal;
96 }
97
98}
99
100#
101# Set the state with the data we now have accumulated
102# Note that due to the order of testing, warnings have precedence over
103# criticals. This is logical, since you should be able to create a criticals
104# range which encompasses a warning range. eg. following should be possible:
105#
106# check_javaproc -w 5:10 -c 3:12
107# proper specification of the ranges is the responsibility of the script user.
108#
109$state = 'CRITICAL' if (defined $min_crit && $total < $min_crit);
110$state = 'CRITICAL' if (defined $max_crit && $total > $max_crit);
111$state = 'CRITICAL' if (!defined $min_crit && !defined $max_crit && $total==0 );
112$state = 'WARNING' if (defined $min_warn && $total < $min_warn);
113$state = 'WARNING' if (defined $max_warn && $total > $max_warn);
114
115print $msgout;
116print "$state\n" if ($verbose);
117exit $ERRORS{$state};
118
119###################################
120# Support routines for Nagios
121###################################
122sub check_ranges($$$$) {
123 my ($opt, $min, $max, $rangename) = @_;
124
125 if ( defined $opt ) {
126 if ( $opt =~ /^([0-9]*)\:([0-9]*)$/) {
127 $$min = $1 if $1 > 0;
128 $$max= $2 if $2 > 0;
129 } else {
130 usage("Invalid $rangename range: $opt\n");
131 }
132 }
133
134 if ( defined $$min && defined $$max ) {
135 usage("Min value of $rangename range larger than max value: $opt\n") if ( $$min > $$max);
136 }
137}
138
139sub print_usage () {
140 print "Usage: $PROGNAME [-v] [-w <min:max>] [-c <min:max>] [ -n <classname>]\n";
141}
142
143sub print_help () {
144 revision();
145 print "Copyright (c) 2002 by Wim Rijnders
146
147Perl Check java processes plugin for Nagios
148
149";
150 print_usage();
151 print "
152-v, --verbose
153 Return additional information.
154 Intended as a command-line aid, not recommended for Nagios script usage.
155
156-w, --warning=INTEGER:INTEGER
157 Minimum and maximum number of processes outside of which a warning will be
158 generated. If omitted, no warning is generated.
159
160-c, --critical=INTEGER:INTEGER
161 Minimum and maximum number of processes outside of which a critical will be
162 generated. If omitted, a critical is generated if no processes are running.
163
164-n, --name=STRING
165 Name of class specified on the java command line (from which main() is run).
166 If omitted, all java processes are taken into account.
167
168";
169 support();
170}
171
172sub revision() {
173 print_revision($PROGNAME,'$Revision: 211 $ ');
174}
175
176sub version () {
177 revision();
178 exit $ERRORS{'OK'};
179}
180
181sub help () {
182 print_help();
183 exit $ERRORS{'OK'};
184}
185
186###################################
187# Routines for delivering the data
188###################################
189
190#
191# Generate a formatted list of running java processes.
192#
193# Returns an array of strings having the following syntax:
194#
195# <java class running as main> <parameters if any> <#processes for this class>
196#
197sub getJavaList() {
198
199 my @output;
200
201 # Untaint
202 local $ENV{'PATH'} = '/bin:/usr/bin';
203 local $ENV{'BASH_ENV'} = '~/.bashrc';
204
205 # We are only interested in the full command line
206 # The -H opstion is important for the order of the processes;
207 # this option ensures that all child processes are listed under
208 # their parents
209 @output=`ps -AHo \"\%a\" -ww`;
210
211 #remove preceding whitespace and final EOL
212 foreach (@output) {
213 s/^\s*//;
214 chop;
215 }
216
217 #Combine any consecutive processes with exactly the same command line
218 #into a single item
219 @output = checkSameLine(@output);
220
221 #Filter out all java processes
222 my @javalist;
223 for (my $i = 0; $i < scalar @output; ++$i) {
224 push @javalist, $output[$i] if $output[$i] =~ /^\S*java/;
225 }
226
227 foreach (@javalist) {
228 #The java statement at the beginning is redundant; remove it
229 s/^\S*java//;
230
231 #remove all defines
232 s/\-D\S+//g;
233
234 #remove classpath
235 s/\-(classpath|cp)\s+\S+//g;
236
237 #remove any other parameters we don't want to see
238 s/\-server\s+//g;
239 s/\-X\S*\s+//g;
240
241 #remove any redundant whitespaces at the beginning
242 s/^\s+//;
243
244 }
245
246 @javalist;
247}
248
249
250#
251# Combine all consecutive lines with an identical command line
252# to a signle line with a count at the end
253#
254sub checkSameLine {
255 my @input = @_;
256 my @output;
257 my $prevline= "";
258 my $prevcount = 0;
259
260 foreach my $a (@input) {
261 if ( $prevline eq $a) {
262 ++$prevcount;
263 } else {
264 push @output, $prevline . " " . ($prevcount + 1);
265 $prevcount = 0;
266 }
267 $prevline = $a;
268 }
269
270 #don't forget the last item!
271 if ( $prevcount > 0 ) {
272 push @output, $prevline . " " . ($prevcount + 1);
273 }
274
275 @output;
276}
277
278#======= end check_javaproc =====
diff --git a/contrib/check_joy.sh b/contrib/check_joy.sh
deleted file mode 100755
index 8783a59..0000000
--- a/contrib/check_joy.sh
+++ /dev/null
@@ -1,69 +0,0 @@
1#! /bin/sh
2
3PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
4
5PROGNAME=`basename $0`
6PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
7REVISION=`echo '$Revision: 2 $' | sed -e 's/[^0-9.]//g'`
8STATUS=""
9
10. $PROGPATH/utils.sh
11
12
13print_usage() {
14 echo "Usage: $PROGNAME /dev/js<#> <button #>"
15}
16
17print_help() {
18 print_revision $PROGNAME $REVISION
19 echo ""
20 print_usage
21 echo ""
22 echo "This plugin checks a joystick button status using the "
23 echo "joyreadbutton utility from the joyd package."
24 echo ""
25 support
26 exit 0
27}
28
29if [ $# -ne 2 ]; then
30 print_usage
31 exit 0
32fi
33
34case "$1" in
35 --help)
36 print_help
37 exit 0
38 ;;
39 -h)
40 print_help
41 exit 0
42 ;;
43 --version)
44 print_revision $PROGNAME $REVISION
45 exit 0
46 ;;
47 -V)
48 print_revision $PROGNAME $REVISION
49 exit 0
50 ;;
51 /dev/js*)
52 joyreadbutton $1 $2 1>&1 1>/dev/null
53 STATUS=$?
54 if [ "$STATUS" -eq 0 ]; then
55 echo OK
56 exit 0
57 elif [ "$STATUS" -eq 1 ];then
58 echo CRITICAL
59 exit 2
60 else
61 echo UNKNOWN
62 exit -1
63 fi
64 ;;
65 *)
66 print_usage
67 exit 0
68 ;;
69esac
diff --git a/contrib/check_linux_raid.pl b/contrib/check_linux_raid.pl
deleted file mode 100644
index 6650a42..0000000
--- a/contrib/check_linux_raid.pl
+++ /dev/null
@@ -1,125 +0,0 @@
1#!/usr/bin/perl -w
2
3# Copyright (c) 2002 ISOMEDIA, Inc.
4# originally written by Steve Milton
5# later updates by sean finney <seanius@seanius.net>
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20#
21# Usage: check_raid [raid-name]
22# Example: check_raid md0
23# WARNING md0 status=[UUU_U], recovery=46.4%, finish=123.0min
24
25use strict;
26use lib "/usr/local/nagios/libexec";
27use utils qw(%ERRORS);
28
29# die with an error if we're not on Linux
30if ($^O ne 'linux') {
31 print "This plugin only applicable on Linux.\n";
32 exit $ERRORS{'UNKNOWN'};
33}
34
35sub max_state($$){
36 my ($a, $b) = @_;
37 if ($a eq "CRITICAL" || $b eq "CRITICAL") { return "CRITICAL"; }
38 elsif ($a eq "WARNING" || $b eq "WARNING") { return "WARNING"; }
39 elsif ($a eq "OK" || $b eq "OK") { return "OK"; }
40 elsif ($a eq "UNKNOWN" || $b eq "UNKNOWN") { return "UNKNOWN"; }
41 elsif ($a eq "DEPENDENT" || $b eq "DEPENDENT") { return "DEPENDENT"; }
42 return "UNKNOWN";
43}
44
45my $nextdev;
46if(defined $ARGV[0]) { $nextdev = shift; }
47else { $nextdev = "md[0-9]+"; }
48
49my $code = "UNKNOWN";
50my $msg = "";
51my %status;
52my %recovery;
53my %resyncing;
54my %finish;
55my %active;
56my %devices;
57
58while(defined $nextdev){
59 open (MDSTAT, "< /proc/mdstat") or die "Failed to open /proc/mdstat";
60 my $device = undef;
61 while(<MDSTAT>) {
62 if (defined $device) {
63 if (/(\[[_U]+\])/) {
64 $status{$device} = $1;
65 } elsif (/recovery =\s+(.*?)\s/) {
66 $recovery{$device} = $1;
67 ($finish{$device}) = /finish=(.*?min)/;
68 $device=undef;
69 } elsif (/resync =\s+(.*?)\s/) {
70 $resyncing{$device} = $1;
71 ($finish{$device}) = /finish=(.*?min)/;
72 $device=undef;
73 } elsif (/^\s*$/) {
74 $device=undef;
75 }
76 } elsif (/^($nextdev)\s*:/) {
77 $device=$1;
78 $devices{$device}=$device;
79 if (/\sactive/) {
80 $status{$device} = ''; # Shall be filled later if available
81 $active{$device} = 1;
82 }
83 }
84 }
85 $nextdev = shift;
86}
87
88foreach my $k (sort keys %devices){
89 if (!exists($status{$k})) {
90 $msg .= sprintf " %s inactive with no status information.",
91 $devices{$k};
92 $code = max_state($code, "CRITICAL");
93 } elsif ($status{$k} =~ /_/) {
94 if (defined $recovery{$k}) {
95 $msg .= sprintf " %s status=%s, recovery=%s, finish=%s.",
96 $devices{$k}, $status{$k}, $recovery{$k}, $finish{$k};
97 $code = max_state($code, "WARNING");
98 } else {
99 $msg .= sprintf " %s status=%s.", $devices{$k}, $status{$k};
100 $code = max_state($code, "CRITICAL");
101 }
102 } elsif ($status{$k} =~ /U+/) {
103 if (defined $resyncing{$k}) {
104 $msg .= sprintf " %s status=%s, resync=%s, finish=%s.",
105 $devices{$k}, $status{$k}, $resyncing{$k}, $finish{$k};
106 $code = max_state($code, "WARNING");
107 } else {
108 $msg .= sprintf " %s status=%s.", $devices{$k}, $status{$k};
109 $code = max_state($code, "OK");
110 }
111 } else {
112 if ($active{$k}) {
113 $msg .= sprintf " %s active with no status information.",
114 $devices{$k};
115 $code = max_state($code, "OK");
116 } else {
117 # This should't run anymore, but is left as a catch-all
118 $msg .= sprintf " %s does not exist.\n", $devices{$k};
119 $code = max_state($code, "CRITICAL");
120 }
121 }
122}
123
124print $code, $msg, "\n";
125exit ($ERRORS{$code});
diff --git a/contrib/check_lmmon.pl b/contrib/check_lmmon.pl
deleted file mode 100644
index bf4b438..0000000
--- a/contrib/check_lmmon.pl
+++ /dev/null
@@ -1,19 +0,0 @@
1#!/usr/bin/perl
2# NetSaint Temp warning script
3# Written by: Nathan LeSueur
4
5if ($#ARGV < 1) {
6print "Usage: $0 <critical temp> <warning temp> <normal temp>\n";
7exit; } $crit = shift; $warn = shift; $norm = shift; if ($warn >
8$crit) { print "Warning level cannot be greater than critical
9level!\n"; exit; } @b = qx{/usr/local/bin/lmmon -s}; foreach(@b) { @c
10= split(/ \/ /, $_); $d = $c[1]; } @e = split(/F/, $d); $f = $e[0];
11
12$status = "$f degrees F\n";
13
14if($f >= $crit) {print "CRITICAL - $status"; exit 2;}
15if($f >= $warn) {print "WARNING - $status"; exit 1;}
16if($f <= $norm && $f != 0) {print "OK - $status"; exit 0;}
17else{print "UNKNOWN - unable to access smb\n"; exit (-1);}
18
19
diff --git a/contrib/check_log2.pl b/contrib/check_log2.pl
deleted file mode 100644
index f1533a0..0000000
--- a/contrib/check_log2.pl
+++ /dev/null
@@ -1,202 +0,0 @@
1#!/usr/bin/perl -w
2#
3# $Id: check_log2.pl 1300 2005-12-16 18:41:45Z harpermann $
4#
5# Log file regular expression detector for Nagios.
6# Written by Aaron Bostick (abostick@mydoconline.com)
7# Last modified: 05-02-2002
8#
9# Thanks and acknowledgements to Ethan Galstad for Nagios and the check_log
10# plugin this is modeled after.
11#
12# Usage: check_log2 -l <log_file> -s <seek_file> -p <pattern> [-n <negpattern>]
13#
14# Description:
15#
16# This plugin will scan arbitrary text files looking for regular expression
17# matches. The text file to scan is specified with <log_file>.
18# <log_seek_file> is a temporary file used to store the seek byte position
19# of the last scan. This file will be created automatically on the first
20# scan. <pattern> can be any RE pattern that perl's s/// syntax accepte. Be
21# forewarned that a bad pattern will send this script into never never land!
22#
23# Output:
24#
25# This plugin returns OK when a file is successfully scanned and no pattern
26# matches are found. WARNING is returned when 1 or more patterns are found
27# along with the pattern count and the line of the last pattern matched.
28# CRITICAL is returned when an error occurs, such as file not found, etc.
29#
30# Notes (paraphrased from check_log's notes):
31#
32# 1. The "max_attempts" value for the service should be 1, as this
33# will prevent Nagios from retrying the service check (the
34# next time the check is run it will not produce the same results).
35#
36# 2. The "notify_recovery" value for the service should be 0, so that
37# Nagios does not notify you of "recoveries" for the check. Since
38# pattern matches in the log file will only be reported once and not
39# the next time, there will always be "recoveries" for the service, even
40# though recoveries really don't apply to this type of check.
41#
42# 3. You *must* supply a different <log_Seek_file> for each service that
43# you define to use this plugin script - even if the different services
44# check the same <log_file> for pattern matches. This is necessary
45# because of the way the script operates.
46#
47# Examples:
48#
49# Check for error notices in messages
50# check_log2 -l /var/log/messages -s ./check_log2.messages.seek -p 'err'
51#
52
53
54BEGIN {
55 if ($0 =~ s/^(.*?)[\/\\]([^\/\\]+)$//) {
56 $prog_dir = $1;
57 $prog_name = $2;
58 }
59}
60
61require 5.004;
62
63use lib $main::prog_dir;
64use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
65use Getopt::Long;
66my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks);
67
68sub print_usage ();
69sub print_version ();
70sub print_help ();
71
72 # Initialize strings
73 $log_file = '';
74 $seek_file = '';
75 $critical = '';
76 $re_pattern = '';
77 $neg_re_pattern = '';
78 $pattern_count = 0;
79 $pattern_line = '';
80 $plugin_revision = '$Revision: 1300 $ ';
81
82 # Grab options from command line
83 GetOptions
84 ("l|logfile=s" => \$log_file,
85 "s|seekfile=s" => \$seek_file,
86 "c|critical" => \$critical,
87 "p|pattern=s" => \$re_pattern,
88 "n|negpattern:s" => \$neg_re_pattern,
89 "v|version" => \$version,
90 "h|help" => \$help);
91
92 !($version) || print_version ();
93 !($help) || print_help ();
94
95 # Make sure log file is specified
96 ($log_file) || usage("Log file not specified.\n");
97 # Make sure seek file is specified
98 ($seek_file) || usage("Seek file not specified.\n");
99 # Make sure re pattern is specified
100 ($re_pattern) || usage("Regular expression not specified.\n");
101
102 # Open log file
103 open (LOG_FILE, $log_file) || die "Unable to open log file $log_file: $!";
104
105 # Try to open log seek file. If open fails, we seek from beginning of
106 # file by default.
107 if (open(SEEK_FILE, $seek_file)) {
108 chomp(@seek_pos = <SEEK_FILE>);
109 close(SEEK_FILE);
110
111 # If file is empty, no need to seek...
112 if ($seek_pos[0] != 0) {
113
114 # Compare seek position to actual file size.
115 # If file size is smaller
116 # then we just start from beginning i.e. file was rotated, etc.
117 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat(LOG_FILE);
118
119 if ($seek_pos[0] <= $size) {
120 seek(LOG_FILE, $seek_pos[0], 0);
121 }
122 }
123 }
124
125 # Loop through every line of log file and check for pattern matches.
126 # Count the number of pattern matches and remember the full line of
127 # the most recent match.
128 while (<LOG_FILE>) {
129 if ($neg_re_pattern) {
130 if ((/$re_pattern/) && !(/$neg_re_pattern/)) {
131 $pattern_count += 1;
132 $pattern_line = $_;
133 }
134 } elsif (/$re_pattern/) {
135 $pattern_count += 1;
136 $pattern_line = $_;
137 }
138 }
139
140 # Overwrite log seek file and print the byte position we have seeked to.
141 open(SEEK_FILE, "> $seek_file") || die "Unable to open seek count file $seek_file: $!";
142 print SEEK_FILE tell(LOG_FILE);
143
144 # Close seek file.
145 close(SEEK_FILE);
146 # Close the log file.
147 close(LOG_FILE);
148
149 # Print result and return exit code.
150 if ($pattern_count) {
151 if ($critical) {
152 print "CRITICAL: ";
153 } else {
154 print "WARNING: ";
155 }
156 print "($pattern_count): $pattern_line";
157 if ($critical) {
158 exit $ERRORS{'CRITICAL'};
159 } else {
160 exit $ERRORS{'WARNING'};
161 }
162 } else {
163 print "OK - No matches found.\n";
164 exit $ERRORS{'OK'};
165 }
166
167#
168# Subroutines
169#
170
171sub print_usage () {
172 print "Usage: $prog_name -l <log_file> -s <log_seek_file> -p <pattern> [-n <negpattern>] -c | --critical\n";
173 print "Usage: $prog_name [ -v | --version ]\n";
174 print "Usage: $prog_name [ -h | --help ]\n";
175}
176
177sub print_version () {
178 print_revision($prog_name, $plugin_revision);
179 exit $ERRORS{'OK'};
180}
181
182sub print_help () {
183 print_revision($prog_name, $plugin_revision);
184 print "\n";
185 print "Scan arbitrary log files for regular expression matches.\n";
186 print "\n";
187 print_usage();
188 print "\n";
189 print "-l, --logfile=<logfile>\n";
190 print " The log file to be scanned\n";
191 print "-s, --seekfile=<seekfile>\n";
192 print " The temporary file to store the seek position of the last scan\n";
193 print "-p, --pattern=<pattern>\n";
194 print " The regular expression to scan for in the log file\n";
195 print "-n, --negpattern=<negpattern>\n";
196 print " The regular expression to skip in the log file\n";
197 print "-c, --critical\n";
198 print " Return critical instead of warning on error\n";
199 print "\n";
200 support();
201 exit $ERRORS{'OK'};
202}
diff --git a/contrib/check_lotus.pl b/contrib/check_lotus.pl
deleted file mode 100755
index 8bedced..0000000
--- a/contrib/check_lotus.pl
+++ /dev/null
@@ -1,260 +0,0 @@
1#!/usr/bin/perl -w
2
3# $Id: check_lotus.pl 1096 2005-01-25 09:04:26Z stanleyhopcroft $
4
5# Revision 1.1 2005/01/25 09:04:26 stanleyhopcroft
6# New plugin to check responsiveness of Louts Notes (v5 at least) servers
7#
8# Revision 1.10 2005-01-25 15:44:07+11 anwsmh
9# 1 use packet_utils instead of hard coding subroutines (pdump and tethereal)
10# 2 redo indentation using tabs (set at 4 spaces)
11#
12
13use strict ;
14
15use IO::Socket;
16use Getopt::Long ;
17
18my ($timeout, $debug, $lotus_host, $server, $indiv_dn, $packet_debug) ;
19
20use lib qw(/usr/local/nagios/libexec) ;
21use utils qw($TIMEOUT %ERRORS &print_revision &support &usage) ;
22use packet_utils qw(pdump &tethereal) ;
23
24my $PROGNAME = 'check_lotus_notes' ;
25
26sub print_help ();
27sub print_usage ();
28sub help ();
29sub version ();
30
31my $TEST_COUNT = 2 ;
32 # Number of Lotus client hellos sent without reply
33my $BUFFER_SIZE = 1500 ;
34 # buffer size used for 'recv' calls.
35my $LOTUS_PORT = 1352 ;
36
37Getopt::Long::Configure('no_ignore_case');
38GetOptions
39 ("V|version" => \&version,
40 "h|help" => \&help,
41 "v|debug" => \$debug,
42 "vv|i_packet_debug" => \$packet_debug,
43 "H|lotus_host=s"=> \$lotus_host,
44 # "I|indivual_dn:s" => \$indiv_dn,
45 "S|server:s" => \$server,
46 "T|t_timeout:i" => \$timeout,
47) ;
48
49usage("You must provide the DNS name or IP (v4) address of the Lotus server to be checked.\n")
50 unless $lotus_host and (
51 $lotus_host =~ m#^\d+\.\d+\.\d+\.\d+$# or
52 $lotus_host =~ m#^[\w\._-]+$#
53 ) ;
54
55$server ||= $lotus_host
56 if $lotus_host =~ m#^[\w-]+$# ;
57
58usage("You must provide a server option unless the lotus_host option looks like an unqualified host name.\n")
59 unless $server ;
60
61$timeout ||= $TIMEOUT ;
62$debug = 1
63 if $packet_debug ;
64
65my $server_dn = "CN=\U$server" . '(?:/\w+=[\w -]+)*' ;
66
67 # Definitions of query strings. Change at your own risk :)
68 # This info was gathered with tcpdump while using a Lotus Notes 5 client,
69 # so I'm not sure of what each value is.
70
71my $lotus_client_hello = &tethereal(<<'End_of_Tethereal_trace', '82') ;
720030 ff ff dc c5 00 00 82 00 00 00 77 00 00 00 02 00 ..........w.....
730040 00 40 02 0f 00 07 00 39 05 9e 45 54 ad ad 03 00 .@.....9..ET....
740050 00 00 00 02 00 2f 00 00 00 00 00 00 00 00 00 40 ...../.........@
750060 1f a0 af 19 d8 92 da 37 78 c9 ce 60 5e 35 b8 f7 .......7x..`^5..
760070 4e 05 00 10 00 0d 00 00 00 00 00 00 00 00 00 00 N...............
770080 00 00 00 00 00 02 00 08 00 9c dc 22 00 7c 6f 25 ...........".|o%
780090 4a 08 00 10 00 00 00 00 00 00 00 00 00 00 00 00 J...............
7900a0 00 00 00 00 00 04 00 10 00 ba ac 8c 49 67 ee a1 ............Ig..
8000b0 22 6f 63 bb 04 b4 75 0b 8f 00 "oc...u...
81End_of_Tethereal_trace
82
83 # XXXX
84 # Notes 5 accepts this
85 # _wrongly_ encoded DN
86 # but in general the
87 # server will reset
88 # the connection if
89 # it receives malformed
90 # packets.
91
92my $lotus_client_m1 = &tethereal(<<'End_of_Tethereal_trace', 'de') ;
930000 de 00 00 00 d4 00 00 00 13 00 00 40 01 00 9e 45 ...........@...E
940010 54 ad ad 03 00 00 00 00 02 00 29 13 23 00 b9 68 T.........).#..h
950020 25 00 9f 87 27 00 8f f4 25 00 00 00 88 00 24 00 %...'...%.....$.
960030 28 00 00 00 42 56 04 00 31 2e 30 00 42 43 01 00 (...BV..1.0.BC..
970040 03 42 41 01 00 30 42 4c 02 00 76 02 4e 4e 50 00 .BA..0BL..v.NNP.
980050 cf ee 9d 19 99 ca e0 bf 97 d3 59 a1 c5 78 16 82 ..........Y..x..
990060 76 09 8c 2c 96 ae 5a c1 15 bd 4e e9 b7 0f a9 d4 v..,..Z...N.....
1000070 5a 03 d9 0d bc e4 7d 4f e0 f2 79 89 cf cd 23 19 Z.....}O..y...#.
1010080 40 55 98 81 98 be d9 17 8d 69 8e 09 de c8 e8 92 @U.......i......
1020090 24 86 6f 5a 09 81 1f 71 be 29 b7 47 78 8c 2e 00 $.oZ...q.).Gx...
10300a0 45 4e 04 00 95 63 00 00 4d 41 08 00 64 a1 b4 b3 EN...c..MA..d...
10400b0 a1 01 45 c2 80 00 50 55 52 53 41 46 22 00 43 4e ..E...PURSAF".CN
10500c0 3d 4d 72 20 46 6f 6f 2f 4f 55 3d 42 61 72 20 68 =Mr Foo/OU=Bar h
10600d0 6f 74 65 6c 2f 4f 3d 42 61 7a 20 4a 75 6e 63 74 otel/O=Baz Junct
10700e0 69 6f 6e ion
108End_of_Tethereal_trace
109
110my $buff = '';
111
112my $valid_resp_cr = sub {
113 my ($resp, $dn, $err_ind_sr) = @_ ;
114 if ( $resp =~ /($dn)/ ) {
115 return $1
116 } else {
117 ($$err_ind_sr) = $resp =~ m#(CN=[\w -]+(?:/\w+=[\w -]+)*)# ;
118 return 0 ;
119 }
120} ;
121
122my @send = (
123 { Msg => 'Helo', Send => $lotus_client_hello, Ok => $valid_resp_cr },
124 { Msg => 'm1', Send => $lotus_client_m1, Ok => $valid_resp_cr },
125) ;
126
127my $tcp ;
128
129eval {
130
131 $tcp = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => $lotus_host, PeerPort => $LOTUS_PORT, Timeout => $timeout)
132 # Some versions (eg 1.1603) croak on a connect failure ..
133} ;
134
135&outahere("Connect to $lotus_host:$LOTUS_PORT failed:", $@)
136 if $@ || ! defined($tcp) ;
137
138my $found = '' ;
139
140foreach (@send) {
141
142 print STDERR "Sending Lotus client $_->{Msg} to $lotus_host.\n"
143 if $debug ;
144
145 &pdump($_->{Send})
146 if $packet_debug ;
147
148 eval {
149
150 local $SIG{"ALRM"} = sub { die 'Alarm clock restart' } ;
151
152 alarm($timeout) ;
153
154 $tcp->send($_->{Send}, 0) ||
155 &outahere("Send to $lotus_host failed: $!") ;
156
157 defined( $tcp->recv($buff, $BUFFER_SIZE, 0 ) ) ||
158 &outahere("Recv from $lotus_host failed: $!")
159
160 } ;
161
162 alarm(0) ;
163
164 &outahere('Unexpected exception raised by eval:', $@)
165 if $@ and $@ !~ /Alarm clock restart/ ;
166
167 &outahere("Timeout after $timeout secs - no response from $lotus_host")
168 if $@ and $@ =~ /Alarm clock restart/ ;
169
170 &outahere("Lotus server $lotus_host reset connection - client protocol (malformed packet sent) error", $@)
171 if $@ and $@ =~ /reset/ ;
172
173 &outahere("Empty recv buff after sending client $_->{Msg} and waiting $timeout secs. NB _no_ timeout exception.")
174 unless $buff ;
175
176 &pdump($buff)
177 if $packet_debug ;
178
179 my $err = '' ;
180
181 &outahere(qq(Response from $lotus_host failed to match CN=$server/.. got "$err") )
182 unless $found = $_->{Ok}->($buff, $server_dn, \$err) ;
183
184 print STDERR "Received Ok reply from $lotus_host - found DN $found in response.\n"
185 if $debug ;
186
187}
188
189close $tcp;
190
191print "Ok. Lotus server $lotus_host responded with $found after ", scalar @send, " packet dialogue.\n" ;
192exit $ERRORS{OK} ;
193
194=begin comment
195
196Normal response from Lotus Notes 5 server
197
1980000 74 00 00 00 69 00 00 00 03 00 00 40 02 0f 00 05 t...i......@....
1990010 00 3d 05 60 f0 3a 38 03 03 00 00 00 00 02 00 2f .=.`.:8......../
2000020 00 26 00 00 00 00 00 00 00 40 1f 3d 73 76 0e 57 .&.......@.=sv.W
2010030 e0 d7 67 cd a3 50 10 e0 99 24 b4 43 4e 3d 43 42 ..g..P...$.CN=CB
2020040 52 4e 4f 54 45 53 30 31 2f 4f 55 3d 53 45 52 56 RNOTES01/OU=SERV
2030050 45 52 53 2f 4f 3d 49 50 41 75 73 74 72 61 6c 69 ERS/O=IPAustrali
2040060 61 05 00 10 00 09 00 00 00 00 00 00 00 00 00 00 a...............
2050070 00 00 00 00 00 00
206
207=end comment
208
209=cut
210
211sub outahere {
212 print "Failed. @_.\n" ;
213 exit $ERRORS{CRITICAL} ;
214}
215
216sub print_usage () {
217 print "Usage: $PROGNAME -H <lotus_host (name _or_ address)>..) [-S <lotus_server name> -T <timeout> -v ]\n";
218}
219
220sub print_help () {
221 print_revision($PROGNAME,'$Revision: 1096 $ ');
222 print "Copyright (c) 2004 Ed Rolison/S Hopcroft
223
224Perl Check Lotus Notes plugin for Nagios.
225
226Returns OK if the named server responds with its name.
227
228";
229 print_usage();
230 print '
231-H, --lotus_host:STRING
232 Name or IP Address of Lotus server to be checked.
233-I, --individual_dn:NOT IMPLEMENTED
234 String of form CN=\w+(?:/OU=\w+)?/O=\w+
235-S, --server:STRING
236 Alpha numeric string specifying the Lotus server name (the CN by which the server is known by
237 in the Domino directory). Defaults to host name if the host name does not look like an IP address.
238-T, --packet-timeout:INTEGER
239 Time to wait for TCP dialogue to complete = send + rcv times (default Nagios timeout [$TIMEOUT sec]).
240-v, --debug
241 Debugging output.
242-vv, --packet_debug
243 Packet dump. Please post to Nag users in the event of trouble with this plugin.
244-h, --help
245 This stuff.
246
247';
248 support();
249}
250
251sub version () {
252 print_revision($PROGNAME,'$Revision: 1096 $ ');
253 exit $ERRORS{'OK'};
254}
255
256sub help () {
257 print_help();
258 exit $ERRORS{'OK'};
259}
260
diff --git a/contrib/check_maxchannels.pl b/contrib/check_maxchannels.pl
deleted file mode 100644
index a3ce525..0000000
--- a/contrib/check_maxchannels.pl
+++ /dev/null
@@ -1,231 +0,0 @@
1#!/usr/bin/perl -w
2#
3# check_maxchannels.pl - nagios plugin
4#
5#
6# Copyright (C) 2000 Christoph Kron
7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License
10# as published by the Free Software Foundation; either version 2
11# of the License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21#
22#
23# Report bugs to: ck@zet.net
24#
25# 11.01.2000 Version 1.0
26
27use strict;
28
29use Net::SNMP;
30use Getopt::Long;
31&Getopt::Long::config('auto_abbrev');
32
33
34my $status;
35my $TIMEOUT = 15;
36
37my %ERRORS = ('UNKNOWN' , '-1',
38 'OK' , '0',
39 'WARNING', '1',
40 'CRITICAL', '2');
41
42
43my $state = "UNKNOWN";
44my $answer = "";
45my $snmpkey;
46my $snmpoid;
47my $key;
48my $community = "public";
49my $port = 161;
50my @snmpoids;
51# free channels
52my $snmpWanAvailableChannels = '1.3.6.1.4.1.529.4.23.0';
53# maximum channels
54my $snmpWanSwitchedChannels = '1.3.6.1.4.1.529.4.24.0';
55my $snmpWanDisabledChannels = '1.3.6.1.4.1.529.4.25.0';
56my $snmpWanActiveChannels = '1.3.6.1.4.1.529.4.26.0';
57my $snmpWanNailedChannels = '1.3.6.1.4.1.529.4.27.0';
58my $snmpWanOutOfServiceChannels = '1.3.6.1.4.1.529.4.28.0';
59my $snmpEventCurrentActiveSessions = '1.3.6.1.4.1.529.10.6.0';
60# since startup
61my $snmpEventTotalNoModems = '1.3.6.1.4.1.529.10.15.0';
62# lan modem
63my $snmpDeadLanModem = '1.3.6.1.4.1.529.15.7.0';
64my $snmpDisabledLanModem = '1.3.6.1.4.1.529.15.5.0';
65my $snmpSuspectLanModem = '1.3.6.1.4.1.529.15.3.0';
66my $snmpAvailLanModem = '1.3.6.1.4.1.529.15.1.0';
67my $snmpBusyLanModem = '1.3.6.1.4.1.529.15.9.0';
68# max modems
69my $snmpMdmNumber = '1.3.6.1.2.1.38.1.1.0';
70my $hostname;
71my $session;
72my $error;
73my $response;
74my %wanStatus;
75
76
77my $WanAvailableChannels;
78my $WanSwitchedChannels;
79my $WanDisabledChannels;
80my $WanActiveChannels;
81my $WanNailedChannels;
82my $WanOutOfServiceChannels;
83my $EventCurrentActiveSessions;
84my $EventTotalNoModems;
85my $DeadLanModem;
86my $DisabledLanModem;
87my $SuspectLanModem;
88my $AvailLanModem;
89my $BusyLanModem;
90my $MdmNumber;
91
92
93sub usage {
94 printf "\nMissing arguments!\n";
95 printf "\n";
96 printf "Perl Check maxchannels plugin for Nagios\n";
97 printf "monitors ISDN lines and modems on Ascend MAX 2000/4000/6000/TNT\n";
98 printf "usage: \n";
99 printf "check_maxchannel.pl -c <READCOMMUNITY> -p <PORT> <HOSTNAME>\n";
100 printf "Copyright (C) 2000 Christoph Kron\n";
101 printf "check_maxchannels.pl comes with ABSOLUTELY NO WARRANTY\n";
102 printf "This programm is licensed under the terms of the ";
103 printf "GNU General Public License\n(check source code for details)\n";
104 printf "\n\n";
105 exit $ERRORS{"UNKNOWN"};
106}
107
108# Just in case of problems, let's not hang Nagios
109$SIG{'ALRM'} = sub {
110 print ("ERROR: No snmp response from $hostname (alarm)\n");
111 exit $ERRORS{"UNKNOWN"};
112};
113alarm($TIMEOUT);
114
115
116$status = GetOptions("community=s",\$community,
117 "port=i",\$port);
118if ($status == 0)
119{
120 &usage;
121}
122
123 #shift;
124 $hostname = shift || &usage;
125
126
127
128push(@snmpoids,$snmpWanAvailableChannels);
129push(@snmpoids,$snmpWanSwitchedChannels);
130push(@snmpoids,$snmpWanDisabledChannels);
131push(@snmpoids,$snmpWanActiveChannels);
132push(@snmpoids,$snmpWanNailedChannels);
133push(@snmpoids,$snmpWanOutOfServiceChannels);
134
135push(@snmpoids,$snmpEventCurrentActiveSessions);
136
137push(@snmpoids,$snmpEventTotalNoModems);
138push(@snmpoids,$snmpDeadLanModem);
139push(@snmpoids,$snmpDisabledLanModem);
140push(@snmpoids,$snmpSuspectLanModem);
141push(@snmpoids,$snmpAvailLanModem);
142push(@snmpoids,$snmpBusyLanModem);
143push(@snmpoids,$snmpMdmNumber);
144
145 ($session, $error) = Net::SNMP->session(
146 -hostname => $hostname,
147 -community => $community,
148 -port => $port
149 );
150
151 if (!defined($session)) {
152 $state='UNKNOWN';
153 $answer=$error;
154 print ("$state: $answer");
155 exit $ERRORS{$state};
156 }
157
158 if (!defined($response = $session->get_request(@snmpoids))) {
159 $answer=$session->error;
160 $session->close;
161 $state = 'CRITICAL';
162 print ("$state: $answer,$community");
163 exit $ERRORS{$state};
164 }
165
166
167$WanAvailableChannels = $response->{$snmpWanAvailableChannels};
168$WanSwitchedChannels = $response->{$snmpWanSwitchedChannels};
169$WanDisabledChannels = $response->{$snmpWanDisabledChannels};
170$WanActiveChannels = $response->{$snmpWanActiveChannels};
171$WanNailedChannels = $response->{$snmpWanNailedChannels};
172$WanOutOfServiceChannels = $response->{$snmpWanOutOfServiceChannels};
173$EventCurrentActiveSessions = $response->{$snmpEventCurrentActiveSessions};
174$EventTotalNoModems = $response->{$snmpEventTotalNoModems};
175$DeadLanModem = $response->{$snmpDeadLanModem};
176$DisabledLanModem = $response->{$snmpDisabledLanModem};
177$SuspectLanModem = $response->{$snmpSuspectLanModem};
178$AvailLanModem = $response->{$snmpAvailLanModem};
179$BusyLanModem = $response->{$snmpBusyLanModem};
180$MdmNumber = $response->{$snmpMdmNumber};
181
182# less than 50% -> WARNING
183if ( 0 < $WanOutOfServiceChannels
184 && $WanOutOfServiceChannels < ($snmpWanSwitchedChannels * 0.5) ) {
185 $state = 'WARNING';
186}
187elsif ($WanOutOfServiceChannels > 0) {
188 $state = 'CRITICAL';
189}
190elsif ($DeadLanModem > 0) {
191 $state = 'CRITICAL';
192}
193elsif ($SuspectLanModem > 0) {
194 $state = 'WARNING';
195}
196elsif ($AvailLanModem == 0) {
197 $state = 'WARNING';
198}
199else {
200 $state = 'OK';
201}
202
203
204$answer = sprintf("active sessions: %d (%d), active modems: %d (%d)<BR>",
205 $EventCurrentActiveSessions,
206 $WanSwitchedChannels,
207 $BusyLanModem,
208 $MdmNumber);
209
210$answer .= sprintf("channels available: %d, disabled: %d",
211 $WanAvailableChannels,
212 $WanDisabledChannels);
213
214$answer .= sprintf(", out of service: %d, nailed: %d<BR>",
215 $WanOutOfServiceChannels,
216 $WanNailedChannels);
217
218$answer .= sprintf("modems avail.: %d, disabled: %d, suspect: %d, dead: %d<BR>",
219 $AvailLanModem,
220 $DisabledLanModem,
221 $SuspectLanModem,
222 $DeadLanModem);
223
224$answer .= sprintf("unserviced modem calls: %d (since startup)\n",
225 $EventTotalNoModems);
226
227$session->close;
228
229print ("$state: $answer");
230exit $ERRORS{$state};
231
diff --git a/contrib/check_maxwanstate.pl b/contrib/check_maxwanstate.pl
deleted file mode 100644
index 4fbb9da..0000000
--- a/contrib/check_maxwanstate.pl
+++ /dev/null
@@ -1,201 +0,0 @@
1#!/usr/bin/perl -w
2#
3# check_maxwanstate.pl - nagios plugin
4#
5#
6# Copyright (C) 2000 Christoph Kron
7#
8# This program is free software; you can redistribute it and/or
9# modify it under the terms of the GNU General Public License
10# as published by the Free Software Foundation; either version 2
11# of the License, or (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21#
22#
23# Report bugs to: ck@zet.net
24#
25# 11.01.2000 Version 1.0
26
27use strict;
28
29use Net::SNMP;
30use Getopt::Long;
31&Getopt::Long::config('auto_abbrev');
32
33
34my $status;
35my $TIMEOUT = 1500;
36
37my %ERRORS = ('UNKNOWN' , '-1',
38 'OK' , '0',
39 'WARNING', '1',
40 'CRITICAL', '2');
41
42my %wanLineState = (
43 1,'ls-unknown',
44 2,'ls-does-not-exist',
45 3,'ls-disabled',
46 4,'ls-no-physical',
47 5,'ls-no-logical',
48 6,'ls-point-to-point',
49 7,'ls-multipoint-1',
50 8,'ls-multipoint-2',
51 9,'ls-loss-of-sync',
52 10,'ls-yellow-alarm',
53 11,'ls-ais-receive',
54 12,'ls-no-d-channel',
55 13,'ls-active',
56 14,'ls-maintenance');
57
58my %wanLineType = (
59 '1.3.6.1.4.1.529.4.1','Any',
60 '1.3.6.1.4.1.529.4.2','T1',
61 '1.3.6.1.4.1.529.4.3','E1',
62 '1.3.6.1.4.1.529.4.4','Dpnss',
63 '1.3.6.1.4.1.529.4.5','Bri',
64 '1.3.6.1.4.1.529.4.6','S562',
65 '1.3.6.1.4.1.529.4.7','S564',
66 '1.3.6.1.4.1.529.4.8','Sdsl',
67 '1.3.6.1.4.1.529.4.9','AdslCap');
68
69my $state = "UNKNOWN";
70my $answer = "";
71my $snmpkey;
72my $snmpoid;
73my $key;
74my $community = "public";
75my $port = 161;
76my @snmpoids;
77my $snmpWanLineName = '1.3.6.1.4.1.529.4.21.1.2';
78my $snmpWanLineType = '1.3.6.1.4.1.529.4.21.1.3';
79my $snmpWanLineState = '1.3.6.1.4.1.529.4.21.1.5';
80my $snmpWanLineUsage = '1.3.6.1.4.1.529.4.21.1.8';
81
82my $hostname;
83my $session;
84my $error;
85my $response;
86my %wanStatus;
87my $ifup =0 ;
88my $ifdown =0;
89my $ifdormant = 0;
90my $ifmessage;
91
92sub usage {
93 printf "\nMissing arguments!\n";
94 printf "\n";
95 printf "Perl Check maxwanstate plugin for Nagios\n";
96 printf "monitors E1/T1 interface status\n";
97 printf "usage: \n";
98 printf "check_maxwanstate.pl -c <READCOMMUNITY> -p <PORT> <HOSTNAME>";
99 printf "Copyright (C) 2000 Christoph Kron\n";
100 printf "check_maxwanstate.pl comes with ABSOLUTELY NO WARRANTY\n";
101 printf "This programm is licensed under the terms of the ";
102 printf "GNU General Public License\n(check source code for details)\n";
103 printf "\n\n";
104 exit $ERRORS{"UNKNOWN"};
105}
106
107# Just in case of problems, let's not hang Nagios
108$SIG{'ALRM'} = sub {
109 print ("ERROR: No snmp response from $hostname (alarm)\n");
110 exit $ERRORS{"UNKNOWN"};
111};
112alarm($TIMEOUT);
113
114
115$status = GetOptions("community=s",\$community,
116 "port=i",\$port);
117if ($status == 0)
118{
119 &usage;
120}
121
122 #shift;
123 $hostname = shift || &usage;
124
125
126
127push(@snmpoids,$snmpWanLineUsage);
128push(@snmpoids,$snmpWanLineState);
129push(@snmpoids,$snmpWanLineName);
130push(@snmpoids,$snmpWanLineType);
131
132foreach $snmpoid (@snmpoids) {
133
134 ($session, $error) = Net::SNMP->session(
135 -hostname => $hostname,
136 -community => $community,
137 -port => $port
138 );
139
140 if (!defined($session)) {
141 $state='UNKNOWN';
142 $answer=$error;
143 print ("$state: $answer");
144 exit $ERRORS{$state};
145 }
146
147 if (!defined($response = $session->get_table($snmpoid))) {
148 $answer=$session->error;
149 $session->close;
150 $state = 'CRITICAL';
151 print ("$state: $answer,$community,$snmpkey");
152 exit $ERRORS{$state};
153 }
154
155 foreach $snmpkey (keys %{$response}) {
156 $snmpkey =~ /.*\.(\d+)$/;
157 $key = $1;
158 $wanStatus{$key}{$snmpoid} = $response->{$snmpkey};
159 }
160 $session->close;
161}
162
163 foreach $key (keys %wanStatus) {
164 # look only at active Interfaces lu-trunk(5)
165 if ($wanStatus{$key}{$snmpWanLineUsage} == 5 ) {
166
167 # 13 -> active
168 if ($wanStatus{$key}{$snmpWanLineState} == 13 ) {
169 $ifup++;
170 }
171 else {
172 $ifdown++ ;
173 $ifmessage .= sprintf("%s interface status : %s (%s)<BR>",
174 $wanLineType{$wanStatus{$key}{$snmpWanLineType}},
175 $wanLineState{$wanStatus{$key}{$snmpWanLineState}},
176 $wanStatus{$key}{$snmpWanLineName});
177
178 }
179 }
180 }
181
182
183 if ($ifdown > 0) {
184 $state = 'CRITICAL';
185 $answer = sprintf("host '%s', interfaces up: %d, down: %d<BR>",
186 $hostname,
187 $ifup,
188 $ifdown);
189 $answer = $answer . $ifmessage . "\n";
190 }
191 else {
192 $state = 'OK';
193 $answer = sprintf("host '%s', interfaces up: %d, down: %d\n",
194 $hostname,
195 $ifup,
196 $ifdown);
197 }
198
199print ("$state: $answer");
200exit $ERRORS{$state};
201
diff --git a/contrib/check_mem.pl b/contrib/check_mem.pl
deleted file mode 100644
index 3227ce2..0000000
--- a/contrib/check_mem.pl
+++ /dev/null
@@ -1,146 +0,0 @@
1#!/usr/bin/perl -w
2# $Id: check_mem.pl 2 2002-02-28 06:42:51Z egalstad $
3
4# check_mem.pl Copyright (C) 2000 Dan Larsson <dl@tyfon.net>
5#
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; either version 2
9# of the License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty
13# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# you should have received a copy of the GNU General Public License
17# along with this program (or with Nagios); if not, write to the
18# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19# Boston, MA 02111-1307, USA
20
21# Tell Perl what we need to use
22use strict;
23use Getopt::Std;
24
25use vars qw($opt_c $opt_f $opt_u $opt_w
26 $free_memory $used_memory $total_memory
27 $crit_level $warn_level
28 %exit_codes @memlist
29 $percent $fmt_pct
30 $verb_err $command_line);
31
32# Predefined exit codes for Nagios
33%exit_codes = ('UNKNOWN' ,-1,
34 'OK' , 0,
35 'WARNING' , 1,
36 'CRITICAL', 2,);
37
38# Turn this to 1 to see reason for parameter errors (if any)
39$verb_err = 0;
40
41# This the unix command string that brings Perl the data
42$command_line = `vmstat | tail -1 | awk '{print \$4,\$5}'`;
43
44chomp $command_line;
45@memlist = split(/ /, $command_line);
46
47# Define the calculating scalars
48$used_memory = $memlist[0];
49$free_memory = $memlist[1];
50$total_memory = $used_memory + $free_memory;
51
52# Get the options
53if ($#ARGV le 0)
54{
55 &usage;
56}
57else
58{
59 getopts('c:fuw:');
60}
61
62# Shortcircuit the switches
63if (!$opt_w or $opt_w == 0 or !$opt_c or $opt_c == 0)
64{
65 print "*** You must define WARN and CRITICAL levels!" if ($verb_err);
66 &usage;
67}
68elsif (!$opt_f and !$opt_u)
69{
70 print "*** You must select to monitor either USED or FREE memory!" if ($verb_err);
71 &usage;
72}
73
74# Check if levels are sane
75if ($opt_w <= $opt_c and $opt_f)
76{
77 print "*** WARN level must not be less than CRITICAL when checking FREE memory!" if ($verb_err);
78 &usage;
79}
80elsif ($opt_w >= $opt_c and $opt_u)
81{
82 print "*** WARN level must not be greater than CRITICAL when checking USED memory!" if ($verb_err);
83 &usage;
84}
85
86$warn_level = $opt_w;
87$crit_level = $opt_c;
88
89if ($opt_f)
90{
91 $percent = $free_memory / $total_memory * 100;
92 $fmt_pct = sprintf "%.1f", $percent;
93 if ($percent <= $crit_level)
94 {
95 print "Memory CRITICAL - $fmt_pct% ($free_memory kB) free\n";
96 exit $exit_codes{'CRITICAL'};
97 }
98 elsif ($percent <= $warn_level)
99 {
100 print "Memory WARNING - $fmt_pct% ($free_memory kB) free\n";
101 exit $exit_codes{'WARNING'};
102 }
103 else
104 {
105 print "Memory OK - $fmt_pct% ($free_memory kB) free\n";
106 exit $exit_codes{'OK'};
107 }
108}
109elsif ($opt_u)
110{
111 $percent = $used_memory / $total_memory * 100;
112 $fmt_pct = sprintf "%.1f", $percent;
113 if ($percent >= $crit_level)
114 {
115 print "Memory CRITICAL - $fmt_pct% ($used_memory kB) used\n";
116 exit $exit_codes{'CRITICAL'};
117 }
118 elsif ($percent >= $warn_level)
119 {
120 print "Memory WARNING - $fmt_pct% ($used_memory kB) used\n";
121 exit $exit_codes{'WARNING'};
122 }
123 else
124 {
125 print "Memory OK - $fmt_pct% ($used_memory kB) used\n";
126 exit $exit_codes{'OK'};
127 }
128}
129
130# Show usage
131sub usage()
132{
133 print "\ncheck_mem.pl v1.0 - Nagios Plugin\n\n";
134 print "usage:\n";
135 print " check_mem.pl -<f|u> -w <warnlevel> -c <critlevel>\n\n";
136 print "options:\n";
137 print " -f Check FREE memory\n";
138 print " -u Check USED memory\n";
139 print " -w PERCENT Percent free/used when to warn\n";
140 print " -c PERCENT Percent free/used when critical\n";
141 print "\nCopyright (C) 2000 Dan Larsson <dl\@tyfon.net>\n";
142 print "check_mem.pl comes with absolutely NO WARRANTY either implied or explicit\n";
143 print "This program is licensed under the terms of the\n";
144 print "GNU General Public License (check source code for details)\n";
145 exit $exit_codes{'UNKNOWN'};
146}
diff --git a/contrib/check_ms_spooler.pl b/contrib/check_ms_spooler.pl
deleted file mode 100755
index 3a80a76..0000000
--- a/contrib/check_ms_spooler.pl
+++ /dev/null
@@ -1,324 +0,0 @@
1#!/usr/bin/perl -w
2
3# $Id: check_ms_spooler.pl 64 2002-07-16 00:04:42Z stanleyhopcroft $
4
5# Revision 1.1 2002/07/16 00:04:42 stanleyhopcroft
6# Primitive and in need of refinement test of MS spooler (with smbclient)
7#
8# Revision 2.5 2002-02-13 07:36:08+11 anwsmh
9# Correct 'apostrophe' disaster.
10# Apostrophes in plugin output cause Netsaint notification commands
11# ( sh echo 'yada $PLUGINOUTPUT$ ..') to fail, usually mysteriously
12# eg notify OK works but notify CRITICAL does not.
13# Replace '$var' in print "output" with \"$var\".
14#
15# Revision 2.4 2001-11-21 21:36:05+11 anwsmh
16# Minor corrections
17# . replace 'die' by print .. exit $ERRORS{CRITICAL}
18# . change concluding message to list the queues (sorted) if there are no enqueued docs.
19#
20# Revision 2.3 2001-11-20 11:00:58+11 anwsmh
21# Major corrections.
22# 1. to sub AUTOLOAD: coderef parms must be @_ (ie the parm when the new sub is called)
23# 2. to processing of queue report (no inspection of $last_line; entire $queue_report is
24# checked for errors)
25# 3. cosmetic and debug changes in many places.
26#
27# Revision 2.2 2001-11-17 23:30:34+11 anwsmh
28# After adapting two different queue reports resulting from
29# different name resolution methods.
30#
31# Revision 2.1 2001-11-17 13:21:54+11 anwsmh
32# Adapt to Netsaint ('use utils, Getopt::Long, and standard switch processing).
33# Fix many peculiarities.
34#
35
36
37use strict ;
38
39use Getopt::Long ;
40use utils ;
41
42use vars qw($opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $debug);
43use vars '$AUTOLOAD' ;
44use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
45
46my $PROGNAME = 'check_ms_spooler' ;
47
48sub print_help ();
49sub print_usage ();
50sub help ();
51sub version ();
52
53delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
54
55use constant SMBCLIENT_PATH => '/usr/local/samba/bin/smbclient' ;
56use constant MAX_QUEUES_TO_CHECK => 20 ; # So that the check doesn't take longer than $TIMEOUT
57
58use constant SMBCLIENT_SVC => sub { return `${\SMBCLIENT_PATH} -L //$_[0] -U $_[1]%$_[2]` } ;
59use constant SMBCLIENT_QUEUE => sub { return `${\SMBCLIENT_PATH} //$_[0]/$_[1] -U $_[2]%$_[3] -c 'queue; quit' 2>/dev/null` } ;
60
61 # The queue results depend on the name resolution method.
62
63 # Forcing 'wins' or 'bcat' name resolution makes the queue results the
64 # same for all spoolers (those that are resolved with WINS have an extra line
65 # 'Got a positive name query response from <ip address of WINS> ..)
66 # but would fail if there is no WINS and when miscreant spoolers
67 # don't respond to broadcasts.
68
69use constant MIN => sub { my $min = $_[0] ; foreach (@_) { $min = $_ if $_ <= $min; } return $min ; } ;
70
71$SIG{"ALRM"} = sub { die "Alarm clock restart" } ;
72
73Getopt::Long::Configure('bundling', 'no_ignore_case');
74GetOptions
75 ("V|version" => \&version,
76 "h|help" => \&help,
77 "d|debug" => \$debug,
78 "p|password=s" => \$opt_p,
79 "u|username=s" => \$opt_u,
80 "H|hostname=s" => \$opt_H);
81
82
83
84($opt_H) || usage("MS Spooler name not specified\n");
85my $spooler = $1 if $opt_H =~ m#(\w+)# ; # MS host names allow __any__ characters (more than \w)
86($spooler) || usage("Invalid MS spooler name: $opt_H\n");
87
88($opt_u) || ($opt_u = 'guest');
89my $user = $1 if $opt_u =~ m#(\w+)# ;
90($user) || usage("Invalid user: $opt_u\n");
91
92($opt_p) || ($opt_p = 'guest');
93my $pass = $1 if ($opt_p =~ /(.*)/);
94($pass) || usage("Invalid password: $opt_p\n");
95
96my ($printer, $queue, @queues, $ms_spooler_status, @results, %junk) ;
97my (@fault_messages, @queue_contents, @services, @prandom_queue_indices) ;
98my ($queue_contents, $number_of_queues, $state, $queue_report) ;
99
100$state = "getting service list (${\SMBCLIENT_PATH} -L $spooler -U $user%$pass) from spooler\n" ;
101
102eval {
103 alarm($TIMEOUT) ;
104 @services = SMBCLIENT_SVC->( $spooler, $user, $pass ) ;
105} ;
106alarm(0) ;
107
108if ($@ and $@ !~ /Alarm clock restart/) {
109 print "Failed. $PROGNAME failed $state. Got \"$@\"\n" ;
110 exit $ERRORS{"CRITICAL"} ;
111}
112
113if ($@ and $@ =~ /Alarm clock restart/) {
114 print "Failed. $PROGNAME timed out $state. Got \"@services\"\n" ;
115 exit $ERRORS{"CRITICAL"} ;
116}
117
118# tsitc> /usr/local/samba/bin/smbclient //ipaprint1/tt03 -U blah%blah -P -c 'queue; quit'
119# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
120# Connection to ipaprint1 failed
121
122# tsitc> /usr/local/samba/bin/smbclient -L sna_spl1 -U blah%blah | & more
123# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
124# Got a positive name query response from 10.0.100.29 ( 10.0.6.20 )
125# session setup failed: ERRDOS - ERRnoaccess (Access denied.)
126
127if ( grep /Connection to $spooler failed|ERR/, @services ) {
128 print "Failed. $PROGNAME failed $state. Got \"@services\"\n" ;
129 # print "Failed. Request for services list to $spooler failed. Got \"@services\"\n" ;
130 exit $ERRORS{"CRITICAL"} ;
131}
132
133# tsitc# /usr/local/samba/bin/smbclient -L ipaprint -U blah%blah
134# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
135# Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0]
136#
137# Sharename Type Comment
138# --------- ---- -------
139# TH02 Printer TH02
140# ADMIN$ Disk Remote Admin
141# IPC$ IPC Remote IPC
142# S431 Printer S431
143# S402 Printer S402
144# S401 Printer S401
145# C$ Disk Default share
146# BW01 Printer BW01
147# BW02 Printer BW02
148# TL11 Printer TL11
149# TL07 Printer TL07
150# S225 Printer Discovery South - 2nd Floor - HP CLJ4500
151# S224 Printer S224
152# S223 Printer Discovery South 2nd Floor Trademarks Training
153# S222 Printer S222
154# S203 Printer S203
155# S202 Printer S202
156
157my @printers = map { my @junk = split; $junk[0] }
158 grep { my @junk = split; defined $junk[1] and $junk[1] eq 'Printer' } @services ;
159 # don't check IPC$, ADMIN$ etc.
160
161$ms_spooler_status = 0 ;
162$number_of_queues = MIN->(MAX_QUEUES_TO_CHECK, (scalar(@services) >> 3) + 1) ;
163
164$state = "checking queues on $spooler" ;
165
166eval {
167 # foreach queues to check
168 # generate a pseudo-random int in 0 .. $#printers
169 # drop it if the index has already been generated ;
170
171 %junk = () ;
172 @prandom_queue_indices = grep { ! $junk{$_}++ }
173 map { int( rand($#printers) ) } ( 1 .. $number_of_queues ) ;
174
175 @queues = @printers[@prandom_queue_indices] ;
176
177 # @queues = @printers[ map { int( rand($#printers) ) } ( 1 .. $number_of_queues ) ] ;
178
179 alarm($TIMEOUT) ;
180
181 @queue_contents = @fault_messages = () ;
182
183 foreach $printer (sort @queues) {
184
185 # Expect 3 lines from a queue report.
186 # If queue is empty, last line is null otherwise
187 # it will contain a queue report or an SMB error
188
189 # Empty Queue.
190 # Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
191 # Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0]
192
193 # Queue command from a spooler with a DNS name.
194 # Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
195 # Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0]
196 # 65 16307 Microsoft Word - Servicesweoffer2.doc
197 # 68 10410 Microsoft Word - Servicesweoffer.doc
198 # 143 24997 Microsoft Word - Miss Samantha Anne Craig.doc
199 # 182 15635 Microsoft Word - services we provide.doc
200
201 # Error.
202 # Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
203 # Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0]
204 # tree connect failed: ERRDOS - ERRnosuchshare (You specified an invalid share name)
205
206 # Can't connect error.
207 # Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
208 # Connection to sna_spl2 failed
209
210
211 # Empty Queue from a spooler with no DNS name, NetBIOS name resolved by WINS.
212 # Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0
213 # Got a positive name query response from 10.0.100.29 ( 10.0.6.20 )
214 # Domain=[SNA_PRINT] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0]
215
216 # There are 3 lines of output from smbclient for those spoolers whose names are
217 # resolved by WINS (because those names are NetBIOS and therefore not in DNS);
218 # 4 lines for errors or enqueued jobs
219
220 print STDERR "${\SMBCLIENT_PATH} //$spooler/$printer -U $user%$pass -c 'queue; quit' ==>\n" if $debug ;
221
222 @results = SMBCLIENT_QUEUE->( $spooler, $printer, $user, $pass ) ;
223
224 print STDERR "\"@results\"\n" if $debug ;
225
226 # set $ms_spooler_status somehow
227
228 chomp( @results ) ;
229 $queue_report = queue_report->(@results) ;
230 print STDERR '$queue_report for $printer ', "$printer: \"$queue_report\"\n\n" if $debug ;
231
232 if ( defined $queue_report and ($queue_report !~ /ERR/ && $queue_report !~ /failed/) ) {
233 $ms_spooler_status = 1 ;
234 push @queue_contents, "$printer: $queue_report" if $queue_report ;
235 } else {
236 push @fault_messages, "$printer: $queue_report" ;
237 }
238 }
239 alarm(0) ;
240} ;
241
242if ($@ and $@ !~ /Alarm clock restart/) {
243 print "Failed. $PROGNAME failed at $state. Got \"$@\"\n" ;
244 exit $ERRORS{"CRITCAL"} ;
245}
246
247if ($@ and $@ =~ /Alarm clock restart/) {
248 my $i ;
249 foreach (@queues) { $i++ ; last if $_ eq $printer }
250 print "Failed. Timed out connecting to $printer ($i of $number_of_queues) on //$spooler after $TIMEOUT secs. Got \"@fault_messages\"\n" ;
251 exit $ERRORS{"CRITICAL"} ;
252}
253
254if (! $ms_spooler_status) {
255 print "Failed. Couldn't connect to @queues on //$spooler as user $user. Got \"@fault_messages\"\n" ;
256 exit $ERRORS{"CRITICAL"} ;
257}
258
259$queue_contents = ( @queue_contents != 0 ? join(" ", (@queue_contents == 1 ? "Queue" : "Queues"), @queue_contents) :
260 "All Queues empty" ) ;
261
262print "Ok. Connected to ", $queue_contents =~ /empty$/ ? "@{[sort @queues]}" : scalar @queues, " queues on //$spooler. $queue_contents\n" ;
263exit $ERRORS{"OK"} ;
264
265sub print_usage () {
266 print "Usage: $PROGNAME -H <spooler> -u <user> -p <password>\n";
267}
268
269sub print_help () {
270 print_revision($PROGNAME,'$Revision: 64 $ ');
271 print "Copyright (c) 2001 Karl DeBisschop/S Hopcroft
272
273Perl Check MS Spooler plugin for NetSaint. Display a subset of the queues on an SMB (Samba or MS) print spooler.
274
275";
276 print_usage();
277 print '
278-H, --hostname=STRING
279 NetBIOS name of the SMB Print spooler (Either Samba or MS spooler)
280-u, --user=STRING
281 Username to log in to server. (Default: "guest")
282-p, --password=STRING
283 Password to log in to server. (Default: "guest")
284-d, --debug
285 Debugging output.
286-h, --help
287 This stuff.
288
289';
290 support();
291}
292
293sub version () {
294 print_revision($PROGNAME,'$Revision: 64 $ ');
295 exit $ERRORS{'OK'};
296}
297
298sub help () {
299 print_help();
300 exit $ERRORS{'OK'};
301}
302
303sub AUTOLOAD {
304
305 my @queue_rep = @_ ;
306
307 # 'Object Oriented Perl', D Conway, p 95
308
309 no strict 'refs' ;
310
311 if ( $AUTOLOAD =~ /.*::queue_report/ ) {
312
313 if ( grep /Got a positive name query response from/, @queue_rep ){
314 *{$AUTOLOAD} = sub { return join ' ', splice(@_, 3) } ;
315 return join '', splice(@queue_rep, 3) ;
316 } else {
317 *{$AUTOLOAD} = sub { return join ' ',splice(@_, 2) } ;
318 return join '', splice(@queue_rep, 2) ;
319 }
320 } else {
321 die "No such subroutine: $AUTOLOAD" ;
322 }
323}
324
diff --git a/contrib/check_mssql.sh b/contrib/check_mssql.sh
deleted file mode 100755
index 77c4dcd..0000000
--- a/contrib/check_mssql.sh
+++ /dev/null
@@ -1,104 +0,0 @@
1#!/bin/sh
2# This script is designed to be used by Nagios. It checks for the availability of both Microsoft SQL Server 7 and 2000.
3#
4# Requirements:
5#
6# FreeTDS 6.0+ (http://www.freetds.org/)
7#
8# It was written by Tom De Blende (tom.deblende@village.uunet.be) in 2003.
9#
10# Version 1.0.
11# Version 1.1: Rewritten the initial script so that it not only works from the CLI but also from within Nagios. Always helpful...
12# Version 1.2: Grouped output so things look a bit better.
13# Version 2.0: Rewritten the plugin to support version 6.0+ of FreeTDS.
14# Removed sqsh requirement as version 6.0+ of FreeTDS now offers its own CLI client: tsql.
15# Older versions of FreeTDS are no longer supported.
16#
17#
18# You might want to change these values:
19
20tsqlcmd=`which tsql`
21catcmd=`which cat`
22grepcmd=`which grep`
23rmcmd=`which rm`
24mktempcmd=`which mktemp`
25wccmd=`which wc`
26sedcmd=`which sed`
27trcmd=`which tr`
28uniqcmd=`which uniq`
29
30###################################################################################################################
31
32hostname=$1
33usr=$2
34pswd=$3
35srv=$4
36
37
38if [ ! "$#" == "4" ]; then
39 echo -e "\nYou did not supply enough arguments. \nUsage: $0 <host> <username> <password> <version> \n \n$0 checks Microsoft SQL Server connectivity. It works with versions 7 and 2000.\n\nYou need a working version of FreeTDS (http://www.freetds.org/) and tsql (included in FreeTDS 6.0+) to connect to the SQL server. \nIt was written by Tom De Blende (tom.deblende@village.uunet.be) in 2003. \n\nExample:\n $0 dbserver sa f00bar 2000\n" && exit "3"
40
41elif [ $tsqlcmd == "" ]; then
42 echo -e "tsql not found! Please verify you have a working version of tsql (included in the FreeTDS version 6.0+) and enter the full path in the script." && exit "3"
43
44fi
45
46exit="3"
47
48
49# Creating the command file that contains the sql statement that has to be run on the SQL server.
50
51tmpfile=`$mktempcmd /tmp/$hostname.XXXXXX`
52
53if [ $srv == "7" ]; then
54 spid=7
55elif [ $srv == "2000" ]; then
56 spid=50
57else
58 echo -e "$srv is not a supported MS SQL Server version!" && exit "3"
59fi
60
61echo -e "select loginame from sysprocesses where spid > $spid order by loginame asc\ngo" > $tmpfile
62
63
64# Running tsql to get the results back.
65
66resultfile=`$mktempcmd /tmp/$hostname.XXXXXX`
67errorfile=`$mktempcmd /tmp/$hostname.XXXXXX`
68$tsqlcmd -S $hostname -U $usr -P $pswd < $tmpfile 2>$errorfile > $resultfile
69
70$grepcmd -q "Login failed for user" $errorfile
71
72if [ "$?" == "0" ]; then
73 $rmcmd -f $tmpfile $resultfile $errorfile;
74 echo CRITICAL - Could not make connection to SQL server. Login failed.;
75 exit 2;
76fi
77
78$grepcmd -q "There was a problem connecting to the server" $errorfile
79
80if [ "$?" == "0" ]; then
81 $rmcmd -f $tmpfile $resultfile $errorfile;
82 echo CRITICAL - Could not make connection to SQL server. Incorrect server name or SQL service not running.;
83 exit 2;
84fi
85
86resultfileln=`$catcmd $resultfile | $wccmd -l | $sedcmd 's/ //g'`
87
88if [ "$resultfileln" == "2" ]; then
89 $rmcmd -f $tmpfile $resultfile $errorfile;
90 echo CRITICAL - Could not make connection to SQL server. No data received from host.;
91 exit 2;
92else
93 nmbr=`$catcmd $resultfile | $grepcmd -v locale | $grepcmd -v charset| $grepcmd -v 1\> | $sedcmd '/^$/d' | $sedcmd 's/ //g' | $wccmd -l | sed 's/ //g'`
94 users=`$catcmd $resultfile | $grepcmd -v locale | $grepcmd -v charset| $grepcmd -v 1\> | $sedcmd '/^$/d' | $sedcmd 's/ //g' | $uniqcmd -c | $trcmd \\\n , | $sedcmd 's/,$/./g' | $sedcmd 's/,/, /g' | $sedcmd 's/ //g' | $trcmd \\\t " " | $sedcmd 's/ \./\./g' | $sedcmd 's/ ,/,/g'`
95 $rmcmd -f $tmpfile $resultfile;
96 echo "OK - MS SQL Server $srv has $nmbr user(s) connected: $users" | sed 's/: $/./g';
97 exit 0;
98fi
99
100# Cleaning up.
101
102$rmcmd -f $tmpfile $resultfile $errorfile
103echo $stdio
104exit $exit
diff --git a/contrib/check_nagios.pl b/contrib/check_nagios.pl
deleted file mode 100644
index 7d15d4d..0000000
--- a/contrib/check_nagios.pl
+++ /dev/null
@@ -1,48 +0,0 @@
1#!/usr/bin/perl
2# denao - denao@uol.com.br - Systems Engineering
3# Universo Online - http://www.uol.com.br
4use DBI;
5use Time::Local;
6
7my $t_lambuja = 5; # (expire_minutes)
8my $databasename = ""; # The name of nagios database (i.e.: nagios)
9my $table = "programstatus";
10my $where = "localhost"; # The machine where the database
11my $port = "3306";
12my $base = "DBI:mysql:$databasename:$where:$port";
13my $user = ""; # the user to connect to the database
14 # (needs permission to "select at programstatus table only"
15my $password = ""; # the password (if any)
16my %results;
17my @fields = qw( last_update );
18my $dbh = DBI->connect($base,$user,$password);
19my $fields = join(', ', @fields);
20my $query = "SELECT $fields FROM $table";
21
22my $sth = $dbh->prepare($query);
23$sth->execute();
24
25@results{@fields} = ();
26$sth->bind_columns(map { \$results{$_} } @fields);
27
28$sth->fetch();
29$sth->finish();
30$dbh->disconnect();
31
32check_update();
33
34sub check_update {
35($yea,$mon,$day,$hou,$min,$sec)=($results{last_update}=~/(\d+)\-(\d+)\-(\d+)\s(\d+)\:(\d+)\:(\d+)/);
36($sec_now, $min_now, $hou_now, $day_now, $mon_now, $yea_now) = (localtime(time))[0,1,2,3,4,5];
37$mon_now+=1; $yea_now+=1900;
38$unixdate=timelocal($sec,$min,$hou,$day,$mon,$yea);
39$unixdate_now=timelocal($sec_now,$min_now,$hou_now,$day_now,$mon_now,$yea_now);
40 if (scalar($unixdate_now - $unixdate) > scalar($t_lambuja * 60)) {
41 print "Nagios problem: nagios is down, for at least " . scalar($t_lambuja) . " minutes.\n";
42 exit(1);
43 } else {
44 print "Nagios ok: status data updated " . scalar($unixdate_now - $unixdate) . " seconds ago\n";
45 exit(0);
46 }
47}
48
diff --git a/contrib/check_nagios_db.pl b/contrib/check_nagios_db.pl
deleted file mode 100644
index 5811d7c..0000000
--- a/contrib/check_nagios_db.pl
+++ /dev/null
@@ -1,89 +0,0 @@
1#!/usr/local/bin/perl -w
2
3use strict;
4$|++;
5
6use vars qw/$opt_e $opt_c/;
7
8$ENV{"PATH"} = "/usr/bin:/usr/sbin:/bin";
9
10use Getopt::Std;
11use DBI;
12
13my $driver = "mysql";
14
15my $CFG_DEF = "/opt/nagios/etc/cgi.cfg";
16my $QUERY = "select *, UNIX_TIMESTAMP(last_update) as ut from programstatus;";
17my $EXPIRE_DEF = 5; ## expressed in minutes
18my $PROCCNT = 0;
19
20use constant OK => 1;
21use constant WARN => 2;
22
23my $STAT = WARN;
24
25sub usage {
26 print STDERR "\n";
27 print STDERR "$0 -F -e <expire time in minutes> -C <process string>\n";
28 print STDERR "\n";
29 exit -1;
30}
31
32getopt("e:c:");
33
34my $EXPIRE = $opt_e || $EXPIRE_DEF;
35my $CFG = $opt_c || $CFG_DEF;
36
37( -f $CFG ) or die "Can't open config file '$CFG': $!\n";
38
39my ($dbhost, $dbport, $dbuser, $dbpass, $dbname);
40
41open(F, "< $CFG");
42while ( <F> ) {
43 if (/^xsddb_host=(.+)/) { $dbhost = $1; next; };
44 if (/^xsddb_port=(.+)/) { $dbport = $1; next; };
45 if (/^xsddb_database=(.+)/) { $dbname = $1; next; };
46 if (/^xsddb_username=(.+)/) { $dbuser = $1; next; };
47 if (/^xsddb_password=(.+)/) { $dbpass = $1; next; };
48}
49close(F);
50
51# print "($dbhost, $dbport, $dbuser, $dbpass, $dbname)\n";
52
53my $dsn = "DBI:$driver:database=$dbname;host=$dbhost;port=$dbport";
54my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1});
55
56my $sth = $dbh->prepare($QUERY);
57if (!$sth) { die "Error:" . $dbh->errstr . "\n"; }
58$sth->execute;
59if (!$sth->execute) { die "Error:" . $sth->errstr . "\n"; }
60
61my %status = ();
62
63my $names = $sth->{'NAME'};
64my $numFields = $sth->{'NUM_OF_FIELDS'};
65my $ref = $sth->fetchrow_arrayref;
66for (my $i = 0; $i < $numFields; $i++) {
67 $status{"$$names[$i]"} = $$ref[$i];
68}
69
70#foreach (keys(%status)) {
71# print "$_: $status{$_}\n";
72#}
73
74my $lastupdated = time() - $status{"ut"};
75if ( $lastupdated < ($EXPIRE*60) ) { ## convert $EXPIRE to seconds
76 $STAT = OK;
77}
78
79open(PS, "ps -eaf | grep $status{nagios_pid} | grep -v grep | ");
80$PROCCNT = 0;
81while(<PS>) {
82 $PROCCNT++;
83}
84close(PS);
85
86if ( $STAT == OK ) {
87 print "Nagios OK: located $PROCCNT processes, program status updated $lastupdated seconds ago\n";
88}
89
diff --git a/contrib/check_nagios_db_pg.pl b/contrib/check_nagios_db_pg.pl
deleted file mode 100644
index 99e5d4e..0000000
--- a/contrib/check_nagios_db_pg.pl
+++ /dev/null
@@ -1,91 +0,0 @@
1#!/usr/bin/perl -w
2
3use strict;
4$|++;
5
6use vars qw/$opt_e $opt_c/;
7
8$ENV{"PATH"} = "/usr/bin:/usr/sbin:/bin";
9
10use Getopt::Std;
11use DBI;
12
13my $driver = "Pg";
14
15my $CFG_DEF = "/etc/nagios/cgi.cfg";
16# this works only in mysql
17# my $QUERY = "select *, UNIX_TIMESTAMP(last_update) as ut from programstatus;";
18# the following is the same for postgres
19my $QUERY = "select *, round(date_part('epoch',last_update)) as ut from programstatus;";
20my $EXPIRE_DEF = 5; ## expressed in minutes
21my $PROCCNT = 0;
22
23use constant OK => 1;
24use constant WARN => 2;
25
26my $STAT = WARN;
27
28sub usage {
29 print STDERR "\n";
30 print STDERR "$0 -F -e &lt;expire time in minutes&gt; -C &lt;process string&gt;\n";
31 print STDERR "\n";
32 exit -1;
33}
34
35getopt("e:c:");
36
37my $EXPIRE = $opt_e || $EXPIRE_DEF;
38my $CFG = $opt_c || $CFG_DEF;
39
40( -f $CFG ) or die "Can't open config file '$CFG': $!\n";
41
42my ($dbhost, $dbport, $dbuser, $dbpass, $dbname);
43
44open(F, "< $CFG");
45while ( <F> ) {
46 if (/^xsddb_host=(.+)/) { $dbhost = $1; next; };
47 if (/^xsddb_port=(.+)/) { $dbport = $1; next; };
48 if (/^xsddb_database=(.+)/) { $dbname = $1; next; };
49 if (/^xsddb_username=(.+)/) { $dbuser = $1; next; };
50 if (/^xsddb_password=(.+)/) { $dbpass = $1; next; };
51}
52close(F);
53
54#print "($dbhost, $dbport, $dbuser, $dbpass, $dbname)\n";
55
56my $dsn = "DBI:$driver:dbname=$dbname;host=$dbhost;port=$dbport";
57my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1});
58
59my $sth = $dbh->prepare($QUERY);
60if (!$sth) { die "Error:" . $dbh->errstr . "\n"; }
61$sth->execute;
62if (!$sth->execute) { die "Error:" . $sth->errstr . "\n"; }
63
64my %status = ();
65
66my $names = $sth->{'NAME'};
67my $numFields = $sth->{'NUM_OF_FIELDS'};
68my $ref = $sth->fetchrow_arrayref;
69for (my $i = 0; $i < $numFields; $i++) {
70 $status{"$$names[$i]"} = $$ref[$i];
71}
72
73#foreach (keys(%status)) {
74# print "$_: $status{$_}\n";
75#}
76
77my $lastupdated = time() - $status{"ut"};
78if ( $lastupdated < ($EXPIRE*60) ) { ## convert $EXPIRE to seconds
79 $STAT = OK;
80}
81
82open(PS, "ps -eaf | grep $status{nagios_pid} | grep -v grep | ");
83$PROCCNT = 0;
84while(<PS>) {
85 $PROCCNT++;
86}
87close(PS);
88
89if ( $STAT == OK ) {
90 print "Nagios OK: located $PROCCNT processes, program status updated $lastupdated seconds ago\n";
91}
diff --git a/contrib/check_netapp.pl b/contrib/check_netapp.pl
deleted file mode 100755
index d556e9d..0000000
--- a/contrib/check_netapp.pl
+++ /dev/null
@@ -1,178 +0,0 @@
1#!/usr/bin/perl -wT
2# check_netapp
3#
4# Copyright (C) 2000 Leland E. Vandervort <leland@mmania.com>
5#
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; either version 2
9# of the License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty
13# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# you should have received a copy of the GNU General Public License
17# along with this program (or with Nagios); if not, write to the
18# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19# Boston, MA 02111-1307, USA
20####################################
21# checks for overtemperature, fans, psu, and nfs operations/second on
22# Network Appliance Filers.
23# Returns:
24# OK if temp, fans, psu OK and Ops/Sec below warning and critical
25# Thresholds (default is warning=3500, critical=5000)
26# ** Note: See the specifications for your Filer model for
27# the thresholds !
28# Returns Warning if NFS Ops/Sec is above warning threshold
29# (default 3500, or specified by -o command line option)
30# Returns Critical if NFS Ops/Sec is above critical threshold
31# ( -m option, or default 5000), or if overtem, psufault, or
32# fanfault detected.
33#
34####################################
35# Notes on operational limits for NetApp Filers:
36# Platform Maximum Ops/Second (recommended)
37# -------------------------------------------------------------
38# F230 1000
39# F740 5500
40# F760 9000
41####################################
42
43use Net::SNMP;
44use Getopt::Long;
45&Getopt::Long::config('auto_abbrev');
46
47my $status;
48my $response = "";
49my $TIMEOUT = 10;
50my $community = "public";
51my $port = 161;
52my $opsthresh = "3500";
53my $critical = "5000";
54
55my $status_string = "";
56
57my %OIDLIST = (
58 overtemp => '1.3.6.1.4.1.789.1.2.4.1.0',
59 failedfan => '1.3.6.1.4.1.789.1.2.4.2.0',
60 failedpsu => '1.3.6.1.4.1.789.1.2.4.4.0',
61 nfsops => '1.3.6.1.4.1.789.1.2.2.1.0'
62 );
63
64
65
66my %STATUSCODE = ( 'UNKNOWN' => '-1',
67 'OK' => '0',
68 'WARNING' => '1',
69 'CRITICAL' => '2');
70
71my $state = "UNKNOWN";
72
73
74$SIG{'ALRM'} = sub {
75 print "ERROR: No snmp response from $hostname (sigALRM)\n";
76 exit($STATUSCODE{"UNKNOWN"});
77};
78
79alarm($TIMEOUT);
80
81sub get_nfsops {
82 my $nfsops_start = &SNMPGET($OIDLIST{nfsops});
83 sleep(1);
84 my $nfsops_end = &SNMPGET($OIDLIST{nfsops});
85 my $nfsopspersec = $nfsops_end - $nfsops_start;
86 return($nfsopspersec);
87}
88
89
90sub show_help {
91 printf("\nPerl NetApp filer plugin for Nagios\n");
92 printf("Usage:\n");
93 printf("
94 check_netapp [options] <hostname>
95 Options:
96 -c snmp-community
97 -p snmp-port
98 -o Operations per second warning threshold
99 -m Operations per second critical threshold
100
101");
102 printf("Copyright (C)2000 Leland E. Vandervort\n");
103 printf("check_netapp comes with absolutely NO WARRANTY either implied or explicit\n");
104 printf("This program is licensed under the terms of the\n");
105 printf("GNU General Public License\n(check source code for details)\n\n\n");
106 exit($STATUSCODE{"UNKNOWN"});
107}
108
109
110$status = GetOptions( "community=s", \$community,
111 "port=i", \$port,
112 "opsthresh=i", \$opsthresh,
113 "maxops=i", \$critical );
114
115if($status == 0) {
116 &show_help;
117}
118
119sub SNMPGET {
120 $OID = shift;
121 ($session,$error) = Net::SNMP->session(
122 Hostname => $hostname,
123 Community => $community,
124 Port => $port
125 );
126 if(!defined($session)) {
127 printf("$state %s\n", $error);
128 exit($STATUSCODE{$state});
129 }
130 if(!defined($response = $session->get_request($OID))) {
131 printf("$state %s\n", $session->error());
132 $session->close();
133 exit($STATUSCODE{$state});
134 }
135 $session->close();
136 return($response->{$OID});
137}
138
139$hostname = shift || &show_help;
140
141my $tempcheck = &SNMPGET($OIDLIST{overtemp});
142if($tempcheck == 1) {
143 $state = "OK";
144 $status_string .= "Temp OK ";
145}
146else {
147 $state = "CRITICAL";
148 $status_string .= "Temp CRIT";
149}
150
151foreach $element ('failedfan','failedpsu') {
152 my $my_return = &SNMPGET($OIDLIST{$element});
153 if(($my_return =~ /no/) || ($my_return == 0)) {
154 $status_string .= "$element = $my_return ";
155 $state = "OK";
156 }
157 else {
158 $status_string .= "$element = $my_return ";
159 $state = "CRITICAL";
160 }
161}
162
163my $tmp_opssec = &get_nfsops();
164
165if ($tmp_opssec >= $critical) {
166 $state = "CRITICAL";
167}
168elsif ($tmp_opssec >= $opsthresh) {
169 $state = "WARNING";
170}
171else {
172 $state = "OK";
173}
174
175$status_string .= "Ops\/Sec = $tmp_opssec ";
176
177print "$state $status_string\n";
178exit($STATUSCODE{$state});
diff --git a/contrib/check_nmap.py b/contrib/check_nmap.py
deleted file mode 100644
index 481a62b..0000000
--- a/contrib/check_nmap.py
+++ /dev/null
@@ -1,441 +0,0 @@
1#!/usr/bin/python
2# Change the above line if python is somewhere else
3
4#
5# check_nmap
6#
7# Program: nmap plugin for Nagios
8# License: GPL
9# Copyright (c) 2000 Jacob Lundqvist (jaclu@galdrion.com)
10#
11_version_ = '1.21'
12#
13#
14# Description:
15#
16# Does a nmap scan, compares open ports to those given on command-line
17# Reports warning for closed that should be open and error for
18# open that should be closed.
19# If optional ports are given, no warning is given if they are closed
20# and they are included in the list of valid ports.
21#
22# Requirements:
23# python
24# nmap
25#
26# History
27# -------
28# 1.21 2004-07-23 rippeld@hillsboroughcounty.org Updated parsing of nmap output to correctly identify closed ports
29# 1.20 2000-07-15 jaclu Updated params to correctly comply to plugin-standard
30# moved support classes to utils.py
31# 1.16 2000-07-14 jaclu made options and return codes more compatible with
32# the plugin developer-guidelines
33# 1.15 2000-07-14 jaclu added random string to temp-file name
34# 1.14 2000-07-14 jaclu added check for error from subproc
35# 1.10 2000-07-14 jaclu converted main part to class
36# 1.08 2000-07-13 jaclu better param parsing
37# 1.07 2000-07-13 jaclu changed nmap param to -P0
38# 1.06 2000-07-13 jaclu make sure tmp file is deleted on errors
39# 1.05 2000-07-12 jaclu in debug mode, show exit code
40# 1.03 2000-07-12 jaclu error handling on nmap output
41# 1.01 2000-07-12 jaclu added license
42# 1.00 2000-07-12 jaclu implemented timeout handling
43# 0.20 2000-07-10 jaclu Initial release
44
45
46import sys, os, string, random
47
48import tempfile
49from getopt import getopt
50
51#
52# import generic Nagios-plugin stuff
53#
54import utils
55
56# Where temp files should be placed
57tempfile.tempdir='/usr/local/nagios/var'
58
59# Base name for tempfile
60tempfile.template='check_nmap_tmp.'
61
62# location and possibly params for nmap
63nmap_cmd='/usr/bin/nmap -P0'
64
65
66
67
68
69
70#
71# the class that does all the real work in this plugin...
72#
73#
74class CheckNmap:
75
76 # Retcodes, so we are compatible with nagios
77 #ERROR= -1
78 UNKNOWN= -1
79 OK= 0
80 WARNING= 1
81 CRITICAL= 2
82
83
84 def __init__(self,cmd_line=[]):
85 """Constructor.
86 arguments:
87 cmd_line: normaly sys.argv[1:] if called as standalone program
88 """
89 self.tmp_file=''
90 self.host='' # host to check
91 self.timeout=10
92 self.debug=0 # 1= show debug info
93 self.ports=[] # list of mandatory ports
94 self.opt_ports=[] # list of optional ports
95 self.ranges='' # port ranges for nmap
96 self.exit_code=0 # numerical exit-code
97 self.exit_msg='' # message to caller
98
99 self.ParseCmdLine(cmd_line)
100
101 def Run(self):
102 """Actually run the process.
103 This method should be called exactly once.
104 """
105
106 #
107 # Only call check_host if cmd line was accepted earlier
108 #
109 if self.exit_code==0:
110 self.CheckHost()
111
112 self.CleanUp()
113 return self.exit_code,self.exit_msg
114
115 def Version(self):
116 return 'check_nmap %s' % _version_
117
118 #-----------------------------------------
119 #
120 # class internal stuff below...
121 #
122 #-----------------------------------------
123
124 #
125 # Param checks
126 #
127 def param2int_list(self,s):
128 lst=string.split(string.replace(s,',',' '))
129 try:
130 for i in range(len(lst)):
131 lst[i]=int(lst[i])
132 except:
133 lst=[]
134 return lst
135
136 def ParseCmdLine(self,cmd_line):
137 try:
138 opt_list=getopt(cmd_line,'vH:ho:p:r:t:V',['debug','host=','help',
139 'optional=','port=','range=','timeout','version'])
140 for opt in opt_list[0]:
141 if opt[0]=='-v' or opt[0]=='--debug':
142 self.debug=1
143 elif opt[0]=='-H' or opt[0]=='--host':
144 self.host=opt[1]
145 elif opt[0]=='-h' or opt[0]=='--help':
146 doc_help()
147 self.exit_code=1 # request termination
148 break
149 elif opt[0]=='-o' or opt[0]=='--optional':
150 self.opt_ports=self.param2int_list(opt[1])
151 elif opt[0]=='-p' or opt[0]=='--port':
152 self.ports=self.param2int_list(opt[1])
153 elif opt[0]=='-r' or opt[0]=='--range':
154 r=string.replace(opt[1],':','-')
155 self.ranges=r
156 elif opt[0]=='-t' or opt[0]=='--timeout':
157 self.timeout=opt[1]
158 elif opt[0]=='-V' or opt[0]=='--version':
159 print self.Version()
160 self.exit_code=1 # request termination
161 break
162 else:
163 self.host=''
164 break
165
166 except:
167 # unknown param
168 self.host=''
169
170 if self.debug:
171 print 'Params:'
172 print '-------'
173 print 'host = %s' % self.host
174 print 'timeout = %s' % self.timeout
175 print 'ports = %s' % self.ports
176 print 'optional ports = %s' % self.opt_ports
177 print 'ranges = %s' % self.ranges
178 print
179
180 #
181 # a option that wishes us to terminate now has been given...
182 #
183 # This way, you can test params in debug mode and see what this
184 # program recognised by suplying a version param at the end of
185 # the cmd-line
186 #
187 if self.exit_code<>0:
188 sys.exit(self.UNKNOWN)
189
190 if self.host=='':
191 doc_syntax()
192 self.exit_code=self.UNKNOWN
193 self.exit_msg='UNKNOWN: bad params, try running without any params for syntax'
194
195
196 def CheckHost(self):
197 'Check one host using nmap.'
198 #
199 # Create a tmp file for storing nmap output
200 #
201 # The tempfile module from python 1.5.2 is stupid
202 # two processes runing at aprox the same time gets
203 # the same tempfile...
204 # For this reason I use a random suffix for the tmp-file
205 # Still not 100% safe, but reduces the risk significally
206 # I also inserted checks at various places, so that
207 # _if_ two processes in deed get the same tmp-file
208 # the only result is a normal error message to nagios
209 #
210 self.tmp_file=tempfile.mktemp('.%s') % random.randint(0,100000)
211 if self.debug:
212 print 'Tmpfile is: %s'%self.tmp_file
213 #
214 # If a range is given, only run nmap on this range
215 #
216 if self.ranges<>'':
217 global nmap_cmd # needed, to avoid error on next line
218 # since we assigns to nmap_cmd :)
219 nmap_cmd='%s -p %s' %(nmap_cmd,self.ranges)
220 #
221 # Prepare a task
222 #
223 t=utils.Task('%s %s' %(nmap_cmd,self.host))
224 #
225 # Configure a time-out handler
226 #
227 th=utils.TimeoutHandler(t.Kill, time_to_live=self.timeout,
228 debug=self.debug)
229 #
230 # Fork of nmap cmd
231 #
232 t.Run(detach=0, stdout=self.tmp_file,stderr='/dev/null')
233 #
234 # Wait for completition, error or timeout
235 #
236 nmap_exit_code=t.Wait(idlefunc=th.Check, interval=1)
237 #
238 # Check for timeout
239 #
240 if th.WasTimeOut():
241 self.exit_code=self.CRITICAL
242 self.exit_msg='CRITICAL - Plugin timed out after %s seconds' % self.timeout
243 return
244 #
245 # Check for exit status of subprocess
246 # Must do this after check for timeout, since the subprocess
247 # also returns error if aborted.
248 #
249 if nmap_exit_code <> 0:
250 self.exit_code=self.UNKNOWN
251 self.exit_msg='nmap program failed with code %s' % nmap_exit_code
252 return
253 #
254 # Read output
255 #
256 try:
257 f = open(self.tmp_file, 'r')
258 output=f.readlines()
259 f.close()
260 except:
261 self.exit_code=self.UNKNOWN
262 self.exit_msg='Unable to get output from nmap'
263 return
264
265 #
266 # Store open ports in list
267 # scans for lines where first word contains '/'
268 # and stores part before '/'
269 #
270 self.active_ports=[]
271 try:
272 for l in output:
273 if len(l)<2:
274 continue
275 s=string.split(l)[0]
276 if string.find(s,'/')<1:
277 continue
278 p=string.split(s,'/')[0]
279 if string.find(l,'open')>1:
280 self.active_ports.append(int(p))
281 except:
282 # failure due to strange output...
283 pass
284
285 if self.debug:
286 print 'Ports found by nmap: ',self.active_ports
287 #
288 # Filter out optional ports, we don't check status for them...
289 #
290 try:
291 for p in self.opt_ports:
292 self.active_ports.remove(p)
293
294 if self.debug and len(self.opt_ports)>0:
295 print 'optional ports removed:',self.active_ports
296 except:
297 # under extreame loads the remove(p) above failed for me
298 # a few times, this exception hanlder handles
299 # this bug-alike situation...
300 pass
301
302 opened=self.CheckOpen()
303 closed=self.CheckClosed()
304
305 if opened <>'':
306 self.exit_code=self.CRITICAL
307 self.exit_msg='PORTS CRITICAL - Open:%s Closed:%s'%(opened,closed)
308 elif closed <>'':
309 self.exit_code=self.WARNING
310 self.exit_msg='PORTS WARNING - Closed:%s'%closed
311 else:
312 self.exit_code=self.OK
313 self.exit_msg='PORTS ok - Only defined ports open'
314
315
316 #
317 # Compares requested ports on with actually open ports
318 # returns all open that should be closed
319 #
320 def CheckOpen(self):
321 opened=''
322 for p in self.active_ports:
323 if p not in self.ports:
324 opened='%s %s' %(opened,p)
325 return opened
326
327 #
328 # Compares requested ports with actually open ports
329 # returns all ports that are should be open
330 #
331 def CheckClosed(self):
332 closed=''
333 for p in self.ports:
334 if p not in self.active_ports:
335 closed='%s %s' % (closed,p)
336 return closed
337
338
339 def CleanUp(self):
340 #
341 # If temp file exists, get rid of it
342 #
343 if self.tmp_file<>'' and os.path.isfile(self.tmp_file):
344 try:
345 os.remove(self.tmp_file)
346 except:
347 # temp-file colition, some other process already
348 # removed the same file...
349 pass
350
351 #
352 # Show numerical exits as string in debug mode
353 #
354 if self.debug:
355 print 'Exitcode:',self.exit_code,
356 if self.exit_code==self.UNKNOWN:
357 print 'UNKNOWN'
358 elif self.exit_code==self.OK:
359 print 'OK'
360 elif self.exit_code==self.WARNING:
361 print 'WARNING'
362 elif self.exit_code==self.CRITICAL:
363 print 'CRITICAL'
364 else:
365 print 'undefined'
366 #
367 # Check if invalid exit code
368 #
369 if self.exit_code<-1 or self.exit_code>2:
370 self.exit_msg=self.exit_msg+' - undefined exit code (%s)' % self.exit_code
371 self.exit_code=self.UNKNOWN
372
373
374
375
376
377#
378# Help texts
379#
380def doc_head():
381 print """
382check_nmap plugin for Nagios
383Copyright (c) 2000 Jacob Lundqvist (jaclu@galdrion.com)
384License: GPL
385Version: %s""" % _version_
386
387
388def doc_syntax():
389 print """
390Usage: check_nmap.py [-v|--debug] [-H|--host host] [-V|--version] [-h|--help]
391 [-o|--optional port1,port2,port3 ...] [-r|--range range]
392 [-p|--port port1,port2,port3 ...] [-t|--timeout timeout]"""
393
394
395def doc_help():
396 'Help is displayed if run without params.'
397 doc_head()
398 doc_syntax()
399 print """
400Options:
401 -h = help (this screen ;-)
402 -v = debug mode, show some extra output
403 -H host = host to check (name or IP#)
404 -o ports = optional ports that can be open (one or more),
405 no warning is given if optional port is closed
406 -p ports = ports that should be open (one or more)
407 -r range = port range to feed to nmap. Example: :1024,2049,3000:7000
408 -t timeout = timeout in seconds, default 10
409 -V = Version info
410
411This plugin attempts to verify open ports on the specified host.
412
413If all specified ports are open, OK is returned.
414If any of them are closed, WARNING is returned (except for optional ports)
415If other ports are open, CRITICAL is returned
416
417If possible, supply an IP address for the host address,
418as this will bypass the DNS lookup.
419"""
420
421
422#
423# Main
424#
425if __name__ == '__main__':
426
427 if len (sys.argv) < 2:
428 #
429 # No params given, show syntax and exit
430 #
431 doc_syntax()
432 sys.exit(-1)
433
434 nmap=CheckNmap(sys.argv[1:])
435 exit_code,exit_msg=nmap.Run()
436
437 #
438 # Give Nagios a msg and a code
439 #
440 print exit_msg
441 sys.exit(exit_code)
diff --git a/contrib/check_ora_table_space.pl b/contrib/check_ora_table_space.pl
deleted file mode 100644
index 7ce90c8..0000000
--- a/contrib/check_ora_table_space.pl
+++ /dev/null
@@ -1,82 +0,0 @@
1#!/usr/bin/perl
2#
3# Program check_ora_table_space
4# Written by: Erwan Arzur (erwan@netvalue.com)
5# License: GPL
6#
7# Last Modified: $Date: 2002-02-28 01:42:51 -0500 (Thu, 28 Feb 2002) $
8# Revisiin: $Revision: 2 $
9#
10# "check_ora_table_space.pl" plugin to check the state of Oracle
11# table spaces. Scarce documentation.
12#
13# you need DBD-Oracle-1.03.tar.gz and DBI-1.13.tar.gz from CPAN.org as
14# well as some Oracle client stuff to use it.
15#
16# The SQL request comes from www.dbasupport.com
17#
18
19use DBI;
20$ENV{"ORACLE_HOME"}="/intranet/apps/oracle";
21
22my $host = shift || &usage ("no host specified");
23my $sid = shift || &usage ("no sid specified");
24my $port = shift || &usage ("no port specified");
25my $dbuser = shift || &usage ("no user specified");
26my $dbpass = shift || &usage ("no password specified");
27my $tablespace = shift || &usage ("no table space specified");
28
29my $alertpct = int(shift) || &usage ("no warning state percentage specified");
30my $critpct = int(shift) || &usage ("no critical state percentage specified");
31
32my $dbh = DBI->connect( "dbi:Oracle:host=$host;port=$port;sid=$sid", $dbuser, $dbpass, { PrintError => 0, AutoCommit => 1, RaiseError => 0 } )
33 || &error ("cannot connect to $dbname: $DBI::errstr\n");
34
35#$sth = $dbh->prepare(q{SELECT tablespace_name, SUM(BYTES)/1024/1024 FreeSpace FROM dba_free_space group by tablespace_name})
36my $exit_code = -1;
37$sth = $dbh->prepare(<<EOF
38select a.TABLESPACE_NAME, a.total,nvl(b.used,0) USED,
39nvl((b.used/a.total)*100,0) PCT_USED
40from (select TABLESPACE_NAME, sum(bytes)/(1024*1024) total
41from sys.dba_data_files group by TABLESPACE_NAME) a,
42(select TABLESPACE_NAME,bytes/(1024*1024) used from sys.SM\$TS_USED) b
43where a.TABLESPACE_NAME='$tablespace' and
44 a.TABLESPACE_NAME=b.TABLESPACE_NAME(+)
45EOF
46)
47 || &error("Cannot prepare request : $DBI::errstr\n");
48$sth->execute
49 || &error("Cannot execute request : $DBI::errstr\n");
50
51while (($tbname, $total, $used, $pct_used) = $sth->fetchrow)
52{
53 $pct_used=int($pct_used);
54 print STDOUT "size: " . $total . " MB Used:" . int($used) . " MB (" . int($pct_used) . "%)\n";
55 #print "table space $answer\n";
56 if ($pct_used > $alertpct) {
57 if ($pct_used > $critpct) {
58 $exit_code = 2
59 } else {
60 $exit_code = 1;
61 }
62 } else {
63 $exit_code = 0;
64 }
65}
66
67$rc = $dbh->disconnect
68 || &error ("Cannot disconnect from database : $dbh->errstr\n");
69
70exit ($exit_code);
71
72sub usage {
73 print "@_\n" if @_;
74 print "usage : check_ora_table_space.pl <host> <sid> <port> <user> <passwd> <tablespace> <pctwarn> <pctcrit>\n";
75 exit (-1);
76}
77
78sub error {
79 print "@_\n" if @_;
80 exit (2);
81}
82
diff --git a/contrib/check_oracle_instance.pl b/contrib/check_oracle_instance.pl
deleted file mode 100644
index 3ba8d57..0000000
--- a/contrib/check_oracle_instance.pl
+++ /dev/null
@@ -1,470 +0,0 @@
1#!/usr/bin/perl
2# $Id: check_oracle_instance.pl 10 2002-04-03 02:58:47Z sghosh $
3
4# Copyright (c) 2002 Sven Dolderer
5# some pieces of Code adopted from Adam vonNieda's oracletool.pl
6# (http://www.oracletool.com)
7#
8# You may distribute under the terms of either the GNU General Public
9# License or the Artistic License, as specified in the Perl README file,
10# with the exception that it cannot be placed on a CD-ROM or similar media
11# for commercial distribution without the prior approval of the author.
12
13# This software is provided without warranty of any kind.
14
15require 5.003;
16
17use strict;
18use Getopt::Long;
19
20# We need the DBI and DBD-Oracle Perl modules:
21require DBI || die "It appears that the DBI module is not installed! aborting...\n";
22require DBD::Oracle || die "It appears that the DBD::Oracle module is not installed! aborting...\n";
23
24use vars qw($VERSION $PROGNAME $logfile $debug $state $dbh $database $username $password $message $sql $cursor $opt_asession $opt_nsession $opt_tablespace $opt_nextents $opt_fextents $opt_aextents $privsok $warn $critical);
25
26'$Revision: 10 $' =~ /^.*(\d+.\d+) \$$/; # Use The Revision from RCS/CVS
27$VERSION = $1;
28$0 =~ m!^.*/([^/]+)$!;
29$PROGNAME = $1;
30#$debug="true";
31$logfile = "/tmp/check_oracle_instance.log";
32my %ERRORS = (UNKNOWN => -1, OK => 0, WARNING => 1, CRITICAL => 2);
33
34# Read cmdline opts:
35Getopt::Long::Configure('bundling', 'no_ignore_case');
36GetOptions (
37 "V|version" => \&version,
38 "h|help" => \&usage,
39 "u|user=s" => \$username,
40 "p|passwd=s" => \$password,
41 "c|connect=s" => \$database,
42 "a|active-sessions:s" => \$opt_asession,
43 "s|num-sessions:s" => \$opt_nsession,
44 "t|tablespaces:s" => \$opt_tablespace,
45 "n|num-extents:s" => \$opt_nextents,
46 "f|free-extents:s" => \$opt_fextents,
47 "x|allocate-extents" => \$opt_aextents
48 );
49($database && $username && $password) || die "mandatory parameters missing (try -h)\n";
50logit(" \$opt_asession = \"$opt_asession\"");
51logit(" \$opt_nsession = \"$opt_nsession\"");
52logit(" \$opt_tablespace = \"$opt_tablespace\"");
53logit(" \$opt_nextents = \"$opt_nextents\"");
54logit(" \$opt_fextents = \"$opt_fextents\"");
55logit(" \$opt_aextents = \"$opt_aextents\"");
56
57# so let's connect to the instance...
58$dbh = dbConnect($database,$username,$password);
59
60$message="$database: ";
61check_sessions($opt_nsession) if ($opt_nsession && $privsok);
62check_sessions($opt_asession,"active") if ($opt_asession && $privsok);
63check_tablespaces($opt_tablespace) if ($opt_tablespace && $privsok);
64check_nextents($opt_nextents) if ($opt_nextents && $privsok);
65check_fextents($opt_fextents) if ($opt_fextents && $privsok);
66check_aextents() if ($opt_aextents && $privsok);
67
68$message=$message . "ok. " . getDbVersion($dbh) unless ($state);
69print "$message\n";
70exit $state;
71
72
73sub usage {
74 copyright();
75 print "
76This plugin will check various things of an oracle database instance.
77
78Prerequisties are: a local oracle client,
79 perl > v5.003, and DBI and DBD::Oracle perl modules.
80
81Usage: $PROGNAME -u <user> -p <passwd> -c <connectstring>
82 [-a <w>/<c>] [-s <w>/<c>] [-t <w>/<c>] [-n <w>/<c>] [-f <w>/<c>] [-x]
83 $PROGNAME [-V|--version]
84 $PROGNAME [-h|--help]
85";
86 print "
87Options:
88 -u, --user=STRING
89 the oracle user
90 -p, --passwd=STRING
91 the oracle password
92 -c, --connect=STRING
93 the oracle connectstring as defined in tnsnames.ora
94 -a, --active-sessions=WARN/CRITICAL
95 check the number of active (user-)sessions
96 WARN(Integer): number of sessions to result in warning status,
97 CRITICAL(Integer): number of sessions to result in critical status
98 -s, --num-sessions=WARN/CRITICAL
99 check the total number of (user-)sessions
100 WARN(Integer): number of sessions to result in warning status,
101 CRITICAL(Integer): number of sessions to result in critical status
102 -t, --tablespaces=WARN/CRITICAL
103 check the percent of used space in every tablespace
104 WARN(Integer): percentage to result in warning status,
105 CRITICAL(Integer): percentage to result in critical status
106 -n, --num-extents=WARN/CRITICAL
107 check the number of extents of every object (excluding SYS schema)
108 WARN(Integer): number of extents to result in warning status,
109 CRITICAL(Integer): number of extents to result in critical status
110 -f, --free-extents=WARN/CRITICAL
111 check the number of free extents of every object: max_extents - #extents
112 WARN(Integer): number of free extents to result in warning status,
113 CRITICAL(Integer): number of free extents to result in critical status
114 -x, --allocate-extents
115 warn if an object cannot allocate a next extent.
116";
117 exit $ERRORS{"UNKNOWN"};
118}
119
120
121sub version {
122 copyright();
123 print "
124$PROGNAME $VERSION
125";
126 exit $ERRORS{"UNKNOWN"};
127}
128
129
130sub copyright {
131 print "The netsaint plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
132copies of the plugins under the terms of the GNU General Public License.
133For more information about these matters, see the file named COPYING.
134Copyright (c) 2002 Sven Dolderer\n";
135}
136
137
138sub logit {
139 my $text = shift;
140 if ($debug) {
141 open (LOG,">>$logfile") || die "Cannot open log file \"$logfile\"!";
142 print LOG "$text\n";
143 close (LOG);
144 }
145}
146
147
148sub dbConnect {
149 logit("Enter subroutine dbConnect");
150
151 my $database = shift;
152 my $username = shift;
153 my $password = shift;
154
155# Attempt to make connection to the database..
156 my $data_source = "dbi:Oracle:$database";
157 $dbh = DBI->connect($data_source,$username,$password,{PrintError=>0});
158
159# Show an error message for these errors.
160# ORA-12224 - "The connection request could not be completed because the listener is not running."
161# ORA-01034 - "Oracle was not started up."
162# ORA-01090 - "Shutdown in progress - connection is not permitted""
163# ORA-12154 - "The service name specified is not defined correctly in the TNSNAMES.ORA file."
164# ORA-12505 - "TNS:listener could not resolve SID given in connect descriptor."
165# ORA-12545 - "TNS:name lookup failure."
166
167 unless ($dbh) {
168 logit(" Error message is ~$DBI::errstr~");
169 if ( $DBI::errstr =~ /ORA-01017|ORA-1017|ORA-01004|ORA-01005/ ) {
170 $message="Login error: ~$DBI::errstr~";
171 $state=$ERRORS{"UNKNOWN"};
172 } elsif ( $DBI::errstr =~ /ORA-12224/ ) {
173 $message= "You received an ORA-12224, which usually means the listener is down, or your connection definition in your tnsnames.ora file is incorrect. Check both of these things and try again.";
174 $state=$ERRORS{"CRITICAL"};
175 } elsif ( $DBI::errstr =~ /ORA-01034/ ) {
176 $message= "You received an ORA-01034, which usually means the database is down. Check to be sure the database is up and try again.";
177 $state=$ERRORS{"CRITICAL"};
178 } elsif ( $DBI::errstr =~ /ORA-01090/ ) {
179 $message= "You received an ORA-01090, which means the database is in the process of coming down.";
180 $state=$ERRORS{"CRITICAL"};
181 } elsif ( $DBI::errstr =~ /ORA-12154/ ) {
182 $message= "You received an ORA-12154, which probably means you have a mistake in your TNSNAMES.ORA file for the database that you chose.";
183 $state=$ERRORS{"UNKNOWN"};
184 } elsif ( $DBI::errstr =~ /ORA-12505/ ) {
185 $message= "You received an ORA-12505, which probably means you have a mistake in your TNSNAMES.ORA file for the database that you chose, or the database you are trying to connect to is not defined to the listener that is running on that node.";
186 $state=$ERRORS{"UNKNOWN"};
187 } elsif ( $DBI::errstr =~ /ORA-12545/ ) {
188 $message= "You received an ORA-12545, which probably means you have a mistake in your TNSNAMES.ORA file for the database that you chose. (Possibly the node name).";
189 $state=$ERRORS{"UNKNOWN"};
190 } else {
191 $message="Unable to connect to Oracle ($DBI::errstr)\n";
192 $state=$ERRORS{"UNKNOWN"};
193 }
194
195 } else {
196 logit(" Login OK.");
197
198 # check to be sure this user has "SELECT ANY TABLE" privilege.
199 logit(" checking for \"SELECT ANY TABLE\" privilege");
200 if (checkPriv("SELECT ANY TABLE") < 1) {
201 $message="user $username needs \"SELECT ANY TABLE\" privilege.";
202 $state=$ERRORS{"UNKNOWN"};
203 } else {
204 $privsok="yep";
205 $state=$ERRORS{"OK"};
206 }
207 }
208 return ($dbh);
209}
210
211
212sub getDbVersion {
213
214 logit("Enter subroutine getDbVersion");
215
216 my $dbh = shift;
217 my $oraversion;
218
219# Find out if we are dealing with Oracle7 or Oracle8
220 logit(" Getting Oracle version");
221 $sql = "select banner from v\$version where rownum=1";
222
223 $cursor = $dbh->prepare($sql) or logit("Error: $DBI::errstr");
224 $cursor->execute;
225 (($oraversion) = $cursor->fetchrow_array);
226 $cursor->finish;
227 logit(" Oracle version = $oraversion");
228 return $oraversion;
229}
230
231
232sub checkPriv {
233 logit("Enter subroutine checkPriv");
234 my ($privilege,$yesno);
235 $privilege = shift;
236 logit(" Checking for privilege \"$privilege\"");
237
238 $sql = "SELECT COUNT(*) FROM SESSION_PRIVS WHERE PRIVILEGE = '$privilege'";
239 $cursor=$dbh->prepare($sql);
240 $cursor->execute; $yesno = $cursor->fetchrow_array;
241 $cursor->finish;
242
243 return($yesno);
244}
245
246
247sub get_values {
248 logit("Enter subroutine get_values");
249 my ($args, $inverse, $abort);
250 $args = shift;
251 $inverse = shift;
252 if ($args =~ m!^(\d+)/(\d+)$!) {
253 $warn = $1;
254 $critical = $2;
255
256 # TODO: check for positive numbers!
257
258 if (! $inverse && $warn >= $critical) {
259 print "\"$args\": warning threshold must be less than critical threshold. aborting...\n";
260 $abort="yep";
261 }
262 if ($inverse && $warn <= $critical) {
263 print "\"$args\": warning threshold must be greater than critical threshold. aborting...\n";
264 $abort="yep";
265 }
266 } else {
267 print "\"$args\": invalid warn/critical thresholds. aborting...\n";
268 $abort="yep";
269 }
270 exit $ERRORS{"UNKNOWN"} if $abort;
271 logit (" args=$args, warn=$warn, critical=$critical");
272}
273
274
275sub check_sessions {
276 logit("Enter subroutine check_sessions");
277 my ($args, $add, $sqladd, $count);
278 $args = shift;
279 $add = shift || '#'; # Default: Number of sessions
280 $sqladd = "AND STATUS = 'ACTIVE'" if ($add eq "active");
281
282 get_values($args);
283
284 $sql = "SELECT COUNT(*) FROM V\$SESSION WHERE TYPE <> 'BACKGROUND' $sqladd";
285 $cursor=$dbh->prepare($sql);
286 $cursor->execute;
287 $count = $cursor->fetchrow_array;
288 $cursor->finish;
289 logit (" $add sessions is $count");
290
291 if ($count >= $critical) {
292 $message = $message . "$add sessions critical ($count) ";
293 $state=$ERRORS{"CRITICAL"};
294 } elsif ($count >= $warn) {
295 $message = $message . "$add sessions warning ($count) ";
296 $state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"};
297 }
298}
299
300
301sub check_tablespaces {
302 logit("Enter subroutine check_tablespaces");
303 my ($args, $tablespace, $pctused, $mymsg, $mywarn, $mycritical);
304 $args = shift;
305 $mymsg = "Tablespace usage ";
306
307 get_values($args);
308
309 $sql = "SELECT
310 DF.TABLESPACE_NAME \"Tablespace name\",
311 NVL(ROUND((DF.BYTES-SUM(FS.BYTES))*100/DF.BYTES),100) \"Percent used\"
312 FROM DBA_FREE_SPACE FS,
313 (SELECT TABLESPACE_NAME, SUM(BYTES) BYTES FROM DBA_DATA_FILES GROUP BY
314 TABLESPACE_NAME ) DF
315 WHERE FS.TABLESPACE_NAME (+) = DF.TABLESPACE_NAME
316 GROUP BY DF.TABLESPACE_NAME, DF.BYTES
317 ORDER BY 2 DESC";
318
319 $cursor=$dbh->prepare($sql);
320 $cursor->execute;
321 while (($tablespace, $pctused) = $cursor->fetchrow_array) {
322 logit (" $tablespace - $pctused% used");
323 if ($pctused >= $critical) {
324 unless ($mycritical) {
325 $mymsg = $mymsg . "critical: ";
326 $mycritical="yep";
327 }
328 $mymsg = $mymsg . "$tablespace ($pctused%) ";
329 $state=$ERRORS{"CRITICAL"};
330 } elsif ($pctused >= $warn) {
331 unless ($mywarn) {
332 $mymsg = $mymsg . "warning: ";
333 $mywarn="yep";
334 }
335 $mymsg = $mymsg . "$tablespace ($pctused%) ";
336 $state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"};
337 }
338 }
339 $cursor->finish;
340 $message = $message . $mymsg . " " if ($mycritical || $mywarn);
341}
342
343
344sub check_nextents {
345 logit("Enter subroutine check_nextents");
346 my ($args, $owner, $objname, $objtype, $extents, $mymsg, $mywarn, $mycritical);
347 $args = shift;
348 $mymsg = "#Extents ";
349
350 get_values($args);
351
352 $sql = "SELECT
353 OWNER \"Owner\",
354 SEGMENT_NAME \"Object name\",
355 SEGMENT_TYPE \"Object type\",
356 COUNT(*) \"Extents\"
357 FROM DBA_EXTENTS WHERE OWNER <> 'SYS'
358 GROUP BY SEGMENT_TYPE, SEGMENT_NAME, TABLESPACE_NAME, OWNER
359 HAVING COUNT(*) >= $warn
360 ORDER BY 4 DESC";
361
362 $cursor=$dbh->prepare($sql);
363 $cursor->execute;
364 while (($owner, $objname, $objtype, $extents) = $cursor->fetchrow_array) {
365 if ($extents >= $critical) {
366 unless ($mycritical) {
367 $mymsg = $mymsg . "critical: ";
368 $mycritical="yep";
369 }
370 $mymsg = $mymsg . "$owner.$objname($objtype)=$extents ";
371 $state=$ERRORS{"CRITICAL"};
372 } elsif ($extents >= $warn) {
373 unless ($mywarn) {
374 $mymsg = $mymsg . "warning: ";
375 $mywarn="yep";
376 }
377 $mymsg = $mymsg . "$owner.$objname($objtype)=$extents ";
378 $state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"};
379 }
380 }
381 $cursor->finish;
382 $message = $message . $mymsg . " " if ($mycritical || $mywarn);
383}
384
385
386sub check_fextents {
387 logit("Enter subroutine check_fextents");
388 my ($args, $owner, $objname, $objtype, $extents, $maxextents, $freextents, $mymsg, $mywarn, $mycritical);
389 $args = shift;
390 $mymsg = "Free extents ";
391
392 get_values($args, "inverse");
393
394 $sql = "SELECT
395 OWNER \"Owner\",
396 SEGMENT_NAME \"Object name\",
397 SEGMENT_TYPE \"Object type\",
398 EXTENTS \"Extents\",
399 MAX_EXTENTS \"Max extents\",
400 MAX_EXTENTS - EXTENTS \"Free extents\"
401 FROM DBA_SEGMENTS
402 WHERE (EXTENTS + $warn) >= MAX_EXTENTS
403 AND SEGMENT_TYPE != 'CACHE'
404 ORDER BY 6";
405
406 $cursor=$dbh->prepare($sql);
407 $cursor->execute;
408 while (($owner, $objname, $objtype, $extents, $maxextents, $freextents) = $cursor->fetchrow_array) {
409 if ($freextents <= $critical) {
410 unless ($mycritical) {
411 $mymsg = $mymsg . "critical: ";
412 $mycritical="yep";
413 }
414 $mymsg = $mymsg . "$owner.$objname($objtype)=$extents ";
415 $state=$ERRORS{"CRITICAL"};
416 } elsif ($freextents <= $warn) {
417 unless ($mywarn) {
418 $mymsg = $mymsg . "warning: ";
419 $mywarn="yep";
420 }
421 $mymsg = $mymsg . "$owner.$objname($objtype)=$extents/$maxextents ";
422 $state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"};
423 }
424 }
425 $cursor->finish;
426 $message = $message . $mymsg . " " if ($mycritical || $mywarn);
427}
428
429
430sub check_aextents {
431 logit("Enter subroutine check_aextents");
432 my ($args, $owner, $objname, $objtype, $tablespace_name, $mymsg, $mywarn);
433 my (@tablespaces);
434
435 # Get a list of all tablespaces
436 $sql = "SELECT TABLESPACE_NAME
437 FROM DBA_TABLESPACES ORDER BY TABLESPACE_NAME";
438 $cursor = $dbh->prepare($sql);
439 $cursor->execute;
440 while ($tablespace_name = $cursor->fetchrow_array) {
441 push @tablespaces, $tablespace_name;
442 }
443 $cursor->finish;
444
445 # Search every tablespace for objects which cannot allocate a next extent.
446 foreach $tablespace_name(@tablespaces) {
447 logit (" checking tablespace $tablespace_name");
448 $sql = "SELECT
449 OWNER \"Owner\",
450 SEGMENT_NAME \"Object name\",
451 SEGMENT_TYPE \"Object type\"
452 FROM DBA_SEGMENTS
453 WHERE TABLESPACE_NAME = '$tablespace_name'
454 AND NEXT_EXTENT > (SELECT NVL(MAX(BYTES),'0') FROM DBA_FREE_SPACE
455 WHERE TABLESPACE_NAME = '$tablespace_name')";
456 $cursor = $dbh->prepare($sql);
457 $cursor->execute;
458 while (($owner, $objname, $objtype) = $cursor->fetchrow_array) {
459 logit (" found: $owner.$objname($objtype)");
460 unless ($mywarn) {
461 $mymsg = $mymsg . "warning: ";
462 $mywarn="yep";
463 }
464 $mymsg = $mymsg . "$owner.$objname($objtype) ";
465 $state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"};
466 }
467 $cursor->finish;
468 }
469 $message = $message . $mymsg . "cannot allocate a next extent. " if $mywarn;
470}
diff --git a/contrib/check_oracle_tbs b/contrib/check_oracle_tbs
deleted file mode 100644
index 8281a4e..0000000
--- a/contrib/check_oracle_tbs
+++ /dev/null
@@ -1,218 +0,0 @@
1#!/usr/local/bin/perl -w
2
3# (c)2004 John Koyle, RFP Depot, LLC.
4# This is free software use it however you would like.
5
6use strict;
7use DBI;
8use Getopt::Long 2.16;
9use lib "/usr/local/nagios/libexec";
10use utils qw(%ERRORS);
11
12
13#*******************************************************************************
14# Set user configureable options here.
15#
16# Global Oracle info set here rather than command line to avoid output in ps -ef
17# Make sure this script is mode 700 and owner of the nrpe user
18#
19#*******************************************************************************
20my $orasid = "";
21my $orauser = "";
22my $orapwd = "";
23
24
25if (!$ENV{ORACLE_HOME}) {
26 $ENV{ORACLE_HOME} = '/u01/app/oracle/product/9.2';
27}
28
29#*******************************************************************************
30my $state = $ERRORS{'UNKNOWN'};
31my $answer = undef;
32
33my ($MAJOR_VERSION, $MINOR_VERSION) = q$Revision: 1134 $ =~ /(\d+)\.(\d+)/;
34my $VERSION = sprintf("%d.%02d", $MAJOR_VERSION - 1, $MINOR_VERSION);
35
36my $opt_debug; # -d|--debug
37my $opt_help; # -h|--help
38my $opt_version; # -V|--version
39my $opt_warn_space; # -w|--warn-space
40my $opt_crit_space; # -c|--crit-space
41
42
43
44my $help = <<MARK; # help statement
45
46check_oracle_tbs v$VERSION
47
48Checks the tablespaces in an Oracle database for available free space.
49Usage: check_oracle_tbs [-w <warn>] [-c <crit>]
50
51 -d, --debug Output debug to screen.
52 -h, --help Displays this help and exits.
53 -w, --warn-space=... Warning threshold % free (default 15)
54 -c, --crit-space=... Critical threshold % free (default 10)
55 -V, --version Output version information and exit.
56
57MARK
58
59## We want exact matches to the switches
60
61Getopt::Long::config('no_auto_abbrev', 'no_ignore_case');
62
63
64my $rc = GetOptions(
65 "debug|d" => \$opt_debug,
66 "help|h" => \$opt_help,
67 "w|warn-space=s" => \$opt_warn_space,
68 "c|crit-space=s" => \$opt_crit_space,
69 "V|version" => \$opt_version,
70 );
71
72
73#***********************************************************************
74# Process command-line switches
75#***********************************************************************
76
77if (! $rc || defined $opt_help)
78{
79 print STDERR $help;
80 exit (defined $opt_help ? 0 : 1);
81}
82
83if (defined $opt_version)
84{
85 print STDERR "check_oracle_tbs v$VERSION\n";
86 exit 0;
87}
88
89if (! defined $opt_warn_space)
90{
91 if(defined $opt_debug) {
92 print STDOUT "Warn space not defined, using 80%\n\n";
93 }
94 $opt_warn_space = 15;
95}
96
97if (! defined $opt_crit_space)
98{
99 if(defined $opt_debug) {
100 print STDOUT "Crit space not defined, using 90%\n\n";
101 }
102 $opt_crit_space = 10;
103}
104
105my $array_ref = executeSQL();
106
107# Don't match certain tablespaces.
108foreach my $row (@$array_ref) {
109 my ( $tbs_name, $free_mb, $tot_mb, $free_pct) = @$row;
110 if ($opt_debug) { print STDOUT "Output: $tbs_name\t$tot_mb\t$free_mb\t$free_pct\n\n"; }
111 if ($free_pct < $opt_crit_space && $tbs_name !~ /RBS/ && $tbs_name !~ /PERFSTAT/ && $tbs_name !~ /UNDOTBS/) {
112 $state = $ERRORS{'CRITICAL'};
113 $answer .= "Critical: $tbs_name = $free_pct\% ";
114 last;
115 }
116 if ($free_pct < $opt_warn_space && $tbs_name !~ /RBS/ && $tbs_name !~ /PERFSTAT/ && $tbs_name !~ /UNDOTBS/) {
117 $state = $ERRORS{'WARNING'};
118 $answer .= "Warning: $tbs_name = $free_pct\% ";
119 }
120}
121
122if ($state != $ERRORS{'CRITICAL'} && $state != $ERRORS{'WARNING'}) {
123 $state = $ERRORS{'OK'};
124 $answer = "All Tablespaces OK";
125}
126
127if ($opt_debug && $state != $ERRORS{'OK'}) { print STDOUT "The following tablespaces are in question: $answer\n\n"; }
128
129foreach my $key (keys %ERRORS) {
130 if ($state==$ERRORS{$key}) {
131 print ("$key: $answer");
132 last;
133 }
134}
135exit $state;
136
137#------------------SUBS-------------------------------------------------------
138sub executeSQL
139{
140 my ($dbh, $sth, $results);
141
142 $dbh = openOracle();
143
144 eval {
145 $dbh->{RaiseError} = 1;
146 $sth = $dbh->prepare(q{
147 select ts.tablespace_name,
148 trunc(sum(ts.free_b)/1024/1024) free,
149 trunc(sum(ts.max_b)/1024/1024) total,
150 trunc( sum(ts.free_b)/sum(ts.max_b)*1000) / 10 as pct_free
151 from
152 (select a.file_id,
153 a.tablespace_name,
154 decode(a.autoextensible,'YES',a.maxsize-a.bytes+b.free,'NO',b.free) free_b,
155 a.maxsize max_b
156 from (select file_id,
157 tablespace_name,
158 autoextensible,
159 bytes,
160 decode(autoextensible,'YES',maxbytes,bytes) maxsize
161 from dba_data_files) a,
162 (select file_id,
163 tablespace_name,
164 sum(bytes) free
165 from dba_free_space
166 group by file_id, tablespace_name) b
167 where a.file_id=b.file_id(+)) ts
168 group by tablespace_name
169 });
170
171 $sth->execute();
172 $results = $sth->fetchall_arrayref();
173 $sth->finish;
174 $dbh->{RaiseError} = 0;
175 };
176
177 if ($@) {
178 closeOracle($dbh);
179 if($opt_debug) { print STDOUT "DB Failed Query: $@\n"; }
180 CleanupAndExit($ERRORS{'UNKNOWN'});
181 }
182
183 closeOracle($dbh);
184
185 return $results;
186}
187
188#------ Open the connection to the database and return the handle
189sub openOracle
190{
191 my ($dbh);
192
193 $dbh = DBI->connect("$orasid", "$orauser", "$orapwd", "Oracle");
194
195 if (!$dbh) {
196 if ($opt_debug) { print "ERROR: Could not connect to Oracle!\n\n"; }
197 CleanupAndExit($ERRORS{'UNKNOWN'});
198 }
199 if ($opt_debug) { print "Connected to Oracle SID $orasid\n\n"; }
200 return $dbh;
201}
202
203#------- Close the database connection
204sub closeOracle()
205{
206 my ($dbh) = @_;
207
208 $dbh->disconnect;
209}
210
211#------ Exit with the current return code
212sub CleanupAndExit
213{
214 my ($rc) = @_;
215
216 exit($rc);
217}
218
diff --git a/contrib/check_pcpmetric.py b/contrib/check_pcpmetric.py
deleted file mode 100644
index 71d816d..0000000
--- a/contrib/check_pcpmetric.py
+++ /dev/null
@@ -1,106 +0,0 @@
1#! /usr/bin/env python
2#
3# Nagios client for checking Performance Co-Pilot metrics
4#
5#
6
7from sys import argv,exit
8import popen2, getopt, string, types
9
10DEBUG=0
11
12nagios_pcpclient_version = 0.01
13PMVAL='/usr/bin/pmval'
14COMMANDLINE=PMVAL + " -s 1"
15METRIC='undefined'
16CRITICAL=0
17WARNING=0
18
19def usage():
20 print "Usage:", argv[0], "[options]"
21 print "Options:"
22 print "\t[-H host]\tHostname to contact"
23 print "\t[-m metric]\tPCP metric to check"
24 print "\t[-i instance]\tPCP metric instance"
25 print "\t[-w warn]\tIssue warning alert if value is larger than this"
26 print "\t[-c critical]\tIssue critical alert value is larger than this"
27 print "\t[-V]\t\tProgram version"
28 print "\t[-h]\t\tThis helptext"
29 print ""
30 print "F.ex. to check 5 minute loadaverage, warn if the load is above 2,"
31 print "and give critical warning if it's above 10:"
32 print "\n\t%", argv[0], " -i 5 -m kernel.all.load -w 2 -c 10"
33 print ""
34 print "A list of all PCP metrics can be found with the command 'pminfo'."
35 print "A list of all instances within a metric can be found with 'pminfo -f metric'."
36 print "F.ex. to see all available instances of 'filesys.full' execute:"
37 print "\n\t% pminfo -f filesys.full"
38 print "\tfilesys.full"
39 print """\t\tinst [0 or "/dev/root"] value 45.35514044640914"""
40 print """\t\tinst [1 or "/dev/sda1"] value 46.74285959344712"""
41 print """\t\tinst [2 or "/dev/sdb1"] value 0.807766570678168"""
42 print ""
43 print "And the command to have nagios monitor the /dev/sda1 filesystem would be:"
44 print "\n\t", argv[0], " -i /dev/sda1 -m filesys.full -w 70 -c 90"
45
46
47opts, args = getopt.getopt(argv[1:],'hH:c:w:m:i:V')
48for opt in opts:
49 key,value = opt
50 if key == '-H':
51 COMMANDLINE = COMMANDLINE + " -h " + value
52 elif key == '-m':
53 METRIC=value
54 elif key == '-i':
55 COMMANDLINE = COMMANDLINE + " -i " + value
56 elif key == '-c':
57 CRITICAL = value
58 elif key == '-w':
59 WARNING = value
60 elif key == '-h':
61 usage()
62 exit(0)
63 elif key == '-V':
64 print "Nagios Performance CoPilot client v%.2f" % nagios_pcpclient_version
65 print "Written by Jan-Frode Myklebust <janfrode@parallab.uib.no>"
66 exit(0)
67
68if METRIC == 'undefined':
69 usage()
70 exit(3)
71
72COMMANDLINE = COMMANDLINE + " " + METRIC
73if DEBUG: print COMMANDLINE
74p=popen2.Popen4(COMMANDLINE)
75exitcode=p.wait()
76
77# Get the last line of output from 'pmval':
78buffer = p.fromchild.readline()
79while (buffer != ''):
80 output=buffer
81 buffer = p.fromchild.readline()
82
83returndata = string.split(output)[0]
84
85
86# Confirm that we have gotten a float, and not
87# some errormessage in the returndata. If not,
88# print the error, and give the UNKNOWN exit code:
89
90try:
91 retval = string.atof(returndata)
92except ValueError, e:
93 print e
94 exit(3)
95
96if (retval < WARNING):
97 EXITCODE=0
98elif (retval > CRITICAL):
99 EXITCODE=2
100elif (retval > WARNING):
101 EXITCODE=1
102else:
103 EXITCODE=3
104
105print retval
106exit(EXITCODE)
diff --git a/contrib/check_pfstate b/contrib/check_pfstate
deleted file mode 100644
index 57dde3f..0000000
--- a/contrib/check_pfstate
+++ /dev/null
@@ -1,75 +0,0 @@
1#!/usr/bin/perl
2
3use strict;
4use Getopt::Long;
5use vars qw($opt_V $opt_h $opt_P $opt_H $opt_w $opt_c $PROGNAME);
6use lib "/usr/local/nagios/libexec" ;
7use utils qw(%ERRORS &print_revision &support &usage);
8
9my $remote_user = "root";
10my $path_to_ssh = "/usr/bin/ssh";
11my $path_to_grep = "/usr/bin/grep";
12my $path_to_awk = "/usr/bin/awk";
13my $warn = 50000;
14my $crit = 60000;
15
16$PROGNAME = "check_pfstate";
17$ENV{'PATH'}='';
18$ENV{'BASH_ENV'}='';
19$ENV{'ENV'}='';
20
21Getopt::Long::Configure('bundling');
22GetOptions
23 ("V" => \$opt_V, "version" => \$opt_V,
24 "h" => \$opt_h, "help" => \$opt_h,
25 "H=s" => \$opt_H, "hostname=s" => \$opt_H,
26 "w=s" => \$opt_w, "warning=s" => \$opt_w,
27 "c=s" => \$opt_c, "critical=s" => \$opt_c);
28
29if ($opt_V) {
30 print_revision($PROGNAME,'$Revision: 1112 $');
31 exit $ERRORS{'OK'};
32}
33if ($opt_h) {
34 print_help();
35 exit $ERRORS{'OK'};
36}
37if ($opt_w) {
38 if ($opt_w =~ /(\d+)/) {
39 $warn = $1;
40 } else {
41 usage("Invalid values: $opt_w\n");
42 exit $ERRORS{'OK'};
43 }
44}
45if ($opt_c) {
46 if ($opt_c =~ /(\d+)/) {
47 $crit = $1;
48 } else {
49 usage("Invalid values: $opt_c\n");
50 exit $ERRORS{'OK'};
51 }
52}
53($opt_H) || usage("Host name/address not specified\n");
54my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
55($host) || usage("Invalid host: $opt_H\n");
56
57my $result = `$path_to_ssh -l $remote_user $host '/sbin/pfctl -s info' | $path_to_grep entries`;
58chomp $result;
59$result =~ /(\d+)/;
60$result = $1;
61
62print "$result PF state entries\n";
63
64exit $ERRORS{'CRITICAL'} if ($result >= $crit);
65exit $ERRORS{'WARNING'} if ($result >= $warn);
66exit $ERRORS{'OK'};
67
68
69sub print_help {
70 print_revision($PROGNAME,'$Revision: 1112 $');
71 print "Copyright (c) 2002 Jason Dixon\n\nThis plugin checks the number of state table entries on a PF-enabled OpenBSD system.\n\n";
72 print "Usage:\t-H, --hostname=<HOST> [-w, --warning=<WARNING>] [-c, --critical=<CRITICAL>]\n\n\tDefault warning is 50000 and critical is 60000.\n\n";
73 support();
74}
75
diff --git a/contrib/check_qmailq.pl b/contrib/check_qmailq.pl
deleted file mode 100755
index 4c3f68f..0000000
--- a/contrib/check_qmailq.pl
+++ /dev/null
@@ -1,121 +0,0 @@
1#!/usr/bin/perl
2#
3# check_qmailq.pl - nagios plugin
4# This plugin allows you to check the number of Mails in a qmail-
5# queue. PLUGIN NEEDS CONFIGURATION ! (see below)
6#
7# Copyright 2000 Benjamin Schmid
8#
9# This program is free software; you can redistribute it and/or
10# modify it under the terms of the GNU General Public License
11# as published by the Free Software Foundation; either version 2
12# of the License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22#
23#
24# Emergency E-Mail :) blueshift@gmx.net
25#
26
27### CONFIGURATION SECTION ####################
28
29my $statcommand = "/var/qmail/bin/qmail-qstat";
30my $queuewarn = 5; # Warning, if more than x mail in Queue
31my $queuecrit = 10; # Critical if "--"
32my $prewarn = 1; # Warning, if more than x unhandled mails
33 # (not in Queue
34my $precrit = 5; # Critical, if "--"
35
36### CONFIURATION SECTION END ################
37
38use strict;
39use Carp;
40
41#use Getopt::Long;
42#&Getopt::Long::config('auto_abbrev');
43
44
45
46my $TIMEOUT = 15;
47
48my %ERRORS = ('UNKNOWN' , '-1',
49 'OK' , '0',
50 'WARNING', '1',
51 'CRITICAL', '2');
52
53my $state = "UNKNOWN";
54my $answer = "";
55
56#sub usage {
57# printf "\nMissing arguments!\n";
58# printf "\n";
59# printf "Printer Server Queue Nagios Plugin\n";
60# printf "monitors jobs in lpr queues\n";
61# printf "usage: \n";
62# printf "check_lpq.pl \n";
63# printf "Copyright (C) 2000 Benjamin Schmid\n";
64# printf "check_lpq.pl comes with ABSOLUTELY NO WARRANTY\n";
65# printf "This programm is licensed under the terms of the ";
66# printf "GNU General Public License\n(check source code for details)\n";
67# printf "\n\n";
68# exit $ERRORS{"UNKNOWN"};
69#}
70
71# Just in case of problems, let's not hang Nagios
72$SIG{'ALRM'} = sub {
73 print ("ERROR: check_lpq.pl Time-Out $TIMEOUT s \n");
74 exit $ERRORS{"UNKNOWN"};
75};
76alarm($TIMEOUT);
77
78
79#$status = GetOptions("community=s",\$community,
80# "port=i",\$port);
81#if ($status == 0)
82#{
83# &usage;
84#}
85
86# $hostname = shift || &usage;
87
88if (! open STAT, "$statcommand|") {
89 print ("$state: $statcommand returns no result!");
90 exit $ERRORS{$state};
91}
92my @lines = <STAT>;
93close STAT;
94
95# Mails in Queues
96if ($lines[0]=~/^messages in queue: (\d+)/) {
97 my $anzq = $1;
98 $answer = $answer . "$anzq";
99 $state='WARNING' if ($anzq >= $queuewarn);
100 $state='CRITICAL' if ($anzq >= $queuecrit);
101} else {
102 $state='CRITICAL';
103 $answer="Keine gueltigte Antwort (Zeile #1) von $statcommand\n";
104}
105
106# Unverarbeite Mails
107if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) {
108 my $anzp = $1;
109 $answer = $answer . " E-Mail(s) nicht ausgeliefert, $anzp unverarbeitet.";
110 $state='WARNING' if ($anzp >= $prewarn && $state eq 'UNKNOWN');
111 $state='CRITICAL' if ($anzp >= $precrit);
112} else {
113 $state='CRITICAL';
114 $answer=$answer . "Keine gueltigte Antwort (Zeile #2) von $statcommand\n";
115}
116
117$state = 'OK' if ($state eq 'UNKNOWN');
118
119print ("$state: $answer\n");
120exit $ERRORS{$state};
121
diff --git a/contrib/check_rbl.c b/contrib/check_rbl.c
deleted file mode 100644
index eec84ad..0000000
--- a/contrib/check_rbl.c
+++ /dev/null
@@ -1,328 +0,0 @@
1/******************************************************************************
2*
3* check_rbl.c
4*
5* Modified by Tim Bell <bhat@trinity.unimelb.edu.au> 2002-06-05
6* based on:
7*
8* * check_dig.c
9* *
10* * Program: dig plugin for NetSaint
11* * License: GPL
12* * Copyright (c) 2000
13* *
14* * $Id: check_rbl.c 970 2004-12-02 00:30:32Z opensides $
15*
16*****************************************************************************/
17
18#include "config.h"
19#include "common.h"
20#include "utils.h"
21#include "popen.h"
22#include "string.h"
23
24const char progname = "check_rbl";
25const char *revision = "$Revision: 970 $";
26//const char *copyright = "2000-2003";
27//const char *email = "nagiosplug-devel@lists.sourceforge.net";
28
29int process_arguments(int, char **);
30int call_getopt(int, char **);
31int validate_arguments(void);
32int check_disk(int usp,int free_disk);
33void print_help(void);
34void print_usage(void);
35char *reverse_ipaddr(char *ipaddr);
36
37char *query_address=NULL;
38char *query_address_rev=NULL;
39char *dns_server=NULL;
40char *rbl_name=NULL;
41int verbose=FALSE;
42
43int main(int argc, char **argv){
44 char input_buffer[MAX_INPUT_BUFFER];
45 char *command_line=NULL;
46 char *output=NULL;
47 int result=STATE_OK;
48
49 /* Set signal handling and alarm */
50 if (signal(SIGALRM,popen_timeout_alarm_handler)==SIG_ERR)
51 usage("Cannot catch SIGALRM\n");
52
53 if (process_arguments(argc,argv)!=OK)
54 usage (_("check_rbl: could not parse arguments\n"));
55
56 /* reverse the octets in the IP address */
57 query_address_rev = reverse_ipaddr(query_address);
58
59 /* build the command to run */
60 if (dns_server) {
61 command_line=ssprintf(command_line,"%s @%s %s.%s",
62 PATH_TO_DIG,dns_server,
63 query_address_rev, rbl_name);
64 } else {
65 command_line=ssprintf(command_line,"%s %s.%s",
66 PATH_TO_DIG,
67 query_address_rev, rbl_name);
68 }
69 alarm(timeout_interval);
70 time(&start_time);
71
72 if (verbose)
73 printf("%s\n",command_line);
74 /* run the command */
75 child_process=spopen(command_line);
76 if (child_process==NULL) {
77 printf("Could not open pipe: %s\n",command_line);
78 return STATE_UNKNOWN;
79 }
80
81 child_stderr=fdopen(child_stderr_array[fileno(child_process)],"r");
82 if(child_stderr==NULL)
83 printf("Could not open stderr for %s\n",command_line);
84
85 output=strscpy(output,"");
86
87 while (fgets(input_buffer,MAX_INPUT_BUFFER-1,child_process)) {
88
89 /* the server is responding, we just got the host name... */
90 if (strstr(input_buffer,";; ANSWER SECTION:")) {
91
92 /* get the host address */
93 if (!fgets(input_buffer,MAX_INPUT_BUFFER-1,child_process))
94 break;
95
96 if (strpbrk(input_buffer,"\r\n"))
97 input_buffer[strcspn(input_buffer,"\r\n")] = '\0';
98
99 if (strstr(input_buffer,query_address_rev)==input_buffer) {
100 output=strscpy(output,input_buffer);
101 /* we found it, which means it's listed! */
102 result=STATE_CRITICAL;
103 } else {
104 strcpy(output,"Server not RBL listed.");
105 result=STATE_OK;
106 }
107
108 continue;
109 }
110
111 }
112
113 /*
114 if (result!=STATE_OK) {
115 strcpy(output,"No ANSWER SECTION found");
116 }
117 */
118
119 while (fgets(input_buffer,MAX_INPUT_BUFFER-1,child_stderr)) {
120 /* If we get anything on STDERR, at least set warning */
121 result=error_set(result,STATE_WARNING);
122 printf("%s",input_buffer);
123 if (!strcmp(output,""))
124 strcpy(output,1+index(input_buffer,':'));
125 }
126
127 (void)fclose(child_stderr);
128
129 /* close the pipe */
130 if (spclose(child_process)) {
131 result=error_set(result,STATE_WARNING);
132 if (!strcmp(output,""))
133 strcpy(output,"nslookup returned an error status");
134 }
135
136 (void)time(&end_time);
137
138 if (result==STATE_OK)
139 printf("RBL check okay - not listed.\n");
140 else if (result==STATE_WARNING)
141 printf("RBL WARNING - %s\n",!strcmp(output,"")?" Probably a non-existent host/domain":output);
142 else if (result==STATE_CRITICAL)
143 printf("RBL CRITICAL - %s is listed on %s\n",query_address, rbl_name);
144 else
145 printf("DNS problem - %s\n",!strcmp(output,"")?" Probably a non-existent host/domain":output);
146
147 return result;
148}
149
150
151
152/* reverse the ipaddr */
153char *reverse_ipaddr(char *ipaddr)
154{
155 static char revip[MAX_HOST_ADDRESS_LENGTH];
156 int a, b, c, d;
157
158 if (strlen(ipaddr) >= MAX_HOST_ADDRESS_LENGTH ||
159 sscanf(ipaddr, "%d.%d.%d.%d", &a, &b, &c, &d) != 4) {
160 usage("IP address invalid or too long");
161 }
162 sprintf(revip, "%d.%d.%d.%d", d, c, b, a);
163
164 return revip;
165}
166
167
168
169/* process command-line arguments */
170int process_arguments(int argc, char **argv)
171{
172 int c;
173
174 if(argc<2)
175 return ERROR;
176
177
178 c=0;
179 while((c+=(call_getopt(argc-c,&argv[c])))<argc){
180
181 if (is_option(argv[c]))
182 continue;
183
184 if (query_address==NULL) {
185 if (is_host(argv[c])) {
186 query_address=argv[c];
187 } else {
188 usage("Invalid host name");
189 }
190 }
191 }
192
193 return validate_arguments();
194}
195
196
197
198int call_getopt(int argc, char **argv)
199{
200 int c,i=0;
201
202#ifdef HAVE_GETOPT_H
203 int option_index = 0;
204 static struct option long_options[] =
205 {
206 {"hostname", required_argument,0,'H'},
207 {"server", required_argument,0,'s'},
208 {"rblname", required_argument,0,'r'},
209 {"verbose", no_argument, 0,'v'},
210 {"version", no_argument, 0,'V'},
211 {"help", no_argument, 0,'h'},
212 {0,0,0,0}
213 };
214#endif
215
216 while (1){
217#ifdef HAVE_GETOPT_H
218 c = getopt_long(argc,argv,"+hVvt:s:H:r:",long_options,&option_index);
219#else
220 c = getopt(argc,argv,"+?hVvt:s:H:r:");
221#endif
222
223 i++;
224
225 if(c==-1||c==EOF||c==1)
226 break;
227
228 switch (c)
229 {
230 case 't':
231 case 'l':
232 case 'H':
233 i++;
234 }
235
236 switch (c)
237 {
238 case 'H': /* hostname */
239 if (is_host(optarg)) {
240 query_address=optarg;
241 } else {
242 usage("Invalid host name (-H)\n");
243 }
244 break;
245 case 's': /* server */
246 if (is_host(optarg)) {
247 dns_server=optarg;
248 } else {
249 usage("Invalid host name (-s)\n");
250 }
251 break;
252 case 'r': /* rblname */
253 rbl_name=optarg;
254 break;
255 case 'v': /* verbose */
256 verbose=TRUE;
257 break;
258 case 't': /* timeout */
259 if (is_intnonneg(optarg)) {
260 timeout_interval=atoi(optarg);
261 } else {
262 usage("Time interval must be a nonnegative integer\n");
263 }
264 break;
265 case 'V': /* version */
266 print_revision(progname,"$Revision: 970 $");
267 exit(STATE_OK);
268 case 'h': /* help */
269 print_help();
270 exit(STATE_OK);
271 case '?': /* help */
272 printf (_("%s: Unknown argument: %s\n\n"), progname, optarg);
273 print_usage ();
274 exit (STATE_UNKNOWN);
275 }
276 }
277 return i;
278}
279
280
281
282int validate_arguments(void)
283{
284 if (query_address == NULL || rbl_name == NULL)
285 return ERROR;
286 else
287 return OK;
288}
289
290
291
292void print_help(void)
293{
294 print_revision(progname,"$Revision: 970 $");
295 printf
296 ("Copyright (c) 2000 Karl DeBisschop\n\n"
297 "This plugin uses dig to test whether the specified host is on any RBL lists.\n\n");
298 print_usage();
299 printf
300 ("\nOptions:\n"
301 " -H, --hostname=IPADDRESS\n"
302 " Check status of indicated host\n"
303 " -s, --server=STRING or IPADDRESS\n"
304 " DNS server to use\n"
305 " -r, --rblname=STRING\n"
306 " RBL domain name to use (e.g. relays.ordb.org)\n"
307 " -t, --timeout=INTEGER\n"
308 " Seconds before connection attempt times out (default: %d)\n"
309 " -v, --verbose\n"
310 " Print extra information (command-line use only)\n"
311 " -h, --help\n"
312 " Print detailed help screen\n"
313 " -V, --version\n"
314 " Print version information\n\n",
315 DEFAULT_SOCKET_TIMEOUT);
316 support();
317}
318
319
320
321void print_usage(void)
322{
323 printf
324 ("Usage: %s -H hostip -r rblname [-s server] [-t timeout] [-v]\n"
325 " %s --help\n"
326 " %s --version\n",
327 progname, progname, progname);
328}
diff --git a/contrib/check_remote_nagios_status.pl b/contrib/check_remote_nagios_status.pl
deleted file mode 100644
index dc99705..0000000
--- a/contrib/check_remote_nagios_status.pl
+++ /dev/null
@@ -1,666 +0,0 @@
1#!/usr/bin/perl -w
2
3# check_status.pl Nagios Plugin - Version 1.3
4# Last Updated: 1/9/2003
5#
6# Report any bugs/questions to Russell Scibetti at russell@quadrix.com
7#
8# check_status Change Log:
9#
10# To do for 1.4
11# - Better help and documentation (separate doc?)
12# - Take argument (patterns to match) from a separate spec file
13#
14# New Addition to 1.3
15# - Added ChangeLog information and updated --help output
16# - hostdown (hd) argument for how a service check should respond
17# when its host is Down/Unreachable
18# (--hostdown="ok|warning|critical|unknown")
19# - Changed name from check_state to check_status
20# - Set hostdown to default to OK when the argument isn't specified
21# - Number of Hosts checked is now output in OK result
22#
23# Version 1.2 additions:
24#
25# - Added ability to handle ack'd and downtimed services differently
26# depending on argument provided
27# (--ack="ok|warning|critical|unknown|down|unreachable"
28# --dt="ok|warning|critical|unknown|down|unreachable")
29#
30# Version 1.1 additions:
31#
32# - Added --host=<regex>, --servhost=<regex> to allow for specific field
33# matching (host for matching hostname in host checks, servhost for
34# matching the hostname in service checks, service for matching the
35# service name in service checks)
36# - Output the number of OK services for an OK output
37#
38# Version 1.0 features:
39#
40# - Freshness check of status.log (timestamp)
41# - Match service or host checks
42# - Can ignore acknowledged or downtimes services/hosts (--ack, --dt)
43# - Can output different levels of detail dependent on # of problems
44# - Can check for number of critical, warning, or unknowns
45#
46#############################################################
47
48use Getopt::Long;
49use File::stat;
50
51Getopt::Long::Configure('bundling');
52
53GetOptions
54 ("V" => \$version, "version" => \$version,
55 "h" => \$help, "help" => \$help,
56 "v" => \$verbose, "verbose" => \$verbose,
57 "w=s" => \$warning, "warning=s" => \$warning,
58 "c=s" => \$critical, "critical=s" => \$critical,
59 "u=s" => \$unknown, "unknown=s" => \$unknown,
60 "p=s" => \$pattern, "pattern=s" => \$pattern,
61 "S:s" => \$service, "service:s" => \$service,
62 "s=s" => \$status, "status=s" => \$status,
63 "d=s" => \$dir, "dir=s" => \$dir,
64 "D=s" => \$details, "details=s" => \$details,
65 "H:s" => \$host, "host:s" => \$host,
66 "f=s" => \$freshness, "freshness=s" => \$freshness,
67 "servhost=s" => \$servhost,
68 "a:s" => \$ack, "ack:s" => \$ack,
69 "dt:s"=> \$dt, "downtime:s" => \$dt,
70 "hd:s"=> \$hdown, "hostdown:s" => \$hdown,
71 "ok" => \$ok);
72
73#Constants:
74my $OK = 0;
75my $WARNING = 1;
76my $CRITICAL = 2;
77my $UNKNOWN = 3;
78
79my $crit="CRITICAL";
80my $warn="WARNING";
81my $unk="UNKNOWN";
82my $down="DOWN";
83my $unreach="UNREACHABLE";
84
85# Print out Help information
86if ($help) {
87 printVersion();
88 printHelp();
89 exitcheck($UNKNOWN);
90}
91
92# Print out version information
93if ($version) {
94 printVersion();
95 exitcheck($UNKNOWN);
96}
97
98# Check for status log or directory argument or print usage
99if (!$status) {
100 if (!$dir) {
101 print "Usage: $0 -s <status file> | -d <Nagios log dir>\n";
102 print "Use the --help option for full list of arguments\n";
103 exitcheck($UNKNOWN);
104 }
105 elsif ($dir =~ m#[^/]/$#) {
106 $status = $dir . "status.log";
107 }
108 else {
109 $status = $dir . "/status.log";
110 }
111}
112
113if (defined $host) {
114 if (!$host) {
115 $host="[^\\s]*";
116 }
117}
118
119if (!$host && !$servhost) {
120 $servhost="[^\\s]*";
121}
122
123if (!$host && !$service) {
124 $service="[^\\s]*";
125}
126
127if (defined $ack) {
128 if (!$ack) {
129 $ack="ok";
130 }
131 elsif (!($ack =~ "ok|critical|warning|unknown|down|unreachable")) {
132 print "Invalid value for ack\n";
133 exitcheck($UNKNOWN);
134 }
135}
136
137if (defined $dt) {
138 if (!$dt) {
139 $dt="ok";
140 }
141 elsif (!($dt =~ "ok|critical|warning|unknown|down|unreachable")) {
142 print "Invalid value for dt\n";
143 exitcheck($UNKNOWN);
144 }
145}
146
147if (defined $hdown) {
148 if (!$hdown) {
149 $hdown="ok";
150 }
151 elsif (!($hdown =~ "ok|critical|warning|unknown|down|unreachable")) {
152 print "Invalid value for hostdown\n";
153 exitcheck($UNKNOWN);
154 }
155}
156
157my $much_details = 0;
158
159my $ServiceNotOK = "CRITICAL|WARNING|UNKNOWN";
160my $HostNotOK = "DOWN|UNREACHABLE";
161
162my %numprob = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0,"DOWN",0,"UNREACHABLE",0);
163
164my $CritOnly = 0;
165my $WarnOnly = 0;
166my $UnkOnly = 0;
167
168my @wlev;
169my @clev;
170my @ulev;
171my %warnlevel = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0);
172my %critlevel = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0);
173my %unklevel = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0);
174my %hostlevel = ("DOWN",0,"UNREACHABLE",0);
175
176# Store Hosts in downtime
177my @hostdowntime;
178my $numdowntime = 0;
179
180# Store Hosts in a Down/Unreachable state
181my @hostdown;
182my $numdown = 0;
183
184# Hash for storing state-change to OK times for hosts:
185my %hostoktimes;
186
187# Number of matches in parsing
188my $nummatch = 0;
189
190if ($warning) {
191 if ($warning =~ /,/) {
192 @wlev = split /,/,$warning;
193 $warnlevel{"WARNING"} = $wlev[0];
194 $warnlevel{"CRITICAL"} = $wlev[1];
195 if ($wlev[2] ) {
196 $warnlevel{"UNKNOWN"} = $wlev[2];
197 }
198 }
199 else {
200 $WarnOnly = $warning;
201 }
202}
203else {
204 $WarnOnly = 1;
205}
206
207if ($critical) {
208 if ($critical =~ /,/) {
209 @clev = split /,/,$critical;
210 $critlevel{"WARNING"} = $clev[0];
211 $critlevel{"CRITICAL"} = $clev[1];
212 if ($clev[2] ) {
213 $critlevel{"UNKNOWN"} = $clev[2];
214 }
215 }
216 else {
217 $CritOnly = $critical;
218 }
219}
220else {
221 $CritOnly = 1;
222}
223
224if ($unknown) {
225 if ($unknown =~ /,/) {
226 @ulev = split /,/,$unknown;
227 $unklevel{"WARNING"} = $ulev[0];
228 $unklevel{"CRITICAL"} = $ulev[1];
229 if ($ulev[2] ) {
230 $unklevel{"UNKNOWN"} = $ulev[2];
231 }
232 }
233 else {
234 $UnkOnly = $unknown;
235 }
236}
237else {
238 $UnkOnly = 1;
239}
240
241
242if (!$freshness) {
243 $freshness = 30 * 60;
244}
245else {
246 $freshness = $freshness * 60;
247}
248
249my %ct = ("CRITICAL",0,"WARNING",0,"UNKNOWN",0,"DOWN",0,"UNREACHABLE",0);
250my %much_ct = ("CRITICAL",0,"WARNING",0,"UNKNOWN",0,"DOWN",0,"UNREACHABLE",0);
251
252my %output = ("CRITICAL","","WARNING","","UNKNOWN","","DOWN","","UNREACHABLE","");
253my %much_output = ("CRITICAL","","WARNING","","UNKNOWN","","DOWN","","UNREACHABLE","");
254
255if ($details) {
256 if ($details =~ /,/) {
257 my @tempv = split /,/,$details;
258 $much_details = $tempv[0];
259 $details = $tempv[1];
260 }
261}
262
263open("sta","$status") || die "Cannot open status file $status!";
264
265$curr_time = time;
266$file_time = stat($status)->mtime;
267
268if ($curr_time - $file_time > $freshness) {
269 printf "State CRITICAL - Status file is stale!!!\n";
270 exitcheck($CRITICAL);
271}
272
273while(<sta>) {
274 chomp;
275 if (/^[^\s]+[\s]+HOST;/) {
276 @hdata = split /;/,$_;
277
278# If you care about matching hosts (not services):
279 if ($host && $hdata[1] =~ /$host/) {
280 $nummatch++;
281 if ( $hdata[2] =~ /$HostNotOK/ ) {
282 addproblem($_,$hdata[2]);
283 }
284 }
285
286# If you are matching services, gather host information:
287 else {
288 if ( $hdata[2] =~ /$HostNotOK/ ) {
289 $hostdown[$numdown] = $hdata[1];
290 $numdown++;
291 }
292 else {
293 $hostoktimes{$hdata[1]} = $hdata[4];
294 }
295 if ( $hdata[17] ne "0" ) {
296 $hostdowntime[$numdowntime] = $hdata[1];
297 $numdowntime++;
298 }
299 }
300 }
301 elsif (!$host && /^[^\s]+[\s]+SERVICE;/) {
302 @servdata = split /;/,$_;
303 if ( ( $pattern && ($_ =~ /$pattern/)) ||
304 (($servdata[1] =~ /$servhost/) && ($servdata[2] =~ /$service/)) ){
305 $nummatch++;
306 if (($servdata[5] eq "HARD") && ($servdata[3] =~ /$ServiceNotOK/)) {
307 addproblem($_,$servdata[3]);
308 }
309 }
310 }
311}
312
313close("sta");
314
315if ($nummatch==0) {
316 print "Nothing Matches your criteria!\n";
317 exitcheck($UNKNOWN);
318}
319
320# Count the number of problems (for reference):
321if ($host) {
322 $total = $numprob{"DOWN"} + $numprob{"UNREACHABLE"};
323}
324else {
325 $total = $numprob{"WARNING"} + $numprob{"CRITICAL"} + $numprob{"UNKNOWN"};
326}
327
328my $numok = $nummatch - $total;
329
330# If this is a host state check:
331if ($host) {
332 if ($numprob{"DOWN"}>0 || $numprob{"UNREACHABLE"}>0 ) {
333 if ($details && ($total <= $details)) {
334 print "State CRITICAL - $total Host Problems: $output{$down} $output{$unreach}\n";
335 exitcheck($CRITICAL);
336 }
337 else {
338 print "State CRITICAL - $numprob{$down} Hosts Down, $numprob{$unreach} Hosts Unreachable\n";
339 exitcheck($CRITICAL);
340 }
341 }
342 else {
343 print "State OK - $numok Hosts Up, $total Problems\n";
344 exitcheck($OK);
345 }
346}
347
348#If you only defined a Critical level in terms of # of criticals...
349elsif ($CritOnly && ($numprob{"CRITICAL"} >= $CritOnly)) {
350 countAndPrint($crit,$numprob{$crit},0);
351 exitcheck($CRITICAL);
352}
353
354#Critical in terms on # criticals and # warnings...
355elsif (!$CritOnly && ($numprob{"WARNING"} >= $critlevel{"WARNING"} ||
356 $numprob{"CRITICAL"} >= $critlevel{"CRITICAL"} ||
357 $numprob{"UNKNOWN"} >= $critlevel{"UNKNOWN"} )) {
358 countAndPrint($crit,$total,1);
359 exitcheck($CRITICAL);
360}
361
362#Warning in terms of # warnings only...
363elsif ($WarnOnly && ($numprob{"WARNING"} >= $WarnOnly)) {
364 countAndPrint($warn,$numprob{$warn},0);
365 exitcheck($WARNING);
366}
367
368#Warning in terms of # warnings and # criticals...
369elsif (!$WarnOnly && ($numprob{"WARNING"} >= $warnlevel{"WARNING"} ||
370 $numprob{"CRITICAL"} >= $warnlevel{"CRITICAL"} ||
371 $numprob{"UNKNOWN"} >= $warnlevel{"UNKNOWN"})) {
372 countAndPrint($warn,$total,1);
373 exitcheck($WARNING);
374}
375
376#Unknown in terms on # unknown only...
377elsif ( $UnkOnly && ($numprob{"UNKNOWN"}>=$UnkOnly) ) {
378 countAndPrint($unk,$numprob{$unk},0);
379 exitcheck($UNKNOWN);
380}
381
382#Unknown in terms of # warning, critical, and unknown...
383elsif (!$UnkOnly && ($numprob{"WARNING"} >= $unklevel{"WARNING"} ||
384 $numprob{"CRITICAL"} >= $unklevel{"CRITICAL"} ||
385 $numprob{"UNKNOWN"} >= $unklevel{"UNKNOWN"})) {
386 countAndPrint($unk,$total,1);
387 exitcheck($UNKNOWN);
388}
389
390# Everything is OK!
391else {
392 print "State OK - $numok OK, $total problems\n";
393 exitcheck($OK);
394}
395
396
397
398############################
399# Subroutines
400############################
401
402# Return the proper exit code for Critical, Warning, Unknown, or OK
403sub exitcheck {
404 if ($ok) {
405 exit 0;
406 }
407 else {
408 exit $_[0];
409 }
410}
411
412# Decide what to print for services:
413sub countAndPrint {
414 my $state = $_[0];
415 my $count = $_[1];
416 my $alltypes = $_[2];
417 my $output = "State $state - ";
418
419 if ($details) {
420 if ($count<=$much_details) {
421 if ($alltypes) {
422 $output .= "$count problems: $much_output{$crit} $much_output{$warn} $much_output{$unk}";
423 }
424 else {
425 $output .= "$count \L$state\E: $much_output{$state}";
426 }
427 }
428 elsif ($count<=$details) {
429 if ($alltypes) {
430 $output .= "$count problems: $output{$crit} $output{$warn} $output{$unk}";
431 }
432 else {
433 $output .= "$count \L$state\E: $output{$state}";
434 }
435 }
436 else {
437 if ($alltypes) {
438 $output .= "$numprob{$crit} critical, $numprob{$warn} warning, $numprob{$unk} unknown";
439 }
440 else {
441 $output .= "$count \L$state\E";
442 }
443 }
444 }
445 else {
446 $output .= "$count problems";
447 }
448
449 print "$output\n";
450}
451
452
453# Add-in the problem found in the status log
454sub addproblem {
455
456 $test = 1;
457 $type = $_[1];
458 my $diffout = "";
459
460 my @values = split /;/,$_[0];
461
462 if (!$host) {
463 my $namehold = $values[1];
464 if ($ack && ($values[13] eq "1")) {
465 if ($ack =~ "ok") {
466 $test = 0;
467 }
468 else {
469 $type = "\U$ack";
470 }
471 }
472 elsif ($hdown && grep /$namehold/, @hostdown) {
473 if ($hdown =~ "ok") {
474 $test = 0;
475 }
476 else {
477 $type = "\U$hdown";
478 $diffout = "$values[1] is down";
479 }
480 }
481 elsif ($dt && (($values[27] ne "0") || (grep /$namehold/, @hostdowntime))){
482 if ($dt =~ "ok") {
483 $test = 0;
484 }
485 else {
486 $type = "\U$dt";
487 }
488 }
489 elsif (exists $hostoktimes{$namehold}) {
490 # If the state change time of the host is more recent than the last
491 # service check, must wait until the next service check runs!
492 if ($hostoktimes{$namehold} > $values[6]) {
493 $test = 0;
494 }
495 }
496 }
497 else {
498 if ($ack && $values[5]) {
499 if ($ack =~ "ok") {
500 $test = 0;
501 }
502 else {
503 $type = "\U$ack";
504 }
505 }
506 elsif ($dt && ($values[17] ne "0")) {
507 if ($dt =~ "ok") {
508 $test = 0;
509 }
510 else {
511 $type = "\U$dt";
512 }
513 }
514 }
515
516 if ($details && $test) {
517 if (!$host) {
518 if ($diffout) {
519 $much_output{$type} .= " $diffout;";
520 $output{$type} .= "$diffout;";
521 $much_ct{$type}++;
522 $ct{$type}++;
523 }
524 else {
525 if ($much_details && $much_ct{$type}<$much_details) {
526 $much_output{$type} .= " $values[2] on $values[1] $values[31];";
527 $much_ct{$type}++;
528 }
529 if ($ct{$type} < $details) {
530 $output{$type} .= " $values[2] on $values[1];";
531 $ct{$type}++;
532 }
533 }
534 }
535 else {
536 $much_output{$type} .= " $values[1] $_[1] $values[20],";
537 $much_ct{type}++;
538 $output{$type} .= " $values[1] HOST $_[1],";
539 $ct{$type}++;
540 }
541 }
542 if ($test) {
543 $numprob{$type}++;
544 }
545}
546
547################################
548#
549# Version and Help Information
550#
551################################
552
553sub printVersion {
554 printf <<EndVersion;
555$0 (nagios-plugins) 1.3
556The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute
557copies of the plugins under the terms of the GNU General Public License.
558For more information about these matters, see the file named COPYING.
559EndVersion
560}
561
562sub printHelp {
563 printf <<EOF;
564
565This plugin parses through the Nagios status log and will return a
566Critical, Warning, or Unknown state depending on the number of
567Critical, Warning, and/or Unknown services found in the log
568(or Down/Unreachable hosts when matching against hosts)
569
570Usage: $0 -s <Status File> | -d <Nagios Log Directory>
571 [-w #[,#][,#]] [-c #[,#][,#]] [-u #[,#][,#]]
572 [--service=<RegEx> | --servhost=<RegEx> | --pattern=<RegEx> |
573 --host | --host=<RegEx>]
574 [--ack[=string]] [--dt[=string]] [--hostdown[=string]]
575 [-D #[,#]] [--ok] [-f <Log freshness in # minutes>]
576 $0 --help
577 $0 --version
578NOTE: One of -s and -d must be specified
579
580Options:
581 -s, --status=FILE_NAME
582 Location and name of status log (e.g. /usr/local/nagios/var/status.log)
583 -d, --dir=DIRECTORY_NAME
584 Directory that contains the nagios logs (e.g. /usr/local/nagios/var/)
585 -w, --warning=INTEGER[,INTEGER][,INTEGER]
586 #: Number of warnings to result in a WARNING state
587 OR
588 #,#: Warning,Criticals to result in a WARNING state
589 OR
590 #,#,#: Warning,Critical,Unknown to result in a WARNING state
591 Default: -w=1
592 -c, --critical=INTEGER[,INTEGER][,INTEGER]
593 #: Number of criticals to result in a CRITICAL state
594 OR
595 #,#: Warning,Criticals to result in a CRITICAL state
596 OR
597 #,#,#: Warning,Critical,Unknown to result in a CRITICAL state
598 Default: -c=1
599 -u, --unknown=INTEGER[,INTEGER][,INTEGER]
600 #: Number of unknowns to result in a UNKNOWN state
601 OR
602 #,#: Warning,Criticals to result in a UNKNOWN state
603 OR
604 #,#,#: Warning,Critical,Unknown to result in a UNKNOWN state
605 Default: -u=1
606 -r, --service[=REGEX]
607 Only match services [that match the RegEx]
608 (--service is default setting if no other matching arguments provided)
609 --servhost=REGEX
610 Only match services whose host match the RegEx
611 -p, --pattern=REGEX
612 Only parse for this regular expression (services only, not hosts)
613 --host[=REGEX]
614 Report on the state of hosts (whose name matches the RegEx if provided)
615 -a, --ack[=ok|warning|critical|unknown|down|unreachable]
616 Handle Acknowledged problems [--ack defaults to ok]
617 --dt, --downtime[=ok|warning|critical|unknown|down|unreachable]
618 Handle problems in scheduled downtime [--dt defaults to ok]
619 --hd, --hostdown[=ok|warning|critical|unknown|down|unreachable]
620 Handle services whose Host is down [--hd defaults to ok]
621 -D, --details=INTEGER[,INTEGER]
622 Amount of verbosity to output
623 If # problems:
624 <= 1st integer, return full details (each plugin's output)
625 <= 2nd integer, return some details (list each service host pair)
626 > 2nd integer, return the # of problems
627 -f, --freshness=INTEGER
628 Number of minutes old the log can be to make sure Nagios is running
629 (Default = 30 minutes)
630 --ok
631 Return an OK exit code, regardless of number of problems found
632 -h, --help
633 Print detailed help screen
634 -V, --version
635 Print version information
636
637For service checking (use --service and/or --servhost):
6381. The values of warning, critical, and unknown default to 1, i.e.
639$0 will return CRITICAL if there is at least 1 critical service,
640WARNING if there is at least 1 warning service, and UNKNOWN if there is
641at least one unknown service.
642
6432. If a service's host is DOWN or UNREACHABLE, $0 will use the
644value of --hostdown to determine how to treat the service. Without that
645argument, $0 will count the service as OK.
646
6473. If a service's host is OK, but the last host-state change occurred more
648recently than the last service check, $0 will ignore that service
649(want to wait until the service has been checked after a host has recovered
650or you may get service alert for services that still need to be checked)
651
6524. If the --dt, --ack, or --hd tags are used, $0 will use the value
653of the arguments to determine how to handle services in downtime, acknowledged,
654or with down hosts (default=OK). For service checks, --dt will also check
655if the service's host is in a downtime.
656
657For host checking (use --host):
6581. Using the --host argument, $0 will look for DOWN and UNREACHABLE
659hosts. If any are found, $0 will return a CRITICAL. You can provide
660an REGEX for --host to only check hosts with matching host names.
661
6622. If the --dt or --ack tags are used, $0 will use the value of the
663--dt/--ack arguments to determine the state of the host (default is OK)
664
665EOF
666}
diff --git a/contrib/check_rrd_data.pl b/contrib/check_rrd_data.pl
deleted file mode 100644
index 0ff8750..0000000
--- a/contrib/check_rrd_data.pl
+++ /dev/null
@@ -1,129 +0,0 @@
1#!/usr/bin/perl -wT
2
3# check_rrd_data plugin for nagios
4#
5# usage:
6# check_rrd machine_id perlexp_warn perlexp_crit perlexp_default [ds]
7#
8# Checks data from a RRD file. machine_id is normally an IP address, that has
9# to be mapped to a RRD file, by means of the config file (by default
10# /var/spool/nagios/rrd-files, a file with pairs of (machine_id,rrd_file),
11# separated by whitespace). It can be a RRD file, too.
12#
13# The Perl expressions are expressions to be evaluated in the following cases:
14#
15# - perlexp_crit. The first one, to check if there is a critical situation. If
16# it returns other than "", it will be a critical message.
17# - perlexp_warn. The second one to be evaluated. If returns other than "", a
18# warning will be issued to Nagios.
19# - perlexp_default. If both of the above return "", it will be evaluated, and
20# wathever returns this expression will be returned by the script. NOTE that
21# this is different from the other two cases, to allow the user issue a
22# warning or critical failure even if the other two don't return it.
23#
24# Use these hosts.cfg entries as examples
25#
26# command[check_ping]=$USER1$/check_rrd_data.pl $HOSTADDRESS$ \
27# 'return "CHECK_CRICKET_PING: Warning\n" if ($value > 10);' 'return \
28# "CHECK_CRICKET_PING: Critical\n" if ($value > 100);' 'printf \
29# "PING OK - RTA = %.2fms\n", $value; return 0;' 1
30# service[machine]=PING;0;24x7;3;5;1;router-admins;240;24x7;1;1;1;;check_ping
31#
32# initial version: 28 Nov 2000 by Esteban Manchado Velázquez
33# current status: 0.1
34#
35# Copyright Notice: GPL
36#
37
38# Doesn't work! Why?
39# BEGIN {
40 # my $runtimedir = substr($0,0,rindex($0,'/'));
41 # require "$runtimedir/utils.pm";
42# }
43
44require '/usr/libexec/nagios/plugins/utils.pm';
45use RRD::File;
46# use strict; # RRD:File and utils.pm don't like this
47
48my $configfilepath = "/var/spool/nagios/rrd-files"; # Change if needed
49my %hostfile; # For storing config
50my $rrdfile; # RRD file to open
51
52$ENV{'PATH'} = "/bin:/usr/bin";
53$ENV{'ENV'} = "";
54
55if (scalar @ARGV != 4 && scalar @ARGV != 5) {
56 print STDERR join "' '", @ARGV, "\n";
57 my $foo = 'check_rrd_data';
58 print STDERR $foo, " <file.rrd> <perl_exp_warn> <perl_exp_crit> <perl_exp_default> [<ds>]\n\n";
59 print STDERR "<perl_exp_*> is an expression that gets evaluated with \$_ at the current\n";
60 print STDERR "value of the data source. If it returns something other than \"\", there\n";
61 print STDERR "will be a warning or a critical failure. Else, the expression\n";
62 print STDERR "<perl_exp_default> will be evaluated\n";
63 exit;
64}
65
66# Check configuration file
67open F, $configfilepath or do {
68 print "Can't open config file $configfilepath\n";
69 return $ERRORS{'UNKNOWN'};
70};
71while (<F>) {
72 next unless /(.+)\s+(.+)/;
73 $hostfile{$1} = $2;
74}
75close F;
76
77# Default
78my $ds = defined $ARGV[4]?$ARGV[4]:0;
79 # print "\$ds = " . $ds . ":";
80 # print "\$ARGV[4] = " . $ARGV[4] . ":";
81$ds =~ s/\$//g; # Sometimes Nagios gives 1$ as the last parameter
82
83# Guess which RRD file have to be opened
84$rrdfile = $ARGV[0] if (-r $ARGV[0]); # First the parameter
85$rrdfile = $hostfile{$ARGV[0]} unless $rrdfile; # Second, the config file
86 # print "$ARGV[0]:";
87
88if (! $rrdfile) {
89 print "Can't open data file for $ARGV[0]\n"; # Aaaargh!
90 return $ERRORS{'UNKNOWN'}; # Unknown
91}
92
93 # print "Opening file $rrdfile:";
94my $rrd = new RRD::File ( -file => $rrdfile );
95$rrd->open();
96if (! $rrd->loadHeader()) {
97 print "Couldn't read header from $rrdfile\n";
98 exit $ERRORS{'UNKNOWN'}; # Unknown
99}
100my $value = $rrd->getDSCurrentValue($ds);
101$rrd->close();
102
103# Perl expressions to evaluate
104my ($perl_exp_warn, $perl_exp_crit, $perl_exp_default) =
105 ($ARGV[1], $ARGV[2], $ARGV[3]);
106my $result; # Result of the expressions (will be printed)
107my @data; # Special data reserved for the expressions, to pass data
108
109# First check for critical errors
110$perl_exp_crit =~ /(.*)/;
111$perl_exp_crit = $1;
112$result = eval $perl_exp_crit;
113if ($result) {
114 print $result;
115 exit 2; # Critical
116}
117
118# Check for warnings
119$perl_exp_warn =~ /(.*)/;
120$perl_exp_warn = $1;
121$result = eval $perl_exp_warn;
122if ($result) {
123 print $result;
124 exit 1; # Warning
125}
126
127$perl_exp_default =~ /(.*)/;
128$perl_exp_default = $1;
129eval $perl_exp_default; # Normally returns 0 (OK)
diff --git a/contrib/check_sap.sh b/contrib/check_sap.sh
deleted file mode 100755
index 726d750..0000000
--- a/contrib/check_sap.sh
+++ /dev/null
@@ -1,89 +0,0 @@
1#!/bin/sh
2################################################################################
3#
4# CHECK_SAP plugin for Nagios
5#
6# Originally Written by Karel Salavec (karel.salavec@ct.cz)
7#
8# Last Modified: 26 May 2003 by Tom De Blende (tom.deblende@village.uunet.be)
9#
10# Version 1.1 (Tom De Blende)
11# - Added output to feed to Nagios instead of just an exit code.
12# - Changed info on where to get the SAP client tools for Linux.
13#
14# Version 1.0 (Karel Salavec)
15#
16# Command line: check_sap.sh <typ_of_check> <param1> <param2> [<param3>]
17#
18# Description:
19# This plugin will attempt to open an SAP connection with the message
20# server or application server.
21# It need the sapinfo program installed on your server (see Notes).
22#
23# Notes:
24# - This plugin requires that the sapinfo program is installed.
25# - Sapinfo is part of a client package that can be found
26# at ftp://ftp.sap.com/pub/linuxlab/contrib/.
27#
28#
29# Parameters:
30# $1 - type of checking - valid values: "ms" = message server
31# "as" = application server
32# $2 - SAP server identification - can be IP address, DNS name or SAP
33# connect string (for example: /H/saprouter/S/sapdp01/H/sapserv3)
34# $3 - for $1="ms" - SAP system name (for example: DEV, TST, ... )
35# for $1="as" - SAP system number - note: central instance have sysnr=00
36# $4 - valid only for $1="ms" - logon group name - default: PUBLIC
37#
38# Example of command definitions for nagios:
39#
40# command[check_sap_ms]=/usr/local/nagios/libexec/check_sap ms $HOSTADDRESS$ $ARG1$ $ARG2$
41# command[check_sap_as]=/usr/local/nagios/libexec/check_sap as $HOSTADDRESS$ $ARG1$
42# command[check_sap_ex]=/usr/local/nagios/libexec/check_sap as $ARG1$ $ARG2$
43# (for ARG1 see SAP OOS1 transaction)
44#
45##############################################################################
46
47sapinfocmd='/usr/sap/rfcsdk/bin/sapinfo'
48grepcmd=`which grep`
49wccmd=`which wc`
50cutcmd=`which cut`
51awkcmd=`which awk`
52
53##############################################################################
54
55if [ $# -lt 3 ]; then
56echo "Usage: $0 <typ_of_check> <param1> <param2> [<param3>]"
57exit 2
58fi
59
60case "$1"
61 in
62 ms)
63 if [ $4 ]
64 then
65 params="r3name=$3 mshost=$2 group=$4"
66 else
67 params="r3name=$3 mshost=$2"
68 fi
69 ;;
70 as)
71 params="ashost=$2 sysnr=$3"
72 ;;
73 *)
74 echo "The first parameter must be ms (message server) or as (application server)!"
75 exit 2
76 ;;
77esac
78
79output="$($sapinfocmd $params)"
80error="$(echo "$output" | $grepcmd ERROR | $wccmd -l)"
81if [ "$error" -gt "0" ]; then
82 output="$(echo "$output" | $grepcmd Key | $cutcmd -dy -f2)"
83 echo "CRITICAL - SAP server not ready: " $output.
84 exit 2
85else
86 output="$(echo "$output" | $grepcmd Destination | $awkcmd '{ print $2 }')"
87 echo "OK - SAP server $output available."
88 exit 0
89fi
diff --git a/contrib/check_smart.pl b/contrib/check_smart.pl
deleted file mode 100644
index 3f9104d..0000000
--- a/contrib/check_smart.pl
+++ /dev/null
@@ -1,180 +0,0 @@
1#!/usr/bin/perl -w
2
3# chec_smart
4# Check S.M.A.R.T. enabled disks status.
5#
6# This uses smartmontools to check for disk status.
7# This is NOT compatible with smartsuite
8# Please use smartctl --smart=on --offlineauto=on --saveauto=on /dev/something
9# or similar to enable automatic data collection, and RTFM about it.
10#
11# this uses sudo to access the smartctl program, so please add a line in sudoers
12# nagios computername = NOPASSWD:/usr/sbin/smartctl
13#
14# CopyLeft Roy Sigurd Karlsbakk <roy@karlsbakk.net>
15# Developed under Debian/SID
16# No warranties what so ever. If this toasts your PC, or your wife
17# runs away with your girlfriend, or even me, don't blame me.
18#
19# Licenced under GPL
20#
21
22use strict;
23use Getopt::Long;
24
25my (
26 $s, $i, $out, $retcode, $errtxt, $exitcode,
27 $device, $text_mode, $exitcode_mode, $help, $verbose, $type,
28);
29my $smartctl = "sudo /usr/sbin/smartctl";
30my $e_commandline = 0;
31my $e_devopen = 0;
32my $e_chksum = 0;
33my $e_disk_failing = 0;
34my $e_prefail = 0;
35my $e_mayprefail = 0;
36my $e_errlog = 0;
37my $e_selftestlog = 0;
38
39sub end {
40 $s = shift;
41 $i = shift;
42 if ($i == 0) {
43 $s = "OK: $s";
44 } elsif ($i == 1) {
45 $s = "WARNNG: $s";
46 } elsif ($i == 2) {
47 $s = "CRITICAL: $s";
48 } elsif ($i == 3) {
49 $s = "UNKNOWN: $s";
50 } else {
51 $s = "OUT OF RANGE: $s";
52 }
53 print "$s\n";
54 exit($i);
55}
56
57sub syntax {
58 $s = shift or $s = 'Unknown';
59 printf STDERR ("Error: $s\n") unless ($help);
60 printf STDERR ("Syntax: %s (-t|-e) -d <device> [-vh]\n", $0);
61 printf STDERR (" --text-mode -t check by parsing smartctl's output\n");
62 printf STDERR (" --exitcode-mode -e check smartctl's exitcode (only works on IDE)\n");
63 printf STDERR (" --device -d disk device to check\n");
64 printf STDERR (" --type -T drive type. See the -d flag in the smartctl manual\n");
65 printf STDERR (" --verbose -v verbose\n");
66 printf STDERR (" --help -h this help\n");
67 exit(0) if $help;
68 exit(3);
69}
70
71Getopt::Long::Configure('bundling');
72GetOptions(
73 "d=s" => \$device, "device=s" => \$device,
74 "T=s" => \$type, "type=s" => \$type,
75 "t" => \$text_mode, "text-mode" => \$text_mode,
76 "e" => \$exitcode_mode, "exitcode-mode" => \$exitcode_mode,
77 "h" => \$help, "help" => \$help,
78 "v" => \$verbose, "verbose" => \$verbose
79) || syntax("RTFM!");
80
81syntax if ($help);
82syntax("Need device to check") unless ($device);
83syntax("Conflicting modes") if ($text_mode && $exitcode_mode);
84syntax("Need test mode") unless ($text_mode || $exitcode_mode);
85syntax("Exitcode mode only works on ATA drives") if ($exitcode_mode && ! ($device =~ /\/dev\/hd./));
86
87if ($type) {
88 $type =~ s/[\r\n]*?//g;
89 print "type: '$type'\n" if ($verbose);
90 syntax("Valid --type entries include ata, scsi and 3ware,n")
91 unless (($type =~ /^ata$/) || ($type =~ /^scsi$/) || ($type =~ /^3ware,\d+$/));
92}
93if (defined($type)) {
94 $type = "--device=$type";
95} else {
96 $type = "";
97}
98
99if ($text_mode) {
100 print "running $smartctl $type -H $device" if ($verbose);
101 unless (open SMARTCTL,"$smartctl $type -H $device|") {
102 print STDERR "Can't execute $smartctl: $!\n";
103 exit(3);
104 }
105 while (<SMARTCTL>) {
106 last if (/=== START OF READ SMART DATA SECTION ===/);
107 }
108 $out = <SMARTCTL>;
109 print $out;
110 exit(0) if ($out =~ /PASSED/);
111 exit(2) if ($out =~ /SAVE ALL DATA/ || $out =~ /FAILED/);
112 exit(3);
113} elsif ($exitcode_mode) {
114 print "Running $smartctl $type -q silent $device\n" if ($verbose);
115 system("$smartctl $type -q silent $device");
116 $retcode = $?;
117 $e_commandline = 1 if ($retcode & 0x0100);
118 $e_devopen = 1 if ($retcode & 0x0200);
119 $e_chksum = 1 if ($retcode & 0x0400);
120 $e_disk_failing = 1 if ($retcode & 0x0800);
121 $e_prefail = 1 if ($retcode & 0x1000);
122 $e_mayprefail = 1 if ($retcode & 0x2000);
123 $e_errlog = 1 if ($retcode & 0x4000);
124 $e_selftestlog = 1 if ($retcode & 0x8000);
125
126 print "$e_commandline $e_devopen $e_chksum $e_disk_failing $e_prefail $e_mayprefail $e_errlog $e_selftestlog\n"
127 if ($verbose);
128
129 $exitcode = 0;
130 $errtxt = "";
131 if ($exitcode) {
132 if ($e_commandline) {
133 $errtxt .= "Commandline didn't parse, ";
134 $exitcode = 3 if ($exitcode == 0);
135 }
136 if ($e_devopen) {
137 $errtxt .= "Device could not be opened, ";
138 $exitcode = 3 if ($exitcode == 0);
139 }
140 if ($e_chksum) {
141 $errtxt .= "Checksum failure somewhere, ";
142 $exitcode = 1 if ($exitcode != 2);
143 }
144 if ($e_disk_failing) {
145 $errtxt .= "Disk is failing!, ";
146 $exitcode = 2;
147 }
148 if ($e_prefail) {
149 $errtxt .= "Disk is in prefail, ";
150 $exitcode = 1 if ($exitcode != 2);
151 }
152 if ($e_mayprefail) {
153 $errtxt .= "Disk is close to prefail. Please check manually, ";
154 $exitcode = 1 if ($exitcode != 2);
155 }
156 if ($e_errlog) {
157 $errtxt .= "The device error log contains records of errors, ";
158 $exitcode = 1 if ($exitcode != 2);
159 }
160 if ($e_selftestlog) {
161 $errtxt .= "The device self-test log contains records of errors, ";
162 $exitcode = 1 if ($exitcode != 2);
163 }
164 if ($exitcode == 1) {
165 $errtxt = "WARNNG: $errtxt";
166 } elsif ($exitcode == 2) {
167 $errtxt = "CRITICAL: $errtxt";
168 } else {
169 $errtxt = "UNKNOWN: $errtxt";
170 }
171 } else {
172 $errtxt = "OK";
173 }
174 print "$errtxt\n";
175 exit($exitcode);
176} else {
177 print STDERR "Something's strange is going on :~|\n";
178 exit(3);
179}
180# vim:ts=4:sw=4:cindent
diff --git a/contrib/check_smb.sh b/contrib/check_smb.sh
deleted file mode 100644
index 9d0da72..0000000
--- a/contrib/check_smb.sh
+++ /dev/null
@@ -1,111 +0,0 @@
1#!/bin/bash
2#
3# Program : check_smb
4# :
5# Author : Cal Evans <cal@calevans.com>
6# :
7# Purpose : Nagios plugin to return the number of users logged into a smb
8# : server and the number of files open.
9# :
10# Parameters : --help
11# : --version
12# :
13# Returns : Standard Nagios status_* codes as defined in utils.sh
14# :
15# Notes :
16#============:==============================================================
17# 1.0 : 06/27/2002
18# : Initial coding
19# :
20# 1.1 : 06/28/2002
21# : Re-wrote the user counter to match the file-lock counter.
22# :
23
24#
25# Shamelessly stolen from other Nagios plugins.
26#
27PROGNAME=`basename $0`
28PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'`
29REVISION=`echo '$Revision: 71 $' | sed -e 's/[^0-9.]//g'`
30
31
32. $PROGPATH/utils.sh
33
34print_usage() {
35 echo "Usage: $PROGNAME --help"
36 echo "Usage: $PROGNAME --version"
37}
38
39print_help() {
40 print_revision $PROGNAME $REVISION
41 echo ""
42 print_usage
43 echo ""
44 echo "Samba status check."
45 echo ""
46 support
47}
48
49# No command line arguments are required for this script. We accept only 2,
50# --help and --version. If more than 1 is passed in then we have an error
51# condition.
52
53if [ $# -gt 1 ]; then
54 print_usage
55 exit $STATE_UNKNOWN
56fi
57
58
59#
60# If we have arguments, process them.
61#
62exitstatus=$STATE_WARNING #default
63while test -n "$1"; do
64 case "$1" in
65 --help)
66 print_help
67 exit $STATE_OK
68 ;;
69 -h)
70 print_help
71 exit $STATE_OK
72 ;;
73 --version)
74 print_revision $PROGNAME $REVISION
75 exit $STATE_OK
76 ;;
77 -V)
78 print_revision $PROGNAME $REVISION
79 exit $STATE_OK
80 ;;
81
82 *)
83 echo "Unknown argument: $1"
84 print_usage
85 exit $STATE_UNKNOWN
86 ;;
87 esac
88 shift
89done
90
91#
92# No arguments. Let's kick this pig.
93#
94total_users=$(smbstatus -b | grep "^[0-9]" | wc -l)
95
96#
97# Ok, now let's grab a count of the files.
98#
99total_files=$(smbstatus | grep "^[0-9]" | wc -l)
100
101#
102# now for the dismount.
103#
104echo "Total Users:$total_users Total Files:$total_files"
105
106#
107# let Nagios know that everything is ok.
108#
109exit $STATE_OK
110
111
diff --git a/contrib/check_snmp_disk_monitor.pl b/contrib/check_snmp_disk_monitor.pl
deleted file mode 100644
index 9a2edaa..0000000
--- a/contrib/check_snmp_disk_monitor.pl
+++ /dev/null
@@ -1,185 +0,0 @@
1#!/usr/local/bin/perl
2# author: Al Tobey <albert.tobey@priority-health.com>
3# what: monitor diskspace using the host-resources mib
4# license: GPL - http://www.fsf.org/licenses/gpl.txt
5#
6# Todo:
7
8use strict;
9require 5.6.0;
10use lib qw( /opt/nagios/libexec );
11use utils qw(%ERRORS $TIMEOUT &print_revision &support &usage);
12use SNMP 5.0;
13use Getopt::Long;
14use vars qw( $exit $message $opt_version $opt_timeout $opt_help $opt_command $opt_host $opt_community $opt_verbose $opt_warning $opt_critical $opt_port $opt_mountpoint $opt_stats $snmp_session $PROGNAME $TIMEOUT %mounts );
15
16$PROGNAME = "snmp_disk_monitor.pl";
17$opt_verbose = undef;
18$opt_host = undef;
19$opt_community = 'public';
20$opt_command = undef;
21$opt_warning = 99;
22$opt_critical = 100;
23$opt_port = 161;
24$opt_stats = undef;
25$message = undef;
26$exit = 'OK';
27%mounts = ();
28
29sub process_options {
30 my( $opt_crit, $opt_warn ) = ();
31 Getopt::Long::Configure( 'bundling' );
32 GetOptions(
33 'V' => \$opt_version, 'version' => \$opt_version,
34 'v' => \$opt_verbose, 'verbose' => \$opt_verbose,
35 'h' => \$opt_help, 'help' => \$opt_help,
36 's' => \$opt_stats, 'statistics' => \$opt_stats,
37 'H:s' => \$opt_host, 'hostname:s' => \$opt_host,
38 'p:i' => \$opt_port, 'port:i' => \$opt_port,
39 'C:s' => \$opt_community, 'community:s' => \$opt_community,
40 'c:i' => \$opt_crit, 'critical:i' => \$opt_crit,
41 'w:i' => \$opt_warn, 'warning:i' => \$opt_warn,
42 't:i' => \$TIMEOUT, 'timeout:i' => \$TIMEOUT,
43 'm:s' => \$opt_mountpoint, 'mountpoint:s'=> \$opt_mountpoint
44 );
45 if ( defined($opt_version) ) { local_print_revision(); }
46 if ( defined($opt_verbose) ) { $SNMP::debugging = 1; }
47 if ( !defined($opt_host) || defined($opt_help) || !defined($opt_mountpoint) ) {
48 print_help();
49 exit $ERRORS{UNKNOWN};
50 }
51 $opt_mountpoint = [ split(/,/, $opt_mountpoint) ];
52}
53
54sub local_print_revision {
55 print_revision( $PROGNAME, '$Revision: 82 $ ' )
56}
57
58sub print_usage {
59 print "Usage: $PROGNAME -H <host> -C <snmp_community> [-s] [-w <low>,<high>] [-c <low>,<high>] [-t <timeout>] -m <mountpoint>\n";
60}
61
62sub print_help {
63 local_print_revision();
64 print "Copyright (c) 2002 Al Tobey <albert.tobey\@priority-health.com>\n\n",
65 "SNMP Disk Monitor plugin for Nagios\n\n";
66 print_usage();
67 print <<EOT;
68-v, --verbose
69 print extra debugging information
70-h, --help
71 print this help message
72-H, --hostname=HOST
73 name or IP address of host to check
74-C, --community=COMMUNITY NAME
75 community name for the host's SNMP agent
76-m, --mountpoint=MOUNTPOINT
77 a mountpoint, or a comma delimited list of mountpoints
78-w, --warning=INTEGER
79 percent of disk used to generate WARNING state (Default: 99)
80-c, --critical=INTEGER
81 percent of disk used to generate CRITICAL state (Default: 100)
82-s, --statistics
83 output statistics in Nagios format
84EOT
85}
86
87sub verbose (@) {
88 return if ( !defined($opt_verbose) );
89 print @_;
90}
91
92sub check_for_errors {
93 if ( $snmp_session->{ErrorNum} ) {
94 print "UNKNOWN - error retrieving SNMP data: $snmp_session->{ErrorStr}\n";
95 exit $ERRORS{UNKNOWN};
96 }
97}
98
99# =========================================================================== #
100# =====> MAIN
101# =========================================================================== #
102process_options();
103
104alarm( $TIMEOUT ); # make sure we don't hang Nagios
105
106$snmp_session = new SNMP::Session(
107 DestHost => $opt_host,
108 Community => $opt_community,
109 RemotePort => $opt_port,
110 Version => '2c'
111);
112
113# retrieve the data from the remote host
114my( $mps, $alloc, $size, $used ) = $snmp_session->bulkwalk( 0, 4, [['hrStorageDescr'],['hrStorageAllocationUnits'],['hrStorageSize'],['hrStorageUsed']] );
115check_for_errors();
116
117alarm( 0 ); # all done with the network connection
118
119# move all the data into a nice, convenient hash for processing
120foreach my $mp ( @$mps ) { $mounts{$mp->iid}->{mountpoint} = $mp->val; }
121foreach my $a ( @$alloc ) { $mounts{$a->iid}->{alloc_units} = $a->val; }
122foreach my $si ( @$size ) {
123 if ( exists($mounts{$si->iid}->{alloc_units}) ) {
124 $mounts{$si->iid}->{size} = $si->val * $mounts{$si->iid}->{alloc_units};
125 }
126 else {
127 $mounts{$si->iid}->{size} = $si->val;
128 }
129}
130foreach my $us ( @$used ) {
131 if ( exists($mounts{$us->iid}->{alloc_units}) ) {
132 $mounts{$us->iid}->{used} = $us->val * $mounts{$us->iid}->{alloc_units};
133 }
134 else {
135 $mounts{$us->iid}->{used} = $us->val;
136 }
137}
138
139# now find the mountpoint or mountpoints that were actually requested and push onto an array for output
140my @matches = ();
141foreach my $mp ( @$opt_mountpoint ) {
142 my $found = scalar(@matches); # count all matches
143 foreach my $key ( keys(%mounts) ) {
144 if ( $mounts{$key}->{mountpoint} eq $mp ) {
145
146 # find the percentate - eval to avoid divide by zero errors
147 eval { $mounts{$key}->{percent_used} = $mounts{$key}->{used} / $mounts{$key}->{size} };
148 $mounts{$key}->{percent_used} =~ s/^0\.([0-9]{1,2})([0-9]?).*/\1/; # truncate
149 if ( $2 >= 5 ) { $mounts{$key}->{percent_used}++ }; # round the number number
150
151 verbose "mountpoint $mp has ", $mounts{$key}->{percent_used}, "% used, ",
152 $mounts{$key}->{size}, " bytes and ",$mounts{$key}->{used}, " used\n";
153
154 push( @matches, $mounts{$key} );
155 }
156 }
157 if ( scalar(@matches) == $found ) {
158 print "UNKNOWN - could not locate mountpoint $mp on host\n";
159 exit $ERRORS{UNKNOWN};
160 }
161}
162
163# now run through and check the thresholds
164foreach my $mp ( @matches ) {
165 if ( $mp->{percent_used} >= $opt_warning ) {
166 $exit = 'WARNING';
167 if ( $mp->{percent_used} >= $opt_critical ) { $exit = 'CRITICAL'; }
168 }
169 $message .= $mp->{percent_used}.'% used on '.$mp->{mountpoint}.', ';
170}
171$message =~ s/,\s*$//;
172
173# append statistics if requested
174if ( defined($opt_stats) ) {
175 my @tmp = ();
176 foreach my $mp ( @matches ) {
177 push( @tmp, join(',',$mp->{mountpoint},$mp->{size},$mp->{used}) );
178 }
179 $message .= '|'.join( ':', @tmp );
180}
181
182print "Disk $exit - $message\n";
183exit $ERRORS{$exit};
184
185
diff --git a/contrib/check_snmp_printer.pl b/contrib/check_snmp_printer.pl
deleted file mode 100755
index cc7943b..0000000
--- a/contrib/check_snmp_printer.pl
+++ /dev/null
@@ -1,605 +0,0 @@
1#!/usr/local/bin/perl -w
2
3# check_snmp_printer - check for printer status via snmp
4# Supports both standard PRINT-MIB (RFC-1759) and HP Enterprise print-mib
5# that is supported by some of the older JetDirect interfaces
6
7# Acknowledgements:
8# the JetDirect code is taken from check_hpjd.c by Ethan Galstad
9#
10# The idea for the plugin (as well as some code) were taken from Jim
11# Trocki's pinter alert script in his "mon" utility, found at
12# http://www.kernel.org/software/mon
13#
14
15# Notes:
16# 'JetDirect' is copyrighted by Hewlett-Packard
17#
18#
19# License Information:
20# This program is free software; you can redistribute it and/or modify
21# it under the terms of the GNU General Public License as published by
22# the Free Software Foundation; either version 2 of the License, or
23# (at your option) any later version.
24#
25# This program is distributed in the hope that it will be useful,
26# but WITHOUT ANY WARRANTY; without even the implied warranty of
27# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28# GNU General Public License for more details.
29#
30# You should have received a copy of the GNU General Public License
31# along with this program; if not, write to the Free Software
32# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33#
34############################################################################
35#
36# TODO: Query HOST-RESOURCE MIB for a quick status
37#
38# hrPrinterStatus = .1.3.6.1.2.1.25.3.5.1;
39# hrPrinterDetectedErrorState = .1.3.6.1.2.1.25.3.5.1.2
40#
41# hrPrinterStatus OBJECT-TYPE
42# SYNTAX INTEGER {
43# other(1),
44# unknown(2),
45# idle(3),
46# printing(4),
47# warmup(5)
48# }
49#
50# hrPrinterDetectedErrorState OBJECT-TYPE
51# SYNTAX OCTET STRING
52# MAX-ACCESS read-only
53# STATUS current
54# DESCRIPTION
55# "This object represents any error conditions detected
56# by the printer. The error conditions are encoded as
57# bits in an octet string, with the following
58# definitions:
59#
60# Condition Bit #
61#
62# lowPaper 0
63#
64# noPaper 1
65# lowToner 2
66# noToner 3
67# doorOpen 4
68# jammed 5
69# offline 6
70# serviceRequested 7
71# inputTrayMissing 8
72# outputTrayMissing 9
73# markerSupplyMissing 10
74# outputNearFull 11
75# outputFull 12
76# inputTrayEmpty 13
77# overduePreventMaint 14
78#
79#
80#
81use strict;
82use Getopt::Long;
83use vars qw($opt_V $opt_h $opt_H $opt_P $opt_t $opt_d $session $error $answer $key
84 $response $PROGNAME $port $hostname );
85use lib "utils.pm";
86use utils qw(%ERRORS &print_revision &support &usage );
87use Net::SNMP;
88
89sub print_help ();
90sub print_usage ();
91
92$ENV{'PATH'}='';
93$ENV{'BASH_ENV'}='';
94$ENV{'ENV'}='';
95
96# defaults
97my $ptype = 1; # to standard RFC printer type
98my $state = $ERRORS{'UNKNOWN'};
99my $community = "public";
100my $snmp_version = 1;
101my $port = 161;
102
103Getopt::Long::Configure('bundling');
104GetOptions
105 ("d" => \$opt_d, "debug" => \$opt_d,
106 "V" => \$opt_V, "version" => \$opt_V,
107 "P=s" => \$opt_P, "Printer=s" => \$opt_P, # printer type - HP or RFC
108 "v=i" => \$snmp_version, "snmp_version=i" => \$snmp_version,
109 "p=i" => \$port, "port=i" => \$port,
110 "C=s" => \$community,"community=s" => \$community,
111 "h" => \$opt_h, "help" => \$opt_h,
112 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
113
114
115
116$PROGNAME = "check_snmp_printer";
117
118if ($opt_V) {
119 print_revision($PROGNAME,'$Revision: 795 $');
120 exit $ERRORS{'OK'};
121}
122
123if ($opt_h) {print_help(); exit $ERRORS{'OK'};}
124
125unless (defined $opt_H) {
126 print "No target hostname specified\n";
127 exit $ERRORS{"UNKNOWN"};
128}
129$hostname = $opt_H;
130if (! utils::is_hostname($hostname)){
131 usage(" $hostname did not match pattern\n");
132 exit $ERRORS{"UNKNOWN"};
133}
134
135if (defined $opt_P) {
136 if ($opt_P eq "HP" ) {
137 $ptype = 2;
138 }elsif ($opt_P eq "RFC" ) {
139 $ptype = 1;
140 }else{
141 print "Only \"HP\" and \"RFC\" are supported as printer options at this time.\n";
142 exit $ERRORS{"UNKNOWN"};
143 }
144}
145
146
147if ( $snmp_version =~ /[12]/ ) {
148
149 ($session, $error) = Net::SNMP->session(
150 -hostname => $hostname,
151 -community => $community,
152 -port => $port,
153 -version => $snmp_version
154 );
155
156 if (!defined($session)) {
157 $state='UNKNOWN';
158 $answer=$error;
159 print ("$state: no session - $answer\n");
160 exit $ERRORS{$state};
161 }
162
163 print "Opened session|" if (defined ($opt_d));
164
165}elsif ( $snmp_version =~ /3/ ) {
166 $state='UNKNOWN';
167 print ("$state: No support for SNMP v3 yet\n");
168 exit $ERRORS{$state};
169}else{
170 $state='UNKNOWN';
171 print ("$state: No support for SNMP v$snmp_version yet\n");
172 exit $ERRORS{$state};
173}
174
175
176
177
178
179
180### main logic
181
182if ( $ptype == 1 ) { # STD MIB
183 print "STD-MIB|" if (defined ($opt_d));
184
185 my %snmp_response;
186 my $snmp_index;
187 my $col_oid;
188 my %std_mib_inst_count ;
189 my %std_mib_instances;
190 my $display;
191 my $inst;
192 my $group;
193
194
195 #### RFC1759 MIB OIDS
196
197 # sub-unit status - textual convention
198 my $subunit_status; # integer from 0-126
199
200
201 # column oid - not instances
202 my %std_mib = (
203 std_mib_input_status => ".1.3.6.1.2.1.43.8.2.1.11", # 2 element index
204 std_mib_input_name => ".1.3.6.1.2.1.43.8.2.1.13",
205 std_mib_output_remaining_capacity => ".1.3.6.1.2.1.43.9.2.1.5",
206 std_mib_output_status => ".1.3.6.1.2.1.43.9.2.1.6",
207 std_mib_marker_tech => ".1.3.6.1.2.1.43.10.2.1.2",
208 std_mib_marker_counter_unit => ".1.3.6.1.2.1.43.10.2.1.3",
209 std_mib_marker_life_count => ".1.3.6.1.2.1.43.10.2.1.4",
210 std_mib_marker_status => ".1.3.6.1.2.1.43.10.2.1.15",
211 std_mib_supplies_type => ".1.3.6.1.2.1.43.11.1.1.5",
212 std_mib_supplies_level => ".1.3.6.1.2.1.43.11.1.1.9",
213 std_mib_media_path_type => ".1.3.6.1.2.1.43.13.4.1.9",
214 std_mib_media_path_status => ".1.3.6.1.2.1.43.13.4.1.11",
215
216 std_mib_status_display => ".1.3.6.1.2.1.43.16.5.1.2", # 2 element index
217
218 std_mib_alert_sev_level => ".1.3.6.1.2.1.43.18.1.1.2",
219 std_mib_alert_grp => ".1.3.6.1.2.1.43.18.1.1.4",
220 std_mib_alert_location => ".1.3.6.1.2.1.43.18.1.1.5",
221
222 );
223
224 my %std_mib_marker_tech = (
225 1 => "other",
226 2 => "unknown",
227 3 => "electrophotographicLED",
228 4 => "electrophotographicLaser",
229 5 => "electrophotographicOther",
230 6 => "impactMovingHeadDotMatrix9pin",
231 7 => "impactMovingHeadDotMatrix24pin",
232 8 => "impactMovingHeadDotMatrixOther",
233 9 => "impactMovingHeadFullyFormed",
234 10 => "impactBand",
235 11 => "impactOther",
236 12 => "inkjectAqueous",
237 13 => "inkjetSolid",
238 14 => "inkjetOther",
239 15 => "pen",
240 16 => "thermalTransfer",
241 17 => "thermalSensitive",
242 18 => "thermalDiffusion",
243 19 => "thermalOther",
244 20 => "electroerosion",
245 21 => "electrostatic",
246 22 => "photographicMicrofiche",
247 23 => "photographicImagesetter",
248 24 => "photographicOther",
249 25 => "ionDeposition",
250 26 => "eBeam",
251 27 => "typesetter",
252 );
253
254 my %std_mib_marker_counter_units = (
255 3 => "tenThousandthsOfInches",
256 4 => "micrometers",
257 5 => "characters",
258 6 => "lines",
259 7 => "impressions",
260 8 => "sheets",
261 9 => "dotRow",
262 11 => "hours",
263 16 => "feet",
264 17 => "meters",
265 );
266
267 my %std_mib_alert_groups = (
268 1 => "unspecifiedOther",
269 3 => "printerStorageMemory", # hostResourcesMIBStorageTable
270 4 => "internalDevice", # hostResourcesMIBDeviceTable
271 5 => "generalPrinter",
272 6 => "cover",
273 7 => "localization",
274 8 => "input",
275 9 => "output",
276 10 => "marker",
277 11 => "markerSupplies",
278 12 => "markerColorant",
279 13 => "mediaPath",
280 14 => "connectionChannel",
281 15 => "interpreter",
282 16 => "consoleDisplayBuffer",
283 17 => "consoleLights",
284 );
285
286
287 my %std_mib_prt_alert_code = (
288 1 => "other", # ok if on power save
289 2 => "unknown",
290 # -- codes common to serveral groups
291 3 => "coverOpen",
292 4 => "coverClosed",
293 5 => "interlockOpen",
294 6 => "interlockClosed",
295 7 => "configurationChange",
296 8 => "jam", # critical
297 # -- general Printer group
298 501 => "doorOpen",
299 502 => "doorClosed",
300 503 => "powerUp",
301 504 => "powerDown",
302 # -- Input Group
303 801 => "inputMediaTrayMissing",
304 802 => "inputMediaSizeChange",
305 803 => "inputMediaWeightChange",
306 804 => "inputMediaTypeChange",
307 805 => "inputMediaColorChange",
308 806 => "inputMediaFormPartsChange",
309 807 => "inputMediaSupplyLow",
310 808 => "inputMediaSupplyEmpty",
311 # -- Output Group
312 901 => "outputMediaTrayMissing",
313 902 => "outputMediaTrayAlmostFull",
314 903 => "outputMediaTrayFull",
315 # -- Marker group
316 1001 => "markerFuserUnderTemperature",
317 1002 => "markerFuserOverTemperature",
318 # -- Marker Supplies group
319 1101 => "markerTonerEmpty",
320 1102 => "markerInkEmpty",
321 1103 => "markerPrintRibbonEmpty",
322 1104 => "markerTonerAlmostEmpty",
323 1105 => "markerInkAlmostEmpty",
324 1106 => "markerPrintRibbonAlmostEmpty",
325 1107 => "markerWasteTonerReceptacleAlmostFull",
326 1108 => "markerWasteInkReceptacleAlmostFull",
327 1109 => "markerWasteTonerReceptacleFull",
328 1110 => "markerWasteInkReceptacleFull",
329 1111 => "markerOpcLifeAlmostOver",
330 1112 => "markerOpcLifeOver",
331 1113 => "markerDeveloperAlmostEmpty",
332 1114 => "markerDeveloperEmpty",
333 # -- Media Path Device Group
334 1301 => "mediaPathMediaTrayMissing",
335 1302 => "mediaPathMediaTrayAlmostFull",
336 1303 => "mediaPathMediaTrayFull",
337 # -- interpreter Group
338 1501 => "interpreterMemoryIncrease",
339 1502 => "interpreterMemoryDecrease",
340 1503 => "interpreterCartridgeAdded",
341 1504 => "interpreterCartridgeDeleted",
342 1505 => "interpreterResourceAdded",
343 1506 => "interpreterResourceDeleted",
344 );
345
346 ## Need multiple passes as oids are all part of tables
347 foreach $col_oid (sort keys %std_mib ){
348
349 if ( !defined( $response = $session->get_table($std_mib{$col_oid}) ) ) {
350 print "Error col_oid $col_oid|" if (defined ($opt_d));
351
352 if (! ($col_oid =~ m/std_mib_alert/ ) ) { # alerts don't have to exist all the time!
353 $answer=$session->error;
354 $session->close;
355 $state = 'CRITICAL';
356 print ("$state: $answer for $std_mib{$col_oid}\n");
357 exit $ERRORS{$state};
358 }
359 }
360
361 print "NoError col_oid $col_oid|" if (defined ($opt_d));
362
363 foreach $key (keys %{$response}) {
364 $key =~ /.*\.(\d+)\.(\d+)$/; # all oids have a two part index appended
365 $snmp_index = $1 . "." . $2;
366 print "\n$key => $col_oid.$snmp_index = $response->{$key} \n" if (defined ($opt_d));
367 $snmp_response{$key} = $response->{$key} ;
368
369 $std_mib_inst_count{$col_oid} += 1 ; # count how many instances
370 $std_mib_instances{$col_oid} .= $snmp_index .":" ;
371
372 }
373
374 }
375
376 #foreach $key ( keys %std_mib_inst_count) {
377 # print "$key = $std_mib_inst_count{$key} $std_mib_instances{$key} \n";
378 #}
379 # get (total) "page count" - perfdata
380 #print "\n \n $std_mib_instances{'std_mib_marker_tech'} \n";
381 # how many marker technologies are in use?
382 my ($pg, $pt, $pfd);
383 my @mark_tech = split(/:/, $std_mib_instances{'std_mib_marker_tech'});
384 foreach $inst (sort @mark_tech){
385 $pfd = $std_mib_marker_tech{$snmp_response{$std_mib{'std_mib_marker_tech'}."." .$inst}} ;
386 $pfd .= ",".$snmp_response{$std_mib{'std_mib_marker_life_count'}.".".$inst};
387 $pfd .= ",".$std_mib_marker_counter_units{$snmp_response{$std_mib{'std_mib_marker_counter_unit'}.".".$inst}};
388 $pfd .= ";"; #perf data separator for multiple marker tech
389
390
391 print "pfd = $pfd\n" if (defined ($opt_d));
392 };
393
394 # combine all lines of status display into one line
395 #$std_mib_instances{'std_mib_status_display'} = substr($std_mib_instances{'std_mib_status_display'}, 1);
396 my @display_index = split(/:/, $std_mib_instances{'std_mib_status_display'} );
397
398 foreach $inst ( sort @display_index) {
399 $display .= $snmp_response{$std_mib{'std_mib_status_display'} . "." . $inst} . " ";
400 }
401
402
403
404 # see if there are any alerts
405 if (defined ( $std_mib_inst_count{'std_mib_alert_sev_level'} ) ) {
406
407 if ( ( lc($display) =~ /save/ || lc($display) =~ /warm/ ) && $std_mib_inst_count{'std_mib_alert_sev_level'} == 1 ) {
408 $state='OK';
409 $answer = "Printer ok - $display";
410 print $answer . "|$pfd\n";
411 exit $ERRORS{$state};
412 }
413
414 # sometime during transitions from power save to warming there are 2 alerts
415 # if the 2nd alert is for something else it should get caught in the
416 # next call since warmup typically is much smaller than check time
417 # interval.
418 if ( lc($display) =~ /warm/ && $std_mib_inst_count{'std_mib_alert_sev_level'} == 2 ) {
419 $state='OK';
420 $answer = "$state: Printer - $display";
421 print $answer . "|$pfd\n";
422 exit $ERRORS{$state};
423 }
424
425
426 # We have alerts and the display does not say power save or warming up
427 $std_mib_instances{'std_mib_alert_sev_level'} = substr($std_mib_instances{'std_mib_alert_sev_level'}, 1);
428 @display_index = split(/:/, $std_mib_instances{'std_mib_alert_sev_level'} );
429 $answer = "Alert location(s): ";
430
431 for $inst (@display_index) {
432 $state = 'WARNING';
433 if ( $snmp_response{$std_mib{'std_mib_alert_location'} . "." . $inst} < 1) {
434 $answer .= "unknown location ";
435 }else{
436 $answer .= $std_mib_prt_alert_code{$snmp_response{$std_mib{'std_mib_alert_location'} . "." . $inst} } . " ";
437
438 #print $std_mib_prt_alert_code{$snmp_response{$std_mib{'std_mib_alert_location'}. "." . $inst}} ;
439 }
440 }
441
442 print "$state: $answer|$pfd\n";
443 exit $ERRORS{$state};
444
445 }else{
446 $state='OK';
447 $answer = "$state: Printer ok - $display ";
448 print $answer . "|$pfd\n";
449 exit $ERRORS{$state};
450
451 }
452
453
454
455
456}
457elsif( $ptype == 2 ) { # HP MIB - JetDirect
458
459 #### HP MIB OIDS - instance OIDs
460 my $HPJD_LINE_STATUS= ".1.3.6.1.4.1.11.2.3.9.1.1.2.1.0";
461 my $HPJD_PAPER_STATUS= ".1.3.6.1.4.1.11.2.3.9.1.1.2.2.0";
462 my $HPJD_INTERVENTION_REQUIRED= ".1.3.6.1.4.1.11.2.3.9.1.1.2.3.0";
463 my $HPJD_GD_PERIPHERAL_ERROR= ".1.3.6.1.4.1.11.2.3.9.1.1.2.6.0";
464 my $HPJD_GD_PAPER_JAM= ".1.3.6.1.4.1.11.2.3.9.1.1.2.8.0";
465 my $HPJD_GD_PAPER_OUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.9.0";
466 my $HPJD_GD_TONER_LOW= ".1.3.6.1.4.1.11.2.3.9.1.1.2.10.0";
467 my $HPJD_GD_PAGE_PUNT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.11.0";
468 my $HPJD_GD_MEMORY_OUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.12.0";
469 my $HPJD_GD_DOOR_OPEN= ".1.3.6.1.4.1.11.2.3.9.1.1.2.17.0";
470 my $HPJD_GD_PAPER_OUTPUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.19.0";
471 my $HPJD_GD_STATUS_DISPLAY= ".1.3.6.1.4.1.11.2.3.9.1.1.3.0";
472 #define ONLINE 0
473 #define OFFLINE 1
474
475 my @hp_oids = ( $HPJD_LINE_STATUS,$HPJD_PAPER_STATUS,$HPJD_INTERVENTION_REQUIRED,$HPJD_GD_PERIPHERAL_ERROR,
476 $HPJD_GD_PAPER_JAM,$HPJD_GD_PAPER_OUT,$HPJD_GD_TONER_LOW,$HPJD_GD_PAGE_PUNT,$HPJD_GD_MEMORY_OUT,
477 $HPJD_GD_DOOR_OPEN,$HPJD_GD_PAPER_OUTPUT,$HPJD_GD_STATUS_DISPLAY);
478
479
480
481
482 $state = $ERRORS{'OK'};
483
484 if (!defined($response = $session->get_request(@hp_oids))) {
485 $answer=$session->error;
486 $session->close;
487 $state = 'CRITICAL';
488 print ("$state: $answer \n");
489 exit $ERRORS{$state};
490 }
491
492 # cycle thru the responses and set the appropriate state
493
494 if($response->{$HPJD_GD_PAPER_JAM} ) {
495 $state='WARNING';
496 $answer = "Paper Jam";
497 }
498 elsif($response->{$HPJD_GD_PAPER_OUT} ) {
499 $state='WARNING';
500 $answer = "Out of Paper";
501 }
502 elsif($response->{$HPJD_LINE_STATUS} ) {
503 if ($response->{$HPJD_LINE_STATUS} ne "POWERSAVE ON" ) {
504 $state='WARNING';
505 $answer = "Printer Offline";
506 }
507 }
508 elsif($response->{$HPJD_GD_PERIPHERAL_ERROR} ) {
509 $state='WARNING';
510 $answer = "Peripheral Error";
511 }
512 elsif($response->{$HPJD_INTERVENTION_REQUIRED} ) {
513 $state='WARNING';
514 $answer = "Intervention Required";
515 }
516 elsif($response->{$HPJD_GD_TONER_LOW} ) {
517 $state='WARNING';
518 $answer = "Toner Low";
519 }
520 elsif($response->{$HPJD_GD_MEMORY_OUT} ) {
521 $state='WARNING';
522 $answer = "Insufficient Memory";
523 }
524 elsif($response->{$HPJD_GD_DOOR_OPEN} ) {
525 $state='WARNING';
526 $answer = "Insufficient Memory";
527 }
528 elsif($response->{$HPJD_GD_PAPER_OUTPUT} ) {
529 $state='WARNING';
530 $answer = "OutPut Tray is Full";
531 }
532 elsif($response->{$HPJD_GD_PAGE_PUNT} ) {
533 $state='WARNING';
534 $answer = "Data too slow for Engine";
535 }
536 elsif($response->{$HPJD_PAPER_STATUS} ) {
537 $state='WARNING';
538 $answer = "Unknown Paper Error";
539 }
540 else # add code to parse STATUS DISPLAY here
541 {
542 $state='OK';
543 $answer = "Printer ok - $response->{$HPJD_GD_STATUS_DISPLAY} ";
544 }
545
546 # print and exit
547
548 print "$state: $answer \n";
549 exit $ERRORS{$state};
550
551
552}
553else{ # 3rd printer type - not yet supported
554
555 print "Printer type $opt_P has not been implemented\n";
556 $state='UNKNOWN';
557 exit $ERRORS{$state};
558
559}
560
561
562
563#### subroutines
564sub unit_status {
565 my $stat = shift;
566
567
568}
569
570sub print_usage () {
571 print "Usage: $PROGNAME -H <host> [-C community] [-P HP or RFC] [-p port] [-v snmp_version] [-h help] [-V version]\n";
572}
573
574sub print_help () {
575 print_revision($PROGNAME,'$Revision: 795 $');
576 print "Copyright (c) 2002 Subhendu Ghosh/Ethan Galstad.
577
578This plugin reports the status of an network printer with an SNMP management
579module.
580
581";
582 print_usage();
583 print "
584-H, --hostname=HOST
585 Name or IP address of host to check
586-C --community
587 snmp community string (default: public)
588-P --Printer
589 supported values are \"HP\" for Jetdirect printers and
590 \"RFC\" for RFC 1759 Print MIB based implementations (default: RFC)
591-p --port
592 Port where snmp agent is listening (default: 161)
593-v --snmp_version
594 SNMP version to use (default: version 1)
595-h --help
596 This screen
597-V --version
598 Plugin version
599
600";
601 support();
602}
603
604
605
diff --git a/contrib/check_snmp_process_monitor.pl b/contrib/check_snmp_process_monitor.pl
deleted file mode 100644
index 0f44597..0000000
--- a/contrib/check_snmp_process_monitor.pl
+++ /dev/null
@@ -1,331 +0,0 @@
1#!/usr/local/bin/perl
2# author: Al Tobey <albert.tobey@priority-health.com>
3# what: monitor a process using the host-resources mib
4# license: GPL - http://www.fsf.org/licenses/gpl.txt
5#
6# Todo:
7# * implement memory and cpu utilization checks
8# * maybe cache pids in DBM files if snmp agents get overworked
9###############################################################################
10# to get a list of processes over snmp try this command:
11# snmptable -v2c -c public hostname hrSWRunTable
12# for just a list of valid arguments for the '-e' option:
13# snmpwalk -v2c -c public hostname hrSWRunName |perl -pe 's:.*/::'
14###############################################################################
15
16use strict;
17require 5.6.0;
18use lib qw( /opt/nagios/libexec /usr/local/libexec );
19use utils qw(%ERRORS $TIMEOUT &print_revision &support &usage);
20use SNMP 5.0;
21use Getopt::Long;
22use Storable;
23use vars qw( $exit $opt_version $opt_timeout $opt_help $opt_command $opt_host $opt_community $opt_verbose $opt_warning $opt_critical $opt_memory $opt_cpu $opt_port $opt_regex $opt_stats $opt_cache $opt_nocache $cache_exp $interpreters $snmp_session $PROGNAME $TIMEOUT );
24
25$PROGNAME = "snmp_process_monitor.pl";
26$opt_verbose = undef;
27$opt_host = undef;
28$opt_community = 'public';
29$opt_command = undef;
30$opt_warning = [ 1, -1 ];
31$opt_critical = [ 1, -1 ];
32$opt_memory = undef;
33$opt_cpu = undef;
34$opt_port = 161;
35$opt_cache = 1;
36$opt_nocache = undef;
37$cache_exp = 600;
38$exit = $ERRORS{OK};
39$interpreters = '(perl|/bin/sh|/usr/bin/sh|/bin/bash|/bin/ksh|python)';
40our $cachefile = '/var/opt/nagios/tmp/'; # completed later
41our %processes = ();
42
43sub process_options {
44 my( $opt_crit, $opt_warn ) = ();
45 Getopt::Long::Configure( 'bundling' );
46 GetOptions(
47 'V' => \$opt_version, 'version' => \$opt_version,
48 'v' => \$opt_verbose, 'verbose' => \$opt_verbose,
49 'h' => \$opt_help, 'help' => \$opt_help,
50 's' => \$opt_stats, 'statistics' => \$opt_stats,
51 'nocache' => \$opt_nocache,
52 'H:s' => \$opt_host, 'hostname:s' => \$opt_host,
53 'p:i' => \$opt_port, 'port:i' => \$opt_port,
54 'C:s' => \$opt_community, 'community:s' => \$opt_community,
55 'c:s' => \$opt_crit, 'critical:s' => \$opt_crit,
56 'w:s' => \$opt_warn, 'warning:s' => \$opt_warn,
57 't:i' => \$TIMEOUT, 'timeout:i' => \$TIMEOUT,
58 'e:s' => \$opt_command, 'command:s' => \$opt_command,
59 'r:s' => \$opt_regex, 'regex:s' => \$opt_regex,
60 'cpu:i' => \$opt_cpu, 'memory:i' => \$opt_memory,
61 );
62 if ( defined($opt_version) ) { local_print_revision(); }
63 if ( defined($opt_verbose) ) { $SNMP::debugging = 1; }
64 if ( !defined($opt_host) || defined($opt_help) || (!defined($opt_command) && !defined($opt_regex)) ) {
65 print_help();
66 exit $ERRORS{UNKNOWN};
67 }
68
69 if ( defined($opt_crit) ) {
70 if ( $opt_crit =~ /,/ ) {
71 $opt_critical = [ split(',', $opt_crit) ];
72 }
73 else {
74 $opt_critical = [ $opt_crit, -1 ];
75 }
76 }
77 if ( defined($opt_warn) ) {
78 if ( $opt_warn =~ /,/ ) {
79 $opt_warning = [ split(',', $opt_warn) ];
80 }
81 else {
82 $opt_warning = [ $opt_crit, -1 ];
83 }
84 }
85 if ( defined($opt_memory) ) { $opt_memory = 0 }
86 if ( defined($opt_cpu) ) { $opt_cpu = 0 }
87 if ( defined($opt_nocache)) { $opt_cache = 0 }
88
89 # complete the cachefile's name
90 $cachefile .= $opt_host . '.proc';
91}
92
93sub local_print_revision {
94 print_revision( $PROGNAME, '$Revision: 84 $ ' )
95}
96
97sub print_usage {
98 print "Usage: $PROGNAME -H <host> -C <snmp_community> -e <command> [-w <low>,<high>] [-c <low>,<high>] [-t <timeout>] [-s|--statistics] [--memory] [--cpu] [--nocache]\n";
99}
100
101sub print_help {
102 local_print_revision();
103 print "Copyright (c) 2002 Al Tobey <albert.tobey\@priority-health.com>\n\n",
104 "SNMP Process Monitor plugin for Nagios\n\n";
105 print_usage();
106 print <<EOT;
107-v, --verbose
108 print extra debugging information
109-h, --help
110 print this help message
111-H, --hostname=HOST
112 name or IP address of host to check
113-C, --community=COMMUNITY NAME
114 community name for the host's SNMP agent
115-e, --command=COMMAND NAME (ps -e style)
116 what command should be monitored?
117-r, --regex=Perl RE
118 use a perl regular expression to find your process
119-w, --warning=INTEGER[,INTEGER]
120 minimum and maximum number of processes before a warning is issued (Default 1,-1)
121-c, --critical=INTEGER[,INTEGER]
122 minimum and maximum number of processes before a critical is issued (Default 1,-1)
123--memory
124 combined with '-s', will print the number of bytes of real memory used by process
125--cpu
126 combined with '-s', will print the number of seconds of cpu time consumed by process
127EOT
128}
129
130sub verbose (@) {
131 return if ( !defined($opt_verbose) );
132 print @_;
133}
134
135sub check_for_errors {
136 if ( $snmp_session->{ErrorNum} ) {
137 %processes = ();
138 print "UNKNOWN - error retrieving SNMP data: $snmp_session->{ErrorStr}\n";
139 exit $ERRORS{UNKNOWN};
140 }
141}
142
143sub init_cache {
144 if ( !defined($opt_cache) ) {
145 %processes = ();
146 return;
147 }
148 if ( -r $cachefile ) {
149 eval {
150 verbose "loading cache from $cachefile\n";
151 %processes = %{ retrieve( $cachefile ) };
152 };
153 if ( $@ ) {
154 verbose "cache loading failed - using blank cache: $@\n";
155 %processes = ()
156 }
157 }
158 else {
159 %processes = ();
160 }
161}
162
163sub snmpget {
164 my $tmpvar = SNMP::Varbind->new( shift );
165 $snmp_session->get( $tmpvar );
166 check_for_errors();
167 return $tmpvar->val;
168}
169
170sub update_cache {
171 # expire the cache after $cache_exp seconds
172 if ( $opt_cache != 0 && exists($processes{__last_update})
173 && $processes{__last_update} >= time - $cache_exp ) {
174 verbose "cache file is recent enough - using it\n";
175 return 1;
176 }
177
178 verbose "retrieving full listing of processes from $opt_host\n";
179 my $process_count = snmpget( ['hrSystemProcesses', 0] );
180
181 # retrieve the data from the remote host
182 my ($names) = $snmp_session->bulkwalk( 0, $process_count + 1, [['hrSWRunName']] );
183 check_for_errors();
184
185 # make sure the number of processes from the bulkwalk is close to hrSystemProcesses
186 if ( scalar(@$names) + 10 < $process_count ) {
187 print "UNKNOWN - only ", scalar(@$names), " of ",$process_count, " processes returned\n";;
188 exit $ERRORS{UNKNOWN};
189 }
190
191 # sort through the process names and create a nice hash of processes
192 foreach my $row ( @$names ) {
193 my %hash = {};
194 $hash{name} = $row->val;
195 $hash{abs_name} = $row->val;
196 $hash{name} =~ s#.*/##; # strip path
197
198 if ( defined($opt_regex) ||
199 ($row->val =~ m#$interpreters$#
200 && $opt_command !~ m#$interpreters$#) ) {
201
202 # fetch the runtime parameters of the process
203 my $parameters = snmpget( ['hrSWRunParameters', $row->iid] );
204
205 # only strip if we're looking for a specific command
206 if ( defined($opt_command) ) {
207 verbose "process ",$row->iid," uses $1 as an interpreter - getting parameters\n";
208 $hash{name} = $parameters;
209 $hash{name} =~ s#.*/##; # strip path name off the front
210 $hash{name} =~ s/\s+.*$//; # strip everything from the first space to the end
211 }
212 else {
213 # use the full 'ps -efl' style listing for regular expression matching
214 my $path = snmpget( ['hrSWRunPath', $row->iid] );
215 $hash{name} = "$path $parameters";
216 }
217 }
218 # store in the global hash
219 $processes{$row->iid} = \%hash;
220 }
221
222 # update the timestamp so the cache can expire
223 $processes{__last_update} = time;
224 return 0;
225}
226
227# process the %processes hash and see if there any matches for our command or regex
228sub check_for_matches {
229 my $ret_match = 0;
230 foreach my $key ( keys(%processes) ) {
231 next if ( $key eq '__last_update' );
232 my $match = 0;
233
234 # static matches are letter-for-letter (-e)
235 if ( defined($opt_command) && $processes{$key}->{name} eq $opt_command ) { $match++; }
236 # use /o to make sure the user-supplied regex (-r) is only compiled once
237 elsif ( defined($opt_regex) && $processes{$key}->{name} =~ /$opt_regex/o ) { $match++; }
238
239 # verify the cache's entry by doing an snmpget
240 if ( $match > 0 && $opt_cache != 0 ) {
241 my $proc = snmpget( ['hrSWRunName', $key] );
242 --$match if ( !$proc || $proc ne $processes{$key}->{abs_name} );
243 }
244 # get the process memory usage if requested
245 if ( $match > 0 && defined($opt_memory) ) {
246 $opt_memory += snmpget( ['hrSWRunPerfMem', $key] );
247 }
248 # get the process cpu usage if requested
249 if ( $match > 0 && defined($opt_cpu) ) {
250 $opt_cpu += snmpget( ['hrSWRunPerfCPU', $key] );
251 }
252
253 verbose "process '$processes{$key}->{name}' has pid $processes{$key}->{pid} and index $key\n"
254 if ( $match > 0 );
255
256 $ret_match += $match;
257 }
258 return $ret_match;
259}
260# =========================================================================== #
261# =====> MAIN
262# =========================================================================== #
263process_options();
264
265alarm( $TIMEOUT ); # make sure we don't hang Nagios
266
267# intialize the cache, if it's enabled
268init_cache();
269
270# create a session for conversing with the remote SNMP agent
271$snmp_session = new SNMP::Session(
272 DestHost => $opt_host,
273 Community => $opt_community,
274 RemotePort => $opt_port,
275 Version => '2c'
276);
277
278my $usage = update_cache();
279my $count = check_for_matches();
280
281# always try twice if caching is enabled - once with cache and once without
282if ( $usage != 0 && $opt_cache != 0 && $count <= 0 ) {
283 verbose "did not find process in cache - trying a refresh\n";
284 %processes = ();
285 update_cache();
286 $count = check_for_matches();
287}
288
289
290# the default, OK message
291my $message = "OK - $count process(es) found resembling '". ($opt_command || $opt_regex);
292
293# warning, critical
294if ( ($opt_warning->[0] > 0 && $opt_warning->[0] > $count)
295 || ($opt_warning->[1] > 0 && $opt_warning->[1] <= $count) ) {
296 $message = "WARNING - no processes found resembling '". ($opt_command || $opt_regex);
297 $exit = $ERRORS{WARNING};
298}
299if ( ($opt_critical->[0] > 0 && $opt_critical->[0] > $count)
300 || ($opt_critical->[1] > 0 && $opt_critical->[1] <= $count) ) {
301 $message = "CRITICAL - no processes found resembling '". ($opt_command || $opt_regex);
302 $exit = $ERRORS{CRITICAL};
303}
304
305# output the status message
306print $message, "'";
307
308# print the number of processes if statistics are requested
309if ( defined($opt_stats) ) {
310 print "|count=$count";
311 if ( defined($opt_memory) ) {
312 print ":memory=", $opt_memory;
313 }
314 if ( defined($opt_cpu) ) {
315 $opt_cpu = $opt_cpu / 100;
316 printf ":cpu=%.2f", $opt_cpu;
317 }
318}
319
320# store a copy of the %processes hash if we're using caching
321if ( $exit == $ERRORS{OK} && $opt_cache != 0 ) {
322 eval {
323 unlink( $cachefile ) if ( -e $cachefile );
324 store( \%processes, $cachefile );
325 };
326}
327
328print "\n";
329exit $exit;
330
331
diff --git a/contrib/check_snmp_procs.pl b/contrib/check_snmp_procs.pl
deleted file mode 100644
index 4d19ff1..0000000
--- a/contrib/check_snmp_procs.pl
+++ /dev/null
@@ -1,590 +0,0 @@
1#!/usr/bin/perl -w
2#
3# check_snmp_procs.pl
4# Nagios script to check processes on remote host via snmp
5#
6#
7# Copyright (c) 2003 David Alden
8#
9# This program is free software; you can redistribute it and/or
10# modify it under the terms of the GNU General Public License
11# as published by the Free Software Foundation; either version 2
12# of the License, or (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22#
23#
24# History
25# -------
26# 02-25-2003 - Dave Alden <alden@math.ohio-state.edu>
27# Initial creation
28#
29#
30# TODO
31# ----
32# make it work with snmp version 3
33# Suggestions???
34#
35#use strict;
36use Getopt::Long;
37use Net::SNMP qw (oid_lex_sort oid_base_match SNMP_VERSION_1);
38use lib "/usr/local/nagios/libexec";
39use utils qw(%ERRORS &print_revision &support &usage);
40
41my $PROGNAME="check_snmp_procs";
42my $REVISION="1.0";
43
44#
45my $opt_authprotocol;
46my $opt_authpassword;
47my $opt_community = 'ma4read';
48my $opt_critical;
49my $opt_help;
50my $opt_host = 'euler';
51my $opt_oidname = 'hrSWRunName';
52my $opt_port = 161;
53my $opt_privpassword;
54my $opt_regexp = 0;
55my $opt_snmp_version = '2c';
56my $opt_timeout = $utils::TIMEOUT;
57my $opt_username;
58my $opt_verbose;
59my $opt_version;
60my $opt_wanted_procs;
61my $opt_warning;
62
63#
64my $max_no_processes = 999999;
65my $session;
66my $error;
67my $no_procs;
68my $exit_status;
69
70#
71my @wanted_procs;
72my %current_process_list;
73
74#
75my %OIDS = (hrSWRunName => '1.3.6.1.2.1.25.4.2.1.2',
76 hrSWRunPath => '1.3.6.1.2.1.25.4.2.1.4');
77
78my %OIDS_L = (hrSWRunName => length($OIDS{hrSWRunName}),
79 hrSWRunPath => length($OIDS{hrSWRunPath}));
80
81#
82$ENV{'PATH'}='';
83$ENV{'BASH_ENV'}='';
84$ENV{'ENV'}='';
85
86#
87Getopt::Long::Configure('bundling');
88if (GetOptions(
89 "a:s" => \$opt_authprotocol, "authprotocol:s" => \$opt_authprotocol,
90 "A:s" => \$opt_authpassword, "authpassword:s" => \$opt_authpassword,
91 "C:s" => \$opt_community, "community:s" => \$opt_community,
92 "c:s" => \$opt_critical, "critical:s" => \$opt_critical,
93 "h" => \$opt_help, "help" => \$opt_help,
94 "H:s" => \$opt_host, "hostname:s" => \$opt_host,
95 "o:s" => \$opt_oidname, "oidname:s" => \$opt_oidname,
96 "P=s" => \$opt_password, "password=s" => \$opt_password,
97 "p=i" => \$opt_port, "port=i" => \$opt_port,
98 "r" => \$opt_regexp, "regexp" => \$opt_regexp,
99 "S" => \$opt_snmp_version, "snmpversion" => \$opt_snmp_version,
100 "t=i" => \$opt_timeout, "timeout=i" => \$opt_timeout,
101 "U=s" => \$opt_username, "username=s" => \$opt_username,
102 "v" => \$opt_verbose, "verbose" => \$opt_verbose,
103 "V" => \$opt_version, "version" => \$opt_version,
104 "N=s" => \$opt_wanted_procs, "names=s" => \$opt_wanted_procs,
105 "w:s" => \$opt_warning, "warning:s" => \$opt_warning)
106 == 0) {
107 print_usage();
108 exit $ERRORS{'UNKNOWN'};
109}
110
111if ($opt_version) {
112 print_revision($PROGNAME, "\$Revision: 1771 $REVISION \$");
113 exit $ERRORS{'OK'};
114}
115
116if ($opt_help) {
117 print_help();
118 exit $ERRORS{'OK'};
119}
120
121if (! utils::is_hostname($opt_host)){
122 usage();
123 exit $ERRORS{'UNKNOWN'};
124}
125
126($longest_wanted, @wanted_procs) = parse_wanted_procs($opt_verbose, $opt_wanted_procs, $opt_warning, $opt_critical);
127
128$SIG{'ALRM'} = sub {
129 print "Timeout: No Answer from Client\n";
130 exit $ERRORS{'UNKNOWN'};
131};
132alarm($opt_timeout);
133
134($longest_current, %current_process_list) = get_process_list($opt_verbose, $opt_host, $opt_username, $opt_privpassword, $opt_authprotocol, $opt_authpassword, $opt_community, $opt_port, $opt_oidname, $opt_snmp_version);
135
136$exit_status = compare_process_list($opt_regexp, \%current_process_list, @wanted_procs);
137
138if ($opt_verbose) {
139 print_info($longest_current, \%current_process_list, $longest_wanted, @wanted_procs);
140}
141
142exit($exit_status);
143
144
145#
146sub compare_process_list {
147
148 my($regexp, $current_process_list, @wanted_procs) = @_;
149 my($proc, $i, $no_running_procs, @warning, @critical);
150 my $exit = $ERRORS{'OK'};
151
152 for ($i = 0; $i <= $#wanted_procs; $i++) {
153
154 $proc = $wanted_procs[$i];
155
156 $no_running_procs = get_running_procs($regexp, $$proc{name}, $current_process_list);
157
158 $$proc{no_matches} += $no_running_procs;
159
160 if (($no_running_procs >= $$proc{warn_low}) &&
161 ($no_running_procs <= $$proc{warn_high})) {
162
163 push(@warning, $$proc{name} . "($no_running_procs)");
164
165 if ($exit != $ERRORS{'CRITICAL'}) {
166 $exit = $ERRORS{'WARNING'};
167 }
168
169 } elsif (($no_running_procs < $$proc{minimum}) ||
170 ($no_running_procs >= $$proc{critical_low}) &&
171 ($no_running_procs <= $$proc{critical_high})) {
172
173 push(@critical, $$proc{name} . "($no_running_procs)");
174
175 $exit = $ERRORS{'CRITICAL'};
176 }
177 }
178
179 print "SNMPPROC ";
180
181 if ($#critical >= 0) {
182 print "CRITICAL:";
183 } elsif ($#warning >= 0) {
184 print "WARNING:";
185 } else {
186 print "OK";
187 }
188
189 foreach $i (@critical) {
190 print " $i";
191 }
192
193 if (($#critical >= 0) &&
194 ($#warning >= 0)) {
195 print " WARNING:";
196 }
197
198 foreach $i (@warning) {
199 print " $i";
200 }
201
202 print "\n";
203
204 return $exit;
205}
206
207
208#
209sub get_running_procs {
210
211 my($regex, $name, $process_list) = @_;
212 my $count = 0;
213 my $process;
214
215 $count = 0;
216
217 if ($regex) {
218
219 foreach $process (keys %{$process_list}) {
220
221 if ($process =~ /$name/) {
222 $count += $$process_list{$process};
223 }
224 }
225
226
227 } else {
228
229 if (!defined($count = $$process_list{$name})) {
230 $count = 0;
231 }
232 }
233
234 return $count;
235}
236
237
238#
239sub get_process_list {
240
241 my($verbose, $host, $username, $privpassword, $authprotocol, $authpassword, $community, $port, $oidname, $snmp_version) = @_;
242 my(%process_list, %process_pid_list, $result);
243 my $process_list_longest = 1, $not_done = 1;
244 my(@args, @oids, $oid, $name);
245
246 ($session, $error) = Net::SNMP->session(
247 -hostname => $host,
248 -community => $community,
249 -port => $port,
250 -version => $snmp_version,
251 defined($privpassword) ? (-privpassword => $privpassword) : (),
252 defined($authpassword) ? (-authpassword => $authpassword) : (),
253 defined($authprotocol) ? (-authprotocol => $authprotocol) : (),
254 defined($username) ? (-username => $username) : ());
255
256 if (!defined($session)) {
257 print ("UNKNOWN: $error\n");
258 exit $ERRORS{'UNKNOWN'};
259 }
260
261 @args = (-varbindlist => [$OIDS{$oidname}]);
262
263 if ($session->version == SNMP_VERSION_1) {
264
265 while (defined($session->get_next_request(@args))) {
266
267 $oid = (keys(%{$session->var_bind_list}))[0];
268
269 last if (!oid_base_match($OIDS{$oidname}, $oid));
270
271 $name = $session->var_bind_list->{$oid};
272 $process_list{$name}++;
273
274 if ($verbose && ($process_list_longest < length($name))) {
275 $process_list_longest = length($name);
276 }
277
278 @args = (-varbindlist => [$oid]);
279 }
280
281 } else {
282
283 push(@args, -maxrepetitions => 25);
284
285 while ($not_done && defined($session->get_bulk_request(@args))) {
286
287 @oids = oid_lex_sort(keys(%{$session->var_bind_list}));
288
289 foreach $oid (@oids) {
290 if (!oid_base_match($OIDS{$oidname}, $oid)) {
291
292 $not_done = 0;
293
294 } else {
295
296 $name = $session->var_bind_list->{$oid};
297 $process_list{$name}++;
298
299 if ($verbose && ($process_list_longest < length($name))) {
300 $process_list_longest = length($name);
301 }
302
303 if ($session->var_bind_list->{$oid} eq 'endOfMibView') {
304 $not_done = 0;
305 }
306 }
307 }
308
309 if ($not_done) {
310 @args = (-maxrepetitions => 25, -varbindlist => [pop(@oids)]);
311 }
312 }
313 }
314
315 if ($session->error() ne '') {
316 print ("UNKNOWN: " . $session->error() . "\n");
317 exit $ERRORS{'UNKNOWN'};
318 }
319
320 $session->close;
321
322 return($process_list_longest, %process_list);
323}
324
325
326#
327sub parse_wanted_procs {
328
329 my($verbose, $wanted_procs, $warning, $critical) = @_;
330
331 my(@procs, $process, $i, $critical_low, $critical_high, $warn_low, $warn_high, $process_name, $process_min);
332 my(@process_array, @warn_array, @critical_array);
333 my $exit = 0;
334 my $longest_name = 1;
335
336 if (defined($wanted_procs)) {
337 @process_array = split(/,/, $wanted_procs);
338 }
339
340 if (defined($warning)) {
341 @warn_array = split(/,/, $warning);
342 }
343
344 if (defined($critical)) {
345 @critical_array = split(/,/, $critical);
346 }
347
348 if( defined($warning) && $#process_array != $#warn_array ) {
349
350 print "Error: Number of entries in process list($#process_array) and warn list($#warn_array) don't match\n";
351 exit $ERRORS{'UNKNOWN'};
352 }
353
354 if( defined($critical) && $#process_array != $#critical_array ) {
355
356 print "Error: Number of entries in process list and critical list don't match\n";
357 exit $ERRORS{'UNKNOWN'};
358 }
359
360 for ($i = 0; $i <= $#process_array; $i++) {
361
362 if ((($process_name, $process_min) = split(/:/, $process_array[$i])) != 2) {
363
364 $process_min = 1;
365 }
366
367 if ($verbose && ($longest_name < length($process_name))) {
368
369 $longest_name = length($process_name);
370 }
371
372 if (defined($critical_array[$i])) {
373 if ((($critical_low, $critical_high) = split(/:/, $critical_array[$i])) != 2) {
374
375 $critical_high = $critical_low;
376
377 } else {
378
379 if ($critical_high eq "") {
380 $critical_high = $max_no_processes;
381 }
382
383 if ($critical_low eq "") {
384 $critical_low = 0;
385 }
386 }
387 } else {
388
389 $critical_low = -1;
390 $critical_high = -1;
391 }
392
393 if (defined($warn_array[$i])) {
394 if ((($warn_low, $warn_high) = split(/:/, $warn_array[$i])) != 2) {
395
396 $warn_high = $warn_low;
397
398 } else {
399
400 if ($warn_high eq "") {
401 $warn_high = $max_no_processes;
402 }
403
404 if ($warn_low eq "") {
405 $warn_low = 0;
406 }
407 }
408 } else {
409
410 $warn_low = -1;
411 $warn_high = -1;
412 }
413
414 if ($critical_low > $critical_high) {
415 print "Error: $process_name critical low($critical_low) is larger than high($critical_high)\n";
416 $exit = 1;
417 }
418
419 if ($warn_low > $warn_high) {
420 print "Error: $process_name warn low($warn_low) is larger than high($warn_high)\n";
421 $exit = 1;
422 }
423
424 if (@critical_array &&
425 ($process_min > $critical_low)) {
426 print "Error: $process_name minimum($process_min) is larger than critical low($critical_low)\n";
427 $exit = 1;
428 }
429
430 if (@warn_array &&
431 ($process_min > $warn_low)) {
432 print "Error: $process_name minimum($process_min) is larger than warn low($warn_low)\n";
433 $exit = 1;
434 }
435
436 if (@warn_array && @critical_array &&
437 ((($warn_low >= $critical_low) && ($warn_low <= $critical_high)) ||
438 (($warn_high >= $critical_low) && ($warn_high <= $critical_high)))) {
439
440 print "Error: $process_name warn levels($warn_low:$warn_high) overlap with critical levels($critical_low:$critical_high)\n";
441 $exit = 1;
442 }
443
444 push(@procs,{
445 name => $process_name,
446 critical => defined($critical),
447 critical_low => $critical_low,
448 critical_high => $critical_high,
449 minimum => $process_min,
450 warning => defined($warning),
451 warn_low => $warn_low,
452 warn_high => $warn_high});
453 }
454
455 if ($exit) {
456 exit $ERRORS{'UNKNOWN'};
457 }
458
459 return($longest_name, @procs);
460}
461
462
463#
464sub print_info {
465
466 my ($longest_current, $current_process_list, $longest_wanted, @wanted_procs) = @_;
467
468 if ($longest_wanted < 7) {
469 $longest_wanted = 7;
470 } else {
471 $longest_wanted++;
472 }
473
474 printf("%s---------------------------------------------\n", "-" x $longest_wanted);
475 printf("|%-" . $longest_wanted . "s | | Min | Warn | Critical |\n", "Process");
476 printf("|%-" . $longest_wanted . "s | Qty | Procs| Low | High | Low | High |\n", "Name");
477 printf("%s---------------------------------------------\n", "-" x $longest_wanted);
478
479 for (my $temp=0; $temp <= $#wanted_procs; $temp++) {
480
481 printf("|%-" . $longest_wanted . "s |%6d|%6d|%6d|%6d|%6d|%6d|\n",
482 $wanted_procs[$temp]{name},
483 $wanted_procs[$temp]{no_matches},
484 $wanted_procs[$temp]{minimum},
485 $wanted_procs[$temp]{critical_low},
486 $wanted_procs[$temp]{critical_high},
487 $wanted_procs[$temp]{warn_low},
488 $wanted_procs[$temp]{warn_high});
489 }
490
491 printf("%s---------------------------------------------\n\n", "-" x $longest_wanted);
492
493 if ($longest_current < 7) {
494 $longest_current = 7;
495 } else {
496 $longest_current++;
497 }
498
499 printf("%s----------\n", "-" x $longest_current);
500 printf("|%-" . $longest_current . "s | Qty |\n", "Process");
501 printf("%s----------\n", "-" x $longest_current);
502
503 foreach my $result (sort keys %{$current_process_list}) {
504
505 printf("|%-" . $longest_current . "s |%6d|\n", $result,
506 $current_process_list{$result});
507 }
508 printf("%s----------\n", "-" x $longest_current);
509
510 return;
511}
512
513
514#
515sub print_usage {
516 print "Usage:
517 $PROGNAME -H <host> [-r] [-v]
518 -N <processname>[:minimum][,<processname>[:minimum] ...]
519 [-a <authprotocol>] [-A <authpassword>]
520 [-U <username>] [-P <password>]
521 [-o <oidname>] [ -S <snmpversion> ]
522 [-C <snmp_community>] [-p <port>] [-t <timeout>]
523 [-w <low>:<high>[,<low>:<high> ...]
524 [-c <low>:<high>[,<low>:<high> ...]
525 $PROGNAME (-h | --help) for detailed help
526 $PROGNAME (-V | --version) for version information\n";
527}
528
529
530#
531sub print_help {
532 print_revision($PROGNAME, "\$Revision: 1771 $REVISION \$");
533 print "Copyright (c) 2003 David Alden
534
535Check if processes are running on a host via snmp
536
537";
538
539 print_usage();
540
541 print "
542-a, --authprotocol=<authprotocol>
543 Set the authentication protocol used for authenticated SNMPv3 messages
544-A, --authpassword=<authpassword>
545 Set the authentication pass phrase used for authenticated SNMPv3 messages
546-c, --critical=<low>:<high>[,<low>:<high> ...]
547 exit with CRITICAL status if number of processes is between <low> and <high>
548-C, --community=<snmp_community>
549 SNMP read community (default: $opt_community)
550-h, --help
551 Show this help screen
552-H, --host=<host>
553 Check processes on the indiciated host
554-o, --oidname=<oidname>
555 Which oid tree to search, hrSWRunName or hrSWRunPath (default: $opt_oidname)
556-p, --port=<port>
557 Make connection on the indicated port (default: $opt_port)
558-N, --names=<processname>[:<minimum>][,<processname>[:<minimum>] ...]
559 Process names to check, (optional) minimum number of processes (default: 1)
560-P, --password=<privpassword>
561 Set the privacy pass phrase used for encrypted SNMPv3 messages
562-r, --regex
563 Use regular expression match for <process>
564-S, --snmpversion
565 Use snmp version specified (values: 1|2c|3, default: $opt_snmp_version)
566-t, --timeout
567 Plugin time out in seconds (default: $opt_timeout)
568-U, --username=<securityname>
569 Set the securityname used for encrypted SNMPv3 messages
570-v, --verbose
571 Print some extra debugging information (not advised for normal operation)
572-V, --version
573 Show version and license information
574-w, --warning=<low>:<high>[,<low>:<high> ...]
575 exit with WARNING status if number of processes is between <low> and <high>
576
577
578A CRITICAL error will be indicated unless there are at least <minimum> number
579of processes running (unless <minimum> is set to 0 -- useful if you don't
580mind that there are none of the processes running).
581
582If no processes are specified, the program will still connect to the remote
583host and download the current list of running processes. It will then exit
584with an OK (unless it wasn't able to connect) -- useful if you want to make
585sure that the remote snmpd process is running and returning a list of procs.
586
587
588";
589 support();
590}
diff --git a/contrib/check_sockets.pl b/contrib/check_sockets.pl
deleted file mode 100644
index b8ae24a..0000000
--- a/contrib/check_sockets.pl
+++ /dev/null
@@ -1,145 +0,0 @@
1#! /usr/bin/perl
2# ------------------------------------------------------------------------------
3# File Name: check_sockets.pl
4# Author: Richard Mayhew - South Africa
5# Date: 2000/07/11
6# Version: 1.0
7# Description: This script will check to see how may open sockets
8# a server has and waron respectivly
9# Email: netsaint@splash.co.za
10# ------------------------------------------------------------------------------
11# Copyright 1999 (c) Richard Mayhew
12# Credits go to Ethan Galstad for coding Nagios
13# If any changes are made to this script, please mail me a copy of the
14# changes :)
15# Some code taken from Charlie Cook (check_disk.pl)
16# License GPL
17#
18# ------------------------------------------------------------------------------
19# Date Author Reason
20# ---- ------ ------
21# 1999/09/20 RM Creation
22# 1999/09/20 TP Changed script to use strict, more secure by
23# specifying $ENV variables. The bind command is
24# still insecure through. Did most of my work
25# with perl -wT and 'use strict'
26#
27# ------------------------------------------------------------------------------
28
29# -----------------------------------------------------------------[ Require ]--
30require 5.004;
31# --------------------------------------------------------------------[ Uses ]--
32use Socket;
33use strict;
34# --------------------------------------------------------------[ Enviroment ]--
35$ENV{'PATH'}='/bin:/sbin:/usr/bin:/usr/sbin';
36$ENV{BASH_ENV} = "";
37# ------------------------------------------------------------------[ Global ]--
38my $TIMEOUT = 20;
39my %ERRORS = (
40 'UNKNOWN', '-1',
41 'OK', '0',
42 'WARNING', '1',
43 'CRITICAL', '2');
44# --------------------------------------------------------------[ connection ]--
45sub connection
46{
47 my ($in_total,$in_warn,$in_crit,$in_high) = @_;
48 my $state;
49 my $answer;
50
51 $in_total =~ s/\ //g;
52 if ($in_total >= 0) {
53
54 if ($in_total > $in_crit) {
55 $state = "CRITICAL";
56 $answer = "Critical Number Of Sockets Connected : $in_total (Limit = $in_crit)\n";
57
58 } elsif ($in_total > $in_warn) {
59 $state = "WARNING";
60 $answer = "Warning Number Of Sockets Connected : $in_total (Limit = $in_warn)\n";
61
62 } else {
63 if ($in_high ne "") {
64 $answer = "Sockets OK - Current Sockets: $in_total : $in_high\n";
65 }
66 if ($in_high eq "") {
67 $answer = "Sockets OK - Current Sockets: $in_total\n";
68 }
69 $state = "OK";
70 }
71
72 } else {
73 $state = "UNKNOWN";
74 $answer = "Something is Really WRONG! Sockets Is A Negative Figure!\n";
75 }
76
77 print $answer;
78 exit $ERRORS{$state};
79}
80
81# -------------------------------------------------------------------[ usage ]--
82sub usage
83{
84 print "Minimum arguments not supplied!\n";
85 print "\n";
86 print "Perl Check Sockets plugin for Nagios\n";
87 print "Copyright (c) 2000 Richard Mayhew\n";
88 print "\n";
89 print "Usage: check_sockets.pl <type> <warn> <crit>\n";
90 print "\n";
91 print "<type> = TOTAL, TCP, UDP, RAW.\n";
92 print "<warn> = Number of sockets connected at which a warning message will be generated.[Default = 256]\n";
93 print "<crit> = Number of sockets connected at which a critical message will be generated.[Default = 512]\n";
94 exit $ERRORS{"UNKNOWN"};
95
96}
97
98# ====================================================================[ MAIN ]==
99MAIN:
100{
101 my $type = shift || &usage;
102 my $warn = shift || 256;
103 my $crit = shift || 512;
104 my $data;
105 my @data;
106 my $line;
107 my $data1;
108 my $data2;
109 my $data3;
110 my $junk;
111 my $total1;
112 my $total2;
113 $type = uc $type;
114 if ($type eq "TOTAL") {
115 $type = "sockets";
116 }
117
118 # Just in case of problems, let's not hang Nagios
119 $SIG{'ALRM'} = sub {
120 print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n";
121 exit $ERRORS{"UNKNOWN"};
122 };
123
124 $data = `/bin/cat /proc/net/sockstat`;
125 @data = split("\n",$data);
126 alarm($TIMEOUT);
127 my $output = "";
128 my $high;
129
130
131 foreach $line (@data) {
132 if ($line =~ /$type/) {
133 ($data1,$data2,$data3) = split(" ",$line,3);
134
135 if ($data3 =~ /highest/){
136 ($total1,$junk,$total2) = split(" ",$data3,3);
137 $output = $total1;
138 $high = $total2;
139 }
140 else {$output = $data3;}
141 alarm(0);
142 connection($output,$warn,$crit,$high);
143 }
144 }
145}
diff --git a/contrib/check_temp_cpq b/contrib/check_temp_cpq
deleted file mode 100644
index 6edae6e..0000000
--- a/contrib/check_temp_cpq
+++ /dev/null
@@ -1,162 +0,0 @@
1#!/usr/bin/perl
2#
3#
4# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical]
5#
6# NetSaint host script to get the disk usage from NT snmp
7#
8# Changes and Modifications
9# =========================
10# 3-Aug-2000 - Xavier Dusart
11# Created
12# 2003 - Rainer Duffner
13# Note: CPQ starts numbering sensors etc. with "1"
14
15BEGIN {
16 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
17 $runtimedir = $1;
18 $PROGNAME = $2;
19 }
20}
21
22
23
24require 5.004;
25use POSIX;
26#use strict;
27use Getopt::Std ;
28use BER;
29require 'SNMP_Session.pm';
30use vars qw($opt_H $opt_p $opt_C $opt_s $opt_w $opt_c $opt_h $PROGNAME);
31use lib $main::runtimedir;
32use utils qw($TIMEOUT %ERRORS &print_revision &usage &support );
33
34use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED);
35
36delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
37
38
39getopts('H:p:C:s:w:c:hV') ;
40
41my $ip_address=undef ;
42
43if ($opt_h) {&help();}
44
45if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA
46-Z0-9]*)*)$/) {
47 $ip_address = $opt_H ;
48 }
49else {
50 usage();
51 print "IP-Address format wrong\n";
52 exit $ERRORS{'UNKNOWN'};
53 }
54
55#if ($opt_p =~ m/^[0-9]
56
57my $port = $opt_p;
58
59my $community = $opt_C;
60
61my $sensor = $opt_s ;
62
63my $warning = $opt_w;
64
65my $critical = $opt_c;
66
67
68 my $temperature_locale_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,3,0,$sensor );
69# not used for the moment - gives no usable output
70# if reused, enter at end of list to avoid renumbering !
71 my $temperature_celsius_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,4,0,$sensor );
72 my $temperature_threshold_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,5,0,$sensor );
73 my $temperature_condition_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,6,0,$sensor );
74 my $count=1 ;
75 my $label ;
76 my @r_array=();
77 my $q ;
78 my $diff ;
79 $warning=$warning/100 ;
80 $crititcal=$critical/100 ;
81
82
83# get temperature, temperature_threshold bfore shutdown
84 my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
85
86 if ($session->get_request_response ($temperature_celsius_oid, $temperature_threshold_oid, $temperature_condition_oid, $temperature_locale_oid )) {
87 (my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
88 while ($bindings ne '') {
89 ($binding, $bindings) = &decode_sequence ($bindings) ;
90 ($oid,$value) = &decode_by_template ($binding,"%O%@");
91 $r_array[$count]=&pretty_print($value);
92 $count++;
93 }
94 } else {
95 print "No response from agent\n";
96 exit $ERRORS{'CRITICAL'};
97 }
98 $result_celsius=$r_array[1];
99 $result_threshold=$r_array[2];
100 $result_condition=$r_array[3];
101 $result_locale=$r_array[4];
102
103 if ($result_celsius < 0) {
104 print "Result is negative - Sensor unavailable ?\n";
105 exit $ERRORS{'UNKNOWN'};
106 }
107 if ($result_threshold==0) {
108 print "Division by zero \n";
109 exit $ERRORS{'CRITICAL'};
110 }
111
112 if ($result_condition=="2") {
113 $result_condition="OK";
114 }
115 else {
116 $result_condition=$result_condition." (other)";
117 }
118 $q=$result_celsius/$result_threshold ;
119 $diff=$result_threshold-$result_celsius ;
120
121
122 if ( $q > $critical ) {
123 print "Sensor ". $sensor . " (".$CPQ_LOCALE{$result_locale}.") - Critical: ".$result_celsius." °C - Threshold: ".$result_threshold." °C - Left before shutdown: ".$diff."°C - Overall condition: ". $result_condition ."\n" ;
124 exit $ERRORS{'CRITICAL'} ;
125 }
126 elsif ( $q > $warning ) {
127 print "Sensor ". $sensor . " (".$CPQ_LOCALE{$result_locale}.") - Warning: ".$result_celsius." °C - Threshold: ".$result_threshold." °C - Left before shutdown: ".$diff."°C - Overall condition: ". $result_condition ."\n" ;
128 exit $ERRORS{'WARNING'} ;
129 }
130 else {
131 print "Sensor " .$sensor. " (".$CPQ_LOCALE{$result_locale}.") - OK: ".$result_celsius." °C - Threshold: ".$result_threshold." °C - Left before shutdown: ".$diff."°C - Overall condition: ". $result_condition ."\n" ;
132 exit $ERRORS{'OK'} ;
133 }
134
135
136sub print_usage () {
137 print "Usage: $PROGNAME -H <host> -p <port> -C <community> -s <sensornumber> [-w <warn>] [-c <crit>]\n";
138 }
139
140sub print_help () {
141 print_revision($PROGNAME,'$Revision: 1113 $\n ');
142 print "Copyright (c) 2003 Rainer Duffner\n ";
143 print_usage();
144 print "\n";
145 print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
146 print "<port> = SNMP-Port (normaly 161)\n";
147 print "<community> = SNMP v1 community\n";
148 print "<sensornumber> = Sensornumber (1, 2, 3 etc.)\n";
149 print "<warn> = report warning when more than <warn> % of the temperature is reached defaults to 80\n";
150 print "<crit> = report critical when more than <crit> % of the temperature is reached defaults to 90\n";
151 }
152
153sub version () {
154 print_revision($PROGNAME,'$Revision: 1113 $ ');
155 exit $ERRORS{'OK'};
156}
157
158sub help () {
159 print_help();
160 exit $ERRORS{'OK'};
161}
162
diff --git a/contrib/check_temp_fsc b/contrib/check_temp_fsc
deleted file mode 100644
index 33470ea..0000000
--- a/contrib/check_temp_fsc
+++ /dev/null
@@ -1,160 +0,0 @@
1#!/usr/bin/perl
2#
3#
4# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical]
5#
6# NetSaint host script to get the disk usage from NT snmp
7#
8# Changes and Modifications
9# =========================
10# 3-Aug-2000 - Xavier Dusart
11# Created
12# 2003 - Rainer Duffner
13
14BEGIN {
15 if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) {
16 $runtimedir = $1;
17 $PROGNAME = $2;
18 }
19}
20
21
22
23require 5.004;
24use POSIX;
25#use strict;
26use Getopt::Std ;
27use BER;
28require 'SNMP_Session.pm';
29use vars qw($opt_H $opt_p $opt_C $opt_s $opt_w $opt_c $opt_h $PROGNAME);
30use lib $main::runtimedir;
31use utils qw($TIMEOUT %ERRORS &print_revision &usage &support);
32use snmputil qw(%FSC_LOCALE %FSC_TEMP_CONDITION);
33
34delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer
35
36
37getopts('H:p:C:s:w:c:hV') ;
38
39my $ip_address=undef ;
40
41if ($opt_h) {&help();}
42
43if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA
44-Z0-9]*)*)$/) {
45 $ip_address = $opt_H ;
46 }
47else {
48 usage();
49 print "IP-Address format wrong\n";
50 exit $ERRORS{'UNKNOWN'};
51 }
52
53#if ($opt_p =~ m/^[0-9]
54
55my $port = $opt_p;
56
57my $community = $opt_C;
58
59my $sensor = $opt_s ;
60
61#my $warning = $opt_w;
62
63#my $critical = $opt_c;
64
65
66 my $temperature_locale_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,4,0,$sensor-1 );
67# not used for the moment - gives no usable output
68# if reused, enter at end of list to avoid renumbering !
69 my $temperature_celsius_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,11,0,$sensor-1 );
70 my $temperature_warning_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,6,0,$sensor-1 );
71 my $temperature_critical_oid =encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,8,0,$sensor-1 );
72 my $temperature_condition_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,1,1,3,0,$sensor-1 );
73 my $count=1 ;
74 my $label ;
75 my @r_array=();
76 my $q ;
77 my $diff ;
78 $warning=$warning/100 ;
79 $crititcal=$critical/100 ;
80
81
82# get temperature, temperature_threshold bfore shutdown
83 my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ;
84
85 if ($session->get_request_response ($temperature_celsius_oid, $temperature_warning_oid, $temperature_critical_oid, $temperature_condition_oid, $temperature_locale_oid )) {
86 (my $bindings) = $session->decode_get_response ($session->{pdu_buffer});
87 while ($bindings ne '') {
88 ($binding, $bindings) = &decode_sequence ($bindings) ;
89 ($oid,$value) = &decode_by_template ($binding,"%O%@");
90 $r_array[$count]=&pretty_print($value);
91 $count++;
92 }
93 } else {
94 print "No response from agent\n";
95 exit $ERRORS{'CRITICAL'};
96 }
97 $result_celsius=$r_array[1];
98 $result_warning=$r_array[2];
99 $result_critical=$r_array[3];
100 $result_condition=$r_array[4];
101 $result_locale=$r_array[5];
102
103 if ($result_celsius < 0) {
104 print "Result is negative - Sensor unavailable ?\n";
105 exit $ERRORS{'UNKNOWN'};
106 }
107 if ($result_warning==0) {
108 print "Division by zero \n";
109 exit $ERRORS{'CRITICAL'};
110 }
111
112 if ($result_critical==0) {
113 print "Division by zero \n";
114 exit $ERRORS{'CRITICAL'};
115 }
116
117
118# $q=$result_celsius/$result_threshold ;
119 $diff=$result_critical-$result_celsius ;
120
121
122 if ( $result_celsius > $result_critical ) {
123 print "Sensor ". $sensor . " (".$FSC_LOCALE{$result_locale}.") - Critical: ".$result_celsius." °C - Crit-Threshold:".$result_critical." °C - Left before shutdown:".$diff."°C - Overall condition: ". $FSC_TEMP_CONDITION{$result_condition} ."\n" ;
124 exit $ERRORS{'CRITICAL'} ;
125 }
126 elsif ( $result_celsius > $result_warning ) {
127 print "Sensor ". $sensor . " (".$FSC_LOCALE{$result_locale}.") - Warning: ".$result_celsius." °C - Crit-Threshold:".$result_warning." °C - Left before shutdown:".$diff."°C - Overall condition: ". $FSC_TEMP_CONDITION{$result_condition}."\n" ;
128 exit $ERRORS{'WARNING'} ;
129 }
130 else {
131 print "Sensor " .$sensor. " (".$FSC_LOCALE{$result_locale}.") - OK: ".$result_celsius." °C - Warn-Threshold:".$result_warning." °C - Left before shutdown:".$diff."°C - Overall condition: ". $FSC_TEMP_CONDITION{$result_condition} ."\n" ;
132 exit $ERRORS{'OK'} ;
133 }
134
135
136sub print_usage () {
137 print "Usage: $PROGNAME -H <host> -p <port> -C <community> -s <sensornumber> \n";
138 }
139
140sub print_help () {
141 print_revision($PROGNAME,'$Revision: 1113 $\n ');
142 print "Copyright (c) 2003 Rainer Duffner\n ";
143 print_usage();
144 print "\n";
145 print "<host> = IP-Address or DNS-Name of the W2K-Server\n";
146 print "<port> = SNMP-Port (normaly 161)\n";
147 print "<community> = SNMP v1 community\n";
148 print "<drvnumber> = Sensornumber (1, 2, 3 etc.)\n";
149 }
150
151sub version () {
152 print_revision($PROGNAME,'$Revision: 1113 $ ');
153 exit $ERRORS{'OK'};
154}
155
156sub help () {
157 print_help();
158 exit $ERRORS{'OK'};
159}
160
diff --git a/contrib/check_timeout.c b/contrib/check_timeout.c
deleted file mode 100644
index 858bdfe..0000000
--- a/contrib/check_timeout.c
+++ /dev/null
@@ -1,55 +0,0 @@
1/*****************************************************************************
2 *
3 * CHECK_TIMEOUT.C
4 *
5 * Program: Plugin timeout tester for Nagios
6 * License: GPL
7 * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)
8 *
9 * Last Modified: 01-10-2000
10 *
11 * Command line: CHECK_TIMEOUT <something..>
12 *
13 * Description:
14 * This 'plugin' - if you want to call it that - doesn't do anything. It
15 * just stays in a loop forever and never exits, and is therefore useful for
16 * testing service and host check timeouts in Nagios. You must supply at
17 * least one argument on the command line in order to activate the loop.
18 *
19 ****************************************************************************/
20
21#include <stdio.h>
22#include <unistd.h>
23
24
25int main(int argc, char **argv){
26
27 if(argc==1){
28 printf("Incorrect arguments supplied\n");
29 printf("\n");
30 printf("Plugin timeout tester for Nagios\n");
31 printf("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n");
32 printf("Last Modified: 01-10-2000\n");
33 printf("License: GPL\n");
34 printf("\n");
35 printf("Usage: %s <something>\n",argv[0]);
36 printf("\n");
37 printf("Options:\n");
38 printf(" <something> = Anything at all...\n");
39 printf("\n");
40 printf("Notes:\n");
41 printf("This 'plugin' doesn't do anything. It is designed to never exit and therefore\n");
42 printf("provides an easy way of testing service and host check timeouts in Nagios.\n");
43 printf("\n");
44 return 0;
45 }
46
47 /* let's never leave here, okay? */
48 while(1)
49 sleep(1);
50
51 return 0;
52 }
53
54
55
diff --git a/contrib/check_traceroute-pure_perl.pl b/contrib/check_traceroute-pure_perl.pl
deleted file mode 100644
index 96d1ff8..0000000
--- a/contrib/check_traceroute-pure_perl.pl
+++ /dev/null
@@ -1,119 +0,0 @@
1#!/usr/bin/perl -Wall
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16#
17#
18# check_traceroute is designed to generate and alarm if a traceroute exceeds
19# a certain number of hops. This is useful in cases where a multi-homed
20# network looses a connection and can still ping the remote end because
21# traffic is being re-routed out through the redundent connection.
22#
23# check_traceroute v0.1
24# By mp@xmission.com
25#
26# Thanks to Sebastian Hetze, Linux Information Systems AG who wrote the
27# excellent check_apache plugin, which this plugin was modeled after.
28#
29#############################################################################
30
31use strict;
32use Net::Traceroute;
33use Getopt::Long;
34
35my $version = "v0.1";
36my $opt_v;
37my $opt_t=undef; #for usage () unless ($opt_t) to work right
38my $opt_help;
39my $opt_w;
40my $opt_c;
41
42my %ERRORS = ('UNKNOWN' , '-1',
43 'OK' , '0',
44 'WARNING', '1',
45 'CRITICAL', '2');
46# Set this to whatever you like, but make sure you don't hang Nagios
47# for too long.
48my $timeout = "30";
49
50GetOptions
51 ("v" => \$opt_v, "t=s" => \$opt_t,
52 "help" => \$opt_help, "h" => \$opt_help,
53 "w=i" => \$opt_w, "c=i" => \$opt_c
54 );
55
56if ($opt_v) {
57 print "\nThis is check_traceroute version $version\n";
58 print "\n";
59 print "Please report errors to mp\@xmission\.com";
60 print "\n\n";
61 }
62
63#subs
64sub print_help () {
65 print "\n\nThis is check_traceroute.pl. It is designed to send an alert\n";
66 print "to Nagios if a route to a particular destination exceeds a\n";
67 print "certain number of hops.\n\n";
68 print "Usage:\n";
69 print "\n";
70 print "--help Display this help.\n";
71 print "-v Display the version number of check_traceroute.\n";
72 print "-t Host that you wish to traceroute to.\n";
73 print "-w Number of hops before Nagios generates a WARNING.\n";
74 print "-c Number of hops before Nagios generates a CRITICAL.\n";
75 }
76
77sub usage() {
78 print "check_traceroute -t <host> [-w <warning>] [-c <critical>]\n";
79 }
80
81sub do_check() {
82 if ($opt_t) {
83 unless ($opt_w && $opt_c) {die "You must specify thresholds using -c and -w\n";}
84 my $tr = Net::Traceroute->new(host=>"$opt_t") || die "Can't init traceroute!\n";
85 if($tr->found) {
86 my $hops = $tr->hops;
87 if($hops > $opt_w) {
88 print "Warning: $opt_t is $hops hops away!\n";
89 exit $ERRORS{'WARNING'};
90 }
91 elsif($hops > $opt_c) {
92 print "Critical: $opt_t is $hops hops away!\n";
93 exit $ERRORS{'CRITICAL'};
94 }
95 else {
96 print "OK: $opt_t is $hops hops away\n";
97 exit $ERRORS{'OK'};
98 }
99 }
100 else {
101 print "Couldn't locate host $opt_t!\n";
102 exit $ERRORS{'UNKNOWN'};
103 }
104 }
105 }
106
107# Must be placed at the end for -Wall to compile cleanly, blech
108if ($opt_help) {
109 print_help();
110 }
111usage() unless ($opt_t);
112#timeoutes
113$SIG{'ALRM'} = sub {
114 print ("ERROR: No response from $opt_t (timeout) in $timeout seconds\n");
115 exit $ERRORS{"UNKNOWN"};
116 };
117 alarm($timeout);
118do_check();
119
diff --git a/contrib/check_traceroute.pl b/contrib/check_traceroute.pl
deleted file mode 100755
index 569dc53..0000000
--- a/contrib/check_traceroute.pl
+++ /dev/null
@@ -1,209 +0,0 @@
1#!/usr/bin/perl
2
3# $Id: check_traceroute.pl 1115 2005-01-27 10:34:16Z stanleyhopcroft $
4
5# Revision 1.1 2005/01/27 10:34:16 stanleyhopcroft
6# Jon Meek's check_traceroute for Mon hacked by YT for Nagios. Prob pretty weak
7#
8
9use strict ;
10
11use vars qw(%ERRORS $TIMEOUT) ;
12use utils qw(%ERRORS $TIMEOUT &print_revision &support &usage) ;
13
14sub print_help ();
15sub print_usage ();
16
17$ENV{'PATH'}='/bin:/usr/bin:/usr/sbin';
18
19my $PROGNAME = 'check_traceroute' ;
20 # delay units are millisecs.
21my $MAX_INTERHOP_DELAY = 200 ;
22my $MAX_HOPS = 30 ;
23
24use Getopt::Std;
25
26use vars qw($opt_H $opt_N $opt_r $opt_R $opt_T $opt_d $opt_h $opt_i $opt_v $opt_V) ;
27
28getopts('i:H:N:R:T:dhrvV');
29 # H, N, R, T, and i take parms, others are flags
30
31do { print_help ; exit $ERRORS{OK}; }
32 if $opt_h ;
33
34do { print_revision($PROGNAME, '$Revision: 1115 $'); exit $ERRORS{OK}; }
35 if $opt_V ;
36
37do { print_help; exit $ERRORS{OK}; }
38 unless $opt_R || $opt_r ;
39
40do { print_help; exit $ERRORS{OK}; }
41 unless $opt_R =~ m|
42 (?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}-)+
43 \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
44 |x
45 || $opt_r ;
46
47my $should_be = $opt_R ;
48 # Set default timeout in seconds
49my $TimeOut = $opt_T || $TIMEOUT;
50
51my $max_interhop_delay = $opt_i || $MAX_INTERHOP_DELAY ;
52my $max_hops = $opt_N || $MAX_HOPS ;
53
54my $TRACEROUTE = '/usr/sbin/traceroute';
55
56my $TargetHost = $opt_H ;
57
58print_help
59 unless $TargetHost ;
60
61my ($route, $pid, $rta_list) = ( '', '', '' );
62my %ResultString = () ;
63
64$SIG{ALRM} = sub { die "timeout" };
65
66eval {
67
68 alarm($TimeOut);
69 # XXXX Discarding STDERR _should_ reduce the risk
70 # of unexpected output but consequently, results for
71 # non existent hosts are stupid. However, why would you
72 # specify a route to a NX host, other than a typo ...
73
74 $pid = open(TR, "$TRACEROUTE -n $TargetHost 2>/dev/null |")
75 or do {
76 "Failed. Cannot fork \"$TRACEROUTE\": $!" ;
77 $ERRORS{UNKNOWN} ;
78 } ;
79
80 my $hops = 0 ;
81 while (<TR>) {
82
83 print $_
84 if $opt_d;
85
86 if ( m|#\*\s+\*\s+\*| ) {
87 # Get * * * then give up
88 $route .= '*';
89 # 13 = PIPE, prevents Broken Pipe Error, at least on Solaris
90 kill 13, $pid;
91 last;
92 }
93 # We will only pick up the first IP address listed on a line for now
94 # traceroute to csg.citec.com.au (203.9.184.12), 64 hops max, 44 byte packets
95 # 1 10.254.254.254 0.868 ms 0.728 ms 0.705 ms
96 # 2 192.168.9.1 1.240 ms 1.165 ms 1.191 ms
97
98 my ($ThisHopIP) = m|\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+|;
99 my ($max_rta) = m|\d{1,3}\.\d{1,3}\.\d{1,3}\s+ (\d+\.\d+) ms| ;
100
101 $route .= $ThisHopIP . '-';
102 $rta_list .= sprintf("%.1f", $max_rta) . '-' ;
103
104 if ( $opt_v ) {
105 chomp $_ ;
106 print $_, ' ' x (58 - length), $route, "\n";
107 }
108
109 $hops++ ;
110
111 if ( ($hops >= $max_hops) && ! $opt_r ) {
112 kill 13, $pid ;
113 print qq(Failed. Max hops ($max_hops) exceeeded: incomplete after $hops hops, "$route".\n) ;
114 exit $ERRORS{CRITICAL} ;
115 }
116 if ( ($hops %2 == 0) && ($hops >= 4) && ! $opt_r ) {
117
118 # Check for 2 cycles at end of path ie -(a-b)-(a-b)$
119 # where a and b are IP v4 addresses of IS (routers).
120
121 my ($last_2_is) = $route =~ /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}-\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})-$/ ;
122 if ( $route =~ /$last_2_is-$last_2_is-$/ ) {
123 kill 13, $pid ;
124 print qq(Failed. Last 2 routers ($last_2_is) repeated, "$route".\n) ;
125 exit $ERRORS{CRITICAL} ;
126 }
127
128 }
129
130 }
131};
132
133alarm(0);
134
135if ( $@ and $@ =~ /timeout/ ) {
136 $route .= '*';
137 # It was a traceroute timeout
138 kill 13, $pid;
139} elsif ( $@ and $@ !~ /timeout/ ) {
140 close TR ;
141 print "Failed. Somethings gone wrong with \"$TRACEROUTE\": $!" ;
142 exit $ERRORS{UNKNOWN} ;
143}
144
145close TR;
146 # Remove trailing '-'s
147# $route =~ s/\-$//;
148chop($route) ;
149chop($rta_list) ;
150
151print "$route\n"
152 if $opt_d;
153
154if ( $opt_r ) {
155 print qq(Ok. Traceroute to host "$TargetHost" via route "$route".\n) ;
156 exit $ERRORS{OK};
157}
158
159if ( &RouteEqual($should_be, $route) ) {
160 print qq(Ok. Traceroute to "$TargetHost" via expected route "$route" ($rta_list).\n) ;
161 exit $ERRORS{OK};
162} else {
163 print qq(Failed. Route "$route" ne expected "$should_be".\n) ;
164 exit $ERRORS{CRITICAL};
165}
166
167
168sub RouteEqual {
169 my ($current_route, $prev_route) = @_;
170 return $current_route eq $prev_route ;
171}
172
173sub print_usage () {
174 print "Usage: $PROGNAME [ -R <route_string>|-r ] [ -d -T timeout -v -h -i ] -H <host>\n";
175}
176
177sub print_help () {
178 print_revision($PROGNAME, '$Revision: 1115 $') ;
179 print "Copyright (c) 2004 J Meek/Karl DeBisschop
180
181This plugin checks whether traceroute to the destination succeeds and if so that the route string option (-R) matches the list of routers
182returned by traceroute.
183
184";
185print_usage();
186 print "
187-d
188 Debug
189-h
190 Help
191-i
192 _TODO_
193 Max inter-hop delay (msec).
194-H
195 Host.
196-N
197 Max number of hops.
198-r
199 Record current route (and output to STDOUT). Useful for getting the value of -R option ...
200-v
201 Greater verbosity.
202-R
203 Mandatory route string ie r1-r2-... where ri is the ip address of the ith router.
204-T
205 Maximum time (seconds) to wait for the traceroute command to complete. Defaults to $TIMEOUT seconds.
206
207";
208 support();
209}
diff --git a/contrib/check_uptime.c b/contrib/check_uptime.c
deleted file mode 100644
index 7afeb23..0000000
--- a/contrib/check_uptime.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/******************************************************************************
2 *
3 * CHECK_UPTIME.C
4 *
5 * Program: Uptime plugin for Nagios
6 * License: GPL
7 * Copyright (c) 2000 Teresa Ramanan (teresa@redowl.org)
8 *
9 * Based on CHECK_LOAD.C
10 * Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida@linux.ime.usp.br>
11 *
12 * Last Modified: $Date: 2002-02-28 21:42:56 -0500 (Thu, 28 Feb 2002) $
13 *
14 * Command line: CHECK_UPTIME <host_address>
15 *
16 * Description:
17 *
18 * This plugin parses the output from "uptime", tokenizing it with ',' as the
19 * delimiter. Returning only the number of days and/or the hours and minutes
20 * a machine has been up and running.
21 *
22 *****************************************************************************/
23
24#include "config.h"
25#include "common.h"
26#include "utils.h"
27#include "popen.h"
28
29int main(int argc, char **argv)
30{
31
32 int result;
33 char input_buffer[MAX_INPUT_BUFFER];
34 int ct;
35 int i;
36 char *tok1 = NULL;
37 char *daytok = NULL;
38 char *hrmintok = NULL;
39 char *runstr = NULL;
40 char tempp;
41 char ch;
42 char delim[] = ",";
43
44 if(argc != 2){
45 printf("Incorrect number of arguments supplied\n");
46 printf("\n");
47 print_revision(argv[0],"$Revision: 6 $");
48 printf("Copyright (c) 2000 Teresa Ramanan (tlr@redowl.org)\n");
49 printf("\n");
50 printf("Usage: %s <host_address>\n",argv[0]);
51 printf("\n");
52 return STATE_UNKNOWN;
53 }
54
55 child_process = spopen(PATH_TO_UPTIME);
56 if(child_process==NULL){
57 printf("Error opening %s\n",PATH_TO_UPTIME);
58 return STATE_UNKNOWN;
59 }
60 child_stderr=fdopen(child_stderr_array[fileno(child_process)],"r");
61 if(child_stderr==NULL){
62 printf("Could not open stderr for %s\n",PATH_TO_UPTIME);
63 }
64 fgets(input_buffer,MAX_INPUT_BUFFER-1,child_process);
65 i = 0;
66 ct = 0;
67
68 /* Let's mark the end of this string for parsing purposes */
69 input_buffer[strlen(input_buffer)-1]='\0';
70
71 tempp = input_buffer[0];
72 while(ch != '\0'){
73 ch = (&tempp)[i];
74 if (ch == ',') { ct++; }
75 i++;
76 }
77 runstr = input_buffer;
78 tok1 = strsep(&runstr, delim);
79 if (ct > 4) {
80 hrmintok = strsep(&runstr, delim);
81 hrmintok++;
82 daytok = strstr(tok1,"up");
83 }
84 else {
85 hrmintok = strstr(tok1, "up");
86 }
87
88 result = spclose(child_process);
89 if(result){
90 printf("Error code %d returned in %s\n",result,PATH_TO_UPTIME);
91 return STATE_UNKNOWN;
92 }
93 if (hrmintok == NULL) {
94 printf("Problem - unexpected data returned\n");
95 return STATE_UNKNOWN;
96 }
97 printf("%s%s%s\n",(daytok == NULL)?"":daytok,(daytok == NULL)?"":",",hrmintok);
98 return STATE_OK;
99}
diff --git a/contrib/check_vcs.pl b/contrib/check_vcs.pl
deleted file mode 100644
index 38afdae..0000000
--- a/contrib/check_vcs.pl
+++ /dev/null
@@ -1,165 +0,0 @@
1#!/usr/bin/perl
2#
3# Veritas Cluster System monitor for Nagios.
4# Written by Aaron Bostick (abostick@mydoconline.com)
5# Last modified: 05-22-2002
6#
7# Usage: check_vcs {-g <vcs_group> | -r <vcs_resource> } -s <vcs_system> [-n]
8#
9# Description:
10#
11# This plugin is just a perl wrapper to the vcs commands hagrp and hares.
12# You specify what group/resource and system you want the status for, and
13# the plugin returns a status code based on the output of either hagrp or
14# hares.
15#
16# Normal hagrp/hares status codes are ONLINE and OFFLINE depending on where the
17# cluster service currently lives. I have added an option, -n, which makes
18# the expected state to be OFFLINE rather than ONLINE so you can run the
19# plugin on both sides of the cluster and will receive critical alerts when
20# the cluster fails over i.e. a proper failover will make the standby node
21# go from OFFLINE to ONLINE for the group, so an ONLINE status should alert
22# you! (You do want to know when the cluster fails over, right? :))
23#
24# Output:
25#
26# This plugin returns OK when hagrp/hares -state <grp> -sys <system> returns
27# ONLINE (or OFFLINE if -n is specified). Any other hagrp/hares string returns
28# CRITICAL... Would a WARNING ever be justified??? UNKNOWN is returned if
29# hagrp/hares cannot run for some reason.
30#
31# Examples:
32#
33# Make sure group oracle is ONLINE on server dbserver1:
34# check_vcs -g oracle -s dbserver1
35#
36# Make sure group oracle is OFFLINE on server dbserver2:
37# check_vcs -g oracle -s dbserver2 -n
38#
39# Make sure resource oraip is ONLINE on server dbserver1:
40# check_vcs -r oraip -s dbserver1
41#
42# Make sure resource oraip is OFFLINE on server dbserver2:
43# check_vcs -r oraip -s dbserver2 -n
44#
45
46
47BEGIN {
48 if ($0 =~ s/^(.*?)[\/\\]([^\/\\]+)$//) {
49 $prog_dir = $1;
50 $prog_name = $2;
51 }
52}
53
54require 5.004;
55
56use lib $main::prog_dir;
57use utils qw($TIMEOUT %ERRORS &print_revision &support);
58use Getopt::Long;
59
60sub print_usage ();
61sub print_version ();
62sub print_help ();
63
64 # Initialize strings
65 $vcs_bin = '/opt/VRTSvcs/bin';
66 $vcs_command = '';
67 $vcs_arg = '';
68 $vcs_group = '';
69 $vcs_resource = '';
70 $vcs_system = '';
71 $vcs_negate = '';
72 $vcs_result = '';
73 $vcs_expected_result = 'ONLINE';
74 $plugin_revision = '$Revision: 33 $ ';
75
76 # Grab options from command line
77 GetOptions
78 ("g|group:s" => \$vcs_group,
79 "r|resouce:s" => \$vcs_resource,
80 "s|system=s" => \$vcs_system,
81 "n|negate" => \$vcs_negate,
82 "v|version" => \$version,
83 "h|help" => \$help);
84
85 (!$version) || print_version ();
86 (!$help) || print_help ();
87 (!$vcs_negate) || ($vcs_expected_result = 'OFFLINE');
88
89 # Make sure group and resource is not specified
90 !($vcs_group && $vcs_resource) || usage("Please specify either a group or a resource, but not both.\n");
91 # Make sure group or resource is specified
92 ($vcs_group || $vcs_resource) || usage("HA group or resource not specified.\n");
93 # Make sure system is specified
94 ($vcs_system) || usage("HA system not specified.\n");
95
96 # Specify proper command
97 if ($vcs_group) {
98 $vcs_command = 'hagrp';
99 $vcs_arg = $vcs_group;
100 } else {
101 $vcs_command = 'hares';
102 $vcs_arg = $vcs_resource;
103 }
104
105 # Run command and save output
106 $vcs_result = `$vcs_bin/$vcs_command -state $vcs_arg -sys $vcs_system`;
107 chomp ($vcs_result);
108
109 # If empty result, return UNKNOWN
110 if (!$vcs_result) {
111 print "UNKNOWN: Problem running $vcs_command...\n";
112 exit $ERRORS{'UNKNOWN'};
113 }
114
115 # If result is expected, return OK
116 # If result is not expected, return CRITICAL
117 if ($vcs_result eq $vcs_expected_result) {
118 print "OK: $vcs_command $vcs_arg is $vcs_result\n";
119 exit $ERRORS{'OK'};
120 } else {
121 print "CRITICAL: $vcs_command $vcs_arg is $vcs_result\n";
122 exit $ERRORS{'CRITICAL'};
123 }
124
125
126#
127# Subroutines
128#
129
130sub usage () {
131 print @_;
132 print_usage();
133 exit $ERRORS{'OK'};
134}
135
136sub print_usage () {
137 print "\nUsage: $prog_name { -g <vcs_group> | -r <vcs_resource> } -s <vcs_system> [-n]\n";
138 print "Usage: $prog_name [ -v | --version ]\n";
139 print "Usage: $prog_name [ -h | --help ]\n";
140}
141
142sub print_version () {
143 print_revision($prog_name, $plugin_revision);
144 exit $ERRORS{'OK'};
145}
146
147sub print_help () {
148 print_revision($prog_name, $plugin_revision);
149 print "\n";
150 print "Validate output from hagrp/hares command.\n";
151 print "\n";
152 print_usage();
153 print "\n";
154 print "-g, --group=<vcs_group>\n";
155 print " The HA group to be validated\n";
156 print "-r, --resource=<vcs_resource>\n";
157 print " The HA resource to be validated\n";
158 print "-s, --system=<vcs_system>\n";
159 print " The HA system where the group/resource lives\n";
160 print "-n, --negate=<negate>\n";
161 print " Set expected result to OFFLINE instead of ONLINE\n";
162 print "\n";
163 support();
164 exit $ERRORS{'OK'};
165}
diff --git a/contrib/check_wave.pl b/contrib/check_wave.pl
deleted file mode 100644
index 56b59fe..0000000
--- a/contrib/check_wave.pl
+++ /dev/null
@@ -1,77 +0,0 @@
1#!/usr/bin/perl
2
3# CHECK_WAVE.PL
4# Plugin to test signal strength on Speedlan wireless equipment
5# Contributed by Jeffry Blank
6
7$Host=$ARGV[0];
8$sig_crit=$ARGV[1];
9$sig_warn=$ARGV[2];
10
11
12
13
14$low1 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
15@test=split(/ /,$low1);
16$low1=@test[2];
17
18
19$med1 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
20@test=split(/ /,$med1);
21$med1=@test[2];
22
23
24$high1 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
25@test=split(/ /,$high1);
26$high1=@test[2];
27
28sleep(2);
29
30
31
32$snr = `snmpget $Host public .1.3.6.1.4.1.762.2.5.2.1.17.1`;
33@test=split(/ /,$snr);
34$snr=@test[2];
35$snr=int($snr*25);
36$low2 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`;
37@test=split(/ /,$low2);
38$low2=@test[2];
39
40
41$med2 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`;
42@test=split(/ /,$med2);
43$med2=@test[2];
44
45
46$high2 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`;
47@test=split(/ /,$high2);
48$high2=@test[2];
49
50
51
52$low=$low2-$low1;
53$med=$med2-$med1;
54$high=$high2-$high1;
55
56$tot=$low+$med+$high;
57
58
59if ($tot==0)
60 {
61 $ss=0;
62 }
63else
64 {
65 $lowavg=$low/$tot;
66 $medavg=$med/$tot;
67 $highavg=$high/$tot;
68 $ss=($medavg*50)+($highavg*100);
69 }
70printf("Signal Strength at: %3.0f%, SNR at $snr%",$ss);
71#print "Signal Strength at: $ss%, SNR at $snr%";
72if ($ss<$sig_crit)
73 {exit(2)}
74if ($ss<$sig_warn)
75 {exit(1)}
76
77exit(0);
diff --git a/contrib/check_wins.pl b/contrib/check_wins.pl
deleted file mode 100755
index f11f864..0000000
--- a/contrib/check_wins.pl
+++ /dev/null
@@ -1,247 +0,0 @@
1#!/usr/bin/perl -w
2
3# $Id: check_wins.pl 940 2004-11-25 04:46:16Z stanleyhopcroft $
4
5# Revision 1.3 2004/11/25 04:46:16 stanleyhopcroft
6# Non functional tidy ups to check_wins
7#
8# Revision 1.2 2003/08/20 08:31:49 tonvoon
9# Changed netsaint to nagios in use lib
10#
11# Revision 1.1 2003/02/09 14:16:28 sghosh
12# more contribs
13#
14
15use strict ;
16
17use Getopt::Long ;
18use vars qw($opt_H $opt_D $opt_W $opt_T $debug @my_dcs);
19
20use lib '/usr/local/nagios/libexec/' ;
21use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
22
23my $PROGNAME = 'check_wins' ;
24
25use constant SAMBA_DEBUG_LVL => 2 ;
26use constant MY_DCS => ('dc1','dc2') ;
27
28my $NMBLOOKUP_PATH = '/usr/bin/nmblookup' ;
29my $NMBLOOKUP = sub { return `$NMBLOOKUP_PATH $_[2] -R -U $_[0] $_[1]` } ;
30my $NMBLOOKUP_CMD = $NMBLOOKUP_PATH . ' -R -U' ;
31
32sub print_help ();
33sub print_usage ();
34sub help ();
35sub version ();
36
37delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
38
39$SIG{"ALRM"} = sub { die "Alarm clock restart" } ;
40
41Getopt::Long::Configure('bundling', 'no_ignore_case');
42GetOptions
43 ("V|version" => \&version,
44 "h|help" => \&help,
45 "d|debug" => \$debug,
46 "C|controllers:s" => \@my_dcs,
47 "T|timeout:i" => \$opt_T,
48 "W|wins=s" => \$opt_W,
49 "D|domain=s" => \$opt_D);
50
51
52($opt_D) || usage("MS Domain name not specified\n");
53my $domain = $1 if $opt_D =~ m#(\w+)# ; # NetBIOS names allow __any__ characters (more than \w)
54($domain) || usage("Invalid MS D name: $opt_D\n");
55
56($opt_W) || usage("WINS hostname or address not specified\n");
57my $wins = $1 if $opt_W =~ m#((?:^\w+$)|(?:\d+(?:\.\d+){3,3}$))# ;
58($wins) || usage("Invalid WINS hostname or address: $opt_W\n");
59
60usage("You must provide the names of your domain controllers by updating MY_DCS in the text or use -C dc_name1 -C dc_name2 ..\n")
61 unless (@my_dcs or MY_DCS) ;
62
63@my_dcs = MY_DCS unless defined $my_dcs[0] ;
64$TIMEOUT = $opt_T if defined $opt_T ;
65
66my ($netbios_name, @dcs_of_domain, @dc_addresses) ;
67my (@addr_dcs_of_domain, @found_dcs, %address2dc) ;
68my (@dc_query) ;
69
70# tsitc> /usr/local/samba/bin/nmblookup -R -U wins ipa01
71# Sending queries to 192.168.1.29
72# 192.168.1.16 ipa01<00>
73
74eval {
75 alarm($TIMEOUT) ;
76 @dc_query = $debug ? map { $NMBLOOKUP->($wins, "$_#20", '-d ' . SAMBA_DEBUG_LVL) } @my_dcs :
77 map { ( $NMBLOOKUP->($wins, "$_#20", '') )[1] } @my_dcs ;
78 alarm(0) ;
79} ;
80
81if ($@ and $@ =~ /Alarm clock restart/) {
82 print qq(Failed. Timeout while waiting for response from (one of) "$NMBLOOKUP_CMD $wins @my_dcs"\n) ;
83 exit $ERRORS{"CRITICAL"} ;
84}
85
86if ($@ and $@ !~ /Alarm clock restart/) {
87 print qq(Failed. "$@" in response to "NMBLOOKUP_CMD $wins @my_dcs"\n) ;
88 exit $ERRORS{"UNKNOWN"} ;
89}
90
91chomp @dc_query ;
92if ( scalar grep(/name_query failed/, @dc_query) ) {
93 print qq(Failed. WINS "$wins" failed to resolve), scalar @my_dcs > 1 ? ' at least one of ' : ' ', qq("@my_dcs", the domain controller(s) of "$domain". Got "@dc_query"\n) ;
94 exit $ERRORS{"CRITICAL"} ;
95}
96
97=begin comment
98
99the results of looking up the DCs (by their name) in the WINS
100
101192.168.1.16 ipa01<20>
102192.168.1.1 ipa02<20>
103192.168.1.104 ipa03<20>
104
105=end comment
106
107=cut
108
109@dc_addresses = () ;
110foreach (@dc_query) {
111 next unless /^(\S+)\s+(\S+?)<\S+?>$/ ;
112 $address2dc{$1} = $2 ;
113 push @dc_addresses, $1 ;
114}
115
116$netbios_name = "$domain#1C" ;
117
118eval {
119 alarm($TIMEOUT) ;
120 @dcs_of_domain = $NMBLOOKUP->($wins, $netbios_name, defined $debug ? '-d ' . SAMBA_DEBUG_LVL : '') ;
121 alarm(0) ;
122
123} ;
124
125if ($@ and $@ =~ /Alarm clock restart/) {
126 print qq(Failed. Timeout while waiting for response from "$NMBLOOKUP_CMD $wins $netbios_name"\n) ;
127 exit $ERRORS{"CRITICAL"} ;
128}
129
130if ($@ and $@ !~ /Alarm clock restart/) {
131 print qq(Failed. "$@" in response to "$NMBLOOKUP_CMD $wins $netbios_name"\n) ;
132 exit $ERRORS{"UNKNOWN"} ;
133}
134
135shift @dcs_of_domain ;
136chomp @dcs_of_domain ;
137@addr_dcs_of_domain = map /^(\S+)/, @dcs_of_domain ;
138
139=begin comment
140
141tsitc> /usr/local/samba/bin/nmblookup -R -U wins ipaustralia#1c
142Sending queries to 192.168.1.29
143192.168.1.114 ipaustralia<1c>
144192.168.1.221 ipaustralia<1c>
145192.168.1.61 ipaustralia<1c>
146192.168.1.129 ipaustralia<1c>
147192.168.1.128 ipaustralia<1c>
148192.168.1.214 ipaustralia<1c>
149192.168.1.67 ipaustralia<1c>
150tsitc>
151
152=end comment
153
154=cut
155
156
157my %x ;
158@found_dcs = grep { ! $x{$_}++ } @address2dc{ grep exists $address2dc{$_}, @addr_dcs_of_domain} ;
159# @found_dcs = grep { defined $_} @address2dc{ grep exists $address2dc{$_}, @addr_dcs_of_domain} ;
160 # Gotcha.
161 # 'exists' is necessary to prevent autovivificatiton
162 # of keys in %address2dc
163
164if ( &set_eq( \@found_dcs, [ values %address2dc ] ) ) {
165 print $debug ? qq(Ok. WINS named "$wins" resolved addresses of "@my_dcs" as "@dc_query" and controllers of domain "$domain" as "@dcs_of_domain"\n) :
166 qq(Ok. Found controllers named "@my_dcs" in response to "$domain#1C" name query from WINS named "$wins".\n) ;
167 exit $ERRORS{"OK"} ;
168} elsif ( scalar @found_dcs == 0 ) {
169 print qq(Failed. Found __no__ controllers named "@my_dcs" in response to "$domain#1C" query from WINS named "$wins". Got "@dcs_of_domain"\n) ;
170 exit $ERRORS{"CRITICAL"} ;
171} elsif ( scalar @found_dcs < scalar keys %address2dc ) {
172 print qq(Warning. Not all domain controllers found in response to "$domain#1C" query from WINS named "$wins". Expected "@my_dcs", got "@found_dcs"\n) ;
173 exit $ERRORS{"WARNING"} ;
174}
175
176sub set_eq {
177
178 return 0 unless scalar @{$_[0]} == scalar @{$_[1]} ;
179 foreach my $a ( @{$_[0]} ) {
180 return 0 unless scalar grep { $a eq $_ } @{$_[1]} ;
181 }
182 return 1 ;
183
184}
185
186
187sub print_usage () {
188 print "Usage: $PROGNAME -W <wins> -D <domain>\n";
189}
190
191sub print_help () {
192 print_revision($PROGNAME,'$Revision: 940 $ ');
193 print "Copyright (c) 2001 Karl DeBisschop/S Hopcroft
194
195Perl Check WINS plugin for NetSaint.
196
197Returns OK if the addresses of domain controllers are found in the list of domain controllers returned in the WINS response to a 'domain controllers query'
198
199Why would you want to do this ?
200
201MS File server clients insist on connecting to file servers using NetBIOS names.
202If they __don't__ resolve NetBIOS names with a WINS (NBNS) then they'll either fail to logon and connect to shares or they will
203broadcast requsts for names.
204Both problems are eliminated by a healthy WINS.
205Also, you may have a MS domain spanning a number of WAN connected sites, with domain controllers far away from powerful local
206domain controllers.
207In this case, you want your local clients to have their logon requests validated by the local controllers.
208
209The plugin works by
210 asking the WINS to resolve the addresses of the domain controllers (supplied by -C or from the constant MY_DCS)
211 asking the WINS to return the list of addresses of the domain controllers able to validate requests for the domain
212 whose name is given by -D
213 returning Ok if all controller addresses are in that list (of addresses of domain controllers) or
214 returning WARNING if not all the controller addresses are in the list or
215 returning CRITICAL if there is no reply from the WINS or the list contains none of the contoller addresses
216
217";
218 print_usage();
219 print '
220-W, --wins=STRING
221 Hostname or address of the WINS (Either Samba/nmbd or MS product)
222-D, --domain=STRING
223 MS Domain name to find the Domain controllers of.
224-C, --controllers:STRING
225 Optional __name(s)__ of domain controller that __must__ be found in the response to a domain controller name query.
226 If not defined, then use the constant value MY_DCS. You must use either -C or make sure that MY_DCS contains the names
227 of __your__ domain controllers.
228-T, --timeout:INTEGER
229-d, --debug
230 Debugging output.
231-h, --help
232 This stuff.
233
234';
235 support();
236}
237
238sub version () {
239 print_revision($PROGNAME,'$Revision: 940 $ ');
240 exit $ERRORS{'OK'};
241}
242
243sub help () {
244 print_help();
245 exit $ERRORS{'OK'};
246}
247
diff --git a/contrib/checkciscotemp.pl b/contrib/checkciscotemp.pl
deleted file mode 100644
index 8fdc429..0000000
--- a/contrib/checkciscotemp.pl
+++ /dev/null
@@ -1,166 +0,0 @@
1#!/usr/bin/perl -wT
2# check_ciscotemp.pl
3#
4# Copyright (C) 2000 Leland E. Vandervort <leland@mmania.com>
5#
6# This program is free software; you can redistribute it and/or
7# modify it under the terms of the GNU General Public License
8# as published by the Free Software Foundation; either version 2
9# of the License, or (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty
13# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# you should have received a copy of the GNU General Public License
17# along with this program (or with Nagios); if not, write to the
18# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19# Boston, MA 02111-1307, USA
20####################################
21# Nagios pluging to check inlet and outlet temperatures on
22# Cisco router platforms which support environmental monitoring
23# (7200, 7500, GSR12000...)
24####################################
25# default temperature thresholds are 30C for inlet, 40C outlet.
26# if input or output is less than thresholds, returns OK
27# if equal to (the temps don't change that rapidly) returns WARNING
28# if greater than threshold, returns CRITICAL
29# if undetermined, or cannot access environmental, returns UNKNOWN
30# (in accordance with the plugin coding guidelines)
31####################################
32
33use Net::SNMP;
34use Getopt::Long;
35&Getopt::Long::config('auto_abbrev');
36
37my $status;
38my $response = "";
39my $timeout = 10;
40my $community = "public";
41my $port = 161;
42my $INTAKE_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.1";
43my $OUTLET_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.3";
44my $in_temp;
45my $out_temp;
46my $inlet_thresh = 30;
47my $outlet_thresh = 40;
48
49my %STATUSCODE = ( 'UNKNOWN' => '-1',
50 'OK' => '0',
51 'WARNING' => '1',
52 'CRITICAL' => '2');
53
54my $state = "UNKNOWN";
55
56
57$SIG{'ALRM'} = sub {
58 print "ERROR: No snmp response from $hostname (sigALRM)\n";
59 exit($STATUSCODE{"UNKNOWN"});
60};
61
62Getopt::Long::Configure('bundling');
63$status = GetOptions
64 ("community=s", \$community,
65 "C=s", \$community,
66 "H=s", \$hostname,
67 "hostname=s", \$hostname,
68 "port=i", \$port,
69 "timeout=i", \$timeout,
70 "c=s", \$critical_vals,
71 "w=s", \$warning_vals,
72 "ithresh=i", \$inlet_thresh,
73 "othresh=i", \$outlet_thresh);
74
75if($status == 0) {
76 &show_help;
77}
78
79unless (defined($hostname)) {
80 $hostname = shift || &show_help;
81}
82
83if (defined($critical_vals)) {
84 if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) {
85 ($inlet_thresh,$outlet_thresh) = ($1, $2);
86 } else {
87 die "Cannot Parse Critical Thresholds\n";
88 }
89}
90
91if (defined($warning_vals)) {
92 if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) {
93 ($inlet_warn,$outlet_warn) = ($1, $2);
94 } else {
95 die "Cannot Parse Warning Thresholds\n";
96 }
97}else{
98 $inlet_warn=$inlet_thresh;
99 $outlet_warn=$outlet_thresh;
100}
101
102alarm($timeout);
103
104$in_temp = &SNMPGET($INTAKE_TEMP);
105$out_temp = &SNMPGET($OUTLET_TEMP);
106
107if (($in_temp < $inlet_thresh) && ($out_temp < $outlet_thresh)) {
108 $state = "OK";
109}
110elsif (($in_temp == $inlet_thresh) || ($out_temp == $outlet_thresh)) {
111 if(($in_temp > $inlet_thresh) || ($out_temp > $outlet_thresh)) {
112 $state = "CRITICAL";
113 }
114 else {
115 $state = "WARNING";
116 }
117}
118elsif (($in_temp > $inlet_thresh) || ($out_temp > $outlet_thresh)) {
119 $state = "CRITICAL";
120}
121else {
122 $state = "WARNING";
123}
124
125print "$state Inlet Temp: $in_temp Outlet Temp: $out_temp\n";
126exit($STATUSCODE{$state});
127
128sub show_help {
129 printf("\nPerl envmon temperature plugin for Nagios\n");
130 printf("Usage:\n");
131 printf("
132 check_ciscotemp [options] <hostname>
133 Options:
134 -C snmp-community
135 -p snmp-port
136 -i input temperature threshold
137 -o output temperature threshold
138
139");
140 printf("Copyright (C)2000 Leland E. Vandervort\n");
141 printf("check_ciscotemp comes with absolutely NO WARRANTY either implied or explicit\n");
142 printf("This program is licensed under the terms of the\n");
143 printf("GNU General Public License\n(check source code for details)\n\n\n");
144 exit($STATUSCODE{"UNKNOWN"});
145}
146
147sub SNMPGET {
148 $OID = shift;
149 ($session,$error) = Net::SNMP->session(
150 Hostname => $hostname,
151 Community => $community,
152 Port => $port
153 );
154 if(!defined($session)) {
155 printf("$state %s\n", $error);
156 exit($STATUSCODE{$state});
157 }
158 if(!defined($response = $session->get_request($OID))) {
159 printf("$state %s\n", $session->error());
160 $session->close();
161 exit($STATUSCODE{$state});
162 }
163 $session->close();
164 return($response->{$OID});
165}
166
diff --git a/contrib/mrtgext.pl b/contrib/mrtgext.pl
deleted file mode 100644
index b9e9f6b..0000000
--- a/contrib/mrtgext.pl
+++ /dev/null
@@ -1,291 +0,0 @@
1#!/usr/bin/perl -w
2#
3# mrtgext.pl v0.3
4# (c)2000 Cliff Woolley, Washington and Lee University
5# jwoolley@wlu.edu
6#
7# A UNIX counterpart to Jim Drews' MRTG Extension for netware servers
8# Mimics output of mrtgext.nlm using output of various standard UNIX
9# programs (df, uptime, and uname)
10#
11# Dependencies: I make some assumptions about the output format of
12# your df and uptime commands. If you have nonstandard outputs for
13# any of these, either pick a different command that gives more
14# standard output or modify the script below. Example: use /usr/bin/bdf
15# on HP-UX instead of /usr/bin/df, because bdf follows the output format
16# I expect while df does not. This was written on Linux and tested on
17# HP-UX 10.20 (with changes to the subroutines at the bottom of the
18# program to reflect HP's command parameters); similar tweaking could
19# well be required to port this to other platforms. If you get it
20# working on your platform, please send me any changes you had to
21# make so I can try to incorporate them.
22#
23#
24# Following is what I expect the programs' outputs to look like:
25#
26# ======= df ========
27# Filesystem 1k-blocks Used Available Use% Mounted on
28# /dev/sda1 1014696 352708 609612 37% /
29# /dev/sda2 2262544 586712 1559048 27% /apps
30# /dev/sda3 4062912 566544 3286604 15% /share
31# /dev/sr0 651758 651758 0 100% /cdrom
32# ===================
33#
34# ===== uptime ======
35# 3:17pm up 15 days, 4:40, 5 users, load average: 0.12, 0.26, 0.33
36# ===================
37#
38
39###############################################################
40# Configuration section
41###############################################################
42
43$dfcmd = "/bin/df 2>/dev/null";
44$uptimecmd = "/usr/bin/uptime";
45%customcmds = ( "PROCS" => "numprocesses",
46 "ZOMBIES" => "numzombies",
47 "MEMFREE" => "memfree",
48 "SWAPUSED" => "swapused",
49 "TCPCONNS" => "tcpconns",
50 "CLIENTS" => "ipclients" );
51 # These are functions that you can
52 # define and customize for your system.
53 # You probably need to change the provided
54 # subroutines to work on your system (if
55 # not Linux).
56
57$rootfsnickname = "root"; # this is necessary as a kludge to
58 # better match the netware behavior.
59 # if you already have a _filesystem_
60 # mounted as /root, then you'll need
61 # to change this to something else
62$DEBUG = 0;
63$recvtimeout = 30;
64
65
66###############################################################
67# Program section
68###############################################################
69
70require 5.004;
71
72use Sys::Hostname;
73
74
75$DEBUG = $ARGV[0] unless ($DEBUG);
76$SIG{'ALRM'} = sub { exit 1; };
77
78# some things never change
79$hostname = hostname;
80
81
82if ( $DEBUG ) {
83 $| = 1;
84 print scalar localtime,": mrtgext.pl started\n";
85}
86
87# timeout period
88alarm($recvtimeout);
89my $items = <STDIN>;
90alarm(0);
91
92$items =~ s/[\r\n]//g;
93( $DEBUG ) && print scalar localtime,": request: \"$items\"\n";
94my @items = split (/\s+/,"$items");
95( $DEBUG ) && print scalar localtime,": ",scalar @items," item(s) to process\n";
96
97my $uptime = `$uptimecmd`;
98my @df = grep {/^\//} `$dfcmd`;
99
100my $processed = 1;
101
102foreach $_ (@items) {
103 ( $DEBUG ) && print scalar localtime,": processing item #$processed: \"$_\"\n";
104 $_ = uc; #convert $_ to upper case
105 if ( /^UTIL1$/ ) {
106 $uptime =~ /load average: ([^,]+),/;
107 print $1 * 100,"\n";
108 }
109 elsif ( /^UTIL5$/ ) {
110 $uptime =~ /load average: [^,]+, ([^,]+)/;
111 print $1 * 100,"\n";
112 }
113 elsif ( /^UTIL15$/ ) {
114 $uptime =~ /load average: [^,]+, [^,]+, ([^,]+)/;
115 print $1 * 100,"\n";
116 }
117 elsif ( /^CONNECT$/ ) {
118 $uptime =~ /(\d+) users?,/;
119 print "$1\n";
120 }
121 elsif ( /^NAME$/ ) {
122 print "$hostname\n";
123 }
124 elsif ( /^UPTIME$/ ) {
125 $uptime =~ /up (.*),\s+\d+\s+users?,/;
126 print "$1\n";
127 }
128 elsif ( /^VOLUMES$/ ) {
129 foreach $dfline (@df) {
130 my $volname = (split(/\s+/, "$dfline"))[5];
131 $volname =~ s/^\/$/$rootfsnickname/;
132 $volname =~ s/^\///;
133 $volname =~ s/\//_/g;
134 print "$volname\n";
135 }
136 }
137 elsif ( /^VF(\w*)$/ ) {
138 my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1";
139 foreach $dfline (@df) {
140 my @dfline = split(/\s+/, "$dfline");
141 if ($dfline[5] =~ /^\/?$volname$/i ) {
142 print (($dfline[1]-$dfline[2]) * 1024,"\n");
143 goto done;
144 }
145 }
146 ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n";
147 print "-1\n";
148 }
149 elsif ( /^VU(\w*)$/ ) {
150 my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1";
151 foreach $dfline (@df) {
152 my @dfline = split(/\s+/, "$dfline");
153 if ($dfline[5] =~ /^\/?$volname$/i ) {
154 print ($dfline[2] * 1024,"\n");
155 goto done;
156 }
157 }
158 ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n";
159 print "-1\n";
160 }
161 elsif ( /^VS(\w*)$/ ) {
162 my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1";
163 foreach $dfline (@df) {
164 my @dfline = split(/\s+/, "$dfline");
165 if ($dfline[5] =~ /^\/?$volname$/i ) {
166 print ($dfline[1] * 1024,"\n");
167 goto done;
168 }
169 }
170 ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n";
171 print "-1\n";
172 }
173 elsif ( /^VKF(\w*)$/ ) {
174 my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1";
175 foreach $dfline (@df) {
176 my @dfline = split(/\s+/, "$dfline");
177 if ($dfline[5] =~ /^\/?$volname$/i ) {
178 print (($dfline[1]-$dfline[2]),"\n");
179 goto done;
180 }
181 }
182 ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n";
183 print "-1\n";
184 }
185 elsif ( /^VKU(\w*)$/ ) {
186 my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1";
187 foreach $dfline (@df) {
188 my @dfline = split(/\s+/, "$dfline");
189 if ($dfline[5] =~ /^\/?$volname$/i ) {
190 print ($dfline[2],"\n");
191 goto done;
192 }
193 }
194 ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n";
195 print "-1\n";
196 }
197 elsif ( /^VKS(\w*)$/ ) {
198 my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1";
199 foreach $dfline (@df) {
200 my @dfline = split(/\s+/, "$dfline");
201 if ($dfline[5] =~ /^\/?$volname$/i ) {
202 print ($dfline[1],"\n");
203 goto done;
204 }
205 }
206 ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n";
207 print "-1\n";
208 }
209 elsif ( /^ZERO$/ ) {
210 print "0\n";
211 }
212 elsif (exists( $customcmds{"$_"} )) {
213 my $cmdsub = "$customcmds{$_}";
214 print &$cmdsub."\n";
215 }
216 else {
217 print "-1\n";
218 }
219 done: $processed++;
220}
221( $DEBUG ) && print scalar localtime,": done.\n";
222
223
224###############################################################
225# CUSTOMIZED PROCEDURES
226###############################################################
227
228sub numprocesses {
229
230 my $num = `/bin/ps -eaf | /usr/bin/tail -n +2 | /usr/bin/wc -l`;
231 chomp ($num);
232 $num =~ s/\s+//g;
233
234 $num;
235}
236
237sub numzombies {
238
239 my $num = `/bin/ps -afx | /usr/bin/awk '{print \$3}' | /usr/bin/grep Z | /usr/bin/tail -n +2 | /usr/bin/wc -l`;
240 chomp ($num);
241 $num =~ s/\s+//g;
242
243 $num;
244}
245
246sub tcpconns {
247
248 my $num = `/bin/netstat -nt | /usr/bin/tail -n +3 | /usr/bin/wc -l`;
249 chomp ($num);
250 $num =~ s/\s+//g;
251
252 $num;
253}
254
255sub ipclients {
256
257 my $num = `/bin/netstat -nt | /usr/bin/tail -n +3 | /usr/bin/awk '{print \$5}' | /bin/cut -d : -f 1 | /usr/bin/sort -nu | /usr/bin/wc -l`;
258 chomp ($num);
259 $num =~ s/\s+//g;
260
261 $num;
262}
263
264sub memfree {
265
266 open( FP, "/proc/meminfo" );
267 my @meminfo = <FP>;
268 close(FP);
269
270 # total: used: free: shared: buffers: cached:
271 # Mem: 994615296 592801792 401813504 91193344 423313408 93118464
272 # Swap: 204791808 0 204791808
273 my ($total,$free,$buffers,$cache) = (split(/ +/,$meminfo[1]))[1,3,5,6];
274
275 int(($free+$buffers+$cache)/$total*100);
276}
277
278sub swapused {
279
280 open( FP, "/proc/meminfo" );
281 my @meminfo = <FP>;
282 close(FP);
283
284 # total: used: free: shared: buffers: cached:
285 # Mem: 994615296 592424960 402190336 89821184 423313408 93077504
286 # Swap: 204791808 0 204791808
287
288 my ($total,$used) = (split(/ +/,$meminfo[2]))[1,2];
289
290 int($used/$total*100);
291}
diff --git a/contrib/nagios_sendim.pl b/contrib/nagios_sendim.pl
deleted file mode 100644
index 02870a6..0000000
--- a/contrib/nagios_sendim.pl
+++ /dev/null
@@ -1,66 +0,0 @@
1#!/usr/bin/perl -w
2#
3# SENDIM 1.0 by Sergio Freire (sergio-s-freire@ptinovacao.pt)
4# Nagios plugin to send notifications using instant messages through a jabber server
5#
6# Note: a) you can send messages to several different IM systems like ICQ,AIM,MSN,etc...
7# b) to test this plugin you can execute it with the arguments needed and write the message followed by a CTRL+D
8#
9# Please check http://www.jabber.org and http://www.jabberstudio.org for more information on Jabber Instant Messaging
10
11
12use Net::Jabber qw(Client);
13use Getopt::Std;
14
15my $tmp;
16my $mensagem="";
17getopts("u:p:t:");
18if ( (!defined($opt_u)) || (!defined($opt_p)) || (!defined($opt_t)))
19 {
20 print "USE: sendim -u user_JID -p password -t destination_JID\n";
21 print 'EXAMPLE: sendim -u nagios@jabber.org -p nagios -t bitcoder@nagios.org'."\n";
22 print " (send an instant message as user nagios\@jabber.org to bitcoder\@jabber.org)\n";
23 exit;
24 }
25
26my @buf=split('@',$opt_u);
27my $login=$buf[0];
28@buf=split('/',$buf[1]);
29my $server=$buf[0];
30my $resource=$buf[1] || "nagios";
31my $password=$opt_p;
32my $jid_dest=$opt_t;
33my $debug=0; # Set debug=1 to enable output of debug information
34
35while ($tmp=<STDIN>)
36{
37 $mensagem.=$tmp;
38}
39
40print "LOGIN: $login\nSERVER: $server\nRESOURCE: $resource\n" if $debug;
41print "TO: $jid_dest\n" if $debug;
42
43$Con1 = new Net::Jabber::Client();
44$Con1->Connect(hostname=>$server);
45
46 if ($Con1->Connected()) {
47 print "CON1: We are connected to the server...\n" if $debug;
48 }
49
50 @result1 = $Con1->AuthSend(username=>$login,
51 password=>$password,
52 resource=>$resource);
53
54
55$Con1->PresenceSend();
56$Con1->Process(1);
57
58@result1=$Con1->MessageSend( to=>$jid_dest,
59 subject=>"nagios",
60 body=>$mensagem,
61 type=>"chat",
62 priority=>1);
63
64$Con1->Process(1);
65$Con1->Disconnect();
66exit;
diff --git a/contrib/packet_utils.pm b/contrib/packet_utils.pm
deleted file mode 100755
index 783b333..0000000
--- a/contrib/packet_utils.pm
+++ /dev/null
@@ -1,119 +0,0 @@
1package packet_utils;
2
3# $Id: packet_utils.pm 1100 2005-01-25 09:12:47Z stanleyhopcroft $
4
5# Revision 1.1 2005/01/25 09:12:47 stanleyhopcroft
6# packet creation and dumping hacks used by check_ica* and check_lotus
7#
8# Revision 1.1 2005-01-25 15:28:58+11 anwsmh
9# Initial revision
10#
11
12require Exporter;
13@ISA = qw(Exporter);
14@EXPORT_OK = qw(tethereal pdump);
15
16sub tethereal {
17 my ($tethereal_dump, $start_byte) = @_ ;
18
19 # Return a string or array (depending on context) containing the characters from a tethereal trace.
20 # Skip all stuff until the first byte given by $start_byte in the first row ..
21
22 &outahere("Invalid tethereal dump:", substr($tethereal_dump, 0, 71), 'fails to match m#\d\d\d\d \S\S(?: \S\S){1,15}#')
23 unless $tethereal_dump =~ m#\d\d\d\d \S\S(?: \S\S){1,15}# ;
24
25 my @tethereal_dump = split(/\n/, $tethereal_dump) ;
26 my $first_line = shift @tethereal_dump ;
27 $first_line = unpack('x6 a48', $first_line) ;
28 # Take one extra space (after hex bytes) to use a template of 'a2 x' x 16
29 # instead of 'a2 x' x 15 . 'a2'
30 my $last_line = pop @tethereal_dump ;
31 $last_line = unpack('x6 a48', $last_line) ;
32
33 my $idx = index($first_line, $start_byte) ;
34
35 &outahere(qq(Invalid tethereal dump: "$start_byte" not found in first line - "$first_line"))
36 if $idx == -1 ;
37
38 $first_line = substr($first_line, $idx) ;
39
40 my ($dump, @dump) = ('', ()) ;
41
42 my $bytes = 0 ;
43 $bytes++
44 while $first_line =~ m#\b\S\S#g ;
45 push @dump, unpack('a2x' x $bytes, $first_line) ;
46
47 push @dump, unpack('x6 ' . 'a2x' x 16, $_)
48 foreach @tethereal_dump ;
49
50 $bytes = 0 ;
51 $bytes++
52 while $last_line =~ m#\b\S\S#g ;
53
54 # Be more cautious with the last line; the ASCII decode may
55 # have been omitted.
56
57 push @dump, unpack(('a2x' x ($bytes - 1)) . 'a2', $last_line) ;
58
59 return wantarray ? map pack('H2', $_), @dump : pack('H2' x scalar @dump, @dump) ;
60 # return wantarray ? map hex($_), @dump : pack('H2' x scalar @dump, @dump) ;
61
62}
63
64sub pdump {
65 my ($x) = shift @_ ;
66 my (@bytes_in_row, $row, $dump) ;
67
68 my $number_in_row = 16 ;
69 my $number_of_bytes = length $x ;
70 my $full_rows = int( $number_of_bytes / $number_in_row ) ;
71 my $bytes_in_last_row = $number_of_bytes % $number_in_row ;
72 my $template = "a$number_in_row " x $full_rows ;
73 my $nr = 0 ;
74 # Output format styled on tethereal.
75 foreach $row ( unpack($template, $x) ) {
76 @bytes_in_row = unpack('C*', $row) ;
77 $row =~ tr /\x00-\x1f\x80-\xff/./ ;
78 $dump .= join(' ', sprintf('%4.4x', $nr * 0x10), join(' ', map { sprintf "%2.2x", $_} @bytes_in_row), $row) ;
79 $dump .= "\n" ;
80 $nr++ ;
81 }
82
83 if ( $bytes_in_last_row ) {
84 my $number_of_spaces = ($number_in_row - $bytes_in_last_row)*3 - 2 ;
85
86 # 3 spaces (2 digts + 1 space) for each digit printed
87 # minus two spaces for those added by the join(' ',) below.
88
89 $row = substr($x, -$bytes_in_last_row) ;
90 @bytes_in_row = unpack('C*', $row) ;
91 $row =~ tr /\x00-\x1f\x80-\xff/./ ;
92 # my $bytes = join(' ', map { sprintf "%2.2x", $_} @bytes_in_row) ;
93 # See comment below.
94 my $spaces = ' ' x $number_of_spaces ;
95 $dump .= join(' ', sprintf("%4.4x", $nr * 0x10 ), join(' ', map { sprintf "%2.2x", $_} @bytes_in_row), $spaces, $row) ;
96 $dump .= "\n" ;
97 }
98
99 print STDERR $dump, "\n" ;
100
101=begin comment
102
103tsitc> perl -MBenchmark -e 'timethese(1_00_000, { printf => q<printf "%2.2x %2.2x %2.2x\n", 61, 62, 63>, sprintf => q<$x = sprintf "%2
104.2x %2.2x %2.2x\n", 61, 62, 63; print $x>} )' | perl -ne 'print if /intf/'
105
106Benchmark: timing 100000 iterations of printf, sprintf...
107 printf: 1 wallclock secs ( 0.55 usr + 0.00 sys = 0.55 CPU)
108 sprintf: 0 wallclock secs ( 0.11 usr + 0.00 sys = 0.11 CPU)
109
110so having sprintf in a loop seems more rational than a printf for the line ...
111
112=comment
113
114=cut
115
116}
117
118
119
diff --git a/contrib/rblcheck-dns b/contrib/rblcheck-dns
deleted file mode 100755
index 5e96195..0000000
--- a/contrib/rblcheck-dns
+++ /dev/null
@@ -1,69 +0,0 @@
1#!/usr/bin/perl
2# Multi-RBL Query tool, developer Vikram <vr@udel.edu>
3use strict;
4use Socket;
5my $suspect = $ARGV[1];
6
7die "Syntax: $0 -H <ip address>\n" unless $suspect;
8
9my @rblservers=qw[
10 3y.spam.mrs.kithrup.com
11 block.blars.org
12 bl.redhatgate.com
13 blackholes.five-ten-sg.com
14 blackholes.intersil.net
15 blackholes.mail-abuse.org
16 blackholes.wirehub.net
17 blacklist.spambag.org
18 dev.null.dk
19 dews.qmail.org
20 dialup.blacklist.jippg.org
21 dialups.mail-abuse.org
22 dnsbl.njabl.org
23 dul.maps.vix.com
24 dul.orca.bc.ca
25 dynablock.wirehub.net
26 formmail.relays.monkeys.com
27 ipwhois.rfc-ignorant.org
28 list.dsbl.org
29 multihop.dsbl.org
30 okrelays.nthelp.com
31 pm0-no-more.compu.net
32 proxies.relays.monkeys.com
33 rbl-plus.mail-abuse.org
34 rbl.maps.vix.com
35 rbl.spam.org.tr
36 relays.mail-abuse.org
37 relays.nthelp.com
38 relays.ordb.org
39 relays.radparker.com
40 relays.visi.com
41 sbl.spamhaus.org
42 spamguard.leadmon.net
43 spammers.v6net.org
44 spamsources.fabel.dk
45 spews.org
46 unconfirmed.dsbl.org
47 xbl.selwerd.cx
48];
49
50
51my $spam = 0;
52foreach ( @rblservers ) {
53 my @s = split('\.',$suspect);
54 my $req = "$s[3].$s[2].$s[1].$s[0].".$_;
55
56 my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname($req);
57 next unless (@addrs);
58
59 my $result = inet_ntoa($addrs[0]);
60 #next unless (substr($result, 7) eq '127.0.0');
61
62 print "$suspect is listed in the following RBLS: " if ( $spam == 0 );
63 print $_, " ";
64 $spam = 1;
65}
66
67print "$suspect is not listed in any RBLS" if ( $spam == 0 );
68print "\n";
69exit( $spam );
diff --git a/contrib/rblcheck-web b/contrib/rblcheck-web
deleted file mode 100755
index eb4fcde..0000000
--- a/contrib/rblcheck-web
+++ /dev/null
@@ -1,37 +0,0 @@
1#!/usr/bin/perl
2# Multi-RBL Query tool, developer Vikram <vr@udel.edu>
3use IO::Socket::INET;
4
5die "Syntax: $0 -H <ip address>\n" unless $ARGV[1];
6
7$soc = new IO::Socket::INET->new(PeerPort=>80,
8Proto=>'tcp',
9PeerAddr=>"rbls.org") or die("Cannot connect to CERT");
10
11$ip = $ARGV[1];
12$uri = '/?q='.$ip;
13
14$soc->send("GET $uri HTTP/1.1\nHost: rbls.org\n\n");
15@buff = <$soc>;
16delete @buff[0..7];
17$len = @buff;
18
19$alert = 0;
20
21
22for( $i=0;$i<$len;$i++ ) {
23 next unless( defined $buff[$i] );
24 chomp($buff[$i]);
25 #print "$buff[$i]\n";
26
27 if ( $buff[$i] eq "<tr bgcolor=#ffc0c0>" ) {
28 $rbl = substr($buff[$i+1], 5, index($buff[$i], "</tr>") - 5);
29 next if ( index($rbl, '.') == -1 );
30 print "$ip is listed in the following RBLS: " if ( $alert == 0 );
31 print "$rbl ";
32 $alert = 1;
33 }
34}
35print "$ip is not listed in any RBLS" if ( $alert == 0 );
36print "\n";
37exit($alert);
diff --git a/contrib/restrict.pl b/contrib/restrict.pl
deleted file mode 100755
index 75ea569..0000000
--- a/contrib/restrict.pl
+++ /dev/null
@@ -1,26 +0,0 @@
1#!/usr/bin/perl
2
3eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
4 if 0;
5
6# Set this to your local Nagios plugin path
7my $pluginpath = "/usr/libexec/nagios/plugins/";
8
9# Put all the legal commands (i.e. the commands that are
10# not Nagios checks but are allowed to be executed anyway)
11# in the following associative array.
12my %legal_cmds = ("nc" => "/usr/sbin/nc");
13
14# This will not work on OpenSSH
15# It does work on ssh-1.2.27-1i
16@arg = split ' ',$ENV{'SSH_ORIGINAL_COMMAND'};
17
18$arg[0] =~ s/.*\///; # strip leading path
19$arg[0] =~ tr/-_.a-zA-Z0-9/X/c; # change atypical chars to X
20
21if (!defined ($cmd = $legal_cmds{$arg[0]}))
22{
23 $cmd = $pluginpath . $arg[0];
24}
25
26exec { $cmd } @arg or die "Can't exec $cmd: $!";
diff --git a/contrib/sched_downtime.pl b/contrib/sched_downtime.pl
deleted file mode 100644
index b46b482..0000000
--- a/contrib/sched_downtime.pl
+++ /dev/null
@@ -1,47 +0,0 @@
1#! /usr/bin/perl -w
2#
3# Marko Riedel, EDV Neue Arbeit gGmbH, mriedel@neuearbeit.de
4#
5#
6#
7#
8use POSIX qw(strtol);
9
10my $command_file = '/usr/local/nagios/var/rw/nagios.cmd';
11
12my $hour = (60*60);
13my $next_day = (24*60*60);
14
15my $downtimes =
16 [
17 {
18 host => 'somehost',
19 service => 'SERVICE',
20 times => [ ["00:00", 9], ["18:00", 6] ]
21 }
22 ];
23
24foreach my $entry (@$downtimes) {
25 my ($secstart, $secend, $cmd, $current);
26
27 $current = `/bin/date +"%s"`;
28 chomp $current;
29
30 foreach my $tperiod (@{ $entry->{times} }){
31 $secstart = strtol(`/bin/date -d "$tperiod->[0]" +"%s"`);
32 $secend = $secstart+$tperiod->[1]*$hour;
33
34 $secstart += $next_day;
35 $secend += $next_day;
36
37 $cmd = "[$current] SCHEDULE_SVC_DOWNTIME;";
38 $cmd .= "$entry->{host};$entry->{service};";
39 $cmd .= "$secstart;$secend;";
40 $cmd .= "1;0;$0;automatically scheduled;\n";
41
42 print STDERR $cmd;
43
44 system "echo \"$cmd\" >> $command_file";
45 }
46}
47
diff --git a/contrib/tarballs/bowen-langley_plugins.tar.gz b/contrib/tarballs/bowen-langley_plugins.tar.gz
deleted file mode 100644
index a9ad1e8..0000000
--- a/contrib/tarballs/bowen-langley_plugins.tar.gz
+++ /dev/null
Binary files differ
diff --git a/contrib/tarballs/check_bgp-1.0.tar.gz b/contrib/tarballs/check_bgp-1.0.tar.gz
deleted file mode 100644
index 0496ddb..0000000
--- a/contrib/tarballs/check_bgp-1.0.tar.gz
+++ /dev/null
Binary files differ
diff --git a/contrib/tarballs/check_radius.tar.gz b/contrib/tarballs/check_radius.tar.gz
deleted file mode 100644
index cca6338..0000000
--- a/contrib/tarballs/check_radius.tar.gz
+++ /dev/null
Binary files differ
diff --git a/contrib/tarballs/check_traffic-0.91b.tar.gz b/contrib/tarballs/check_traffic-0.91b.tar.gz
deleted file mode 100644
index 0d8ab79..0000000
--- a/contrib/tarballs/check_traffic-0.91b.tar.gz
+++ /dev/null
Binary files differ
diff --git a/contrib/tarballs/fetchlog-0.94.tar.gz b/contrib/tarballs/fetchlog-0.94.tar.gz
deleted file mode 100644
index 029e119..0000000
--- a/contrib/tarballs/fetchlog-0.94.tar.gz
+++ /dev/null
Binary files differ
diff --git a/contrib/urlize.pl b/contrib/urlize.pl
deleted file mode 100644
index 5acb52d..0000000
--- a/contrib/urlize.pl
+++ /dev/null
@@ -1,29 +0,0 @@
1#!/usr/bin/perl
2#
3# urlize.pl
4# jcw, 5/12/00
5#
6# A wrapper around Nagios plugins that provides a URL link in the output
7#
8#
9# Pay close attention to quoting to ensure that the shell passes the
10# expected data to the plugin. For example, in:
11#
12# urlize http://example.com/ check_http -H example.com -r 'two words'
13#
14# the shell will remove the single quotes and urlize will see:
15#
16# urlize http://example.com/ check_http -H example.com -r two words
17#
18# You probably want:
19#
20# urlize http://example.com/ \"check_http -H example.com -r 'two words'\"
21#
22($#ARGV < 1) && die "Incorrect arguments";
23my $url = shift;
24
25chomp ($result = `@ARGV`);
26print "<A HREF=\"$url\">$result</A>\n";
27
28# exit with same exit value as the child produced
29exit ($? >> 8);
diff --git a/contrib/utils.py b/contrib/utils.py
deleted file mode 100644
index db0f1c9..0000000
--- a/contrib/utils.py
+++ /dev/null
@@ -1,310 +0,0 @@
1#
2#
3# Util classes for Nagios plugins
4#
5#
6
7
8
9#==========================================================================
10#
11# Version: = '$Id: utils.py 2 2002-02-28 06:42:51Z egalstad $'
12#
13# (C) Rob W.W. Hooft, Nonius BV, 1998
14#
15# Contact r.hooft@euromail.net for questions/suggestions.
16# See: <http://starship.python.net/crew/hooft/>
17# Distribute freely.
18#
19# jaclu@galdrion.com 2000-07-14
20# Some changes in error handling of Run() to avoid error garbage
21# when used from Nagios plugins
22# I also removed the following functions: AbortableWait() and _buttonkill()
23# since they are only usable with Tkinter
24
25import sys,os,signal,time,string
26
27class error(Exception):
28 pass
29
30class _ready(Exception):
31 pass
32
33def which(filename):
34 """Find the file 'filename' in the execution path. If no executable
35 file is found, return None"""
36 for dir in string.split(os.environ['PATH'],os.pathsep):
37 fn=os.path.join(dir,filename)
38 if os.path.exists(fn):
39 if os.stat(fn)[0]&0111:
40 return fn
41 else:
42 return None
43
44class Task:
45 """Manage asynchronous subprocess tasks.
46 This differs from the 'subproc' package!
47 - 'subproc' connects to the subprocess via pipes
48 - 'task' lets the subprocess run autonomously.
49 After starting the task, we can just:
50 - ask whether it is finished yet
51 - wait until it is finished
52 - perform an 'idle' task (e.g. Tkinter's mainloop) while waiting for
53 subprocess termination
54 - kill the subprocess with a specific signal
55 - ask for the exit code.
56 Summarizing:
57 - 'subproc' is a sophisticated os.popen()
58 - 'task' is a sophisticated os.system()
59 Another difference of task with 'subproc':
60 - If the Task() object is deleted, before the subprocess status
61 was retrieved, the child process will stay.
62 It will never be waited for (i.e., the process will turn into
63 a zombie. Not a good idea in general).
64
65 Public data:
66 None.
67
68 Public methods:
69 __init__, __str__, Run, Wait, Kill, Done, Status.
70 """
71 def __init__(self,command):
72 """Constructor.
73 arguments:
74 command: the command to run, in the form of a string,
75 or a tuple or list of words.
76 """
77 if type(command)==type(''):
78 self.cmd=command
79 self.words=string.split(command)
80 elif type(command)==type([]) or type(command)==type(()):
81 # Surround each word by ' '. Limitation: words cannot contain ' chars
82 self.cmd="'"+string.join(command,"' '")+"'"
83 self.words=tuple(command)
84 else:
85 raise error("command must be tuple, list, or string")
86 self.pid=None
87 self.status=None
88
89 def Run(self,usesh=0,detach=0,stdout=None,stdin=None,stderr=None):
90 """Actually run the process.
91 This method should be called exactly once.
92 optional arguments:
93 usesh=0: if 1, run 'sh -c command', if 0, split the
94 command into words, and run it by ourselves.
95 If usesh=1, the 'Kill' method might not do what
96 you want (it will kill the 'sh' process, not the
97 command).
98 detach=0: if 1, run 'sh -c 'command&' (regardless of
99 'usesh'). Since the 'sh' process will immediately
100 terminate, the task created will be inherited by
101 'init', so you can safely forget it. Remember that if
102 detach=1, Kill(), Done() and Status() will manipulate
103 the 'sh' process; there is no way to find out about the
104 detached process.
105 stdout=None: filename to use as stdout for the child process.
106 If None, the stdout of the parent will be used.
107 stdin= None: filename to use as stdin for the child process.
108 If None, the stdin of the parent will be used.
109 stderr=None: filename to use as stderr for the child process.
110 If None, the stderr of the parent will be used.
111 return value:
112 None
113 """
114 if self.pid!=None:
115 raise error("Second run on task forbidden")
116 self.pid=os.fork()
117 if not self.pid:
118 for fn in range(3,256): # Close all non-standard files in a safe way
119 try:
120 os.close(fn)
121 except os.error:
122 pass
123 #
124 # jaclu@galdrion.com 2000-07-14
125 #
126 # I changed this bit somewhat, since Nagios plugins
127 # should send only limited errors to the caller
128 # The original setup here corupted output when there was an error.
129 # Instead the caller should check result of Wait() and anything
130 # not zero should be reported as a failure.
131 #
132 try:
133 if stdout: # Replace stdout by file
134 os.close(1)
135 i=os.open(stdout,os.O_CREAT|os.O_WRONLY|os.O_TRUNC,0666)
136 if i!=1:
137 sys.stderr.write("stdout not opened on 1!\n")
138 if stdin: # Replace stdin by file
139 os.close(0)
140 i=os.open(stdin,os.O_RDONLY)
141 if i!=0:
142 sys.stderr.write("stdin not opened on 0!\n")
143 if stderr: # Replace stderr by file
144 os.close(2)
145 i=os.open(stderr,os.O_CREAT|os.O_WRONLY|os.O_TRUNC,0666)
146 if i!=2:
147 sys.stdout.write("stderr not opened on 2!\n")
148 #try:
149 if detach:
150 os.execv('/bin/sh',('sh','-c',self.cmd+'&'))
151 elif usesh:
152 os.execv('/bin/sh',('sh','-c',self.cmd))
153 else:
154 os.execvp(self.words[0],self.words)
155 except:
156 #print self.words
157 #sys.stderr.write("Subprocess '%s' execution failed!\n"%self.cmd)
158 sys.exit(1)
159 else:
160 # Mother process
161 if detach:
162 # Should complete "immediately"
163 self.Wait()
164
165 def Wait(self,idlefunc=None,interval=0.1):
166 """Wait for the subprocess to terminate.
167 If the process has already terminated, this function will return
168 immediately without raising an error.
169 optional arguments:
170 idlefunc=None: a callable object (function, class, bound method)
171 that will be called every 0.1 second (or see
172 the 'interval' variable) while waiting for
173 the subprocess to terminate. This can be the
174 Tkinter 'update' procedure, such that the GUI
175 doesn't die during the run. If this is set to
176 'None', the process will really wait. idlefunc
177 should ideally not take a very long time to
178 complete...
179 interval=0.1: The interval (in seconds) with which the 'idlefunc'
180 (if any) will be called.
181 return value:
182 the exit status of the subprocess (0 if successful).
183 """
184 if self.status!=None:
185 # Already finished
186 return self.status
187 if callable(idlefunc):
188 while 1:
189 try:
190 pid,status=os.waitpid(self.pid,os.WNOHANG)
191 if pid==self.pid:
192 self.status=status
193 return status
194 else:
195 idlefunc()
196 time.sleep(interval)
197 except KeyboardInterrupt:
198 # Send the interrupt to the inferior process.
199 self.Kill(signal=signal.SIGINT)
200 elif idlefunc:
201 raise error("Non-callable idle function")
202 else:
203 while 1:
204 try:
205 pid,status=os.waitpid(self.pid,0)
206 self.status=status
207 return status
208 except KeyboardInterrupt:
209 # Send the interrupt to the inferior process.
210 self.Kill(signal=signal.SIGINT)
211
212 def Kill(self,signal=signal.SIGTERM):
213 """Send a signal to the running subprocess.
214 optional arguments:
215 signal=SIGTERM: number of the signal to send.
216 (see os.kill)
217 return value:
218 see os.kill()
219 """
220 if self.status==None:
221 # Only if it is not already finished
222 return os.kill(self.pid,signal)
223
224 def Done(self):
225 """Ask whether the process has already finished.
226 return value:
227 1: yes, the process has finished.
228 0: no, the process has not finished yet.
229 """
230 if self.status!=None:
231 return 1
232 else:
233 pid,status=os.waitpid(self.pid,os.WNOHANG)
234 if pid==self.pid:
235 #print "OK:",pid,status
236 self.status=status
237 return 1
238 else:
239 #print "NOK:",pid,status
240 return 0
241
242 def Status(self):
243 """Ask for the status of the task.
244 return value:
245 None: process has not finished yet (maybe not even started).
246 any integer: process exit status.
247 """
248 self.Done()
249 return self.status
250
251 def __str__(self):
252 if self.pid!=None:
253 if self.status!=None:
254 s2="done, exit status=%d"%self.status
255 else:
256 s2="running"
257 else:
258 s2="prepared"
259 return "<%s: '%s', %s>"%(self.__class__.__name__,self.cmd,s2)
260
261
262#==========================================================================
263#
264#
265# Class: TimeoutHandler
266# License: GPL
267# Copyright (c) 2000 Jacob Lundqvist (jaclu@galdrion.com)
268#
269# Version: 1.0 2000-07-14
270#
271# Description:
272# On init, suply a call-back kill_func that should be called on timeout
273#
274# Make sure that what ever you are doing is calling Check periodically
275#
276# To check if timeout was triggered call WasTimeOut returns (true/false)
277#
278
279import time,sys
280
281class TimeoutHandler:
282 def __init__(self,kill_func,time_to_live=10,debug=0):
283 'Generic time-out handler.'
284 self.kill_func=kill_func
285 self.start_time=time.time()
286 self.stop_time=+self.start_time+int(time_to_live)
287 self.debug=debug
288 self.aborted=0
289
290 def Check(self):
291 'Call this periodically to check for time-out.'
292 if self.debug:
293 sys.stdout.write('.')
294 sys.stdout.flush()
295 if time.time()>=self.stop_time:
296 self.TimeOut()
297
298 def TimeOut(self):
299 'Trigger the time-out callback.'
300 self.aborted=1
301 if self.debug:
302 print 'Timeout, aborting'
303 self.kill_func()
304
305 def WasTimeOut(self):
306 'Indicates if timeout was triggered 1=yes, 0=no.'
307 if self.debug:
308 print ''
309 print 'call duration: %.2f seconds' % (time.time()-self.start_time)
310 return self.aborted