diff options
97 files changed, 1 insertions, 16690 deletions
diff --git a/Makefile.am b/Makefile.am index cbca5d77..aae8ec9b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,7 @@ SUBDIRS = gl tap lib plugins plugins-scripts plugins-root po @PERLMODS_DIR@ EXTRA_DIST = config.rpath \ ABOUT-NLS ACKNOWLEDGEMENTS AUTHORS BUGS CODING FAQ LEGAL NEWS \ NP-VERSION-GEN REQUIREMENTS SUPPORT THANKS \ - NPTest.pm contrib pkg nagios-plugins.spec \ + NPTest.pm pkg nagios-plugins.spec \ config_test/Makefile config_test/run_tests config_test/child_test.c \ perlmods tools/build_perl_modules \ tools/tinderbox_build diff --git a/contrib-reporting/process_perfdata.pl b/contrib-reporting/process_perfdata.pl deleted file mode 100644 index c97d4832..00000000 --- a/contrib-reporting/process_perfdata.pl +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/local/bin/perl -w -# author: Al Tobey <albert.tobey@priority-health.com> -# what: process perfdata from Nagios and put it into RRD files -# license: GPL - http://www.fsf.org/licenses/gpl.txt -# -# Todo: -# * more documentation (POD) & comments -# * clean up a bit, make it more configurable - possibly a config file - -use strict; -use lib qw( /opt/nagios/libexec ); -use utils qw( %ERRORS ); -use vars qw( $debug_file %data $debug $rrd_base $process_func $rrd_type ); -use RRDs; -$debug_file = undef; #"/var/opt/nagios/perfdata.out"; -$rrd_base = '/var/opt/nagios/rrds'; -$process_func = \&process_multi; -$rrd_type = 'GAUGE'; -$data{hostname} = shift(@ARGV); -$data{metric} = shift(@ARGV); -$data{timestamp} = shift(@ARGV); -$data{perfdata} = join( " ", @ARGV ); $data{perfdata} =~ s/\s+/ /g; - -# make sure there's data to work with -exit $ERRORS{OK} if ( !defined($data{hostname}) || !defined($data{metric}) - || !defined($data{timestamp}) || !defined($data{perfdata}) - || $data{perfdata} eq ' ' || $data{perfdata} eq '' ); - -if ( defined($debug_file) ) { - open( LOGFILE, ">>$debug_file" ); - print LOGFILE "$data{hostname}\t$data{metric}\t$data{timestamp}\t$data{perfdata}\n\n"; -} - -# make sure host directory exists -if ( !-d "$rrd_base/$data{hostname}" ) { - mkdir( "$rrd_base/$data{hostname}" ) - || warn "could not create host directory $rrd_base/$data{hostname}: $!"; -} -our $rrd_dir = $rrd_base .'/'. $data{hostname}; - -# --------------------------------------------------------------------------- # -# do some setup based on the name of the metric - -# host data -if ( $data{metric} eq "HOSTCHECK" ) { - $rrd_dir .= '/hostperf'; -} -# processing disk information -elsif ( $data{metric} =~ /_DISK$/ ) { - $rrd_dir .= '/disk'; -} -# network interface information -elsif ( $data{metric} =~ /^IFACE_/ ) { - $rrd_dir .= '/interfaces'; - $rrd_type = [ 'COUNTER', 'COUNTER' ]; -} -# process performance statistics -elsif ( $data{metric} =~ /_PROC$/ ) { - $rrd_dir .= '/processes'; - $process_func = \&process_single; - $rrd_type = [ 'COUNTER', 'GAUGE' ]; -} -# a resonable guess -elsif ( $data{perfdata} =~ /=/ ) { - $process_func = \&process_single; -} -# everything else -else { - $rrd_dir .= '/other'; -} - -# --------------------------------------------------------------------------- # -# call the proper processing function set up above (functions defined below) -our @processed = ( $process_func->() ); - -# --------------------------------------------------------------------------- # - -if ( !-d $rrd_dir ) { - mkdir( $rrd_dir ) || warn "could not mkdir( $rrd_dir ): $!"; -} -foreach my $datum ( @processed ) { - if ( defined($debug_file) ) { - print LOGFILE $datum->{rrd_name}, " = ", join('--',@{$datum->{data}}), "\n" - } - - my $rrdfile = $rrd_dir.'/'.$datum->{rrd_name}; - - # create the RRD file if it doesn't already exist - if ( !-e $rrdfile ) { - # create a non-useful datasource title for each "part" - RRDs::create( $rrdfile, "-b", $data{timestamp}, "-s", 300, $process_func->($datum, 1), - "RRA:AVERAGE:0.5:1:600", - "RRA:MAX:0.5:1:600", - "RRA:AVERAGE:0.5:6:600", - "RRA:MAX:0.5:6:600", - "RRA:AVERAGE:0.5:24:600", - "RRA:MAX:0.5:24:600", - "RRA:AVERAGE:0.5:288:600", - "RRA:MAX:0.5:288:600" - ); - if ( my $ERROR = RRDs::error ) { print "ERROR: $ERROR\n"; exit $ERRORS{UNKNOWN}; } - } - else { - # create a template to make sure data goes into the RRD as planned - if ( defined($debug_file) ) { - print LOGFILE "updating $rrdfile with data:\n\t", - join(':', $data{timestamp}, @{$datum->{data}}), "\n"; - } - # update the RRD file - RRDs::update( $rrdfile, '-t', $process_func->($datum), - join(':', $data{timestamp}, @{$datum->{data}}) ); - if ( my $ERROR = RRDs::error ) { print "ERROR: $ERROR\n"; exit $ERRORS{UNKNOWN}; } - } -} - -# --------------------------------------------------------------------------- # - -if ( defined($debug_file) ) { - print LOGFILE "-------------------------------------------------------------------------------\n"; - close( LOGFILE ); -} - -exit $ERRORS{OK}; - -# /opt=value,value,value:/=value,value,value - into multiple rrd's -sub process_multi { - my( $datum, $create ) = @_; - - # return a string for creating new RRDs - if ( defined($create) && $create == 1 ) { - my @DS = (); - for ( my $i=0; $i<scalar(@{$datum->{data}}); $i++ ) { - # allow the RRD type to be set in the switch/if above - my $tmp_rrd_type = $rrd_type; - if ( ref($rrd_type) eq 'ARRAY' ) { $tmp_rrd_type = $rrd_type->[$i] } - # put the new datasource into the list - push( @DS, "DS:$data{metric}$i:GAUGE:86400:U:U" ); - } - return @DS; - } - # return a template for updating an RRD - elsif ( defined($datum) && !defined($create) ) { - my @template = (); - for ( my $i=0; $i<scalar(@{$datum->{data}}); $i++ ) { - push( @template, $data{metric}.$i ); - } - return join( ':', @template ); - } - # break the data up into parts for processing (updates and creates) - else { - my @processed = (); - foreach my $part ( split(/:/, $data{perfdata}) ) { # break the line into parts - my @parts = split( /,/, $part ); # break the part into parts - my $rrd_name = $parts[0]; # figure out a good name for the RRD - if ( $parts[0] =~ /^\// ) { # handle /'s in disk names - $rrd_name = $parts[0]; - $rrd_name =~ s#/#_#g; $rrd_name =~ s/^_//; $rrd_name =~ s/_$//; - if ( $parts[0] eq '/' ) { $rrd_name = 'root' }; - } - # store our munged data in an array of hashes - push( @processed, { rrd_name => $rrd_name, name => shift(@parts), data => [ @parts ] } ); - } - return @processed; - } -} - -# name=value:name=value - into one rrd -sub process_single { - my( $datum, $create ) = @_; - - my( @names, @values ) = (); - foreach my $part ( split(/:/, $data{perfdata}) ) { - my( $name, $value ) = split( /=/, $part ); - push( @names, $name ); - push( @values, $value ); - } - - if ( defined($create) && $create == 1 ) { - my @DS = (); - for( my $i=0; $i<scalar(@names); $i++ ) { - my $tmp_rrd_type = $rrd_type; - if ( ref($rrd_type) eq 'ARRAY' ) { $tmp_rrd_type = $rrd_type->[$i] } - push( @DS, 'DS:'.$names[$i].":$tmp_rrd_type:86400:U:U" ); - } - return @DS; - } - elsif ( defined($datum) && !defined($create) ) { - return join( ':', @names ); - } - else { - return( {rrd_name=>lc($data{metric}), name=>$data{metric}, data=>[@values]} ); - } -} diff --git a/contrib/README.TXT b/contrib/README.TXT deleted file mode 100644 index bd9df3c4..00000000 --- a/contrib/README.TXT +++ /dev/null @@ -1,56 +0,0 @@ -Contrib Plugins README ----------------------- - -This directory contains plugins which have been contributed by various people, but that -have not yet been incorporated into the core plugins distribution. - -Most Perl plugins should work without modification. Some of the C plugins may require -a few tweaks to compile. - -If you have questions regarding the use of these plugins, try contacting the author(s) -or post a message to the nagiosplug-help mailing list (nagiosplug-help@lists.sourceforge.net) -requesting assistance. - - - -Contrib Tarballs ----------------- - -In addition to the plugins located in this directory, there are some additional tarballs -containing plugins in the tarballs/ subdirectory. They have not yet been organized. -A brief description of their contents follows. - - -berger-ping.tar.gz - Perl script version of the check_ping plugin and a corresponding - CGI (mtr.cgi) that uses mtr to traceroute a path to a host. - (Gary Berger) - -bowen-langley_plugins.tar.gz - - Several C plugins including check_inode, check_boot, etc. - (Adam Bown & Thomas Langley) - - -check_bgp-1.0.tar.gz - Perl script intended for monitoring BGP sessions on Cisco routers. - Uses Net::Telnet to telnet into a cisco router and - run "sh ip bgp" - -check_memory.tgz - C plugin to check available system memory - -check_radius.tar.gz - C program to check RADIUS authentication. This is a hacked version of - the Cistron Radiusd program radtest that acts as a plugin for Nagios. - The vast majority of the code was written by someone at Livingston - Enterprises and Cistron. NOTE: Due to the copyright restrictions in - this code, it cannot be distributed under the GPL license, and thus - will not appear in the core plugin distribution! - (Adam Jacob) - -radius.tar.gz - Code modifications necessary to make the radexample app - supplied with the radiusclient code work as a RADIUS plugin - for Nagios (Nick Shore) - -fetchlog-0.94.tar.gz - C program: The fetchlog utility displays the last new messages of a - logfile. It is similar like tail(1) but offers some extra functionality - for output formatting. fetchlog can be used standalone or as a Nagios - plugin to monitor local logfiles or together with Net-SNMP to monitor - remote logfiles. The README shows how to setup fetchlog for Nagios. - (Alexander Haderer) diff --git a/contrib/aix/check_failed b/contrib/aix/check_failed deleted file mode 100644 index 50cdf7e1..00000000 --- a/contrib/aix/check_failed +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/perl -#====================== -# Created May 25, 2000 -#====================== - -# This scripts is for checking for failed root login attempts on -# any machine running AIX which has a failedlogin file in /etc/security -# The purpose is to thwart (good word) any unauthorised people from -# even trying to log in as root. This plugin has been developed for Nagios -# running on AIX. -# Lonny Selinger SpEnTBoY lonny@abyss.za.org -# May - - -my $server = $ARGV[0]; - -if (!$ARGV[0]) { - print "You must specify a server to check\n"; - print "usage: ./check_failed <Server Name>\n"; - exit (-1); - } else { - open (DATE, "/bin/date '+%b %d' |"); - while (<DATE>) { - $dline = $_; - @dresults = $dline; - chop $dresults[0]; - } - open (SULOG, "rsh $server -l root who /etc/security/failedlogin | grep root |"); - while (<SULOG>) { - $line = $_; - @results = split (/\s+/,$line); - if ($line =~ /^root/) { - if (join(' ', @results[2,3]) eq $dresults[0]) { - print "FAILED root login on $dresults[0], node: $ARGV[0] from $results[5]\n"; - exit(2); - } - } - } -} -if (join(' ', @results[2,3]) ne $dresults[0]) { - print "No Failed Root Logins on This Node\n"; - exit(0); -} -exit(0); -close(SULOG); -close(DATE); - - diff --git a/contrib/aix/check_io b/contrib/aix/check_io deleted file mode 100644 index 58b25f6d..00000000 --- a/contrib/aix/check_io +++ /dev/null @@ -1,69 +0,0 @@ -#! /bin/sh - -#================================================================= -# -# I/O Checker (KBPS) -# This Script uses iostat to monitor disk io -# Useful for notifications of disk thrashing. -# -# Authors: TheRocker -# SpEnTBoY -# -# Email: therocker@pawprints.2y.net -# lonny@abyss.za.org -# -#================================================================ - -NUMBER1=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c1 | line` -NUMBER2=`rsh $1 -l root iostat -d | grep -e "hdisk" | tr -s ' ' | cut -d' ' -f2 | sort -2 -r | cut -c2 | line` -TMPFILE=/tmp/iotest.hndl -TMPTOO=/tmp/iotwo.hndl - -#=========================================================== -# -# We do an evaluation on $NUMBER1 and $NUMBER2 to see if -# disk io is exceeding 40%. -# -#=========================================================== - -if [ "$NUMBER1" -gt 4 ] && [ "$NUMBER2" -gt 0 ] -then - - `rsh $1 -l root iostat -d | grep -v cd0 | tr -s ' '| cut -d' ' -f1,2 | grep -e "4[0-9]." >> $TMPFILE` - -#==================================================================== -# -# Of course, there may be more than one hard disk on the node -# so we use this bit of code to report on more than one instance -# of excessive disk IO. -# -#==================================================================== - - LINES=`wc -l /tmp/iotest.hndl | cut -c8` - LINESCTL=`wc -l /tmp/iotest.hndl | cut -c8 ` - echo "WARNING!!! Disk I/O Exceeding 40% on --> \c" - - while [ $LINESCTL != 0 ] - do - - cat $TMPFILE | tail -$LINESCTL > $TMPTOO - cat $TMPTOO > $TMPFILE - LINESCTL=$(( $LINESCTL -1 )) - LINES=$(( $LINES -1 )) - DATA=`head -1 /tmp/iotest.hndl` - echo "( $DATA ) " - - - done - echo "\n" - - rm -f $TMPFILE - rm -f $TMPTOO - exit 1 - -else - - print "No Disk I/O Exceeding 40%...OK" - exit 0 - -fi diff --git a/contrib/aix/check_kerberos b/contrib/aix/check_kerberos deleted file mode 100644 index 443ab109..00000000 --- a/contrib/aix/check_kerberos +++ /dev/null @@ -1,49 +0,0 @@ -#! /bin/sh - -#========================================================================= -# Kerberos Ticket Checker -# -# This script is handy if you allow kerberos tickets to expire -# on your nodes. The script will simply warn you when a node has -# kerberos tickets expiring on the current date. This will allow to -# re-initialize the tickets if you wish to do so. -# -# Nothing fancy here, all Nagios will show is the number of tickets -# that are going to (or already have) expired. -# -# An item of note: -# -# We made no provisions for the weekend. If tickets expire on the -# weekend and nobody is around, you won't see a warning on the -# Nagios console because we look for expired on the current day -# only. It's a good idea to have this warning emailed to the -# appropriate admin and if there is something critical that relies -# on Kerberos, you might want to send a page. -# -# Authors: TheRocker -# SpEnTBoY -# -# Email: therocker@pawprints.2y.net -# lonny@abyss.za.org -#========================================================================= - -TMPFILE=/tmp/kerbtmp.hndl -DATE=`date +%b' '%d` - -rsh $1 -l root /usr/lpp/ssp/kerberos/bin/klist | tr -s ' ' | cut -d' ' -f4,5,6 | grep -e "$DATE" > $TMPFILE - - -if [ -s $TMPFILE ] -then - - LINES=`wc -l /tmp/kerbtmp.hndl | cut -c7-8` - echo "Kerberos Tickets set to expire --> \c" - echo "$LINES \c" - echo "\n" - - rm -f $TMPFILE - exit 1 - -fi - echo "Kerberos Tickets are valid" - exit 0 diff --git a/contrib/aix/check_queue b/contrib/aix/check_queue deleted file mode 100644 index 9f709c54..00000000 --- a/contrib/aix/check_queue +++ /dev/null @@ -1,67 +0,0 @@ -#! /bin/sh - -#=============================================================== -# Print Queue Checker -# -# The print queue checker simply looks for an occurance of a -# DOWN queue. A note of warning, if you use remote queues in -# AIX to redirect print jobs from the AIX queue to an NT print -# server that print through DLC rather than IP, it will be very -# s - l - o - w. But it will work. -# -# Author: TheRocker -# Email: therocker@pawprints.2y.net -#=============================================================== - -TMPFILE=/tmp/qtmp.hndl -TMPTOO=/tmp/qtwo.hndl - -#======================================================================= -# -# This script will also work on AIX 4.2.1 BUT you have to change -# the following line. AIX 4.2.1 does not support the -W option -# with lpstat. For AIX 4.2.1 just remove the -W option and it should -# work just fine. -# -#======================================================================= - -`rsh $1 -l root lpstat -W | grep -e "DOWN" | tr -s ' ' | cut -d' ' -f1,3 > /tmp/qtmp.hndl 2> /tmp/q_err` - -if [ -s $TMPFILE ] -then - -#======================================================= -# -# If you've seen the other AIX scripts I wrote you may -# notice that I use this bit of code a lot. Well it -# works and appears to be all purpose. -# -#======================================================= - - LINES=`wc -l /tmp/qtmp.hndl | cut -c8` - LINESCTL=`wc -l /tmp/qtmp.hndl | cut -c8` - - echo "Print Queue DOWN --> \c" - - while [ $LINESCTL != 0 ] - do - - cat $TMPFILE | tail -$LINESCTL > $TMPTOO - cat $TMPTOO > $TMPFILE - LINESCTL=$(( $LINESCTL -1 )) - LINES=$(( $LINES -1 )) - DATA=`head -1 /tmp/qtmp.hndl` - echo "( $DATA ) \c" - - - done - - echo "\n" - - rm -f $TMPFILE - rm -f $TMPTOO - exit 2 - -fi - echo "Print Queues Running... OK" - exit 0 diff --git a/contrib/aix/pg_stat b/contrib/aix/pg_stat deleted file mode 100644 index e0603ec4..00000000 --- a/contrib/aix/pg_stat +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/ksh - -#============================================================================== -# Script was originally created to collect stats and dump then to a log file -# every five minutes. But we like this better (the log file thing is still -# good if you want to track availability). -# -# Authors: SpEnTBoY -# TheRocker -# -# Email: lonny@abyss.za.org -# therocker@pawprints.2y.net -#============================================================================== - -#========================================================================================= -# -# The best way to do this is to use Kerberos but we use rsh here because our monitoring -# workstation doesn't have Kerberos installed. In order for this to work, the remote -# host ($1) must have a .rhosts file that contains a line like: -# -# monitorhost nagiosuser -# -#========================================================================================= - -PAGING2=`rsh $1 -l root lsps -a -s | grep -v Paging | tr -s ' '| cut -d' ' -f3 | cut -d'%' -f1` - - -if [ "$PAGING2" -gt "35" ] && [ "$PAGING2" -lt "50" ] -then - echo "Paging Space is over 35% ("$PAGING2")%" -exit 1 -fi - -if [ "$PAGING2" -gt "49" ] -then - echo "WARNING! Paging Space is over 50% ("$PAGING2")%" -exit 2 -fi - -if [ "$PAGING2" -lt "34" ] -then - echo "Paging Space is less than 34% ("$PAGING2")%" -exit 0 -fi - diff --git a/contrib/check_adptraid.sh b/contrib/check_adptraid.sh deleted file mode 100644 index e3c47bee..00000000 --- a/contrib/check_adptraid.sh +++ /dev/null @@ -1,75 +0,0 @@ -#! /bin/sh -# -# Modified check_sensors to check the alarm status of an Adaptec 3200S RAID -# controller. -# -# Scott Lambert -- lambert@lambertfam.org -# -# Tested on FreeBSD 4.7 with the adptfbsd_323.tgz package installed. This -# package installs all it's programs into /usr/dpt. -# - -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin - -PROGNAME=`basename $0` -PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` -REVISION=`echo '$Revision: 302 $' | sed -e 's/[^0-9.]//g'` - -. $PROGPATH/utils.sh - -RAIDUTIL_CMD="/usr/dpt/raidutil -A ?" - -print_usage() { - echo "Usage: $PROGNAME" -} - -print_help() { - print_revision $PROGNAME $REVISION - echo "" - print_usage - echo "" - echo "This plugin checks alarm status of Adaptec 3200S RAID controller." - echo "" - support - exit 0 -} - -case "$1" in - --help) - print_help - exit 0 - ;; - -h) - print_help - exit 0 - ;; - --version) - print_revision $PROGNAME $REVISION - exit 0 - ;; - -V) - print_revision $PROGNAME $REVISION - exit 0 - ;; - *) - raidutiloutput=`$RAIDUTIL_CMD 2>&1` - status=$? - if test "$1" = "-v" -o "$1" = "--verbose"; then - echo ${raidutiloutput} - fi - if test ${status} -eq 127; then - echo "RAIDUTIL UNKNOWN - command not found (did you install raidutil?)" - exit -1 - elif test ${status} -ne 0 ; then - echo "WARNING - raidutil returned state $status" - exit 1 - fi - if echo ${raidutiloutput} | egrep On > /dev/null; then - echo RAID CRITICAL - RAID alarm detected! - exit 2 - else - echo raid ok - exit 0 - fi - ;; -esac diff --git a/contrib/check_apache.pl b/contrib/check_apache.pl deleted file mode 100644 index b9e69a0c..00000000 --- a/contrib/check_apache.pl +++ /dev/null @@ -1,283 +0,0 @@ -#!/usr/bin/perl -# -# (c)2001 Sebastian Hetze, Linux Information Systems AG -# send bug reports to <S.Hetze@Linux-AG.com> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty -# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# you should have received a copy of the GNU General Public License -# along with this program (or with Nagios); if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA -# -# -# Check apache status information provided by mod_status to find -# out about the load (number of servers working) and the -# performance (average response time for recent requests). -# -# Usage: -# check_apache -H <host> [-lhV] [-w <warn>] [-c <crit>] [-u <url>] -# -# check_apache <host> <warn> <crit> <url> (if you cannot avoid it) -# - -use LWP::UserAgent; -use URI::URL; -use Getopt::Long; -Getopt::Long::Configure('bundling'); - -$version=0.01; - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - - -# -# some default values -# -$perf_w=500; -$perf_c=1000; -$load_w=20; -$load_c=30; -$TIMEOUT=15; - -# -# get command line options the regular way -# -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "l" => \$opt_l, "load" => \$opt_l, - "v" => \$verbose, "verbose" => \$verbose, - "w=s" => \$opt_w, "warning=s" => \$opt_w, - "c=s" => \$opt_c, "critical=s" => \$opt_c, - "H=s" => \$opt_H, "hostname=s" => \$opt_H, - "u=s" => \$opt_u, "url=s" => \$opt_u); - -# -# handle the verbose stuff first -# -if ($opt_V) { - print "\n"; - print "check_apache nagios plugin version $version\n"; - print "\n"; - print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n"; - print "copies of the plugins under the terms of the GNU General Public License.\n"; - print "For more information about these matters, see the file named COPYING.\n"; - print "\n"; - print "Copyright (c) 2001 Sebastian Hetze Linux Information Systems AG\n"; - print "\n"; - print "\n"; - exit $ERRORS{'UNKNOWN'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'UNKNOWN'}; -} - -# -# now get options the weired way and set the defaults -# if nothing else is provided -# -$opt_H = shift unless ($opt_H); -print_usage() unless ($opt_H); - -if($opt_l) { - $autostring="?auto"; - ($opt_w) || ($opt_w = shift) || ($opt_w = $load_w); - $warn = $1 if ($opt_w =~ /([0-9]+)/); - ($opt_c) || ($opt_c = shift) || ($opt_c = $load_c); - $alert = $1 if ($opt_c =~ /([0-9]+)/); -} else { - $autostring=""; - ($opt_w) || ($opt_w = shift) || ($opt_w = $perf_w); - $warn = $1 if ($opt_w =~ /([0-9]+)/); - ($opt_c) || ($opt_c = shift) || ($opt_c = $perf_c); - $alert = $1 if ($opt_c =~ /([0-9]+)/); -} - -($opt_u) || ($opt_u = shift) || ($opt_u = "/server-status"); - - -# -# dont let us wait forever... -# -$SIG{'ALRM'} = sub { - print ("ERROR: No response from HTTP server (alarm)\n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -# -# now we set things up for the real work -# and fire up the request -# -$ua = new LWP::UserAgent; -$ua->agent("Nagios/0.1 " . $ua->agent); - - -$urlstring = "http://" . $opt_H . $opt_u . $autostring; -$url = url($urlstring); - -my $req = new HTTP::Request 'GET', $url; -my $res = $ua->request($req); - -# -# hopefully we´ve got something usefull -# -if ($res->is_success) { - if($opt_l) { - foreach $_ (split /^/m, $res->content) { - next if /^\s*$/; -# -# this is the load checking section -# we parse the whole content, just in case someone -# wants to use this some day in the future -# - if (/^Total Accesses:\s+([0-9.]+)/) { $accesses = $1; next; } - if (/^Total kBytes:\s+([0-9.]+)/) { $kbytes = $1; next; } - if (/^CPULoad:\s+([0-9.]+)\s+/) { $load = $1; next; } - if (/^Uptime:\s+([0-9.]+)\s+/) { $uptime = $1; next; } - if (/^ReqPerSec:\s+([0-9.]+)\s+/) { $rps = $1; next; } - if (/^BytesPerSec:\s+([0-9.]+)\s+/) { $bps = $1; next; } - if (/^BytesPerReq:\s+([0-9.]+)\s+/) { $bpr = $1; next; } - if (/^BusyServers:\s+([0-9.]+)\s+/) { $busy = $1; next; } - if (/^IdleServers:\s+([0-9.]+)\s+/) { $idle = $1; next; } - if (/^Scoreboard:\s+([SRWKDLG_.]+)\s+/) { $score = $1; next; } - print "Unknown Status\n"; - exit $ERRORS{"UNKNOWN"}; - } -# -# now we even parse the whole scoreboard, just for fun -# - foreach $scorepoint (split //m, $score) { - if($scorepoint eq '.') { $scores{'.'}+=1; next; } # Unused - if($scorepoint eq '_') { $scores{'_'}+=1; next; } # Waiting - if($scorepoint eq 'S') { $scores{'S'}+=1; next; } # Starting - if($scorepoint eq 'R') { $scores{'R'}+=1; next; } # Reading - if($scorepoint eq 'W') { $scores{'W'}+=1; next; } # Writing - if($scorepoint eq 'K') { $scores{'K'}+=1; next; } # Keepalive - if($scorepoint eq 'D') { $scores{'D'}+=1; next; } # DNS Lookup - if($scorepoint eq 'L') { $scores{'L'}+=1; next; } # Logging - if($scorepoint eq 'G') { $scores{'G'}+=1; next; } # Going - } - - if($busy>$alert) { - printf "HTTPD CRITICAL: %.0f servers running\n", $busy; - exit $ERRORS{"CRITICAL"}; - } - if($busy>$warn) { - printf "HTTPD WARNING: %.0f servers running\n", $busy; - exit $ERRORS{"WARNING"}; - } - printf "HTTPD ok: %.0f servers running, %d idle\n", $busy, $idle; - exit $ERRORS{"OK"}; - - } else { -# -# this is the performance check section -# We are a bit lazy here, no parsing of the initial data -# block and the scoreboard. -# However, you have the whole set of per server -# information to play with ;-) -# The actual performance is measured by adding up the -# milliseconds required to process the most recent -# requests of all instances and then taking the average. -# - foreach $tablerow (split /<tr>/m, $res->content) { - ($empty,$Srv,$PID,$Acc,$M,$CPU,$SS,$Req,$Conn,$Child,$Slot,$Client,$VHost,$Request) - = split /<td>/, $tablerow; - if($Req) { - $lines+=1; - $req_sum+=$Req; - } - undef $Req; - } - $average=$req_sum/$lines; - if($average>$alert) { - printf "HTTPD CRITICAL: average response time %.0f - milliseconds\n", $average; - exit $ERRORS{"CRITICAL"}; - } - if($average>$warn) { - printf "HTTPD WARNING: average response time %.0f - milliseconds\n", $average; - exit $ERRORS{"WARNING"}; - } - if($average>0) { - printf "HTTPD ok: average response time %.0f milliseconds\n", - $average; - exit $ERRORS{"OK"}; - } - print "Unknown Status\n"; - exit $ERRORS{"UNKNOWN"}; - } -} else { - print "HTTP request failed\n"; - exit $ERRORS{"CRITICAL"}; -} - - -# -# ok, now we are almost through -# These last subroutines do the things for those that do not -# read source code. -# -sub print_usage () { - print "Usage: $0 -H <host> [-lhV] [-w <warn>] [-c <crit>] [-u <url>]\n"; } - -sub print_help () { - print "\n"; - print "\n"; - print "check_apache nagios plugin version $version\n"; - print "\n"; - print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n"; - print "copies of the plugins under the terms of the GNU General Public License.\n"; - print "For more information about these matters, see the file named COPYING.\n"; - print "\n"; - print "Copyright (c) 2001 Sebastian Hetze Linux Information Systems AG\n"; - print "\n"; - print "\n"; - print "This plugin checks the apache HTTP service on the specified host.\n"; - print "It uses the mod_status facilities provided by the apache server.\n"; - print "The monitoring server must be authorized in httpd.conf.\n"; - print "\n"; - print "\n"; - print_usage(); - print "\n"; - print "Options:\n"; - print " -H, --hostname=ADDRESS\n"; - print " host name argument for server.\n"; - print " -l, --load\n"; - print " check load instead of performance.\n"; - print " -h, --help\n"; - print " print detailed help screen.\n"; - print " -V, --version\n"; - print " print version information.\n"; - print " -w, --warning=INTEGER\n"; - print " load / performance level at which a warning message will be gererated.\n"; - print " -c, --critical=INTEGER\n"; - print " load / performance level at which a critical message will be gererated.\n"; - print " -u, --url=PATH\n"; - print " location to call mod_status.\n"; - print "\n"; - print " Defaults for performance checking are $perf_w/$perf_c msec.\n"; - print " Defaults for load checking are $load_w/$load_c servers running.\n"; - print "\n"; - print "\n"; -} -# -# the end -# diff --git a/contrib/check_apc_ups.pl b/contrib/check_apc_ups.pl deleted file mode 100644 index 6bf17662..00000000 --- a/contrib/check_apc_ups.pl +++ /dev/null @@ -1,307 +0,0 @@ -#! /usr/bin/perl -wT -# -# Check_apc_ups - Check APC UPS status via SNMP -# Shamelessly copied from check_breeze.pl -# -# To do: -# - Send SNMP queries directly, instead of forking `snmpget`. -# - Make the status less verbose. Maybe we can send an "onLine, time -# remaining: hh:mm:ss" if all is well, and a list of specific problems -# if something is broken. - -use strict; -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_H $opt_T $opt_t $opt_R $opt_r - $opt_L $opt_l $PROGNAME); -use lib "/usr/local/nagios/libexec"; -use utils qw(%ERRORS &print_revision &support &usage); - -sub print_help (); -sub print_usage (); -sub get_snmp_int_val ($); -sub escalate_exitval ($); - -$ENV{'PATH'}=''; -$ENV{'BASH_ENV'}=''; -$ENV{'ENV'}=''; - -Getopt::Long::Configure('bundling'); -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "T=s" => \$opt_T, "temp-critical" => \$opt_T, - "t=s" => \$opt_t, "temp-warning" => \$opt_t, - "R=s" => \$opt_R, "runtime-critical" => \$opt_R, - "r=s" => \$opt_r, "runtime-warning" => \$opt_r, - "L=s" => \$opt_L, "load-critical" => \$opt_L, - "l=s" => \$opt_l, "load-warning" => \$opt_l, - "H=s" => \$opt_H, "hostname=s" => \$opt_H); - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1771 $'); - exit $ERRORS{'OK'}; -} - -if ($opt_h) {print_help(); exit $ERRORS{'OK'};} - -($opt_H) || ($opt_H = shift) || usage("Host name/address not specified\n"); -my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); -($host) || usage("Invalid host: $opt_H\n"); - -# Defaults - -$opt_R *= 60 * 100 if (defined $opt_R); # Convert minutes to secs/100 -$opt_r *= 60 * 100 if (defined $opt_R); - -my $tempcrit = $opt_T || 60; -my $tempwarn = $opt_t || 40; -my $runtimecrit = $opt_R || 30 * 60 * 100; # Secs / 100 -my $runtimewarn = $opt_r || 60 * 60 * 100; -my $loadcrit = $opt_L || 85; -my $loadwarn = $opt_l || 50; - -if ($tempcrit !~ /\d+/) { usage ("Invalid critical temperature threshold.\n"); } -if ($tempwarn !~ /\d+/) { usage ("Invalid critical temperature threshold.\n"); } - -if ($runtimecrit !~ /\d+/) { - usage ("Invalid critical run time threshold.\n"); -} -if ($runtimewarn !~ /\d+/) { - usage ("Invalid warning run time threshold.\n"); -} - -if ($loadcrit !~ /\d+/ || $loadcrit < 0 || $loadcrit > 100) { - usage ("Invalid critical load threshold.\n"); -} -if ($loadwarn !~ /\d+/ || $loadwarn < 0 || $loadwarn > 100) { - usage ("Invalid warning load threshold.\n"); -} - - -# APC UPS OIDs -# APC MIBs are available at ftp://ftp.apcftp.com/software/pnetmib/mib -my $upsBasicOutputStatus = ".1.3.6.1.4.1.318.1.1.1.4.1.1.0"; -my $upsBasicBatteryStatus = ".1.3.6.1.4.1.318.1.1.1.2.1.1.0"; -my $upsAdvInputLineFailCause = ".1.3.6.1.4.1.318.1.1.1.3.2.5.0"; -my $upsAdvBatteryTemperature = ".1.3.6.1.4.1.318.1.1.1.2.2.2.0"; -my $upsAdvBatteryRunTimeRemaining = ".1.3.6.1.4.1.318.1.1.1.2.2.3.0"; -my $upsAdvBatteryReplaceIndicator = ".1.3.6.1.4.1.318.1.1.1.2.2.4.0"; -my $upsAdvOutputLoad = ".1.3.6.1.4.1.318.1.1.1.4.2.3.0"; -my $upsAdvTestDiagnosticsResults = ".1.3.6.1.4.1.318.1.1.1.7.2.3.0"; - -my @outputStatVals = ( - [ undef, undef ], # pad 0 - [ undef, undef ], # pad 1 - [ "onLine", $ERRORS{'OK'} ], # 2 - [ "onBattery", $ERRORS{'WARNING'} ], # 3 - [ "onSmartBoost", $ERRORS{'WARNING'} ], # 4 - [ "timedSleeping", $ERRORS{'WARNING'} ], # 5 - [ "softwareBypass", $ERRORS{'WARNING'} ], # 6 - [ "off", $ERRORS{'CRITICAL'} ], # 7 - [ "rebooting", $ERRORS{'WARNING'} ], # 8 - [ "switchedBypass", $ERRORS{'WARNING'} ], # 9 - [ "hardwareFailureBypass", $ERRORS{'CRITICAL'} ], # 10 - [ "sleepingUntilPowerReturn", $ERRORS{'CRITICAL'} ], # 11 - [ "onSmartTrim", $ERRORS{'WARNING'} ], # 12 -); - -my @failCauseVals = ( - undef, - "noTransfer", - "highLineVoltage", - "brownout", - "blackout", - "smallMomentarySag", - "deepMomentarySag", - "smallMomentarySpike", - "largeMomentarySpike", - "selfTest", - "rateOfVoltageChnage", -); - -my @battStatVals = ( - [ undef, undef ], # pad 0 - [ undef, undef ], # pad 1 - [ "batteryNormal", $ERRORS{'OK'} ], # 2 - [ "batteryLow", $ERRORS{'CRITICAL'} ], # 3 -); - -my @battReplVals = ( - [ undef, undef ], # pad 0 - [ "noBatteryNeedsReplacing", $ERRORS{'OK'} ], # 1 - [ "batteryNeedsReplacing", $ERRORS{'CRITICAL'} ], # 2 -); - -my @diagnosticsResultsVals = ( - [ undef, undef ], # pad 0 - [ "OK", $ERRORS{'OK'} ], # 1 - [ "failed", $ERRORS{'CRITICAL'} ], # 2 - [ "invalidTest", $ERRORS{'CRITICAL'} ], # 3 - [ "testInProgress", $ERRORS{'OK'} ], # 4 -); - -my $exitval = $ERRORS{'UNKNOWN'}; -my $data; -my $onbattery = 3; - -$data = get_snmp_int_val( $upsBasicOutputStatus ); - -print "Output status: "; -if (defined ($data) && defined ($outputStatVals[$data][0])) { - print "$outputStatVals[$data][0] | "; - escalate_exitval($outputStatVals[$data][1]); -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsAdvBatteryRunTimeRemaining ); - -print "Rem time: "; -if (defined ($data)) { - my $hrs = int($data / (60 * 60 * 100)); # Data is hundredths of a second - my $mins = int($data / (60 * 100)) % 60; - my $secs = ($data % 100) / 100; - printf "%d:%02d:%05.2f | ", $hrs, $mins, $secs; - if ($data <= $runtimecrit) { - escalate_exitval($ERRORS{'CRITICAL'}); - } elsif ($data <= $runtimewarn) { - escalate_exitval($ERRORS{'WARNING'}); - } else { - escalate_exitval($ERRORS{'OK'}); - } -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsBasicBatteryStatus ); - -print "Battery status: "; -if (defined ($data) && defined ($battStatVals[$data][0])) { - my $failcause = "unknown"; - my $fc = get_snmp_int_val( $upsAdvInputLineFailCause ); - if ($data == $onbattery) { - if (defined ($failCauseVals[$fc])) { $failcause = $failCauseVals[$fc]; } - print "$battStatVals[$data][0] ($failcause) | "; - } else { - print "$battStatVals[$data][0] | "; - } - escalate_exitval($battStatVals[$data][1]); -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsAdvBatteryTemperature ); - -print "Battery temp(C): "; -if (defined ($data)) { - print "$data | "; - if ($data >= $tempcrit) { - escalate_exitval($ERRORS{'CRITICAL'}); - } elsif ($data >= $tempwarn) { - escalate_exitval($ERRORS{'WARNING'}); - } else { - escalate_exitval($ERRORS{'OK'}); - } -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsAdvBatteryReplaceIndicator ); - -print "Battery repl: "; -if (defined ($data) && defined ($battReplVals[$data][0])) { - print "$battReplVals[$data][0] | "; - escalate_exitval($battReplVals[$data][1]); -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsAdvOutputLoad ); - -print "Output load (%): "; -if (defined ($data)) { - print "$data | "; - if ($data >= $loadcrit) { - escalate_exitval($ERRORS{'CRITICAL'}); - } elsif ($data >= $loadwarn) { - escalate_exitval($ERRORS{'WARNING'}); - } else { - escalate_exitval($ERRORS{'OK'}); - } -} else { - print "unknown | "; -} - -$data = get_snmp_int_val( $upsAdvTestDiagnosticsResults ); - -print "Diag result: "; -if (defined ($data) && defined ($diagnosticsResultsVals[$data][0])) { - print "$diagnosticsResultsVals[$data][0]\n"; - escalate_exitval($diagnosticsResultsVals[$data][1]); -} else { - print "unknown\n"; -} - - -exit $exitval; - - -sub print_usage () { - print "Usage: $PROGNAME -H <host> -T temp -t temp -R minutes -r minutes\n"; - print " -L percent -l percent\n"; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1771 $'); - print "Copyright (c) 2001 Gerald Combs/Jeffrey Blank/Karl DeBisschop - -This plugin reports the status of an APC UPS equipped with an SNMP management -module. - -"; - print_usage(); - print " --H, --hostname=HOST - Name or IP address of host to check --T --temp-critical - Battery degrees C above which a CRITICAL status will result (default: 60) --t --temp-warning - Battery degrees C above which a WARNING status will result (default: 40) --R --runtime-critical - Minutes remaining below which a CRITICAL status will result (default: 30) --r --runtime-warning - Minutes remaining below which a WARNING status will result (default: 60) --L --load-critical - Output load pct above which a CRITICAL status will result (default: 85 --l --load-warning - Output load pct above which a WARNING status will result (default: 50 - -"; - support(); -} - -sub get_snmp_int_val ($) { - my $val=0; - my $oid = shift(@_); - - $val = `/usr/bin/snmpget $host public $oid 2> /dev/null`; - my @test = split(/ /,$val,3); - - return undef unless (defined ($test[2])); - - if ($test[2] =~ /\(\d+\)/) { # Later versions of UCD SNMP - ($val) = ($test[2] =~ /\((\d+)\)/); - } elsif ($test[2] =~ /: \d+/) { - ($val) = ($test[2] =~ /: (\d+)/); - } else { - $val = $test[2]; - } - - return $val; -} - -sub escalate_exitval ($) { - my $newval = shift(@_); - - if ($newval > $exitval) { $exitval = $newval; } -} diff --git a/contrib/check_appletalk.pl b/contrib/check_appletalk.pl deleted file mode 100644 index 9277686c..00000000 --- a/contrib/check_appletalk.pl +++ /dev/null @@ -1,210 +0,0 @@ -#! /usr/bin/perl -wT -# -# check_atalk_ping plugin for nagios -# -# usage: -# check_atalk_ping atalkaddress -# -# Checks if an atalkhost responds to an atalk echo -# using "aecho" -# -# initial version: 23 October 2002 by Stefan Beck, IT Software Solutions -# current status: $Revision: 1771 $ -# -# Copyright Notice: GPL -# -BEGIN { - if ( $0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/ ) { - $runtimedir = $1; - $PROGNAME = $2; - } - delete $ENV{'LANG'}; -} - -use strict; -use lib "/usr/local/nagios/libexec"; - -use utils qw($TIMEOUT %ERRORS &print_revision &support); -use vars qw($PROGNAME); - -$PROGNAME = "check_atalk"; - -my ( - $verbose, $host, $warning_avg, $warning_loss, - $critical_avg, $critical_loss, $count, $cmd, - $avg, $loss, $line -); -my ( $opt_c, $opt_w, $opt_H, $opt_p ); -$opt_c = $opt_w = $opt_p = $opt_H = ''; - -sub print_help (); -sub print_usage (); -sub help (); -sub version (); - -# Just in case of problems, let's not hang NetSaint -$SIG{'ALRM'} = sub { - print "Plugin Timeout\n"; - exit 2; -}; -alarm($TIMEOUT); - -delete @ENV{ 'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV' }; - -use Getopt::Long; -Getopt::Long::Configure( 'bundling', 'no_ignore_case' ); -GetOptions( - "V|version" => \&version, - "h|help" => \&help, - "p|packets=i" => \$opt_p, - "c|critical=s" => \$opt_c, - "w|warning=s" => \$opt_w, - "H|hostname=s" => \$opt_H -); - - -# appletalk hostname ot address -$opt_H = shift unless ($opt_H); -unless ($opt_H) { print_usage (); exit $ERRORS{'UNKNOWN'}; } -if ( $opt_H && $opt_H =~ m/^([-a-zA-Z\.\:0-9]+)$/ ) { - $host = $1; -} -else { - print "$opt_H is not a valid host name\n"; - exit $ERRORS{'UNKNOWN'}; -} - -# number of packets -$opt_p = 5 unless $opt_p; -if ( $opt_p && $opt_p =~ m/^([1-9]+[0-9]*)$/ ) { - $count = $1; -} -else { - print "$opt_p is not a valid packet number\n"; - exit $ERRORS{'UNKNOWN'}; -} - -if ( $opt_w && $opt_w =~ m/^([1-9]+[0-9]*),([1-9][0-9]*)%$/ ) { - $warning_avg = $1; - $warning_loss = $2; -} -else { - print "$opt_w is not a valid threshold\n"; - exit $ERRORS{'UNKNOWN'}; -} - -if ( $opt_c && $opt_c =~ m/^([1-9]+[0-9]*),([1-9][0-9]*)%$/ ) { - $critical_avg = $1; - $critical_loss = $2; -} -else { - print "$opt_c is not a valid threshold\n"; - exit $ERRORS{'UNKNOWN'}; -} - -$cmd = "/usr/bin/aecho -c $count $host 2>&1 |"; -print "$cmd\n" if ($verbose); -open CMD, $cmd; - -while (<CMD>) { - print $_ if ($verbose); - $line = $_; - - # 5 packets sent, 5 packets received, 0% packet loss - # round-trip (ms) min/avg/max = 0/0/0 - - if (/received, ([0-9]+)% packet loss/) { - $loss = $1; - } - if (/min\/avg\/max = [0-9]+\/([0-9]+)\/[0-9]+/) { - $avg = $1; - } -} - -sub print_help() { - print_revision( $PROGNAME, '$Revision: 1771 $ ' ); - print "Copyright (c) 2002 Stefan Beck\n"; - print "\n"; - print "Check if an atalkhost responds to an atalk echo using\n"; - print " aecho -c <packets> <atalkhost>\n"; - print "\n"; - print_usage (); - print "\n"; - print "-H, --hostname=HOST\n"; - print " host to ping\n"; - print "-w, --warning=THRESHOLD\n"; - print " warning threshold pair\n"; - print "-c, --critical=THRESHOLD\n"; - print " critical threshold pair\n"; - print "-p, --packets=INTEGER\n"; - print " number of ICMP ECHO packets to send (Default: 5)\n"; - print "\n"; - print - "THRESHOLD is <rta>,<pl>% where <rta> is the round trip average -travel\n"; - print - "time (ms) which triggers a WARNING or CRITICAL state, and <pl> -is the\n"; - print "percentage of packet loss to trigger an alarm state.\n"; - print "\n"; - - support(); -} - -sub print_usage () { - print "$PROGNAME -H atalkhost -w <wrta>,<wpl>% -c <crta>,<cpl>%\n"; - print " [-p packets] [-t timeout] [-L]\n"; - print "$PROGNAME [-h | --help]\n"; - print "$PROGNAME [-V | --version]\n"; -} - -sub version () { - print_revision( $PROGNAME, '$Revision: 1771 $ ' ); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help (); - exit $ERRORS{'OK'}; -} - -my $state = "OK"; -my $answer = undef; - -if ( defined $loss && defined $avg ) { - if ( $loss >= $critical_loss ) { - $state = "CRITICAL"; - } - elsif ( $avg >= $critical_avg ) { - $state = "CRITICAL"; - } - elsif ( $loss >= $warning_loss ) { - $state = "WARNING"; - } - elsif ( $avg >= $warning_avg ) { - $state = "WARNING"; - } - else { - $state = "OK"; - } - $answer = "Appletalk PING $state - Packet loss = $loss%, RTA = $avg -ms\n"; -} -else { - $state = "UNKNOWN"; - $answer = "UNKNOWN - $line"; -} -print $answer; -exit $ERRORS{$state}; - - - - -------------------------------------------------------- -This sf.net email is sponsored by:ThinkGeek -Welcome to geek heaven. -http://thinkgeek.com/sf -_______________________________________________ -Nagios-devel mailing list -Nagios-devel@lists.sourceforge.net -https://lists.sourceforge.net/lists/listinfo/nagios-devel diff --git a/contrib/check_arping.pl b/contrib/check_arping.pl deleted file mode 100644 index c41c4a8a..00000000 --- a/contrib/check_arping.pl +++ /dev/null @@ -1,120 +0,0 @@ -#! /usr/bin/perl -w -# -# check_arping.pl - Nagios plugin to check host status via ARP ping -# -# usage: -# check_arping -H hostname -I interface -T timeout -# -# -# Copyright (C) 2003 Kenny Root -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# -# Report bugs to: kenny@the-b.org, nagiosplug-help@lists.sf.net - -use POSIX; -use strict; -use lib "/usr/lib/nagios/plugins" ; -use utils qw($TIMEOUT %ERRORS &print_revision &support); - -use Net::Arping; -use Getopt::Long; - -my $PROGNAME = "check_arping"; - -my($status, $state, $answer); -my($opt_V, $opt_h, $opt_t, $opt_I, $opt_H); - - -#Option checking -$status = GetOptions( - "V|version" => \$opt_V, - "help" => \$opt_h, - "I|interface=s" => \$opt_I, - "H|host=s" => \$opt_H, - "t|timeout=i" => \$opt_t); - -if ($status == 0) -{ - print_help() ; - exit $ERRORS{'OK'}; -} - - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1112 $ '); - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -if ($opt_t) { - if ($opt_t ne int($opt_t)) { - print "Timeout not in seconds!\n"; - print_help(); - exit $ERRORS{'OK'}; - } - $opt_t = int($opt_t); -} else { - $opt_t = 3; -} - -if (! utils::is_hostname($opt_H)){ - usage(); - exit $ERRORS{"UNKNOWN"}; -} - -my $ping = Net::Arping->new(); - -my $reply = $ping->arping(Host => $opt_H, Interface => $opt_I, Timeout => $opt_t); - -if ($reply eq "0") { - $state = "CRITICAL"; - print "$state: no reply from $opt_H on interface $opt_I in $opt_t seconds.\n"; - exit $ERRORS{$state}; -} else { - $state = "OK"; - $answer = "replied with MAC address $reply"; -} - -print "ARPING $state - $answer\n"; -exit $ERRORS{$state}; - - -sub usage { - print "\nMissing arguments!\n"; - print "\n"; - print "check_arping -I <interface> -H <host IP> [-t <timeout>]\n"; - print "\n\n"; - support(); - exit $ERRORS{"UNKNOWN"}; -} - -sub print_help { - print "check_arping pings hosts that normally wouldn't allow\n"; - print "ICMP packets but are still on the local network.\n"; - print "\nUsage:\n"; - print " -H (--host) IP to query - (required)\n"; - print " -I (--interface) Interface to use.\n"; - print " -t (--timeout) Timeout in seconds.\n"; - print " -V (--version) Plugin version\n"; - print " -h (--help) usage help \n\n"; - print_revision($PROGNAME, '$Revision: 1112 $'); - -} diff --git a/contrib/check_asterisk.pl b/contrib/check_asterisk.pl deleted file mode 100644 index 179d3671..00000000 --- a/contrib/check_asterisk.pl +++ /dev/null @@ -1,259 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use IO::Socket; -use Getopt::Long; -$|=1; - -my ( - $host, $username, $password, $verbose, $help, $command, $mode, - $ipaddr, $respaddr, $sendto, $msg, $recvfrom, - $version, $response, $message, $line, - $sock, $port, $reply, - $warning, $critical, - %warnval, %critval, - %channels, - $runmode, - $key, - $s, -); -my $stop = 0; -my $mgr_port = 5038; -my $iax_port = 4569; -my $exitcode = 0; -my $cause = ""; - -my $iax_answer = 0; -my $iax_maxlen = 1024; -my $iax_timeout = 5; -my $iax_src_call = "8000"; #8000 most siginificant bit is IAX packet type full ... required for a poke etc... -my $iax_dst_call = "0000"; -my $iax_timestamp = "00000000"; -my $iax_outbound_seq = "00"; -my $iax_inbound_seq = "00"; -my $iax_type = "06"; #IAX_Control - -sub ok { - $s = shift; - $s =~ s/[\r\n]//g; - print "OK: $s\n"; - exit(0); -} - -sub warning { - $s = shift; - $s =~ s/[\r\n]//g; - print "WARNING: $s\n"; - exit(1); -} - -sub error { - $s = shift; - $s =~ s/[\r\n]//g; - print "ERROR: $s\n"; - exit(2); -} - -sub unknown { - $s = shift; - $s =~ s/[\r\n]//g; - print "UNKNOWN: $s\n"; - exit(3); -} - -sub syntax { - $s = shift; - unless ($s =~ m/Help:/) { - $s = "Error: (".$s.")" or $s = 'Unknown'; - } - print "$s\n" unless ($help); - print "Syntax: $0 -m mgr -h <host> -u <username> -p <password> [-cwv]\n"; - print "Syntax: $0 -m iax -h <host> [-v]\n"; - print "* --host -h Host\n"; - print "* --mode -m Mode - eithr 'mgr' or 'iax'\n"; - print " --username -u Username\n"; - print " --password -p Password\n"; - print " --port -P n Port (if not using $mgr_port for manager or $iax_port for IAX)\n"; - print " --warning xxx=n Return warning if > n channels of type xxx.\n"; - print " --critical xxx=n Return critical if > n channels of type xxx.\n"; - print " --verbose -v Verbose\n"; - print " --help -h This help\n"; - exit(3); -} - -Getopt::Long::Configure('bundling'); -GetOptions - ("p=s" => \$password, "password=s" => \$password, - "u=s" => \$username, "username=s" => \$username, - "h=s" => \$host, "host=s" => \$host, - "P=i" => \$port, "port=i" => \$port, - "H" => \$help, "help" => \$help, - "v" => \$verbose, "verbose" => \$verbose, - "m=s" => \$mode, "mode=s" => \$mode, - "critical=s" => \$critical, "warning=s" => \$warning); - -syntax("Help:") if ($help); -syntax("Missing host") unless (defined($host)); -syntax("Missing mode") unless (defined($mode)); -if ($mode =~ /^iax$/i) { - print "Running in IAX mode\n" if ($verbose); - $runmode = 1; -} elsif ($mode =~ /^mgr$/i) { - print "Running in Manager mode\n" if ($verbose); - $runmode = 2; -} else { - syntax("Unknown mode $mode") -} - -############################################################################## - -if ($runmode == 2) { - $port = $mgr_port; - syntax("Missing username") unless (defined($username)); - syntax("Missing password") unless (defined($password)); - if (defined($warning)) { - foreach $s (split(/,/, $warning)) { - syntax("Warning value given, $s, is invalid") - unless ($s =~ /^(\w+)=(\d+)$/); - $warnval{$1} = $2; - print "Clear to give WARNING after $2 connections on $1\n" if ($verbose); - } - } - if (defined($critical)) { - foreach $s (split(/,/, $critical)) { - syntax("Critical value given, $s, is invalid") - unless ($s =~ /^(\w+)=(\d+)$/); - $critval{$1} = $2; - print "Clear to give CRITICAL after $2 connections on $1\n" if ($verbose); - } - } - - print "Connecting to $host:$port\n" if ($verbose); - unless ($sock = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port, Proto => 'tcp')) { - print("Could not connect to asterisk server ".$host.":".$port."\n"); - exit(2); - } - print "Connected to $host:$port\n" if ($verbose); - $version = <$sock>; - print $version if ($verbose); - - print $sock "Action: Login\r\nUsername: $username\r\nSecret: $password\r\nEvents: off\r\n\r\n"; - print "Action: Login\r\nUsername: $username\r\nSecret: $password\r\n\r\n" if ($verbose); - $response = <$sock>; - $message = <$sock>; - $s = <$sock>; - print $response.$message if ($verbose); - print $s if ($verbose); - - exit(1) unless ($response =~ m/^Response:\s+(.*)$/i); - exit(1) unless ($1 =~ m/Success/i); - - print $sock "Action: Status\r\n\r\n"; - print "Action: Status\r\n\r\n" if ($verbose); - - $response = <$sock>; - $message = <$sock>; - print $response.$message if ($verbose); - - &unknown("Unknown answer $response (wanted Response: something)") unless ($response =~ m/^Response:\s+(.*)$/i); - &unknown("$response didn't say Success") unless ($1 =~ m/Success/i); - &unknown("Unknown answer $response (wanted Message: something)") unless ($message =~ m/^Message:\s+(.*)$/i); - &unknown("didn't understand message $message") unless ($1 =~ m/Channel status will follow/i); - - $stop=0; - while (($stop == 0) && ($line = <$sock>)) { - print "$line" if ($verbose); - if ($line =~ m/Channel:\s+(\w+)\//) { - $channels{$1}++; - print "Found $1 channel\n" if ($verbose); - } - if ($line =~ m/Event:\s*StatusComplete/i) { - $stop++; - } - } - -# Log out - print $sock "Action: Logoff\r\n\r\n"; - - undef($s); - foreach $key (keys %channels) { - $s .= " " . $key . " (" . $channels{$key} . ")"; - } - - foreach $key (keys %critval) { - print "key = $key\n" if ($verbose); - if (defined($channels{$key}) && ($channels{$key} > $critval{$key})) { - $exitcode = 2; - $cause .= $channels{$key} . " $key channels detected. "; - } - } - - if ($exitcode < 2) { - foreach $key (keys %warnval) { - print "key = $key\n" if ($verbose); - if (defined($channels{$key}) && ($channels{$key} > $warnval{$key})) { - $exitcode = 1; - $cause .= $channels{$key} . " $key channels detected. "; - } - } - } - - if ($exitcode == 0) { - print "OK "; - } elsif ($exitcode == 1) { - print "WARNING "; - } elsif ($exitcode == 2) { - print "CRITICAL "; - } elsif ($exitcode > 2) { - print "UNKNOWN "; - } - if (defined($s)) { - $cause .= " Channels:$s"; - } else { - $cause .= " (idle)"; - } - - print $cause; - - print "\n" if ($verbose); - - exit($exitcode); -} elsif ($runmode == 1) { - $port = $iax_port; - - socket(PING, PF_INET, SOCK_DGRAM, getprotobyname("udp")); - - $msg = pack "H24", $iax_src_call . $iax_dst_call . $iax_timestamp . - $iax_outbound_seq . $iax_inbound_seq . $iax_type . $iax_type; - - $ipaddr = inet_aton($host); - $sendto = sockaddr_in($port,$ipaddr); - - send(PING, $msg, 0, $sendto) == length($msg) or die "cannot send to $host : $port : $!\n"; - - eval { - local $SIG{ALRM} = sub { die("alarm time out"); }; - alarm $iax_timeout; - - while (1) { - $recvfrom = recv(PING, $msg, $iax_maxlen, 0) or die "recv: $!"; - ($port, $ipaddr) = sockaddr_in($recvfrom); - $respaddr = inet_ntoa($ipaddr); - $iax_answer++; - # print "Response from $respaddr : $port\n"; - } - - }; - - if ($iax_answer) { - if ($iax_answer == 1) { - $reply = "reply"; - } else { - $reply = "replies"; - } - &ok("Got $iax_answer $reply"); - } else { - &error("Got no reply"); - } -} - diff --git a/contrib/check_axis.sh b/contrib/check_axis.sh deleted file mode 100644 index 231d9da4..00000000 --- a/contrib/check_axis.sh +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/sh - -box=$1 -port=$2 -usr=$3 -pass=$4 - -if [ ! "$#" == "4" ]; then - echo -e "\nYou did not supply enough command line arguments. \nUsage: ./check_axis.sh <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" -fi - -tempfile=/tmp/status-$box.tmp -exit="3" - -ftp -in $box &>/dev/null <<EOF -user $usr $pass -passive -prompt off -lcd /tmp -ascii -get status $tempfile -EOF - -if [ ! -e "$tempfile" ]; then - stdio="Status file could not be transferred from the Axis box." && rm -f $tempfile && echo $stdio && exit 2; -fi - -lines=`cat $tempfile | grep -i $port` -status=`echo $lines | awk '{ print $3 }'` -if [ "$status" == "Printing" ]; then - bytes=`echo $lines | awk '{ print $4 }'`; - comments=`echo $lines | tr -d " -" | awk '{ print $5 " " $6 }'`; -else - comments=`echo $lines | tr -d " -" | awk '{ print $4 " " $5 }'`; -fi - -comma=`echo $comments | grep , | wc -l` -if [ "$comma" -eq "1" ]; then - comments=`echo $comments | cut -d, -f1` -fi - - -if [ "$status" == "Available" ]; then - if [ "$comments" == "Paper out" ]; then - exit="1" && stdio="WARNING - Out of paper."; - elif [ "$comments" == " " ]; then - exit="0" && stdio="OK - Printer is available but returns no comments."; - elif [ "$comments" == "No error" ]; then - exit="0" && stdio="OK - No error."; - elif [ "$comments" == "Ready " ]; then - exit="0" && stdio="OK - Ready."; - elif [ "$comments" == "Off line" ]; then - exit="1" && stdio="WARNING - Printer is off line."; - elif [ "$comments" == "Out of" ]; then - exit="1" && stdio="WARNING - Out of paper."; - elif [ "$comments" == "Busy Out" ]; then - exit="1" && stdio="WARNING - Busy, out of paper."; - elif [ "$comments" == "Printer off-line" ]; then - exit="1" && stdio="WARNING - Printer is off line."; - elif [ "$comments" == "Printer fault" ]; then - exit="2" && stdio="CRITICAL - Printer fault."; - else - exit="3" && stdio="Comments: $comments"; - fi -elif [ "$status" == "Printing" ]; then - if [ "$comments" == "Printer busy" ]; then - exit="0" && stdio="OK - PRINTING. Bytes printed: $bytes."; - elif [ "$comments" == "No error" ]; then - exit="0" && stdio="OK - PRINTING. Bytes printed: $bytes."; - elif [ "$comments" == "Paper out" ]; then - exit="1" && stdio="WARNING - PRINTING. Out of paper."; - elif [ "$comments" == "Out of" ]; then - exit="1" && stdio="WARNING - PRINTING. Out of paper. Bytes printed: $bytes."; - elif [ "$comments" == "Busy Out" ]; then - exit="1" && stdio="WARNING - Busy, out of paper."; - elif [ "$comments" == "Ready " ]; then - exit="0" && stdio="OK - PRINTING. Bytes printed: $bytes."; - elif [ "$comments" == "Printer off-line" ]; then - exit="1" && stdio="WARNING - PRINTING. Printer is off line."; - elif [ "$comments" == "Busy " ]; then - exit="0" && stdio="OK - PRINTING. Busy. Bytes printed: $bytes."; - elif [ "$comments" == "Off line" ]; then - exit="1" && stdio="WARNING - PRINTING. Printer is off line."; - elif [ "$comments" == "Printer fault" ]; then - exit="2" && stdio="CRITICAL - PRINTING. Printer fault. Bytes printed: $bytes."; - else - exit="3" && stdio="Comments: $comments."; - fi -fi - -rm -f $tempfile -echo $stdio -exit $exit diff --git a/contrib/check_backup.pl b/contrib/check_backup.pl deleted file mode 100644 index 703d2424..00000000 --- a/contrib/check_backup.pl +++ /dev/null @@ -1,114 +0,0 @@ -#! /usr/bin/perl -wT - -# (c)2001 Patrick Greenwell, Stealthgeeks, LLC. (patrick@stealthgeeks.net) -# Licensed under the GNU GPL -# http://www.gnu.org/licenses/gpl.html - -# check_backup: Checks a directory to see if at least one file was -# created within a specified period of time that is of equal to or greater -# than a given size. - -# Version 1.0 -# Last Updated: 9/12/01 - - -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} - -require 5.004; -use strict; -use Getopt::Long; -use vars qw($opt_H $opt_d $opt_s $opt_t $verbose $PROGNAME); -use lib $main::runtimedir; -use utils qw($TIMEOUT %ERRORS &print_revision &usage &support &is_error); - -sub help (); -sub print_help (); -sub print_usage (); -sub version (); -sub display_res($$); -my ($filesize, $answer) = (); -my $state = $ERRORS{'UNKNOWN'}; - -# Directory to check. -my $dir = "/backup/"; - -# Time period(in seconds) -my $within = "3600"; - -# Minimum size of file (in bytes) -my $minsize = "40000000"; - -delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; - -Getopt::Long::Configure('bundling', 'no_ignore_case'); -GetOptions - ("V|version" => \&version, - "h|help" => \&help, - "v|verbose" => \$verbose, - "d|directory=s" => \$opt_d, - "s|minsize=s" => \$opt_s, - "t|timeout=s" => \$opt_t, - ); - -($opt_s) || ($opt_s = shift) || usage("Minimum File size not specified\n"); -usage("File size must be numeric value") unless ($opt_s =~ m/^[0-9]+$/); - -(($opt_t) && ($TIMEOUT = $opt_t)) || ($TIMEOUT = 120); -usage("TIMEOUT must be numeric value") unless ($TIMEOUT =~ m/^[0-9]+$/); - -# Don't hang if there are timeout issues -$SIG{'ALRM'} = sub { - print ("ERROR: No response from ftp server (alarm)\n"); - exit $ERRORS{'UNKNOWN'}; -}; -alarm($TIMEOUT); - -# Do stuff - -my $time = time; - -opendir(THISDIR, "$dir") or die "Can't open directory! $!"; -my @allfiles = grep !/^\./, readdir THISDIR; -closedir THISDIR; -while (my $file = $dir . pop @allfiles){ - my ($size, $mtime) = (stat($file))[7,9]; - if (((my $a = ($time - $mtime)) <= $within) and ($size >= $opt_s)){ - display_res("OK: File $file is <= $within and >=$opt_s bytes.\n","OK"); - } -} - -# If we got here nothing matched.... -display_res("CRITICAL: No files in $dir are <= $within and >= $minsize.", "CRITICAL"); - -exit; - -sub print_usage () { - print "Usage: $PROGNAME -s <minimum file size in bytes> -t <timeout> \n"; -} - -sub print_help () { - print_revision($PROGNAME,'$ Revision: 1.0 $ '); - print_usage(); - support(); -} - -sub version () { - print_revision($PROGNAME,'$ Revision: 1.0 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - -sub display_res ($$) { - my ($answer, $state) = @_; - print $answer; - exit $ERRORS{$state}; -} diff --git a/contrib/check_bgpstate.pl b/contrib/check_bgpstate.pl deleted file mode 100644 index 645d7505..00000000 --- a/contrib/check_bgpstate.pl +++ /dev/null @@ -1,215 +0,0 @@ -#!/usr/bin/perl -w -# -# check_bgpstate.pl - nagios plugin -# -# Copyright (C) 2000 Christoph Kron -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# -# Report bugs to: ck@zet.net -# -# 11.01.2000 Version 1.0 - - - -use strict; - -use Net::SNMP; -use Getopt::Long; -&Getopt::Long::config('auto_abbrev'); - - -# whois programm for RIPE database queries -my $whois = '/usr/bin/whois'; -my $status; -my $TIMEOUT = 30; - -# critical bgp sessions -my %uplinks = ( 1273, 'Uplink ECRC', - 1755, 'Uplink EBONE', - 3300, 'Uplink AUCS' - ); - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - - -my %bgpPeerState = ( - '1',"idle", - '2',"connect", - '3',"active", - '4',"opensent", - '5',"openconfirm", - '6',"established" - ); -my $state = "UNKNOWN"; -my $answer = ""; -my $snmpkey; -my $snmpoid; -my $key; -my $community = "public"; -my $port = 161; -my @snmpoids; -my $snmpbgpPeerState = '1.3.6.1.2.1.15.3.1.2'; -my $snmpbgpPeerLocalAddr = '1.3.6.1.2.1.15.3.1.5'; -my $snmpbgpPeerRemoteAddr = '1.3.6.1.2.1.15.3.1.7'; -my $snmpbgpPeerRemoteAs = '1.3.6.1.2.1.15.3.1.9'; -my $hostname; -my $session; -my $error; -my $response; -my %bgpStatus; -my $bgpestablished =0 ; -my $bgpcritical =0; -my $bgpdown =0; -my $bgpidle =0; -my $bgpmessage; -my $asname; -my $remoteas; -my @output; - -sub usage { - printf "\nMissing arguments!\n"; - printf "\n"; - printf "Perl bgpstate plugin for Nagios\n"; - printf "monitors all BGP sessions\n"; - printf "usage: \n"; - printf "check_bgpstate.pl -c <READCOMMUNITY> -p <PORT> <HOSTNAME>\n"; - printf "Copyright (C) 2000 Christoph Kron\n"; - printf "check_bgpstate.pl comes with ABSOLUTELY NO WARRANTY\n"; - printf "This programm is licensed under the terms of the "; - printf "GNU General Public License\n(check source code for details)\n"; - printf "\n\n"; - exit $ERRORS{"UNKNOWN"}; -} - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print ("ERROR: No snmp response from $hostname (alarm)\n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -$status = GetOptions("community=s",\$community, - "port=i",\$port); -if ($status == 0) -{ - &usage; -} - - #shift; - $hostname = shift || &usage; - - -push(@snmpoids, $snmpbgpPeerState); -push(@snmpoids, $snmpbgpPeerLocalAddr); -push(@snmpoids, $snmpbgpPeerRemoteAddr); -push(@snmpoids, $snmpbgpPeerRemoteAs); - -foreach $snmpoid (@snmpoids) { - - ($session, $error) = Net::SNMP->session( - -hostname => $hostname, - -community => $community, - -port => $port - ); - - if (!defined($session)) { - $state='UNKNOWN'; - $answer=$error; - print ("$state: $answer"); - exit $ERRORS{$state}; - } - - if (!defined($response = $session->get_table($snmpoid))) { - $answer=$session->error; - $session->close; - $state = 'CRITICAL'; - print ("$state: $answer,$snmpkey"); - exit $ERRORS{$state}; - } - - foreach $snmpkey (keys %{$response}) { - $snmpkey =~ m/.*\.(\d+\.\d+\.\d+\.\d+$)/; - $key = $1; -# printf "debug: $snmpkey: $key -> $response->{$snmpkey}\n"; - $bgpStatus{$key}{$snmpoid} = $response->{$snmpkey}; - } - $session->close; -} - -foreach $key (keys %bgpStatus) { - if ($bgpStatus{$key}{$snmpbgpPeerState} == 6 ) { - $bgpestablished++; - } - elsif ($bgpStatus{$key}{$snmpbgpPeerState} == 1 ) { - $bgpidle++; - } - else { - $bgpdown++ ; - if (exists($uplinks{$bgpStatus{$key}{$snmpbgpPeerRemoteAs}}) ) { - $bgpcritical++; - } - @output = `$whois -T aut-num AS$bgpStatus{$key}{$snmpbgpPeerRemoteAs}`; - - $asname = ""; - foreach (@output) { - if (m/as-name/) { - $asname = $_; - $asname =~ s/as-name://; - last; - } - if ( $asname =~ "" && m/descr/ ) { - $asname = $_; - $asname =~ s/descr://; - } - } - $asname =~ s/^\s*//; - $asname =~ s/\s*$//; - $bgpmessage .= sprintf("Peering with AS%s not established -> %s<BR>", - $bgpStatus{$key}{$snmpbgpPeerRemoteAs}, - $asname); - } -} - - - if ($bgpdown > 0) { - if ($bgpcritical > 0) { - $state = 'CRITICAL'; - } - else { - $state = 'WARNING'; - } - $answer = sprintf("host '%s', sessions up: %d, down: %d, shutdown: %d<BR>", - $hostname, - $bgpestablished, - $bgpdown, $bgpidle); - $answer = $answer . $bgpmessage . "\n"; - } - else { - $state = 'OK'; - $answer = sprintf("host '%s', sessions up: %d, down: %d, shutdown: %d\n", - $hostname, - $bgpestablished, - $bgpdown,$bgpidle); - } - -print ("$state: $answer"); -exit $ERRORS{$state}; - diff --git a/contrib/check_breeze.pl b/contrib/check_breeze.pl deleted file mode 100644 index bb837657..00000000 --- a/contrib/check_breeze.pl +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/perl - -# Plugin to test signal strength on Breezecom wireless equipment -# Contributed by Jeffrey Blank - -$Host=$ARGV[0]; -$sig_crit=$ARGV[1]; -$sig_warn=$ARGV[2]; -$sig=0; -$sig = `snmpget $Host public .1.3.6.1.4.1.710.3.2.3.1.3.0`; -@test=split(/ /,$sig); -$sig=@test[2]; -$sig=int($sig); -if ($sig>100){$sig=100} - -print "Signal Strength at: $sig%\n"; -if ($sig<$sig_crit) - {exit(2)} -if ($sig<$sig_warn) - {exit(1)} - -exit(0); diff --git a/contrib/check_cluster.c b/contrib/check_cluster.c deleted file mode 100644 index 06519e61..00000000 --- a/contrib/check_cluster.c +++ /dev/null @@ -1,332 +0,0 @@ -/***************************************************************************** - * - * CHECK_CLUSTER.C - Host and Service Cluster Plugin for NetSaint - * - * Copyright (c) 2000 Ethan Galstad (netsaint@netsaint.org) - * License: GPL - * Last Modified: 07-08-2000 - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - - -#include <stdio.h> -#include <stdlib.h> - -#define OK 0 -#define ERROR -1 - -#define TRUE 1 -#define FALSE 0 - -#define CHECK_SERVICES 1 -#define CHECK_HOSTS 2 - -#define MAX_INPUT_BUFFER 1024 - -#define STATE_OK 0 -#define STATE_WARNING 1 -#define STATE_CRITICAL 2 -#define STATE_UNKNOWN 3 - -typedef struct clustermember_struct{ - char *host_name; - char *svc_description; - struct clustermember_struct *next; - }clustermember; - - -int check_cluster_status(void); -int add_clustermember(char *,char *); -void free_memory(void); - -clustermember *clustermember_list=NULL; - -int total_services_ok=0; -int total_services_warning=0; -int total_services_unknown=0; -int total_services_critical=0; - -int total_hosts_up=0; -int total_hosts_down=0; -int total_hosts_unreachable=0; - -char status_log[MAX_INPUT_BUFFER]=""; -int warning_threshold=0; -int critical_threshold=0; - -int check_type=CHECK_SERVICES; - - -int main(int argc, char **argv){ - char input_buffer[MAX_INPUT_BUFFER]; - char *host_name; - char *svc_description; - int return_code=STATE_OK; - int error=FALSE; - - if(argc!=5){ - - printf("Invalid arguments supplied\n"); - printf("\n"); - - printf("Host/Service Cluster Plugin for NetSaint\n"); - printf("Copyright (c) 2000 Ethan Galstad (netsaint@netsaint.org)\n"); - printf("Last Modified: 07-08-2000\n"); - printf("License: GPL\n"); - printf("\n"); - printf("Usage: %s <--service | --host> <status_log> <warn_threshold> <crit_threshold>\n",argv[0]); - printf("\n"); - printf("Options:\n"); - printf(" --service = Check service cluster status\n"); - printf(" --host = Check host cluster status\n"); - printf(" <status_log> = This is the location of the NetSaint status log\n"); - printf(" <warn_threshold> = This is the number of hosts or services in\n"); - printf(" the cluster that must be in a non-OK state\n"); - printf(" in order to result in a warning status level\n"); - printf(" <crit_threshold> = This is the number of hosts or services in\n"); - printf(" the cluster that must be in a non-OK state\n"); - printf(" in order to result in a critical status level\n"); - printf("\n"); - printf("Notes:\n"); - printf("Members of the host or service cluster are read from STDIN.\n"); - printf("One host or service can be specified per line, services must\n"); - printf("be in the format of <host_name>;<svc_description>\n"); - printf("\n"); - - return STATE_UNKNOWN; - } - - /* see if we're checking a host or service clust */ - if(!strcmp(argv[1],"--host")) - check_type=CHECK_HOSTS; - else - check_type=CHECK_SERVICES; - - /* get the status log */ - strncpy(status_log,argv[2],sizeof(status_log)-1); - status_log[sizeof(status_log)-1]='\x0'; - - /* get the warning and critical thresholds */ - warning_threshold=atoi(argv[3]); - critical_threshold=atoi(argv[4]); - - - /* read all data from STDIN until there isn't anymore */ - while(fgets(input_buffer,sizeof(input_buffer)-1,stdin)){ - - if(feof(stdin)) - break; - - /*strip(input_buffer);*/ - - if(!strcmp(input_buffer,"")) - continue; - - if(!strcmp(input_buffer,"\n")) - continue; - - /* get the host name */ - if(check_type==CHECK_SERVICES) - host_name=(char *)strtok(input_buffer,";"); - else - host_name=(char *)strtok(input_buffer,"\n"); - if(host_name==NULL || !strcmp(host_name,"")){ - printf("Error: Host name is NULL!\n"); - continue; - } - - if(check_type==CHECK_SERVICES){ - - /* get the service description */ - svc_description=(char *)strtok(NULL,"\n"); - if(svc_description==NULL || !strcmp(svc_description,"")){ - printf("Error: Service description is NULL!\n"); - continue; - } - } - - /* add the cluster member to the list in memory */ - if(add_clustermember(host_name,svc_description)!=OK) - printf("Error: Could not add cluster member\n"); -#ifdef DEBUG - else - printf("Added cluster member\n"); -#endif - } - - - /* check the status of the cluster */ - if(check_cluster_status()==OK){ - - if(check_type==CHECK_SERVICES){ - if((total_services_warning+total_services_unknown+total_services_critical) >= critical_threshold) - return_code=STATE_CRITICAL; - else if((total_services_warning+total_services_unknown+total_services_critical) >= warning_threshold) - return_code=STATE_WARNING; - else - return_code=STATE_OK; - - printf("Service cluster %s: %d ok, %d warning, %d unknown, %d critical\n",(return_code==STATE_OK)?"ok":"problem",total_services_ok,total_services_warning,total_services_unknown,total_services_critical); - } - else{ - if((total_hosts_down+total_hosts_unreachable) >= critical_threshold) - return_code=STATE_CRITICAL; - else if((total_hosts_down+total_hosts_unreachable) >= warning_threshold) - return_code=STATE_WARNING; - else - return_code=STATE_OK; - - printf("Host cluster %s: %d up, %d down, %d unreachable\n",(return_code==STATE_OK)?"ok":"problem",total_hosts_up,total_hosts_down,total_hosts_unreachable); - } - } - else - return_code=STATE_UNKNOWN; - - free_memory(); - - return return_code; - } - - - -int add_clustermember(char *hst,char *svc){ - clustermember *new_clustermember; - - new_clustermember=(clustermember *)malloc(sizeof(clustermember)); - if(new_clustermember==NULL) - return ERROR; - - new_clustermember->host_name=NULL; - new_clustermember->svc_description=NULL; - - if(hst!=NULL){ - new_clustermember->host_name=(char *)malloc(strlen(hst)+1); - if(new_clustermember->host_name==NULL){ - free(new_clustermember); - return ERROR; - } - strcpy(new_clustermember->host_name,hst); - } - - if(svc!=NULL){ - new_clustermember->svc_description=(char *)malloc(strlen(svc)+1); - if(new_clustermember->svc_description==NULL){ - if(new_clustermember->host_name!=NULL) - free(new_clustermember->host_name); - free(new_clustermember); - return ERROR; - } - strcpy(new_clustermember->svc_description,svc); - } - - new_clustermember->next=clustermember_list; - clustermember_list=new_clustermember; - - return OK; - } - - -void free_memory(void){ - clustermember *this_clustermember; - clustermember *next_clustermember; - - for(this_clustermember=clustermember_list;this_clustermember!=NULL;this_clustermember=next_clustermember){ - next_clustermember=this_clustermember->next; - if(this_clustermember->host_name!=NULL) - free(this_clustermember->host_name); - if(this_clustermember->svc_description!=NULL) - free(this_clustermember->svc_description); - free(this_clustermember); - } - - return; - } - - - -int check_cluster_status(void){ - FILE *fp; - clustermember *temp_clustermember; - char input_buffer[MAX_INPUT_BUFFER]; - char matching_entry[MAX_INPUT_BUFFER]; - - fp=fopen(status_log,"r"); - if(fp==NULL){ - printf("Error: Could not open status log '%s' for reading\n",status_log); - return ERROR; - } - -#ifdef DEBUG - for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){ - if(check_type==CHECK_HOSTS) - printf("Cluster member: '%s'\n",temp_clustermember->host_name); - else - printf("Cluster member: '%s'/'%s'\n",temp_clustermember->host_name,temp_clustermember->svc_description); - } -#endif - - for(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp);!feof(fp);fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){ - - /* this is a host entry */ - if(strstr(input_buffer,"] HOST;") && check_type==CHECK_HOSTS){ - - /* this this a match? */ - for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){ - - snprintf(matching_entry,sizeof(matching_entry)-1,";%s;",temp_clustermember->host_name); - - if(strstr(input_buffer,matching_entry)){ - if(strstr(input_buffer,";DOWN;")) - total_hosts_down++; - else if(strstr(input_buffer,";UNREACHABLE;")) - total_hosts_unreachable++; - else if(strstr(input_buffer,";UP;")) - total_hosts_up++; - } - } - - } - - /* this is a service entry */ - else if(strstr(input_buffer,"] SERVICE;") && check_type==CHECK_SERVICES){ - - /* this this a match? */ - for(temp_clustermember=clustermember_list;temp_clustermember!=NULL;temp_clustermember=temp_clustermember->next){ - - snprintf(matching_entry,sizeof(matching_entry)-1,";%s;%s;",temp_clustermember->host_name,temp_clustermember->svc_description); - - if(strstr(input_buffer,matching_entry)){ - if(strstr(input_buffer,";HOST DOWN;") || strstr(input_buffer,";UNREACHABLE;") || strstr(input_buffer,";CRITICAL;")) - total_services_critical++; - else if(strstr(input_buffer,";WARNING;")) - total_services_warning++; - else if(strstr(input_buffer,";UNKNOWN;")) - total_services_unknown++; - else if(strstr(input_buffer,";OK;") || strstr(input_buffer,";RECOVERY;")) - total_services_ok++; - } - } - - } - } - - fclose(fp); - - return OK; - } diff --git a/contrib/check_cluster2.README b/contrib/check_cluster2.README deleted file mode 100644 index a0149841..00000000 --- a/contrib/check_cluster2.README +++ /dev/null @@ -1,5 +0,0 @@ -check_cluster2 is now part of the core Nagios-Plugins distribution and has -been renamed check_cluster. It will be installed automatically. - -The threshold format has changed and is not backward-compatible; be sure to -understand it correctly. Use --help to print the full help. diff --git a/contrib/check_cluster2.c b/contrib/check_cluster2.c deleted file mode 100644 index e60948d6..00000000 --- a/contrib/check_cluster2.c +++ /dev/null @@ -1,232 +0,0 @@ -/***************************************************************************** - * - * CHECK_CLUSTER2.C - Host and Service Cluster Plugin for Nagios 2.x - * - * Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org) - * License: GPL - * Last Modified: 03-11-2004 - * - * License: - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - *****************************************************************************/ - - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <getopt.h> - -#define OK 0 -#define ERROR -1 - -#define TRUE 1 -#define FALSE 0 - -#define CHECK_SERVICES 1 -#define CHECK_HOSTS 2 - -#define MAX_INPUT_BUFFER 1024 - -#define STATE_OK 0 -#define STATE_WARNING 1 -#define STATE_CRITICAL 2 -#define STATE_UNKNOWN 3 - -int total_services_ok=0; -int total_services_warning=0; -int total_services_unknown=0; -int total_services_critical=0; - -int total_hosts_up=0; -int total_hosts_down=0; -int total_hosts_unreachable=0; - -int warning_threshold=1; -int critical_threshold=1; - -int check_type=CHECK_SERVICES; - -char *data_vals=NULL; -char *label=NULL; - - -int process_arguments(int,char **); - - - -int main(int argc, char **argv){ - char input_buffer[MAX_INPUT_BUFFER]; - char *ptr; - int data_val; - int return_code=STATE_OK; - int error=FALSE; - - if(process_arguments(argc,argv)==ERROR){ - - printf("Invalid arguments supplied\n"); - printf("\n"); - - printf("Host/Service Cluster Plugin for Nagios 2\n"); - printf("Copyright (c) 2000-2004 Ethan Galstad (nagios@nagios.org)\n"); - printf("Last Modified: 03-11-2004\n"); - printf("License: GPL\n"); - printf("\n"); - printf("Usage: %s (-s | -h) [-l label] [-w threshold] [-c threshold] [-d val1,val2,...,valn]\n",argv[0]); - printf("\n"); - printf("Options:\n"); - printf(" -s, --service = Check service cluster status\n"); - printf(" -h, --host = Check host cluster status\n"); - printf(" -l, --label = Optional prepended text output (i.e. \"Host cluster\")\n"); - printf(" -w, --warning = Specifies the number of hosts or services in cluster that must be in\n"); - printf(" a non-OK state in order to return a WARNING status level\n"); - printf(" -c, --critical = Specifies the number of hosts or services in cluster that must be in\n"); - printf(" a non-OK state in order to return a CRITICAL status level\n"); - printf(" -d, --data = The status codes of the hosts or services in the cluster, separated\n"); - printf(" by commas\n"); - printf("\n"); - - return STATE_UNKNOWN; - } - - /* check the data values */ - for(ptr=strtok(data_vals,",");ptr!=NULL;ptr=strtok(NULL,",")){ - - data_val=atoi(ptr); - - if(check_type==CHECK_SERVICES){ - switch(data_val){ - case 0: - total_services_ok++; - break; - case 1: - total_services_warning++; - break; - case 2: - total_services_critical++; - break; - case 3: - total_services_unknown++; - break; - default: - break; - } - } - else{ - switch(data_val){ - case 0: - total_hosts_up++; - break; - case 1: - total_hosts_down++; - break; - case 2: - total_hosts_unreachable++; - break; - default: - break; - } - } - } - - - /* return the status of the cluster */ - if(check_type==CHECK_SERVICES){ - if((total_services_warning+total_services_unknown+total_services_critical) >= critical_threshold) - return_code=STATE_CRITICAL; - else if((total_services_warning+total_services_unknown+total_services_critical) >= warning_threshold) - return_code=STATE_WARNING; - else - return_code=STATE_OK; - printf("%s %s: %d ok, %d warning, %d unknown, %d critical\n",(label==NULL)?"Service cluster":label,(return_code==STATE_OK)?"ok":"problem",total_services_ok,total_services_warning,total_services_unknown,total_services_critical); - } - else{ - if((total_hosts_down+total_hosts_unreachable) >= critical_threshold) - return_code=STATE_CRITICAL; - else if((total_hosts_down+total_hosts_unreachable) >= warning_threshold) - return_code=STATE_WARNING; - else - return_code=STATE_OK; - printf("%s %s: %d up, %d down, %d unreachable\n",(label==NULL)?"Host cluster":label,(return_code==STATE_OK)?"ok":"problem",total_hosts_up,total_hosts_down,total_hosts_unreachable); - } - - return return_code; - } - - - -int process_arguments(int argc, char **argv){ - int c; - int option=0; - static struct option longopts[]={ - {"data", required_argument,0,'d'}, - {"warning", required_argument,0,'w'}, - {"critical", required_argument,0,'c'}, - {"label", required_argument,0,'l'}, - {"host", no_argument, 0,'h'}, - {"service", no_argument, 0,'s'}, - {0,0,0,0} - }; - - /* no options were supplied */ - if(argc<2) - return ERROR; - - while(1){ - - c=getopt_long(argc,argv,"hsw:c:d:l:",longopts,&option); - - if(c==-1 || c==EOF || c==1) - break; - - switch(c){ - - case 'h': /* host cluster */ - check_type=CHECK_HOSTS; - break; - - case 's': /* service cluster */ - check_type=CHECK_SERVICES; - break; - - case 'w': /* warning threshold */ - warning_threshold=atoi(optarg); - break; - - case 'c': /* warning threshold */ - critical_threshold=atoi(optarg); - break; - - case 'd': /* data values */ - data_vals=(char *)strdup(optarg); - break; - - case 'l': /* text label */ - label=(char *)strdup(optarg); - break; - - default: - return ERROR; - break; - } - } - - if(data_vals==NULL) - return ERROR; - - return OK; - } diff --git a/contrib/check_compaq_insight.pl b/contrib/check_compaq_insight.pl deleted file mode 100644 index dfb04402..00000000 --- a/contrib/check_compaq_insight.pl +++ /dev/null @@ -1,296 +0,0 @@ -From mm@elabnet.de Mon Nov 18 09:59:04 2002 -Date: Mon, 18 Nov 2002 12:19:04 +0100 -From: Michael Markstaller <mm@elabnet.de> -To: nagiosplug-devel@lists.sourceforge.net -Subject: [Nagiosplug-devel] Submission: check_insight / checking Compaq - Insight Agent status - -Hi, - -I've been looking to check the status/health of Compaq Insight Agents on -servers and found a spong plugin -(http://spong.sourceforge.net/downloads/plugins/spong-network/check_insi -ght) which I've slightly changed to work with Nagios. -I have pretty no idea of perl at all, just wanted to make it work for -me, so please don't shoot me for this copy-paste-code. I've tested some -basic things, it seems to work at least to report a warning if smthg is -degraded and OK of xcourse ;) -I'm also quite unsure if this is the right way to submit, so I'll just -try ;) -There're some "unknown" components on all servers I've checked so far, -if anybody has a documentation of what's exactly returned when getting -the OID 1.3.6.1.4.1.232.11.2.10.1.0 (CPQHOST_MIB isn't very descriptive) -I'd be happy to fix this. - ---- cut --- -#!/usr/bin/perl -# -# (c)2002 Michael Markstaller, Elaborated Networks GmbH -# send bug reports to <mm@elabnet.de> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty -# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# you should have received a copy of the GNU General Public License -# along with this program (or with Nagios); if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA -# -# -# Check Comapq Insight Management Agents Systems Status by SNMP -# based on the spong-plugin check_insight from: -# -http://spong.sourceforge.net/downloads/plugins/spong-network/check_insig -ht -# -# Usage: -# check_insight -H <host> -C community -# - -use Net::SNMP; -use Getopt::Long; -Getopt::Long::Configure('bundling'); - -$version=0.01; - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - - -# -# some default values -# -$TIMEOUT=15; - -# -# get command line options the regular way -# -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "v" => \$verbose, "verbose" => \$verbose, - "H=s" => \$opt_H, "hostname=s" => \$opt_H, - "C=s" => \$opt_C, "community=s" => \$opt_C); - -# -# handle the verbose stuff first -# -if ($opt_V) { - print "\n"; - print "check_insight nagios plugin version $version\n"; - print "\n"; - print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You -may redistribute\n"; - print "copies of the plugins under the terms of the GNU General -Public License.\n"; - print "For more information about these matters, see the file -named COPYING.\n"; - print "\n"; - print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n"; - print "\n"; - print "\n"; - exit $ERRORS{'UNKNOWN'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'UNKNOWN'}; -} - -# -# now get options the weired way and set the defaults -# if nothing else is provided -# -$opt_H = shift unless ($opt_H); -print_usage() unless ($opt_H); - -# -# dont let us wait forever... -# -$SIG{'ALRM'} = sub { - print ("ERROR: No response from server (alarm)\n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -# -# now we set things up for the real work -# and fire up the request -# - -######################################################################## -######## -my ($host) = ($opt_H); -my ($color, $summary, $message ) = ( "green", "", "" ); -($opt_C) || ($opt_C = shift) || ($opt_C = "public"); -my ($community) = $opt_C; - -# We use some look up tables for checking some config options. -my (@State) = ("Not Available", "Other", "OK", "Degraded", "Failed"); - -my (@MIBName) = ("", "Std", "Unknown", "Array", - "Netware", "SCSI", "Health","Unknown", - "Store", "SM2", "Thresh", "OS", "UPS", - "Unknown", "IDE", "Clusters", "Fibre", - "MIB", "NIC"); - -# These are the positions within the table to actually look at. -my (@MIBs) = (1, 2, 3, 5, 6, 10, 11, 14, 18); - -my ($oid) = "1.3.6.1.4.1.232.11.2.10.1.0"; # SysArray - -# Open the connection. -my ($session, $error) = Net::SNMP->session(Hostname => $host, - Community => $community); - -# If we can't open a connection, just return red straight away. -if (! defined $session) { - print ("ERROR: Unable to contact server '$opt_H'\n"); - exit $ERRORS{"UNKNOWN"}; -} - - -$session->translate; -my ($response) = $session->get_request($oid); - - if (!defined $response) { - # If there's no response, something screwy is going on, give up. - $summary = $session->error; - print ("ERROR: $summary\n"); - exit $ERRORS{"UNKNOWN"}; - $session->close; - } else { - $session->close; - - # I'm not convinced that this is the easiest way to go about this, -this is - # from some code which I've inherited and I've modified for use in -here. - # Hi George! - %h = %$response; - my ($d) = $h{$oid}; - - my (@list) = (); - - # Gobble the first two char's. - $d = substr $d,2; - - while (length($d) > 0) { - my ($v) = substr($d,0,2); - $v = hex($v); - $d = substr $d,2; - push @list, $v; - } - - # Value in $MIBs[1] is the overall status of the machine... - my ($cond) = $MIBs[1]; - $message .= "Status: $State[$cond] "; - - foreach my $v (@MIBs) { - $cond = $list[($v*4)+1]; # A little bit of magic. - - # We only bother printing the status out if it's actually -available, - # as if it's N/A or Unknown then it's probably because the machine - # isn't available. - $message .= "$MIBName[$v]: $State[$cond] " if $cond > 1; - next if $cond < 2; - - # What follows is some trickery to try and not to override a -previous - # message at the same or lower color. - if ($cond == 4) { - if ($color ne 'red') { - $color = 'red'; - $summary = "$MIBName[$v] is failed"; - } - } elsif ($cond == 3) { - if ($color ne 'red') { - $color = 'yellow'; - $summary = "$MIBName[$v] is degraded" if $summary eq ""; - } - } elsif ($cond < 2) { - if ($color eq 'green') { - $color = 'yellow'; - $summary = "$MIBName[$v] is unknown ($cond)" if $summary eq -""; - } - } - } - } - - $summary = "Ok" if $summary eq ""; - -# return ($color, $summary, $message); - -if ($color eq 'red') { - print ("red Output: $message\n"); - exit $ERRORS{"CRITICAL"}; - } elsif ($color eq 'yellow') { - print ("$summary $message\n"); - exit $ERRORS{"WARNING"}; - } elsif ($color eq 'green') { - print ("$message\n"); - exit $ERRORS{"OK"}; -} - - -sub print_usage () { - print "Usage: $0 -H <host> -C <community> \n"; } - -sub print_help () { - print "\n"; - print "\n"; - print "check_insight nagios plugin version $version\n"; - print "\n"; - print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You -may redistribute\n"; - print "copies of the plugins under the terms of the GNU General -Public License.\n"; - print "For more information about these matters, see the file -named COPYING.\n"; - print "\n"; - print "(c)2002 Michael Markstaller, Elaborated Networks GmbH\n"; - print "\n"; - print "\n"; - print "This plugin checks the Compaq Insight Management agents -system status via SNMP on the specified host.\n"; - print "\n"; - print "\n"; - print_usage(); - print "\n"; - print "Options:\n"; - print " -H, --hostname=ADDRESS\n"; - print " host name argument for server.\n"; - print " -C, --community=STRING\n"; - print " SNMP Read-community string.\n"; - print " -h, --help\n"; - print " print detailed help screen.\n"; - print " -V, --version\n"; - print " print version information.\n"; - print "\n"; - print "\n"; -} ---- cut --- - -Michael - - -------------------------------------------------------- -This sf.net email is sponsored by: To learn the basics of securing -your web site with SSL, click here to get a FREE TRIAL of a Thawte -Server Certificate: http://www.gothawte.com/rd524.html -_______________________________________________ -Nagiosplug-devel mailing list -Nagiosplug-devel@lists.sourceforge.net -https://lists.sourceforge.net/lists/listinfo/nagiosplug-devel diff --git a/contrib/check_cpqarray.c b/contrib/check_cpqarray.c deleted file mode 100644 index badffeb4..00000000 --- a/contrib/check_cpqarray.c +++ /dev/null @@ -1,430 +0,0 @@ -/* - check_cpqarray, an extension for Netsaint / Nagios to check the - status of a Compaq SmartArray controller from the commandline. - Copyright (C) 2003 Guenther Mair - - based on the work and using main parts of - - CpqArray Deamon, a program to monitor and remotely configure a - SmartArray controller. - Copyright (C) 1999 Hugo Trippaers - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <unistd.h> -#include <sys/ioctl.h> -#include <sys/utsname.h> -#include <stdio.h> -#include <fcntl.h> -#include <string.h> -#include <errno.h> - -#include "/usr/src/linux/drivers/block/ida_ioctl.h" -#include "/usr/src/linux/drivers/block/ida_cmd.h" -#include "/usr/src/linux/drivers/block/cpqarray.h" - - -const char *controllers[] = -{ - "/dev/ida/c0d0", - "/dev/ida/c1d0", - "/dev/ida/c2d0", - "/dev/ida/c3d0", - "/dev/ida/c4d0", - "/dev/ida/c5d0", - "/dev/ida/c6d0", - "/dev/ida/c7d0" -}; - -const char *statusstr[] = { - "Logical drive /dev/ida/c%dd%d: OK\n", - "Logical drive /dev/ida/c%dd%d: FAILED\n", - "Logical drive /dev/ida/c%dd%d: not configured.\n", - "Logical drive /dev/ida/c%dd%d: using interim recovery mode, %3.2f%% done.\n", - "Logical drive /dev/ida/c%dd%d: ready for recovery operation.\n", - "Logical drive /dev/ida/c%dd%d: is currently recovering, %3.2f%% done.\n", - "Wrong physical drive was replaced.\n", - "A physical drive is not properly connected.\n", - "Hardware is overheating.\n", - "Hardware has overheated.\n", - "Logical drive /dev/ida/c%dd%d: currently expanding, %3.2f%% done.\n", - "Logical drive /dev/ida/c%dd%d: not yet available.\n", - "Logical drive /dev/ida/c%dd%d: queued for expansion.\n", -}; - -extern char *optarg; -extern int optind, opterr, optopt; - -int ctrls_found_num; -int exit_code = 0; -struct controller ctrls_found[8]; - -#define DEBUG(x) fprintf(stderr, x) - -struct opts -{ - char debug; -}; - -struct slog_disk -{ - int status; - float pvalue; -}; - -struct controller -{ - char ctrl_devicename[20]; - int num_logd_found; - struct slog_disk log_disk[16]; -}; - - - -int status_check (struct opts opts) -{ - int devicefd; - int ctrl_cntr; - int logd_cntr; - ida_ioctl_t io, io2; - int status, nr_blks, blks_tr; - float pvalue; - int counter; - - for ( ctrl_cntr=0; - ctrl_cntr < ctrls_found_num; - ctrl_cntr++) { - - devicefd = open (controllers[ctrl_cntr], O_RDONLY); - - for ( logd_cntr=0; - logd_cntr < ctrls_found[ctrl_cntr].num_logd_found; - logd_cntr++) { - - memset (&io, 0, sizeof (io)); - - io.cmd = SENSE_LOG_DRV_STAT; - io.unit = logd_cntr | UNITVALID; - - if (ioctl (devicefd, IDAPASSTHRU, &io) < 0) - { - perror ("SENSE_LOG_DRV_STAT ioctl"); - return 0; - } - - status=io.c.sense_log_drv_stat.status; - - if ((status == 3) || (status == 5) || (status == 7)) { - /* is a progress indicator required? - */ - memset (&io2, 0, sizeof (io)); - - io2.cmd = ID_LOG_DRV; - io2.unit = logd_cntr | UNITVALID; - - if (ioctl (devicefd, IDAPASSTHRU, &io2) < 0) - { - perror ("ID_LOG_DRV ioctl"); - /* return 0; no return this isn't fatal for now */ - } - else - { - nr_blks = io2.c.id_log_drv.nr_blks; - blks_tr = io.c.sense_log_drv_stat.blks_to_recover; - - pvalue = ((float)(nr_blks - blks_tr)/(float)nr_blks) * 100; - } - } - else { - pvalue = 0.0; - } - - if (opts.debug) { - fprintf(stdout, "DEBUG: Status of controller %d unit %d is %d\n", - ctrl_cntr, logd_cntr, status); - fprintf(stdout, "DEBUG: "); - fprintf(stdout, statusstr[status], - ctrl_cntr, logd_cntr, pvalue); - fprintf(stdout, "\n"); - } - - printf(statusstr[status], ctrl_cntr, logd_cntr, pvalue); - - switch(status) - { - case 1: - case 2: - case 6: - case 7: - case 9: - /* CRITICAL */ - exit_code = 2; - break; - case 3: - case 4: - case 5: - case 8: - case 10: - case 11: - case 12: - /* WARNING (only if not yet at CRITICAL LEVEL) */ - if (exit_code < 2) exit_code = 1; - break; - case 0: - default: - /* do nothing */ - break; - } - - ctrls_found[ctrl_cntr].log_disk[logd_cntr].pvalue = pvalue; - ctrls_found[ctrl_cntr].log_disk[logd_cntr].status = status; - } - close (devicefd); - } - - return 1; -} - -int discover_controllers (struct opts opts) -{ - int cntr; - int foundone = 0; - - for (cntr = 0; cntr < 8; cntr++) - { - /* does this device exist ? */ - if ((access (controllers[cntr], R_OK | F_OK)) == 0) - { - /* it does :) */ - if (interrogate_controller (opts, cntr)) - { - foundone = 1; - if (opts.debug) - fprintf (stderr, "DEBUG: %s is a existing controller\n", - controllers[cntr]); - } - } - else if (opts.debug) - { - fprintf (stderr, "DEBUG: Device %s could not be opened\n", controllers[cntr]); - perror ("DEBUG: reason"); - } - } - return foundone; -} - -void boardid2str (unsigned long board_id, char *name) -{ - switch (board_id) - { - case 0x0040110E: /* IDA */ - strcpy (name, "Compaq IDA"); - break; - case 0x0140110E: /* IDA-2 */ - strcpy (name, "Compaq IDA-2"); - break; - case 0x1040110E: /* IAES */ - strcpy (name, "Compaq IAES"); - break; - case 0x2040110E: /* SMART */ - strcpy (name, "Compaq SMART"); - break; - case 0x3040110E: /* SMART-2/E */ - strcpy (name, "Compaq SMART-2/E"); - break; - case 0x40300E11: /* SMART-2/P or SMART-2DH */ - strcpy (name, "Compaq SMART-2/P (2DH)"); - break; - case 0x40310E11: /* SMART-2SL */ - strcpy (name, "Compaq SMART-2SL"); - break; - case 0x40320E11: /* SMART-3200 */ - strcpy (name, "Compaq SMART-3200"); - break; - case 0x40330E11: /* SMART-3100ES */ - strcpy (name, "Compaq SMART-3100ES"); - break; - case 0x40340E11: /* SMART-221 */ - strcpy (name, "Compaq SMART-221"); - break; - case 0x40400E11: /* Integrated Array */ - strcpy (name, "Compaq Integrated Array"); - break; - case 0x40500E11: /* Smart Array 4200 */ - strcpy (name, "Compaq Smart Array 4200"); - break; - case 0x40510E11: /* Smart Array 4250ES */ - strcpy (name, "Compaq Smart Array 4250ES"); - break; - case 0x40580E11: /* Smart Array 431 */ - strcpy (name, "Compaq Smart Array 431"); - break; - default: - /* - * Well, its a SMART-2 or better, don't know which - * kind. - */ - strcpy (name, "Unknown Controller Type"); - } -} - -int interrogate_controller (struct opts opts, int contrnum) -{ - int devicefd; - ida_ioctl_t io; - char buffer[30]; - int foundone = 0; - int cntr; - - devicefd = open (controllers[contrnum], O_RDONLY); - /* no checks, did that before */ - - /* clear io */ - memset (&io, 0, sizeof (io)); - - io.cmd = ID_CTLR; - - if (ioctl (devicefd, IDAPASSTHRU, &io) < 0) - { - if (opts.debug) perror ("DEBUG: ioctl"); - return 0; - } - - boardid2str (io.c.id_ctlr.board_id, buffer); - - strncpy (ctrls_found[ctrls_found_num].ctrl_devicename, - buffer, 20); - - ctrls_found[ctrls_found_num].num_logd_found = 0; - - for (cntr = 0; cntr < io.c.id_ctlr.nr_drvs; cntr++) - { - if (interrogate_logical (opts, devicefd, cntr)) - { - /* logical drive found, this could be used later one */ - foundone = 1; - } - } - - switch (ctrls_found[ctrls_found_num].num_logd_found) - { - case 0: - printf("Found a %s with no logical drives.\n", buffer); - break; - case 1: - printf("Found a %s with one Logical drive.\n", buffer, - ctrls_found[ctrls_found_num].num_logd_found); - break; - default: - printf("Found a %s with %d Logical drives.\n", buffer, - ctrls_found[ctrls_found_num].num_logd_found); - break; - } - - ctrls_found_num++; - - close (devicefd); - return 1; -} - -int interrogate_logical (struct opts opts, int devicefd, int unit_nr) -{ - ida_ioctl_t io; - ida_ioctl_t io2; - int nr_blks, blks_tr; - - if (opts.debug) printf ("DEBUG: interrogating unit %d\n", unit_nr); - - memset (&io, 0, sizeof (io)); - - io.cmd = ID_LOG_DRV; - io.unit = unit_nr | UNITVALID; - - if (ioctl (devicefd, IDAPASSTHRU, &io) < 0) - { - perror ("FATAL: ID_LOG_DRV ioctl"); - return 0; - } - - memset (&io2, 0, sizeof (io2)); - - io2.cmd = SENSE_LOG_DRV_STAT; - io2.unit = unit_nr | UNITVALID; - - if (ioctl (devicefd, IDAPASSTHRU, &io2) < 0) - { - perror ("FATAL: SENSE_LOG_DRV_STAT ioctl"); - return 0; - } - - ctrls_found[ctrls_found_num].num_logd_found++; - /* ctrls_found[ctrls_found_num].log_disk[unit_nr].status = - * io2.c.sense_log_drv_stat.status; - - * nr_blks = io2.c.id_log_drv.nr_blks; - * blks_tr = io.c.sense_log_drv_stat.blks_to_recover; - * ctrls_found[ctrls_found_num].log_disk[unit_nr].pvalue = - * ((float)(nr_blks - blks_tr)/(float)nr_blks) * 100; - */ - ctrls_found[ctrls_found_num].log_disk[unit_nr].status = 0; - ctrls_found[ctrls_found_num].log_disk[unit_nr].pvalue = 0; - - return 1; -} - - -void print_usage() -{ - printf("cpqarrayd [options]\n"); - printf(" -h prints this text\n"); - printf(" -d enables debugging\n"); -} - - -int main(int argc, char *argv[]) -{ - char option; - struct opts opts; /* commandline options */ - - memset(&opts, 0, sizeof(struct opts)); - - /* check options */ - while ((option = getopt (argc, argv, "dh:")) != EOF) - { - switch (option) - { - case 'd': - opts.debug = 1; - break; - case '?': - case 'h': - default: - print_usage(); - exit(0); - break; - } - } - - /* Check for existance of array controllers */ - if (!discover_controllers(opts)) { - printf("No array controller found!\n\n"); - exit(1); - } - - status_check(opts); - - return exit_code; -} diff --git a/contrib/check_digitemp.pl b/contrib/check_digitemp.pl deleted file mode 100755 index d2b40a10..00000000 --- a/contrib/check_digitemp.pl +++ /dev/null @@ -1,252 +0,0 @@ -#!/usr/bin/perl -w - -# check_digitemp.pl Copyright (C) 2002 by Brian C. Lane <bcl@brianlane.com> -# -# This is a NetSaint plugin script to check the temperature on a local -# machine. Remote usage may be possible with SSH -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to -# deal in the Software without restriction, including without limitation the -# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or -# sell copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -# =========================================================================== -# Howto Install in NetSaint (tested with v0.0.7) -# -# 1. Copy this script to /usr/local/netsaint/libexec/ or wherever you have -# placed your NetSaint plugins -# -# 2. Create a digitemp config file in /usr/local/netsaint/etc/ -# eg. digitemp -i -s/dev/ttyS0 -c /usr/local/netsaint/etc/digitemp.conf -# -# 3. Make sure that the webserver user has permission to access the serial -# port being used. -# -# 4. Add a command to /usr/local/netsaint/etc/commands.cfg like this: -# command[check-temp]=$USER1$/check_digitemp.pl -w $ARG1$ -c $ARG2$ \ -# -t $ARG3$ -f $ARG4$ -# (fold into one line) -# -# 5. Tell NetSaint to monitor the temperature by adding a service line like -# this to your hosts.cfg file: -# service[kermit]=Temperature;0;24x7;3;5;1;home-admins;120;24x7;1;1;1;; \ -# check-temp!65!75!1!/usr/local/netsaint/etc/digitemp.conf -# (fold into one line) -# 65 is the warning temperature -# 75 is the critical temperature -# 1 is the sensor # (as reported by digitemp -a) to monitor -# digitemp.conf is the path to the config file -# -# 6. If you use Centigrade instead of Fahrenheit, change the commands.cfg -# line to include the -C argument. You can then pass temperature limits in -# Centigrade in the service line. -# -# =========================================================================== -# Howto Install in Nagios (tested with v1.0b4) -# -# 1. Copy this script to /usr/local/nagios/libexec/ or wherever you have -# placed your Nagios plugins -# -# 2. Create a digitemp config file in /usr/local/nagios/etc/ -# eg. digitemp -i -s/dev/ttyS0 -c /usr/local/nagios/etc/digitemp.conf -# -# 3. Make sure that the webserver user has permission to access the serial -# port being used. -# -# 4. Add a command to /usr/local/nagios/etc/checkcommands.cfg like this: -# -# #DigiTemp temperature check command -# define command{ -# command_name check_temperature -# command_line $USER1$/check_digitemp.pl -w $ARG1$ -c $ARG2$ \ -# -t $ARG3$ -f $ARG4$ -# (fold above into one line) -# } -# -# 5. Tell NetSaint to monitor the temperature by adding a service line like -# this to your service.cfg file: -# -# #DigiTemp Temperature check Service definition -# define service{ -# use generic-service -# host_name kermit -# service_description Temperature -# is_volatile 0 -# check_period 24x7 -# max_check_attempts 3 -# normal_check_interval 5 -# retry_check_interval 2 -# contact_groups home-admins -# notification_interval 240 -# notification_period 24x7 -# notification_options w,u,c,r -# check_command check_temperature!65!75!1! \ -# /usr/local/nagios/etc/digitemp.conf -# (fold into one line) -# } -# -# 65 is the warning temperature -# 75 is the critical temperature -# 1 is the sensor # (as reported by digitemp -a) to monitor -# digitemp.conf is the path to the config file -# -# 6. If you use Centigrade instead of Fahrenheit, change the checkcommands.cfg -# line to include the -C argument. You can then pass temperature limits in -# Centigrade in the service line. -# -# =========================================================================== - -# Modules to use -use strict; -use Getopt::Std; - -# Define all our variable usage -use vars qw($opt_c $opt_f $opt_t $opt_w $opt_F $opt_C - $temperature $conf_file $sensor $temp_fmt - $crit_level $warn_level $null - %exit_codes - $percent $fmt_pct - $verb_err $command_line); - - -# Predefined exit codes for NetSaint -%exit_codes = ('UNKNOWN' ,-1, - 'OK' , 0, - 'WARNING' , 1, - 'CRITICAL', 2,); - -# Default to Fahrenheit input and result (use -C to change this) -$temp_fmt = 3; - - -# Get the options -if ($#ARGV le 0) -{ - &usage; -} else { - getopts('f:t:FCc:w:'); -} - -# Shortcircuit the switches -if (!$opt_w or $opt_w == 0 or !$opt_c or $opt_c == 0) -{ - print "*** You must define WARN and CRITICAL levels!"; - &usage; -} - -# Check if levels are sane -if ($opt_w >= $opt_c) -{ - print "*** WARN level must not be greater than CRITICAL when checking temperature!"; - &usage; -} - - -$warn_level = $opt_w; -$crit_level = $opt_c; - -# Default sensor to read is #0 -if(!$opt_t) -{ - $sensor = 0; -} else { - $sensor = $opt_t; -} - -# Default config file is /etc/digitemp.conf -if(!$opt_f) -{ - $conf_file = "/etc/digitemp.conf"; -} else { - $conf_file = $opt_f; -} - -# Check for config file -if( !-f $conf_file ) { - print "*** You must have a digitemp.conf file\n"; - &usage; -} - - -if($opt_C) -{ - $temp_fmt = 2; -} - -# Read the output from digitemp -# Output in form 0\troom\tattic\tdrink -open( DIGITEMP, "/usr/local/bin/digitemp -c $conf_file -t $sensor -q -o $temp_fmt |" ); - -# Process the output from the command -while( <DIGITEMP> ) -{ -# print "$_\n"; - chomp; - - if( $_ =~ /^nanosleep/i ) - { - print "Error reading sensor #$sensor\n"; - close(DIGITEMP); - exit $exit_codes{'UNKNOWN'}; - } else { - # Check for an error from digitemp, and report it instead - if( $_ =~ /^Error.*/i ) { - print $_; - close(DIGITEMP); - exit $exit_codes{'UNKNOWN'}; - } else { - ($null,$temperature) = split(/\t/); - } - } -} -close( DIGITEMP ); - -if( $temperature and $temperature >= $crit_level ) -{ - print "Temperature CRITICAL - Sensor #$sensor = $temperature "; - if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; } - exit $exit_codes{'CRITICAL'}; -} elsif ($temperature and $temperature >= $warn_level ) { - print "Temperature WARNING - Sensor #$sensor = $temperature "; - if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; } - exit $exit_codes{'WARNING'}; -} elsif( $temperature ) { - print "Temperature OK - Sensor #$sensor = $temperature "; - if( $temp_fmt == 3 ) { print "F\n"; } else { print "C\n"; } - exit $exit_codes{'OK'}; -} else { - print "Error parsing result for sensor #$sensor\n"; - exit $exit_codes{'UNKNOWN'}; -} - -# Show usage -sub usage() -{ - print "\ncheck_digitemp.pl v1.0 - NetSaint Plugin\n"; - print "Copyright 2002 by Brian C. Lane <bcl\@brianlane.com>\n"; - print "See source for License\n"; - print "usage:\n"; - print " check_digitemp.pl -t <sensor> -f <config file> -w <warnlevel> -c <critlevel>\n\n"; - print "options:\n"; - print " -f DigiTemp Config File\n"; - print " -t DigiTemp Sensor #\n"; - print " -F Temperature in Fahrenheit\n"; - print " -C Temperature in Centigrade\n"; - print " -w temperature temperature >= to warn\n"; - print " -c temperature temperature >= when critical\n"; - - exit $exit_codes{'UNKNOWN'}; -} diff --git a/contrib/check_dlswcircuit.pl b/contrib/check_dlswcircuit.pl deleted file mode 100755 index f6ef9311..00000000 --- a/contrib/check_dlswcircuit.pl +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/perl -w -# -# check_dlswcircuit.pl - nagios plugin -# -# Checks if a Cisco Dlsw circuit is connected. -# -# -# Copyright (C) 2000 Carsten Foss & Christoph Kron -# -# Basically this is an adapted version of Christoph Kron's (ck@zet.net) check_ifoperstatus.pl plugin. -# most of the thanks should go to him. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# Arguments : -s <SourceMac> -d <DestMac> -c <READCOMMUNITY> -p <PORT> <HOSTNAME or IP-Addr> -# - -# Source & Dest Mac/Sap arguments must be given in Hex as this example : 40.00.01.37.45.01.ss (Where ss is the sap) -# -# Sample command line : check_dlswcircuit.pl -s 40.00.01.37.45.01.04 -d 40.00.02.37.45.02.04 -c secret 1.2.3.4 -# -# Sample host.cfg entry : -#service[Dlsw-xx]=NCP1-NCP2;0;24x7;3;5;1;router-admins;240;24x7;1;1;0;;check_dlswcircuit!-s 40.00.01.37.45.01.04!-d 40.00..01.37.45.02.04!-c secret!1.2.3.4 -# remember to add the service to commands.cfg , something like this: -# command[check_dlswcircuit]=$USER1$/check_dlswcircuit.pl $ARG1$ $ARG2$ $ARG3$ $ARG4$ $ARG5$ -# -# Report bugs to: cfo@dmdata.dk -# -# 11.03.2000 Version 1.0 - -use strict; - -use Net::SNMP; -use Getopt::Long; -&Getopt::Long::config('auto_abbrev'); - - -my $status; -my $TIMEOUT = 15; - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - -my %dlswCircuitStatus = ( - '1','disconnected', - '2','circuitStart', - '3','resolvePending', - '4','circuitPending', - '5','circuitEstablished', - '6','connectPending', - '7','contactPending', - '8','connected', - '9','disconnectPending', - '10','haltPending', - '11','haltPendingNoack', - '13','circuitRestart', - '14','restartPending'); - -my $state = "UNKNOWN"; -my $answer = ""; -my $smac = ""; -my $dmac = ""; -my $community = "public"; -my $port = 161; -#Dlsw Circuit Oid enterprises.9.10.9.1.5.2.1.17.6.0.96.148.47.230.166.4.6.64.0.1.55.69.2.4 = 8 -my $enterpriseOid = "1.3.6.1.4.1"; -my $ciscoDlswCircuitOid = ".9.10.9.1.5.2.1.17."; -my $unknownOid = "6."; -my $smacOid = ""; -my $dmacOid = ""; -my $tmpOid = ""; -my @tmparg; -my $snmpoid; -my @snmpoids; -my $hostname; -my $session; -my $error; -my $response; -my $p = ""; -my $q = ""; - -sub usage { - printf "\nMissing arguments!\n"; - printf "\n"; - printf "Perl Check Cisco Dlsw Circuit State plugin for Nagios\n"; - printf "checks operational status of specified DLSW Circuit\n"; - printf "usage: \n"; - printf "check_dlswcircuit.pl -s <SourceMac> -d <DestMac> -c <READCOMMUNITY> -p <PORT> <HOSTNAME>"; - printf "\nCopyright (C) 2000 Carsten Foss\n"; - printf "check_dlswcircuit.pl comes with ABSOLUTELY NO WARRANTY\n"; - printf "This programm is licensed under the terms of the "; - printf "GNU General Public License\n(check source code for details)\n"; - printf "\n\n"; - exit $ERRORS{"UNKNOWN"}; -} - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print ("ERROR: No snmp response from $hostname (alarm)\n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -$status = GetOptions("sourcemac=s",\$smac,"destmac=s",\$dmac, - "community=s",\$community, - "port=i",\$port); -if ($status == 0) -{ - &usage; -} - -# -#Convert Source Mac & Sap -# - @tmparg = split(/\./,$smac); - #print "-$smac-\n"; - #print "@tmparg\n"; - #print "$#tmparg\n"; - if($#tmparg != 6) - { - print "SourceMac/Sap format $smac not valid\n"; - &usage; - } - while($p = shift @tmparg) - { - $q = hex($p); - $smacOid = $smacOid.$q; - $smacOid = $smacOid.'.'; - } - - #print "@tmparg1\n"; - #print "$smacOid\n"; - -# -#Convert Dest Mac & Sap -# - @tmparg = split(/\./,$dmac); - #print "-$dmac-\n"; - #print "@tmparg\n"; - #print "$#tmparg\n"; - if($#tmparg != 6) - { - print "DestMac/Sap format $dmac not valid\n"; - &usage; - } - - while($p = shift @tmparg) - { - $q = hex($p); - $dmacOid = $dmacOid.$q; - $dmacOid = $dmacOid.'.'; - } -# Remove Trailing Dot - $dmacOid = substr($dmacOid,0,length($dmacOid)-1); - - - #print "@tmparg1\n"; - #print "$dmacOid\n"; -#Build the Dlsw Oic to use - $snmpoid = $enterpriseOid.$ciscoDlswCircuitOid.$unknownOid.$smacOid.$unknownOid.$dmacOid ; - #print "$snmpoid\n"; - - #shift; - $hostname = shift || &usage; - - ($session, $error) = Net::SNMP->session( - -hostname => $hostname, - -community => $community, - -port => $port - ); - - if (!defined($session)) { - $state='UNKNOWN'; - $answer=$error; - print ("$state: $answer"); - exit $ERRORS{$state}; - } - - push(@snmpoids,$snmpoid); - #push(@snmpoids,$snmpLocIfDescr); - - if (!defined($response = $session->get_request(@snmpoids))) { - $answer=$session->error; - $session->close; - $state = 'CRITICAL'; - print ("$state: $answer,$community,$smac - $dmac"); - exit $ERRORS{$state}; - } - - $answer = sprintf("dlsw circuit %s - %s at host '%s',is %s\n", - $smac, - $dmac, - $hostname, - $dlswCircuitStatus{$response->{$snmpoid}} - ); - - $session->close; - - if ( $response->{$snmpoid} == 8 ) { - $state = 'OK'; - } - else { - $state = 'CRITICAL'; - } - -print ("$state: $answer"); -exit $ERRORS{$state}; diff --git a/contrib/check_dns_random.pl b/contrib/check_dns_random.pl deleted file mode 100644 index 4bed4120..00000000 --- a/contrib/check_dns_random.pl +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/perl -# ------------------------------------------------------------------------------ -# File Name: check_dns_random.pl -# Author: Richard Mayhew - South Africa -# Date: 2000/01/26 -# Version: 1.0 -# Description: This script will check to see if dns resolves hosts -# randomly from a list using the check_dns plugin. -# Email: netsaint@splash.co.za -# ------------------------------------------------------------------------------ -# Copyright 1999 (c) Richard Mayhew -# Credits go to Ethan Galstad for coding Nagios -# If any changes are made to this script, please mail me a copy of the -# changes :) -# License GPL -# ------------------------------------------------------------------------------ -# Date Author Reason -# ---- ------ ------ -# 1999/09/26 RM Creation -# ------------------------------------------------------------------------------ - -# -----------------------------------------------------------------[ Require ]-- -require 5.004; - -# --------------------------------------------------------------------[ Uses ]-- -use Socket; -use strict; - -# --------------------------------------------------------------[ Enviroment ]-- -$ENV{PATH} = "/bin"; -$ENV{BASH_ENV} = ""; -$|=1; - -my $host = shift || &usage; - -my $domainfile = "/usr/local/nagios/etc/domains.list"; -my $wc = `/usr/bin/wc -l $domainfile`; -my $check = "/usr/local/nagios/libexec/check_dns"; -my $x = 0; -my $srv_file = ""; -my $z = ""; -my $y = ""; - -open(DOMAIN,"<$domainfile") or die "Error Opening $domainfile File!\n"; - while (<DOMAIN>) { - $srv_file .= $_; -} - close(DOMAIN); - my @data = split(/\n/,$srv_file); - -chomp $wc; -$wc =~ s/ //g; -$wc =~ s/domains//g; - -$x = rand $wc; -($z,$y) = split(/\./,$x); - -system($check, $data[$z], $host); -exit ($? / 256); - -sub usage -{ - print "Minimum arguments not supplied!\n"; - print "\n"; - print "Perl Check Random DNS plugin for Nagios\n"; - print "Copyright (c) 2000 Richard Mayhew\n"; - print "\n"; - print "Usage: check_dns_random.pl <host>\n"; - print "\n"; - print "<host> = DNS server you would like to query.\n"; - exit -1; - -} - diff --git a/contrib/check_email_loop.pl b/contrib/check_email_loop.pl deleted file mode 100644 index 1b02ea3c..00000000 --- a/contrib/check_email_loop.pl +++ /dev/null @@ -1,309 +0,0 @@ -#!/usr/bin/perl -w -# -# $Id: check_email_loop.pl 1290 2005-11-29 23:21:06Z harpermann $ -# -# (c)2000 Benjamin Schmid, blueshift@gmx.net (emergency use only ;-) -# Copyleft by GNU GPL -# -# -# check_email_loop Nagios Plugin -# -# This script sends a mail with a specific id in the subject via -# an given smtp-server to a given email-adress. When the script -# is run again, it checks for this Email (with its unique id) on -# a given pop3 account and send another mail. -# -# -# Example: check_email_loop.pl -poph=mypop -popu=user -pa=password -# -smtph=mailer -from=returnadress@yoursite.com -# -to=remaileradress@friend.com -pendc=2 -lostc=0 -# -# This example will send eacht time this check is executed a new -# mail to remaileradress@friend.com using the SMTP-Host mailer. -# Then it looks for any back-forwarded mails in the POP3 host -# mypop. In this Configuration CRITICAL state will be reached if -# more than 2 Mails are pending (meaning that they did not came -# back till now) or if a mails got lost (meaning a mail, that was -# send later came back prior to another mail). -# -# Michael Markstaller, mm@elabnet.de various changes/additions -# MM 021003: fixed some unquoted strings -# MM 021116: fixed/added pendwarn/lostwarn -# MM 030515: added deleting of orphaned check-emails -# changed to use "top" instead of get to minimize traffic (required changing match-string from "Subject: Email-ping [" to "Email-Ping [" - -use Net::POP3; -use Net::SMTP; -use strict; -use Getopt::Long; -&Getopt::Long::config('auto_abbrev'); - -# ---------------------------------------- - -my $TIMEOUT = 120; -my %ERRORS = ('OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - 'UNKNOWN' , '3'); - -my $state = "UNKNOWN"; -my ($sender,$receiver, $pophost, $popuser, $poppasswd, $smtphost,$keeporphaned); -my ($poptimeout,$smtptimeout,$pinginterval,$maxmsg)=(60,60,5,50); -my ($lostwarn, $lostcrit,$pendwarn, $pendcrit,$debug); -$debug = 0; - -# Internal Vars -my ($pop,$msgcount,@msglines,$statinfo,@messageids,$newestid); -my (%other_smtp_opts); -my ($matchcount,$statfile) = (0,"check_email_loop.stat"); - -# Subs declaration -sub usage; -sub messagematchs; -sub nsexit; - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print ("ERROR: $0 Time-Out $TIMEOUT s \n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -# Evaluate Command Line Parameters -my $status = GetOptions( - "from=s",\$sender, - "to=s",\$receiver, - "debug", \$debug, - "pophost=s",\$pophost, - "popuser=s",\$popuser, - "passwd=s",\$poppasswd, - "poptimeout=i",\$poptimeout, - "smtphost=s",\$smtphost, - "smtptimeout=i",\$smtptimeout, - "statfile=s",\$statfile, - "interval=i",\$pinginterval, - "lostwarn=i",\$lostwarn, - "lostcrit=i",\$lostcrit, - "pendwarn=i",\$pendwarn, - "pendcrit=i",\$pendcrit, - "maxmsg=i",\$maxmsg, - "keeporphaned=s",\$keeporphaned, - ); -usage() if ($status == 0 || ! ($pophost && $popuser && $poppasswd && - $smtphost && $receiver && $sender )); - -# Try to read the ids of the last send emails out of statfile -if (open STATF, "$statfile") { - @messageids = <STATF>; - chomp @messageids; - close STATF; -} - -# Try to open statfile for writing -if (!open STATF, ">$statfile") { - nsexit("Failed to open mail-ID database $statfile for writing",'CRITICAL'); -} - -# Ok - check if it's time to release another mail - -# ... - -# creating new serial id -my $serial = time(); -$serial = "ID#" . $serial . "#$$"; - - -# sending new ping email -%other_smtp_opts=(); -if ( $debug == 1 ) { - $other_smtp_opts{'Debug'} = 1; -} - -my $smtp = Net::SMTP->new($smtphost,Timeout=>$smtptimeout, %other_smtp_opts) - || nsexit("SMTP connect timeout ($smtptimeout s)",'CRITICAL'); -($smtp->mail($sender) && - $smtp->to($receiver) && - $smtp->data() && - $smtp->datasend("To: $receiver\nSubject: E-Mail Ping [$serial]\n\n". - "This is an automatically sent E-Mail.\n". - "It is not intended for a human reader.\n\n". - "Serial No: $serial\n") && - $smtp->dataend() && - $smtp->quit - ) || nsexit("Error delivering message",'CRITICAL'); - -# no the interessting part: let's if they are receiving ;-) - -$pop = Net::POP3->new( $pophost, - Timeout=>$poptimeout) - || nsexit("POP3 connect timeout (>$poptimeout s, host: $pophost)",'CRITICAL'); - -$msgcount=$pop->login($popuser,$poppasswd); - -$statinfo="$msgcount mails on POP3"; - -nsexit("POP3 login failed (user:$popuser)",'CRITICAL') if (!defined($msgcount)); - -# Check if more than maxmsg mails in pop3-box -nsexit(">$maxmsg Mails ($msgcount Mails on POP3); Please delete !",'WARNING') if ($msgcount > $maxmsg); - -my ($mid, $nid); -# Count messages, that we are looking 4: -while ($msgcount > 0) { - @msglines = @{$pop->top($msgcount,1)}; - for (my $i=0; $i < scalar @messageids; $i++) { - if (messagematchsid(\@msglines,$messageids[$i])) { - $matchcount++; - # newest received mail than the others, ok remeber id. - if (!defined $newestid) { - $newestid = $messageids[$i]; - } else { - $messageids[$i] =~ /\#(\d+)\#/; - $mid = $1; - $newestid =~ /\#(\d+)\#/; - $nid = $1; - if ($mid > $nid) { - $newestid = $messageids[$i]; - } - } - $pop->delete($msgcount); # remove E-Mail from POP3 server - splice @messageids, $i, 1;# remove id from List - last; # stop looking in list - } - } - # Delete orphaned Email-ping msg - my @msgsubject = grep /^Subject/, @msglines; - chomp @msgsubject; - # Scan Subject if email is an Email-Ping. In fact we match and delete also successfully retrieved messages here again. - if (!defined $keeporphaned && $msgsubject[0] =~ /E-Mail Ping \[/) { - $pop->delete($msgcount); # remove E-Mail from POP3 server - } - - $msgcount--; -} - -$pop->quit(); # necessary for pop3 deletion! - -# traverse through the message list and mark the lost mails -# that mean mails that are older than the last received mail. -if (defined $newestid) { - $newestid =~ /\#(\d+)\#/; - $newestid = $1; - for (my $i=0; $i < scalar @messageids; $i++) { - $messageids[$i] =~ /\#(\d+)\#/; - my $akid = $1; - if ($akid < $newestid) { - $messageids[$i] =~ s/^ID/LI/; # mark lost - } - } -} - -# Write list to id-Database -foreach my $id (@messageids) { - print STATF "$id\n"; -} -print STATF "$serial\n"; # remember send mail of this session -close STATF; - -# ok - count lost and pending mails; -my @tmp = grep /^ID/, @messageids; -my $pendingm = scalar @tmp; -@tmp = grep /^LI/, @messageids; -my $lostm = scalar @tmp; - -# Evaluate the Warnin/Crit-Levels -if (defined $pendwarn && $pendingm > $pendwarn) { $state = 'WARNING'; } -if (defined $lostwarn && $lostm > $lostwarn) { $state = 'WARNING'; } -if (defined $pendcrit && $pendingm > $pendcrit) { $state = 'CRITICAL'; } -if (defined $lostcrit && $lostm > $lostcrit) { $state = 'CRITICAL'; } - -if ((defined $pendwarn || defined $pendcrit || defined $lostwarn - || defined $lostcrit) && ($state eq 'UNKNOWN')) {$state='OK';} - - -# Append Status info -$statinfo = $statinfo . ", $matchcount mail(s) came back,". - " $pendingm pending, $lostm lost."; - -# Exit in a Nagios-compliant way -nsexit($statinfo); - -# ---------------------------------------------------------------------- - -sub usage { - print "check_email_loop 1.1 Nagios Plugin - Real check of a E-Mail system\n"; - print "=" x 75,"\nERROR: Missing or wrong arguments!\n","=" x 75,"\n"; - print "This script sends a mail with a specific id in the subject via an given\n"; - print "smtp-server to a given email-adress. When the script is run again, it checks\n"; - print "for this Email (with its unique id) on a given pop3 account and sends \n"; - print "another mail.\n"; - print "\nThe following options are available:\n"; - print " -from=text email adress of send (for mail returnr on errors)\n"; - print " -to=text email adress to which the mails should send to\n"; - print " -pophost=text IP or name of the POP3-host to be checked\n"; - print " -popuser=text Username of the POP3-account\n"; - print " -passwd=text Password for the POP3-user\n"; - print " -poptimeout=num Timeout in seconds for the POP3-server\n"; - print " -smtphost=text IP oder name of the SMTP host\n"; - print " -smtptimeout=num Timeout in seconds for the SMTP-server\n"; - print " -statfile=text File to save ids of messages ($statfile)\n"; - print " -interval=num Time (in minutes) that must pass by before sending\n"; - print " another Ping-mail (gibe a new try);\n"; - print " -lostwarn=num WARNING-state if more than num lost emails\n"; - print " -lostcrit=num CRITICAL \n"; - print " -pendwarn=num WARNING-state if more than num pending emails\n"; - print " -pendcrit=num CRITICAL \n"; - print " -maxmsg=num WARNING if more than num emails on POP3 (default 50)\n"; - print " -keeporphaned Set this to NOT delete orphaned E-Mail Ping msg from POP3\n"; - print " -debug send SMTP tranaction info to stderr\n\n"; - print " Options may abbreviated!\n"; - print " LOST mails are mails, being sent before the last mail arrived back.\n"; - print " PENDING mails are those, which are not. (supposed to be on the way)\n"; - print "\nExample: \n"; - print " $0 -poph=host -pa=pw -popu=popts -smtph=host -from=root\@me.com\n "; - print " -to=remailer\@testxy.com -lostc=0 -pendc=2\n"; - print "\nCopyleft 19.10.2000, Benjamin Schmid / 2003 Michael Markstaller, mm\@elabnet.de\n"; - print "This script comes with ABSOLUTELY NO WARRANTY\n"; - print "This programm is licensed under the terms of the "; - print "GNU General Public License\n\n"; - exit $ERRORS{"UNKNOWN"}; -} - -# --------------------------------------------------------------------- - -sub nsexit { - my ($msg,$code) = @_; - $code=$state if (!defined $code); - print "$code: $msg\n" if (defined $msg); - exit $ERRORS{$code}; -} - -# --------------------------------------------------------------------- - -sub messagematchsid { - my ($mailref,$id) = (@_); - my (@tmp); - my $match = 0; - - # ID - $id =~ s/^LI/ID/; # evtl. remove lost mail mark - @tmp = grep /E-Mail Ping \[/, @$mailref; - chomp @tmp; - if (($tmp[0] =~ /$id/)) - { $match = 1; } - - # Sender: -# @tmp = grep /^From:\s+/, @$mailref; -# if (@tmp && $sender ne "") -# { $match = $match && ($tmp[0]=~/$sender/); } - - # Receiver: -# @tmp = grep /^To: /, @$mailref; -# if (@tmp && $receiver ne "") -# { $match = $match && ($tmp[0]=~/$receiver/); } - - return $match; -} - -# --------------------------------------------------------------------- diff --git a/contrib/check_fan_cpq_present b/contrib/check_fan_cpq_present deleted file mode 100644 index 0bd13909..00000000 --- a/contrib/check_fan_cpq_present +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/perl -# -# -# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical] -# -# NetSaint host script to get the disk usage from NT snmp -# -# Changes and Modifications -# ========================= -# 3-Aug-2000 - Xavier Dusart -# Created -# 2003 - Rainer Duffner - -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} - - - -require 5.004; -use POSIX; -#use strict; -use Getopt::Std ; -use BER; -require 'SNMP_Session.pm'; -use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME); -use lib $main::runtimedir; -use utils qw($TIMEOUT %ERRORS &print_revision &usage &support); -use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED); - -delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer - -getopts('H:p:C:f:hV') ; - -my $ip_address=undef ; - -if ($opt_h) {&help();} - -if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA --Z0-9]*)*)$/) { - $ip_address = $opt_H ; - } -else { - usage(); - print "IP-Address format wrong\n"; - exit $ERRORS{'UNKNOWN'}; - } - -#if ($opt_p =~ m/^[0-9] - -my $port = $opt_p; - -my $community = $opt_C; - -my $fan = $opt_f ; - -#my $err_counter=0 ; -#my $err_status=""; - - my $fan_locale_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,3,0,$fan ); -# not used for the moment - gives no usable output -# if reused, enter at end of list to avoid renumbering ! - my $fan_present_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,4,0,$fan ); - my $fan_speed_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,6,0,$fan ); - my $fan_condition_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,7,1,9,0,$fan ); - my $count=1 ; - my $label ; - my @r_array=(); - my $q ; - my $diff ; - $warning=$warning/100 ; - $crititcal=$critical/100 ; - - -# get temperature, temperature_threshold bfore shutdown - my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ; - - if ($session->get_request_response ($fan_present_oid, $fan_locale_oid, $fan_speed_oid, $fan_condition_oid )) { - (my $bindings) = $session->decode_get_response ($session->{pdu_buffer}); - while ($bindings ne '') { - ($binding, $bindings) = &decode_sequence ($bindings) ; - ($oid,$value) = &decode_by_template ($binding,"%O%@"); - $r_array[$count]=&pretty_print($value); - $count++; - } - } else { - print "No response from agent\n"; - exit $ERRORS{'CRITICAL'}; - } - $result_fan_present= $r_array[1]; - $result_fan_locale= $r_array[2]; - $result_fan_speed= $r_array[3]; - $result_fan_condition=$r_array[4]; - - - if ( $result_fan_present != 3 || $result_fan_speed !=2 ) { - print "Fan ". $fan . " ".$CPQ_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - Critical: Fan ".$CPQ_FAN_PRESENT{$result_fan_present}.". Speed: ". $CPQ_FAN_SPEED{$result_fan_speed}.". Overall condition: ". $CPQ_FAN_OVERALL_COND{$result_fan_condition} ."\n" ; - exit $ERRORS{'CRITICAL'} ; - } - else { - print "Fan " .$fan . " ".$CPQ_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - OK: Fan ".$CPQ_FAN_PRESENT{$result_fan_present}.". Speed: ". $CPQ_FAN_SPEED{$result_fan_speed}.". Overall condition: ". $CPQ_FAN_OVERALL_COND{$result_fan_condition} ."\n" ; - exit $ERRORS{'OK'} ; - } - - -sub print_usage () { - print "Usage: $PROGNAME -H <host> -p <port> -C <community> -f <fannumber>\n"; - } - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1113 $\n '); - print "Copyright (c) 2003 Rainer Duffner\n "; - print_usage(); - print "\n"; - print "<host> = IP-Address or DNS-Name of the W2K-Server\n"; - print "<port> = SNMP-Port (normaly 161)\n"; - print "<community> = SNMP v1 community\n"; - print "<fannumber> = Fannumber (1, 2, 3 etc.)\n"; - } - -sub version () { - print_revision($PROGNAME,'$Revision: 1113 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - diff --git a/contrib/check_fan_fsc_present b/contrib/check_fan_fsc_present deleted file mode 100644 index 19f8e7f0..00000000 --- a/contrib/check_fan_fsc_present +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/perl -# -# -# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical] -# -# NetSaint host script to get the disk usage from NT snmp -# -# Changes and Modifications -# ========================= -# 3-Aug-2000 - Xavier Dusart -# Created -# 2003 - Rainer Duffner - -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} - - - -require 5.004; -use POSIX; -#use strict; -use Getopt::Std ; -use BER; -require 'SNMP_Session.pm'; -use vars qw($opt_H $opt_p $opt_C $opt_f $opt_h $PROGNAME); -use lib $main::runtimedir; -use utils qw($TIMEOUT %ERRORS &print_revision &usage &support); -use snmputil qw(%FSC_LOCALE %FSC_FAN_STATUS); - -delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer - -getopts('H:p:C:f:hV') ; - -my $ip_address=undef ; - -if ($opt_h) {&help();} - -if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA --Z0-9]*)*)$/) { - $ip_address = $opt_H ; - } -else { - usage(); - print "IP-Address format wrong\n"; - exit $ERRORS{'UNKNOWN'}; - } - -#if ($opt_p =~ m/^[0-9] - -my $port = $opt_p; - -my $community = $opt_C; - -my $fan = $opt_f ; - -#my $err_counter=0 ; -#my $err_status=""; - - my $fan_locale_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,4,0,$fan-1 ); -# not used for the moment - gives no usable output -# if reused, enter at end of list to avoid renumbering ! - my $fan_cur_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,8,0,$fan-1 ); - my $fan_nom_max_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,9,0,$fan-1 ); - my $fan_cur_max_speed_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,10,0,$fan-1 ); - my $fan_condition_oid = encode_oid (1,3,6,1,4,1,231,2,10,2,2,5,2,2,1,3,0,$fan-1 ); - my $count=1 ; - my $label ; - my @r_array=(); - my $q ; - my $diff ; - $warning=$warning/100 ; - $crititcal=$critical/100 ; - - -# get temperature, temperature_threshold bfore shutdown - my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ; - - if ($session->get_request_response ($fan_locale_oid, $fan_cur_speed_oid, $fan_nom_max_speed_oid, $fan_cur_max_speed_oid, $fan_condition_oid )) { - (my $bindings) = $session->decode_get_response ($session->{pdu_buffer}); - while ($bindings ne '') { - ($binding, $bindings) = &decode_sequence ($bindings) ; - ($oid,$value) = &decode_by_template ($binding,"%O%@"); - $r_array[$count]=&pretty_print($value); - $count++; - } - } else { - print "No response from agent\n"; - exit $ERRORS{'CRITICAL'}; - } - $result_fan_locale= $r_array[1]; - $result_fan_cur_speed= $r_array[2]; - $result_fan_nom_max_speed= $r_array[3]; - $result_fan_cur_max_speed= $r_array[4]; - $result_fan_condition=$r_array[5]; - - - if ( $result_fan_condition != "3" ) { - print "Fan ". $fan . " ".$FSC_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - Critical: Cur./Nom./Cur-Max-Speed: ". $result_fan_cur_speed."/". $result_fan_nom_max_speed."/".$result_fan_cur_max_speed.". Overall condition: ". $FSC_FAN_STATUS{$result_fan_condition} ."\n" ; - exit $ERRORS{'CRITICAL'} ; - } - else { - print "Fan " .$fan . " ".$FSC_LOCALE{$result_fan_locale}. " (".$result_fan_locale.") - OK: Cur./Nom./Cur-Max-Speed: ". $result_fan_cur_speed."/". $result_fan_nom_max_speed."/".$result_fan_cur_max_speed.". Overall condition: ". $FSC_FAN_STATUS{$result_fan_condition} ."\n" ; - exit $ERRORS{'OK'} ; - } - - -sub print_usage () { - print "Usage: $PROGNAME -H <host> -p <port> -C <community> -f <fannumber>\n"; - } - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1113 $\n '); - print "Copyright (c) 2003 Rainer Duffner\n "; - print_usage(); - print "\n"; - print "<host> = IP-Address or DNS-Name of the W2K-Server\n"; - print "<port> = SNMP-Port (normaly 161)\n"; - print "<community> = SNMP v1 community\n"; - print "<fannumber> = Fannumber (1, 2, 3 etc.)\n"; - } - -sub version () { - print_revision($PROGNAME,'$Revision: 1113 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - diff --git a/contrib/check_flexlm.pl b/contrib/check_flexlm.pl deleted file mode 100644 index 8fa0e334..00000000 --- a/contrib/check_flexlm.pl +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/local/bin/perl -# -# usage: -# check_flexlm.pl license_file -# -# Check available flexlm license managers. -# Use lmstat to check the status of the license server -# described by the license file given as argument. -# Check and interpret the output of lmstat -# and create returncodes and output. -# -# Contrary to the nagios concept, this script takes -# a file, not a hostname as an argument and returns -# the status of hosts and services described in that -# file. Use these hosts.cfg entries as an example -# -#host[anchor]=any host will do;some.address.com;;check-host-alive;3;120;24x7;1;1;1; -#service[anchor]=yodel;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yodel_lic -#service[anchor]=yeehaw;24x7;3;5;5;unix-admin;60;24x7;1;1;1;;check_flexlm!/opt/lic/licfiles/yeehaw_lic -#command[check_flexlm]=/some/path/libexec/check_flexlm.pl $ARG1$ -# -# Notes: -# - you need the lmstat utility which comes with flexlm. -# - set the correct path in the variable $lmstat. -# -# initial version: 9-10-99 Ernst-Dieter Martin edmt@infineon.com -# current status: looks like working -# -# Copyright Notice: Do as you please, credit me, but don't blame me -# - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print "No Answer from Client\n"; - exit 2; -}; -alarm(20); - -$lmstat = "/opt/lic/sw/cadadm/default/bin/lmstat"; - -$licfile = shift; - -#print "$licfile \n"; - -open CMD,"$lmstat -c $licfile |"; - -$serverup = 0; - -while ( <CMD> ) { - if ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*),[0-9]*@([-0-9a-zA-Z_]*)/ ) { - $ls1 = $1; - $ls2 = $2; - $ls3 = $3; - $lf1 = $lf2 = $lf3 = 0; - $servers = 3; - } elsif ( /^License server status: [0-9]*@([-0-9a-zA-Z_]*)/ ) { - $ls1 = $1; - $ls2 = $ls3 = ""; - $lf1 = $lf2 = $lf3 = 0; - $servers = 1; - } elsif ( / *$ls1: license server UP/ ) { - print "$ls1 UP, "; - $lf1 = 1 - } elsif ( / *$ls2: license server UP/ ) { - print "$ls2 UP, "; - $lf2 = 1 - } elsif ( / *$ls3: license server UP/ ) { - print "$ls3 UP, "; - $lf3 = 1 - } elsif ( / *([^:]*: UP .*)/ ) { - print " license server for $1\n"; - $serverup = 1; - } -} -if ( $serverup == 0 ) { - print " license server not running\n"; - exit 2; -} - -exit 0 if ( $servers == $lf1 + $lf2 + $lf3 ); -exit 1 if ( $servers == 3 && $lf1 + $lf2 + $lf3 == 2 ); -exit 2; diff --git a/contrib/check_frontpage b/contrib/check_frontpage deleted file mode 100644 index 21c5267b..00000000 --- a/contrib/check_frontpage +++ /dev/null @@ -1,151 +0,0 @@ -#! /usr/bin/perl -w -# -# $Id: check_frontpage 1112 2005-01-27 04:46:08Z stanleyhopcroft $ -# -# Check that FrontPage extensions appear to be working on a specified host. -# Currently only checks that the hit counter is not returning an error. -# -# Probably not a good idea to use this on a host that someone's counting -# the hits on, so create a separate vhost for frontpage extensions testing, -# or just install the extensions on the default/root host for your server, and -# point it against that hostname, running it against all vhosts on a server is -# probably rather wasteful. -# -# Kev Green, oRe Net (http://www.orenet.co.uk/). - - -use strict; -use lib "/usr/lib/nagios/plugins"; -use utils qw($TIMEOUT %ERRORS &print_revision &support); -use vars qw($PROGNAME); -use Getopt::Long; -use LWP; -use vars qw($opt_V $opt_h $verbose $opt_w $opt_c $opt_H); -my ($tt,$url,$response,$stime, $etime,$warning,$critical,$mimetype,$failtype,$temp,$message); -my $rt = 0; - -$PROGNAME = "check_frontpage"; -sub print_help (); -sub print_usage (); - -$ENV{'PATH'}=''; -$ENV{'BASH_ENV'}=''; -$ENV{'ENV'}=''; - -Getopt::Long::Configure('bundling'); -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "v" => \$verbose, "verbose" => \$verbose, - "w=s" => \$opt_w, "warning=s" => \$opt_w, - "c=s" => \$opt_c, "critical=s" => \$opt_c, - "H=s" => \$opt_H, "hostname=s" => \$opt_H); - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1112 $'); #' - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -$opt_H = shift unless ($opt_H); -print_usage() unless $opt_H; -my $host = $1 if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]+(\.[a-zA-Z0-9][-a-zA-Z0-9]+)*)$/); -print_usage() unless $host; - -($opt_c) || ($opt_c = shift) || ($opt_c = 120); -if ($opt_c =~ /([0-9]+)/) { - $critical = $1; -} else { - $critical = 10; -} - -($opt_w) || ($opt_w = shift) || ($opt_w = 60); -if ($opt_w =~ /([0-9]+)/) { - $warning = $1; -} else { - $warning = 5; -} - -# Guts go here, once we're through argument parsing and have warning and -# critical thresholds. -my $browser = LWP::UserAgent->new; - -my @urls = ( - # This is the "Hit Counter", which continues to work if frontpage extensions - # are 'uninstall'ed from the site, but not when they are 'fulluninstall'ed. - { - url => "_vti_bin/fpcount.exe?Page=_borders/right.htm|Image=4", - mimetype => "image/gif", - message => "None, or broken frontpage extensions on server, or virtual site 'fulluninstall'ed?", - failtype => "CRITICAL" - }, - # This is the "FrontPage Configuration Information" file, which is removed - # when you 'uninstall' the extensions from a site. - { - url => "_vti_inf.html", - mimetype => "text/html", - message => "Someone 'uninstall'ed extensions on virtual site?", - failtype => "WARNING" - } -); - -print "FRONTPAGE: "; - -foreach $temp (@urls) { - $url = $temp->{'url'}; - $mimetype = $temp->{'mimetype'}; - $failtype = $temp->{'failtype'}; - $message = $temp->{'message'}; - $stime = time(); - $response=$browser->get("http://".$host."/".$url); - $etime = time(); - $tt = $etime - $stime; - -# If we got a server error, or unknown output type, report back as critical. - if ($response->status_line !~ "^200") { - print $message." (".$response->status_line.")\r\n"; - exit $ERRORS{$failtype}; - } elsif ($response->content_type !~ $mimetype) { - print $message." (Wrong Content-type: ".$response->content_type.")\r\n"; - exit $ERRORS{$failtype}; - } else { - # Because we're dealing with multiple URL's - $rt += $tt; - } - -# Decide if the response time was critical or not. -# - if ($rt > $critical) { - print "Response time ".$rt." over critical threshold ".$critical."\r\n"; - exit($ERRORS{'CRITICAL'}); - } elsif ($rt > $warning) { - print "Response time ".$rt." over warning threshold ".$warning."\r\n"; - exit($ERRORS{'WARNING'}); - } -} -printf(" %s - %s second response time, ",$response->status_line, $rt); - -# If all the required URL's give the right responses quick enough, then we -# should be okay. -exit($ERRORS{'OK'}); - -sub print_usage () { - print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n"; - exit; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1112 $'); - print "Copyright (c) 2003 Kev Green\n"; - print "\n"; - print "FrontPage remains a copyright/trademark of Microsoft Corporation.\n"; - print_usage(); - print "\n"; - print "<warn> = Unknown.\n"; - print "<crit> = Server error from FrontPage extensions.\n\n"; - support(); -} diff --git a/contrib/check_hltherm.c b/contrib/check_hltherm.c deleted file mode 100644 index 85c989f5..00000000 --- a/contrib/check_hltherm.c +++ /dev/null @@ -1,209 +0,0 @@ -/****************************************************************************************** - * - * CHECK_HLTHERM.C - * - * Program: Hot Little Therm temperature plugin for Nagios - * License: GPL - * Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org) - * - * Last Modified: 02-28-2002 - * - * Command line: check_hltherm <probe> <wtemp> <ctemp> [-l label] [-s scale] [-lower] - * - * Description: - * - * This plugin checks the temperature of a given temperature probe on a - * Hot Little Therm digital thermometer. The plugin uses the 'therm' utility - * that is included with the HLT software to check the probe temperature. Both - * the HLT digital thermometer and software are produced by Spiderplant. See - * their website at http://www.spiderplant.com/hlt for more information. - * - *****************************************************************************************/ - -#include "config.h" -#include "common.h" -#include "popen.h" - -#define DEFAULT_TIMEOUT 10 /* default timeout in seconds */ - -#define HLTHERM_COMMAND "/usr/local/bin/therm" /* this should be moved out to the configure script */ - - -static void timeout_alarm_handler(int); /* author must provide */ -int process_arguments(int, char **); - -int timeout_interval=DEFAULT_TIMEOUT; - -double wtemp=0.0L; -double ctemp=0.0L; - -int check_lower_temps=FALSE; - -char probe[MAX_INPUT_BUFFER]=""; -char label[MAX_INPUT_BUFFER]="Temperature"; -char scale[MAX_INPUT_BUFFER]="Degrees"; - -FILE *fp; - - -int main(int argc, char **argv){ - int result=STATE_OK; - char command[MAX_INPUT_BUFFER]; - double temp=0.0L; - char input_buffer[MAX_INPUT_BUFFER]; - int found=0; - - /* process command line arguments */ - result=process_arguments(argc,argv); - - /* display usage if there was a problem */ - if(result==ERROR){ - printf("Incorrect arguments supplied\n"); - printf("\n"); - printf("Hot Little Therm temperature plugin for Nagios\n"); - printf("Copyright (c) 1999-2002 Ethan Galstad (nagios@nagios.org)\n"); - printf("Last Modified: 02-28-2002\n"); - printf("License: GPL\n"); - printf("\n"); - printf("Usage: %s <probe> <wtemp> <ctemp> [-l label] [-s scale] [-lower]\n",argv[0]); - printf("\n"); - printf("Options:\n"); - printf(" <wtemp> = Temperature necessary to result in a WARNING state\n"); - printf(" <ctemp> = Temperature necessary to result in a CRITICAL state\n"); - printf(" [label] = A descriptive label for the probe. Example: \"Outside Temp\"\n"); - printf(" [scale] = A descriptive label for the temperature scale. Example: \"Celsius\"\n"); - printf(" [-lower] = Evaluate temperatures with lower values being more critical\n"); - printf("\n"); - printf("This plugin checks the temperature of a given temperature probe on a\n"); - printf("Hot Little Therm digital thermometer. The plugin uses the 'therm' utility\n"); - printf("included with the HLT software to check the probe temperature. Both the\n"); - printf("HLT digital thermometer and software are produced by Spiderplant. See\n"); - printf("their website at http://www.spiderplant.com/hlt for more information.\n"); - printf("\n"); - return STATE_UNKNOWN; - } - - - result=STATE_OK; - - /* Set signal handling and alarm */ - if(signal(SIGALRM,timeout_alarm_handler)==SIG_ERR){ - printf("Cannot catch SIGALRM"); - return STATE_UNKNOWN; - } - - /* handle timeouts gracefully */ - alarm(timeout_interval); - - /* create the command line we're going to use */ - snprintf(command,sizeof(command),"%s %s",HLTHERM_COMMAND,probe); - command[sizeof(command)-1]='\x0'; - - /* run the command to check the temperature on the probe */ - fp=spopen(command); - if(fp==NULL){ - printf("Could not open pipe: %s\n",command); - return STATE_UNKNOWN; - } - - if(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){ - found=1; - temp=(double)atof(input_buffer); - } - - /* close the pipe */ - spclose(fp); - - if(result==STATE_OK){ - - if(found==0){ - printf("Therm problem - Could not read program output\n"); - result=STATE_CRITICAL; - } - else{ - if(check_lower_temps==TRUE){ - if(temp<=ctemp) - result=STATE_CRITICAL; - else if(temp<=wtemp) - result=STATE_WARNING; - } - else{ - if(temp>=ctemp) - result=STATE_CRITICAL; - else if(temp>=wtemp) - result=STATE_WARNING; - } - - printf("Therm %s: %s = %2.1f %s\n",(result==STATE_OK)?"ok":"problem",label,temp,scale); - } - } - - return result; - } - - -/* process command-line arguments */ -int process_arguments(int argc, char **argv){ - int x; - - /* not enough options were supplied */ - if(argc<4) - return ERROR; - - /* first option is always the probe name */ - strncpy(probe,argv[1],sizeof(probe)-1); - probe[sizeof(probe)-1]='\x0'; - - /* 2nd and 3rd options are temperature thresholds */ - wtemp=(double)atof(argv[2]); - ctemp=(double)atof(argv[3]); - - /* process all remaining arguments */ - for(x=5;x<=argc;x++){ - - /* we got the lower temperature option */ - if(!strcmp(argv[x-1],"-lower")) - check_lower_temps=TRUE; - - /* we got the label */ - else if(!strcmp(argv[x-1],"-l")){ - if(x<argc){ - strncpy(label,argv[x],sizeof(label)); - label[sizeof(label)-1]='\x0'; - x++; - } - else - return ERROR; - } - - /* we got the scale */ - else if(!strcmp(argv[x-1],"-s")){ - if(x<argc){ - strncpy(scale,argv[x],sizeof(scale)); - scale[sizeof(scale)-1]='\x0'; - x++; - } - else - return ERROR; - } - - /* else we got something else... */ - else - return ERROR; - } - - return OK; - } - - - -/* handle timeouts gracefully... */ -static void timeout_alarm_handler(int signo){ - - if(signo==SIGALRM){ - - kill(childpid[fileno(fp)],SIGKILL); - printf("Therm problem - Check timed out after %d seconds\n",timeout_interval); - exit(STATE_CRITICAL); - } - } diff --git a/contrib/check_hprsc.pl b/contrib/check_hprsc.pl deleted file mode 100755 index 7a856502..00000000 --- a/contrib/check_hprsc.pl +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/perl -wT -# -# Copyright (c) 2000 Hugo Gayosso -# -# Description: -# Nagios plug-in that monitors the resources on an HP-UX machine -# by querying the SNMP daemon -# -# License: General Public License (GPL) -# http://www.gnu.org/copyleft/gpl.txt -# -# ChangeLog -# - -# Requirements: Perl 5.005 or higher - -# Variable initialization -$ENV{'PATH'}=""; -$ENV{'ENV'}=""; -$ENV{'BASH_ENV'}=""; - - -if (-e "/usr/bin/snmpwalk") { - $snmpwalk = "/usr/bin/snmpwalk"; -} elsif (-e "/usr/local/bin/snmpwalk") { - $snmpwalk = "/usr/local/bin/snmpwalk"; -} - - -# HP-UX SNMP OIDs -$filesystemID1_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.1"; -$mounted_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.3"; -$totalspace_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.4"; -$freespace_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.6"; -$path_OID = ".1.3.6.1.4.1.11.2.3.1.2.2.1.10"; -$cpu_5min_OID = ".1.3.6.1.4.1.11.2.3.1.1.4"; - -use Getopt::Long; - -GetOptions( "check-filesystem" => \$chk_fs, - "show-filesystems" => \$show_fs, - "check-filesystemID" => \$chk_fsid, - "check-cpu" => \$chk_cpu, - "host=s" => \$target_host, - "community=s" => \$target_community, - "filesystemID1=i" => \$fsid1_opt, - "filesystem=s" => \$fs_opt, - "protocol:s" => \$proto_opt, - "warning=i" => \$warning_opt, - "critical=i" => \$critical_opt); - -$proto_opt = 1 - unless $proto_opt == 1 || - $proto_opt == '2c' || - $proto_opt == 3; - -if ($chk_fs) { - walk_data($snmpwalk, $target_host, $target_community, $mounted_OID,$proto_opt ); - walk_data($snmpwalk, $target_host, $target_community, $totalspace_OID,$proto_opt ); - walk_data($snmpwalk, $target_host, $target_community, $freespace_OID,$proto_opt ); check_filesystem($fs_opt, $warning_opt, $critical_opt); -} elsif ($show_fs) { - walk_data($snmpwalk, $target_host, $target_community, $filesystemID1_OID,$proto_opt); - walk_data($snmpwalk, $target_host, $target_community, $mounted_OID,$proto_opt ); - walk_data($snmpwalk, $target_host, $target_community, $path_OID,$proto_opt); - show_filesystem(); -} elsif ($chk_fsid){ - $totalspace_fsID_OID = "$totalspace_OID.$fsid1_opt"; - $freespace_fsID_OID = "$freespace_OID.$fsid1_opt"; - walk_data($snmpwalk, $target_host, $target_community, $totalspace_fsID_OID,$proto_opt); - walk_data($snmpwalk, $target_host, $target_community, $freespace_fsID_OID,$proto_opt); - check_filesystemID1($fsid1_opt, $warning_opt, $critical_opt); -} elsif ($chk_cpu) { - get_cpu_load($snmpwalk, $target_host, $target_community, $cpu_5min_OID,$proto_opt); - check_cpu_5min($cpu, $warning_opt, $critical_opt); -} else { - print "\n\nUsage:\n"; - print "Checking 5-min CPU Load:\n"; - print " $0 --check-cpu -warning <threshold> --critical <threshold> --host <yourhost> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n"; - print "Checking local filesystem mounted on a host:\n"; - print " $0 --show-filesystems --host <hostname> --community <SNMP community> --protocol <SNMP version [1|2c|3]>\n\n"; - print "Checking by filesystem name:\n"; - 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"; - print "Checking by filesystem ID:\n"; - 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"; -} - -sub get_cpu_load { - my ($snmpwalk, $target_host, $target_community, $OID,$vers) = @_; - die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|")); - - if ($pid) { # parent - while (<SNMPWALK>) { - my @snmpdata = split(/:/,$_); - $cpu = $snmpdata[1]/100; - } - close(SNMPWALK) or warn "kid exited $?"; - } else { # child - exec($snmpwalk,'-c',$target_community,'-v',$vers,$target_host,$OID) or die "can't exec program: $!"; - } -} - -sub walk_data { -#This function queries the SNMP daemon for the specific OID - my ($snmpwalk, $target_host, $target_community, $OID,$vers) = @_; - - die "cannot fork: $!" unless defined($pid = open(SNMPWALK, "-|")); - - if ($pid) { # parent - while (<SNMPWALK>) { - $output = $_; - sort_walk_data($output); - } - close(SNMPWALK) or warn "kid exited $?"; - } else { # child - exec($snmpwalk,'-c',$target_community,'-v',$vers,$target_host,$OID) or die "can't exec program: $!"; - } -} - -sub sort_walk_data { - my ($snmp_data) = @_; - @fields = split(/\./,$snmp_data); - $item = $fields[8]; - $filesystemID1 = $fields[9]; - @fields2 = split(/=/,$fields[10]); -# $filesystemID2 = $fields2[0]; - $value = $fields2[1]; - chomp($value); - if ($value =~ /"/) { - @fields3 = split(/"/,$value); - $value = $fields3[1]; - } - if ($item == 3) { - $mounted{$filesystemID1} = "$value"; - } elsif ($item == 4) { - $totalspace{$filesystemID1} = "$value"; - } elsif ($item == 6) { - $freespace{$filesystemID1} = "$value"; - } elsif ($item == 10) { - $filesystempath{$filesystemID1} = "$value"; - } -} - -sub show_filesystem { - print "\n\nfilesystemID1\tmounted filesystem\tfilesystem path\n"; - foreach $element (keys %mounted) { - print "$element\t$mounted{$element}\t\t$filesystempath{$element}\n"; - } - print "\n\n"; -} - -sub check_filesystem { - -# Warning = percentage of used space >= $warning and < $critical -# Critical = percentage of used space > $warning and >= $critical -# OK = percentage of used space < $warning and < $critical - - my ($mounted_filesystem, $warning, $critical) = @_; - foreach $element (keys %mounted) { - if ($mounted{$element} eq $mounted_filesystem) { - my $warning_result = $totalspace{$element}*(100-$warning)/100; - my $critical_result = $totalspace{$element}*(100-$critical)/100; - my $result_percent = $freespace{$element}*100/$totalspace{$element}; - if (($freespace{$element} <= $warning_result) && ($freespace{$element} > $critical_result)) { - printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 1; - } elsif ($freespace{$element} <= $critical_result) { - printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 2; - } else { - printf "Disk ok - %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 0; - } - } - } - print "$mounted_filesystem doesn't exist in $target_host\n\n"; - exit -1; -} - -sub check_filesystemID1{ -# Warning = percentage of used space >= $warning and < $critical -# Critical = percentage of used space > $warning and >= $critical -# OK = percentage of used space < $warning and < $critical - - my ($fsid1, $warning, $critical) = @_; - foreach $element (keys %totalspace) { - if ($element eq $fsid1) { - my $warning_result = $totalspace{$element}*(100-$warning)/100; - my $critical_result = $totalspace{$element}*(100-$critical)/100; - my $result_percent = $freespace{$element}*100/$totalspace{$element}; - if (($freespace{$element} <= $warning_result) && ($freespace{$element} >= $critical_result)) { - printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 1; - } elsif ($freespace{$element} <= $critical_result) { - printf "Only %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 2; - } else { - printf "Disk ok - %d M (%d%s) free\n",$freespace{$element}/1024,$result_percent,"%"; - exit 0; - } - } - } - print "$fsid1 doesn't exist in $target_host\n\n"; - exit -1; -} - -sub check_cpu_5min { - my ($cpu, $warn, $crit) = @_; - if ($cpu >= $crit) { - print "Critical- 5-min load: $cpu\n"; - exit 2; - } elsif ($cpu >= $warn) { - print "Warning - 5-min load: $cpu\n"; - exit 1; - } else { - print "Load ok - 5-min load: $cpu\n"; - exit 0; - } -} - - - diff --git a/contrib/check_hw.sh b/contrib/check_hw.sh deleted file mode 100644 index 9d3b5743..00000000 --- a/contrib/check_hw.sh +++ /dev/null @@ -1,66 +0,0 @@ -#! /bin/sh -# -# Tested on SuSE 9.1 Professional with the hwinfo-8.62-0.2 package installed. -# -# Before you can run this plugin, you must do: -# /usr/sbin/hwinfo --short > /etc/hw.original -# add to cron job: -# /usr/sbin/hwinfo --short > /etc/hw.current -# /usr/bin/diff /etc/hw.original /etc/hw.current > /tmp/hw.check -# -# -# Rok Debevc -- rok.debevc@agenda.si -# -# -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin - -PROGNAME=`basename $0` -PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` -REVISION=`echo '$Revision: 939 $' | sed -e 's/[^0-9.]//g'` - -. $PROGPATH/utils.sh - - -print_usage() { - echo "Usage: $PROGNAME" -} - -print_help() { - print_revision $PROGNAME $REVISION - echo "" - print_usage - echo "" - echo "This plugin checks hardware changes." - echo "" - support - exit 0 -} - -case "$1" in - --help) - print_help - exit 0 - ;; - -h) - print_help - exit 0 - ;; - --version) - print_revision $PROGNAME $REVISION - exit 0 - ;; - -V) - print_revision $PROGNAME $REVISION - exit 0 - ;; - *) - if `du /tmp/hw.check | cut -c 1|grep "^[0]" > /dev/null` ; then - echo No hardware is changed - exit 0 - else - echo ***hardware is changed*** look into /tmp/hw.check - exit 2 - fi - ;; -esac - diff --git a/contrib/check_ica_master_browser.pl b/contrib/check_ica_master_browser.pl deleted file mode 100755 index 922e7187..00000000 --- a/contrib/check_ica_master_browser.pl +++ /dev/null @@ -1,228 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: check_ica_master_browser.pl 1099 2005-01-25 09:09:33Z stanleyhopcroft $ - -# Revision 1.1 2005/01/25 09:09:33 stanleyhopcroft -# New plugin - checks that ICA master browser is what it should be (important for firewalled dialup) -# - -use strict ; - -use IO::Socket; -use IO::Select; -use Getopt::Long ; - -use lib qw(/usr/local/nagios/libexec) ; -use utils qw(%ERRORS &print_revision &support &usage); -use packet_utils qw(&pdump &tethereal) ; - -my $PROGNAME = 'check_ica_master_browser' ; - -# You might have to change this... - -my $PACKET_TIMEOUT = 1; - # Number of seconds to wait for further UDP packets -my $TEST_COUNT = 2; - # Number of datagrams sent without reply -my $BUFFER_SIZE = 1500; - # buffer size used for 'recv' calls. -my $ICA_PORT = 1604; - # what port ICA runs on. Unlikely to change. - -# End user config. - -my ($debug, $preferred_master, $bcast_addr, $ica_browser, $timeout) ; - -Getopt::Long::Configure('bundling', 'no_ignore_case'); -GetOptions - ("V|version" => \&version, - "h|help" => \&help, - "v|verbose" => \$debug, - "B|broadcast_addr:s" => \$bcast_addr, - "I|ica_browser:s" => \$ica_browser, - "P|preferred_master:s" => \$preferred_master, - "T|Packet_timeout:i" => \$timeout, -) ; - - -my $broadcast_addr = $1 if $bcast_addr and $bcast_addr =~ m#(\d+\.\d+\.\d+\.\d+)# ; -usage("Invalid broadcast address: $bcast_addr") - if $bcast_addr and not defined($broadcast_addr) ; - -usage("You must provide either the name of an ICA browser or the broadcast address of the subnet containing them\n") - unless ($ica_browser or $broadcast_addr) ; - -usage("You must provide the name or address of a preferred ICA master browser\n") - unless ($preferred_master) ; - -my $preferred_master_n = $preferred_master =~ m#(\d+\.\d+\.\d+\.\d+)# - ? $preferred_master - : inet_ntoa(scalar gethostbyname($preferred_master)) ; - -my $Timeout = $timeout || $PACKET_TIMEOUT ; - - # Definitions of query strings. Change at your own risk :) - # this info was gathered with tcpdump whilst trying to use an ICA client, - # so I'm not 100% sure of what each value is. - -my $bcast_helo = &tethereal(<<'End_of_Tethereal_trace', '1e') ; -0020 ff ff 04 d6 06 44 00 26 4a 76 1e 00 01 30 02 fd .....D.&Jv...0.. -0030 a8 e3 00 02 f5 95 9f f5 30 07 00 00 00 00 00 00 ........0....... -0040 00 00 00 00 00 00 01 00 ........ -End_of_Tethereal_trace - -my $direct_helo = &tethereal(<<'End_of_Tethereal_trace', '20') ; -0020 64 17 05 0f 06 44 00 28 ab b5 20 00 01 30 02 fd d....D.(.. ..0.. -0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0040 00 00 00 00 00 00 00 00 00 00 ........ -End_of_Tethereal_trace - -my $Udp = IO::Socket::INET->new( Proto => 'udp' ) - || die "Socket failure: $!"; - - # select is here to allow us to set timeouts on the connections. Otherwise they - # just 'stop' until a server appears. - -my $select = IO::Select->new($Udp) - || die "Select failure: $!"; - -$Udp->sockopt(SO_BROADCAST, 1 ); - -my ($remote_host, $buff, $destination, $raddr, $rport, $rhost, @remote_response); -my ($query_message, $send_addr, $this_test) ; - -$buff = ''; -$this_test = 0; - - # If there is no response to the first helo packet it will be resent - # up to $TEST_COUNT (see at the top). - -$query_message = $broadcast_addr ? $bcast_helo : $direct_helo ; -$destination = $broadcast_addr ? $broadcast_addr: $ica_browser ; -$send_addr = sockaddr_in($ICA_PORT, inet_aton($destination) ) ; - -while ( ++$this_test <= $TEST_COUNT && !$buff ) { - - print "Sending helo datagram. datagram number: ", $this_test, "\n" - if $debug ; - - print "Querying $destination for master browser\n" - if $debug ; - &pdump($query_message) - if $debug ; - $Udp->send($query_message, 0, $send_addr ); - if ( $select->can_read($Timeout) ) { - $remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 ); - } - - last - if $buff ; - sleep 1 ; - -} - - # Ok we've looped several times, looking for a response. If we don't have one - # yet, we simply mark the whole lot as being unavailable. - -unless ( $buff ) { - print "Failed. No response to helo datagram (master browser query) from $destination.\n" ; - exit $ERRORS{CRITICAL} ; -} - -($rport, $raddr) = sockaddr_in( $remote_host ); -$rhost = gethostbyaddr( $raddr, AF_INET ); -my @tmpbuf = unpack('C*', $buff ); -if ( $debug ) { - print "$rhost:$rport responded with: ",length($buff), " bytes\n"; - &pdump($buff) ; -} - - # Now we have a response, then we need to figure out the master browser, and - # query it for published applications... - -my $master_browser = join '.', @tmpbuf[32..35] ; -my ($master_browser_a) = gethostbyaddr(inet_aton($master_browser), AF_INET) =~ /^(\w+?)\./ ; - - # Ok should probably error check this, because it's remotely possible - # that a server response might be completely wrong... - -print "Master browser = $master_browser_a/$master_browser\n" - if $debug ; - -$send_addr = sockaddr_in($ICA_PORT, inet_aton($master_browser)); - -my $subject_clause = $bcast_addr ? "of the \"$destination\" subnet" : "known to ICA server \"$destination\"" ; - -if ( $master_browser eq $preferred_master_n ) { - print "Preferred master browser \"$preferred_master\" __is__ the master browser (\"$master_browser_a/$master_browser\") $subject_clause.\n" ; - exit $ERRORS{OK} ; -} else { - print "\"\u$preferred_master\" is __not__ the master browser (\"$master_browser_a/$master_browser\") $subject_clause: remote clients (dialup) may not find Published applications from Master Browser.\n" ; - exit $ERRORS{CRITICAL} ; -} - -close $Udp; - - -sub print_usage () { - print "Usage: $PROGNAME (-B <broadcast_address>| -I <citrix_server>) - P <preferred_master_browser>" ; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1099 $ '); - print "Copyright (c) 2002 Ed Rolison/Tom De Blende/S Hopcroft - -Perl Check Citrix Master Browser plugin for Nagios. - -Returns OK if the Citrix master browser is that given by the -P option. - -The plugin works by - If the -B option is specified, sends a broadcast helo to find the address of the Citrix master browser in the specified subnet. - return critical if there is no reply; - Else if the -I option is specified - send a direct helo to the specified server until there is a response (containing the address of the Citrix master browser) - - - return Critical if the response does not contain the address of the 'preferred master browser' (-P option). - return OK - - How ICA Clients Use the Master ICA Browser. - -Citrix ICA Clients must locate the master browser to get the address of a server or published application. - -The Citrix ICA Client can locate the master browser by sending out broadcast packets, or, -if the address of a Citrix server is specified in the Citrix ICA Client or in an ICA file, -the ICA Client locates the master browser by sending directed packets to the specified address. -The ICA Client requests the address of the ICA master browser from the Citrix server. - -"; - print_usage(); - print ' --B, --broadcast_address:STRING - The broadcast address that should contain Citrix master browser. This option takes precedence over -I. --I, --ica_browser:STRING - Optional name or address of an ICA server that could be the master browser (used when broadcast not possible). --P, --preferred_master:STRING - Name or address of the ICA server that _should_ be the master browser. - Required. --T, --packet-timeout:INTEGER - Time to wait for UDP packets (default 1 sec). --v, --verbose - Debugging output. --h, --help - This stuff. - -'; - support(); -} - -sub version () { - print_revision($PROGNAME,'$Revision: 1099 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - diff --git a/contrib/check_ica_metaframe_pub_apps.pl b/contrib/check_ica_metaframe_pub_apps.pl deleted file mode 100755 index 0edbdcaf..00000000 --- a/contrib/check_ica_metaframe_pub_apps.pl +++ /dev/null @@ -1,381 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: check_ica_metaframe_pub_apps.pl 1098 2005-01-25 09:07:39Z stanleyhopcroft $ - -# Revision 1.1 2005/01/25 09:07:39 stanleyhopcroft -# Replacement (structured name mainly) for check_citrix: check of ICA browse service -# -# Revision 1.1 2005-01-25 17:00:24+11 anwsmh -# Initial revision -# - -use strict ; - -use IO::Socket; -use IO::Select; -use Getopt::Long ; - -my ($bcast_addr, $timeout, $debug, @citrix_servers, $crit_pub_apps, $warn_pub_apps, $long_list) ; - -use lib qw(/usr/local/nagios/libexec) ; -use utils qw(%ERRORS &print_revision &support &usage) ; -use packet_utils qw(&pdump &tethereal) ; - -my $PROGNAME = 'check_ica_metaframe_pub_apps' ; - -sub print_help (); -sub print_usage (); -sub help (); -sub version (); - - # You might have to change this... - -my $PACKET_TIMEOUT = 1; - # Number of seconds to wait for further UDP packets -my $TEST_COUNT = 2; -# Number of datagrams sent without reply -my $BUFFER_SIZE = 1500; - # buffer size used for 'recv' calls. -my $LONG_LIST = 0 ; - # this is for if you have many published applications. - # if you set it, it won't do any harm, but may slow the test - # down a little. (Since it does a 'recv' twice instead of - # once and therefore may have to wait for a timeout). -my $ICA_PORT = 1604; - # what port ICA runs on. Unlikely to change. - -Getopt::Long::Configure('bundling', 'no_ignore_case'); -GetOptions - ("V|version" => \&version, - "h|help" => \&help, - "v|verbose" => \$debug, - "B|broadcast_addr:s" => \$bcast_addr, - "C|citrix_servers:s" => \@citrix_servers, - "L|long_list" => \$long_list, - "P|crit_pub_apps:s" => \$crit_pub_apps, - "T|Packet_timeout:i" => \$timeout, - "W|warn_pub_apps:s" => \$warn_pub_apps, -) ; - - -my $broadcast_addr = $1 if $bcast_addr and $bcast_addr =~ m#(\d+\.\d+\.\d+\.\d+)# ; -usage("Invalid broadcast address: $bcast_addr\n") - if $bcast_addr and not defined($broadcast_addr) ; - -usage("You must provide either the names of citrix servers or the broadcast address of the subnet containing them\n") - unless (@citrix_servers or $broadcast_addr) ; - -my @target = defined $broadcast_addr ? ($broadcast_addr) : @citrix_servers ; - -usage("You must provide the names of the published applications that the Citrix browser should be advertising\n") - unless $crit_pub_apps or $warn_pub_apps ; - -my $Timeout = $timeout - if defined $timeout ; -$Timeout = $PACKET_TIMEOUT - unless defined $Timeout ; -$long_list = $LONG_LIST - unless defined $long_list ; - -my @crit_pub_apps = $crit_pub_apps ? split(/,/, $crit_pub_apps) : () ; -my @warn_pub_apps = $warn_pub_apps ? split(/,/, $warn_pub_apps) : () ; - - # Definitions of query strings. Change at your own risk :) - # this info was gathered with tcpdump whilst trying to use an ICA client, - # so I'm not 100% sure of what each value is. - -my $bcast_helo = &tethereal(<<'End_of_Tethereal_trace', '1e') ; -0020 ff ff 04 d6 06 44 00 26 4a 76 1e 00 01 30 02 fd .....D.&Jv...0.. -0030 a8 e3 00 02 f5 95 9f f5 30 07 00 00 00 00 00 00 ........0....... -0040 00 00 00 00 00 00 01 00 ....... -End_of_Tethereal_trace - -my $bcast_query_app = &tethereal(<<'End_of_Tethereal_trace', '24') ; -0020 64 17 04 50 06 44 00 2c 85 6a 24 00 01 32 02 fd d..P.D.,.j$..2.. -0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0040 00 00 00 00 00 00 21 00 02 00 00 00 00 00 ......!...... -End_of_Tethereal_trace - -my $direct_helo = &tethereal(<<'End_of_Tethereal_trace', '20') ; -0020 64 17 05 0f 06 44 00 28 ab b5 20 00 01 30 02 fd d....D.(.. ..0.. -0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0040 00 00 00 00 00 00 00 00 00 00 ......... -End_of_Tethereal_trace - -my $direct_query_app = &tethereal(<<'End_of_Tethereal_trace', '2c') ; -0020 64 17 05 10 06 44 00 34 7a 9a 2c 00 02 32 02 fd d....D.4z.,..2.. -0030 a8 e3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ -0040 00 00 00 00 00 00 21 00 02 00 01 00 00 00 00 00 ......!......... -0050 00 00 00 00 00 00 ...... -End_of_Tethereal_trace - -my $Udp = IO::Socket::INET->new( Proto => 'udp' ) - || die "Socket failure: $!"; - - # Select is here to allow us to set timeouts on the connections. - # Otherwise they just 'stop' until a server appears. - -my $select = IO::Select->new($Udp) - || die "Select failure: $!"; - # Helo needs to be broadcastt, but query does not. -$Udp->sockopt(SO_BROADCAST, 1 ); - -my ($remote_host, $buff, $buff2, $raddr, $rport, $rhost, @remote_response); -my ($query_message, $send_addr, $this_test) ; - -$buff = $buff2 = ''; -$this_test = 0; - - # If there is no response to the first helo packet it will be resent - # up to TEST_COUNT (see at the top). - -while ( ++$this_test <= $TEST_COUNT && !$buff ) { - - print "Sending helo datagram. datagram number: ", $this_test, "\n" - if $debug ; - - # If we have multiple targets, we probe each of them until we get a - # response... - - foreach my $destination (@target) { - $query_message = $broadcast_addr ? $bcast_helo : $direct_helo ; - print "Querying $destination for master browser\n" - if $debug ; - $send_addr = sockaddr_in($ICA_PORT, inet_aton($destination) ); - &pdump($query_message) - if $debug ; - $Udp->send($query_message, 0, $send_addr ); - if ( $select->can_read($Timeout) ) { - $remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 ); - } - - last - if $buff ; - sleep 1 ; - - } -} - - # Ok we've looped several times, looking for a response. If we don't have one - # yet, we simply mark the whole lot as being unavailable. - -unless ( $buff ) { - print "Failed. No response to helo datagram (master browser query) from ", $broadcast_addr ? $broadcast_addr : "@citrix_servers", ".\n" ; - exit $ERRORS{CRITICAL} ; -} - -($rport, $raddr) = sockaddr_in( $remote_host ); -$rhost = gethostbyaddr( $raddr, AF_INET ); -my @tmpbuf = unpack('C*', $buff ); -if ( $debug ) { - print "$rhost:$rport responded with: ", length($buff), " bytes\n"; - &pdump($buff) ; -} - - # Now we have a response, then we need to figure out the master browser, and - # query it for published applications... - -my $master_browser = join '.', @tmpbuf[32..35] ; - - # Ok should probably error check this, because it's remotely possible - # that a server response might be completely wrong... - -print "Master browser = $master_browser\n" - if $debug ; - -$send_addr = sockaddr_in($ICA_PORT, inet_aton($master_browser)); - -if ( $broadcast_addr ) { - print "using broadcast query\n" - if $debug ; - $query_message = $bcast_query_app; -} else { - print "using directed query\n" - if $debug ; - $query_message = $direct_query_app; -} - - # Now we send the appropriate query string, to the master browser we've found. - -$buff = ''; -$this_test = 0 ; - -print "Querying master browser for published application list\n" - if $debug ; - -while ( ++$this_test <= $TEST_COUNT && !$buff ) { - print "Sending application query datagram. datagram number: ", $this_test, "\n" - if $debug ; - &pdump($query_message) - if $debug ; - $Udp->send($query_message, 0, $send_addr); - - if ( $select->can_read($Timeout) ) { - $remote_host = $Udp->recv($buff, $BUFFER_SIZE, 0 ); - # $buff = substr($buff, 32) ; - # Hope that ICA preamble is first 32 bytes - } - - # Long application lists are delivered in multiple packets - - my $buff2 = '' ; - while ( $long_list && $select->can_read($Timeout) ) { - $remote_host = $Udp->recv($buff2, $BUFFER_SIZE, 0); - $buff .= $buff2 - if $buff2 ; - # $buff .= substr($buff2, 32) if $buff2 ; - # Hope that ICA preamble is first 32 bytes - } - - last if $buff ; - sleep 1 ; - -} - -unless ( $buff ) { - print "Failed. No response to application query datagram from ", $master_browser, ".\n" ; - exit $ERRORS{CRITICAL} ; -} - - # we got a response from a couple of retries of the app query - -($rport, $raddr) = sockaddr_in ( $remote_host ); -$rhost = gethostbyaddr ( $raddr, AF_INET ); -if ( $debug ) { - print "$rhost:$rport responded to app query with: ", length($buff), " bytes\n"; - &pdump($buff) ; -} - -my $app_list = $buff ; - # delete nulls in unicode - # but only if there is unicode (usually from - # broadcast query) - -$app_list =~ s/(?:(\w| |-)\x00)/$1/g - if $app_list =~ /(?:(?:(?:\w| |-)\x00){3,})/ ; - # FIXME an application name is - # 3 or more unicoded characters - - # FIXME locale - # extract null terminated strings - -my (@clean_app_list, $clean_app_list) ; -$clean_app_list = join(',', @clean_app_list = $app_list =~ m#([A-Za-z](?:\w| |-|[ÄÖÜäöüß])+?(?=\x00))#g ) ; - - # patch for German umlauts et al from Herr Mike Gerber. - - # $clean_app_list = join(',', @clean_app_list = $app_list =~ m#([A-Z](?:\w| |-)+?(?=\x00))#g ) ; - - # FIXME everyones apps don't start with caps - -print qq(Received list of applications: "$clean_app_list".\n) - if $debug ; - -if ( scalar @crit_pub_apps and my @missing = &simple_diff(\@clean_app_list, \@crit_pub_apps) ) { - print qq(Failed. "@missing" not found in list of published applications), - qq(" $clean_app_list" from master browser "$master_browser".\n) ; - exit $ERRORS{CRITICAL} ; -} - -if ( my @missing = &simple_diff(\@clean_app_list, \@warn_pub_apps) ) { - print qq(Warning. "@missing" not found in list of published applications), - qq(" $clean_app_list" from master browser "$master_browser".\n) ; - exit $ERRORS{WARNING} ; -} - -my @x = (@crit_pub_apps, @warn_pub_apps) ; -my $blah = ( scalar(@x) == 1 - ? 'the published application "' . join(',', @x) . '" is available' - : 'the published applications "' . join(',', @x) . '" are available' ) ; - -print qq(Ok. Citrix master browser "$master_browser" reported that $blah.\n) ; -exit $ERRORS{OK} ; - - # sleep $Timeout; - # because otherwise we can get responses from - # the WRONG servers. DOH -close $Udp; - - -sub print_usage () { - print "Usage: $PROGNAME (-B <broadcast_address>| -C <citrix_server>..) -W <pub_app1,pub_app2..> -P <pub_app1,pub_app2,>\n"; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1098 $ '); - print "Copyright (c) 2002 Ed Rolison/Tom De Blende/S Hopcroft - -Perl Check Citrix plugin for Nagios. - -Returns OK if the Citrix master browser returns a 'published application' list that contain names specified by the -W or -P options - -The plugin works by - If the -B option is specified, sending a broadcast helo to find the address of the Citrix master browser in the specified subnet. - return critical if there is no reply; - Else if the -C option is specified - send a direct helo to the specified server until there is a response (containing the address of the Citrix master browser) - - Query the master browser (using a 'broadcast published applications query ' if -B) and compare the published applications returned - to those specified by -W and -P options - - return Critical if the published applications specified by -P is not a subset of the query responses; - return Warning if the published applications specified by -W is not a subset of the query responses; - return OK - -"; - print_usage(); - print ' --B, --broadcast_address=STRING - The broadcast address that should contain Citrix master browser. This option takes precedence over -C. --C, --citrix_server:STRING - Optional __name(s)__ of Citrix servers that could be the master browser (used when broadcast not possible). --L, --long_list - Set this if you have heaps of published applications (ie more than will fit in _one_ UDP packet) --P, --crit_published_app=STRING - Optional comma separated list of published application that must be in the response from the master browser. - Check returns critical otherwise. --T, --packet-timeout:INTEGER - Time to wait for UDP packets (default 1 sec). --W, --warn_published_app=STRING - Optional comma separated list of published application that should be in the response from the master browser. - Check returns warning otherwise. --v, --verbose - Debugging output. --h, --help - This stuff. - -'; - support(); -} - -sub version () { - print_revision($PROGNAME,'$Revision: 1098 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - - -sub simple_diff { - -my ( $a_list, $b_list) = @_ ; - - # simple set difference 'Recipe 4.7 Perl Cookbook', Christiansen and Torkington - - my (%seen, @missing) ; - - @seen{@$a_list} = () ; - - foreach my $item (@$b_list) { - push @missing, $item - unless exists $seen{$item} ; - } - - @missing ; -} - - - diff --git a/contrib/check_ica_program_neigbourhood.pl b/contrib/check_ica_program_neigbourhood.pl deleted file mode 100755 index 1f0fb455..00000000 --- a/contrib/check_ica_program_neigbourhood.pl +++ /dev/null @@ -1,618 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: check_ica_program_neigbourhood.pl 1097 2005-01-25 09:05:53Z stanleyhopcroft $ - -# Revision 1.1 2005/01/25 09:05:53 stanleyhopcroft -# New plugin to check Citrix Metaframe XP "Program Neighbourhood" -# -# Revision 1.1 2005-01-25 16:50:30+11 anwsmh -# Initial revision -# - -use strict ; - -use Getopt::Long; - -use utils qw($TIMEOUT %ERRORS &print_revision &support); -use LWP 5.65 ; -use XML::Parser ; - -my $PROGNAME = 'check_program_neigbourhood' ; -my ($debug, $xml_debug, $pn_server, $pub_apps, $app_servers, $server_farm, $usage) ; - -Getopt::Long::Configure('bundling', 'no_ignore_case') ; -GetOptions - ("V|version" => \&version, - "A|published_app:s" => \$pub_apps, - "h|help" => \&help, - 'usage|?' => \&usage, - "F|server_farm=s" => \$server_farm, - "P|pn_server=s" => \$pn_server, - "S|app_server=s" => \$app_servers, - "v|verbose" => \$debug, - "x|xml_debug" => \$xml_debug, -) ; - -$pn_server || do { - print "Name or IP Address of _one_ Program Neighbourhood server is required.\n" ; - &print_usage ; - exit $ERRORS{UNKNOWN} ; -} ; - -$pub_apps ||= 'Word 2003' ; -$pub_apps =~ s/["']//g ; -my @pub_apps = split /,\s*/, $pub_apps ; - -my @app_servers = split /,\s*/, $app_servers ; - -@app_servers || do { - print "IP Address of _each_ Application server in the Metaframe Citrix XP server farm is required.\n" ; - &print_usage ; - exit $ERRORS{UNKNOWN} ; -} ; - -my @non_ip_addresses = grep ! /\d+\.\d+\.\d+\.\d+/, @app_servers ; - -scalar(@non_ip_addresses) && do { - print qq(Application servers must be specified by IP Address (not name): "@non_ip_addresses".\n) ; - &print_usage ; - exit $ERRORS{UNKNOWN} ; -} ; - -$server_farm || do { - print "Name of Citrix Metaframe XP server farm is required.\n" ; - &print_usage ; - exit $ERRORS{UNKNOWN} ; -} ; - -my %xml_tag = () ; -my @tag_stack = () ; - -my $xml_p = new XML::Parser(Handlers => {Start => \&handle_start, - End => sub { pop @tag_stack }, - Char => \&handle_char}) ; - -# values required by Metaframe XP that don't appear to matter too much - -my $client_host = 'Nagios server (http://www.Nagios.ORG)' ; -my $user_name = 'nagios' ; -my $domain = 'Nagios_Uber_Alles' ; - -# end values required by Metaframe XP - -my $nilpotent_req = <<'EOR' ; -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"><NFuseProtocol version="1.1"> - <RequestProtocolInfo> - <ServerAddress addresstype="dns-port" /> - </RequestProtocolInfo> -</NFuseProtocol> -EOR - -my $server_farm_req = <<'EOR' ; -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> - <RequestServerFarmData> - <Nil /> - </RequestServerFarmData> -</NFuseProtocol> -EOR - -my $spec_server_farm_req = <<EOR ; -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> - <RequestAddress> - <Name> - <UnspecifiedName>$server_farm*</UnspecifiedName> - </Name> - <ClientName>$client_host</ClientName> - <ClientAddress addresstype="dns-port" /> - <ServerAddress addresstype="dns-port" /> - <Flags /> - <Credentials> - <UserName>$user_name</UserName> - <Domain>$domain</Domain> - </Credentials> - </RequestAddress> -</NFuseProtocol> -EOR - -my $app_req = <<EOR ; -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> - <RequestAddress> - <Name> - <UnspecifiedName>PUBLISHED_APP_ENCODED</UnspecifiedName> - </Name> - <ClientName>Nagios_Service_Check</ClientName> - <ClientAddress addresstype="dns-port"/> - <ServerAddress addresstype="dns-port" /> - <Flags /> - <Credentials> - <UserName>$PROGNAME</UserName> - <Domain>$domain</Domain> - </Credentials> - </RequestAddress> -</NFuseProtocol> -EOR - -my $ua = LWP::UserAgent->new ; -my $req = HTTP::Request->new('POST', "http://$pn_server/scripts/WPnBr.dll") ; - $req->content_type('text/xml') ; - -my $svr ; - -my @pubapp_encoded = map { my $x = $_ ; $x =~ s/(\W)/'&#' . ord($1) . ';'/eg; $x } @pub_apps ; - -my $error_tag_cr = sub { ! exists($xml_tag{ErrorId}) } ; - -my @app_reqs = ( - # { Content => url, Ok => ok_condition, Seq => \d+ } - - { Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 0 }, - { Content => $server_farm_req, Ok => sub { - ! exists($xml_tag{ErrorId}) && - exists( $xml_tag{ServerFarmName}) && - defined($xml_tag{ServerFarmName}) && - $xml_tag{ServerFarmName} eq $server_farm - }, Seq => 2 }, - { Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 4 }, - { Content => $spec_server_farm_req, Ok => sub { - ! exists($xml_tag{ErrorId}) && - exists( $xml_tag{ServerAddress}) && - defined($xml_tag{ServerAddress}) && - $xml_tag{ServerAddress} =~ /\d+\.\d+\.\d+\.\d+:\d+/ - }, Seq => 6 }, - { Content => $nilpotent_req, Ok => $error_tag_cr, Seq => 8 }, - { Content => $app_req, Ok => sub { - ! exists($xml_tag{ErrorId}) && - exists( $xml_tag{ServerAddress}) && - defined($xml_tag{ServerAddress}) && - (($svr) = split(/:/, $xml_tag{ServerAddress})) && - defined($svr) && - scalar(grep $_ eq $svr, @app_servers) - }, Seq => 10 } -) ; - -my $app_location ; - -foreach my $pub_app (@pub_apps) { - - my $pubapp_enc = shift @pubapp_encoded ; - my $app_req_tmp = $app_reqs[5]{Content} ; - $app_reqs[5]{Content} =~ s/PUBLISHED_APP_ENCODED/$pubapp_enc/ ; - - foreach (@app_reqs) { - - $req->content($_->{Content}) ; - - $debug && print STDERR "App: $pub_app Seq: $_->{Seq}\n", $req->as_string, "\n" ; - - my $resp = $ua->request($req) ; - - $debug && print STDERR "App: $pub_app Seq: ", $_->{Seq} + 1, "\n", $resp->as_string, "\n" ; - - $resp->is_error && do { - my $err = $resp->as_string ; - $err =~ s/\n//g ; - &outahere(qq(Failed. HTTP error finding $pub_app at seq $_->{Seq}: "$err")) ; - } ; - my $xml = $resp->content ; - - my $xml_disp ; - ($xml_disp = $xml) =~ s/\n//g ; - $xml_disp =~ s/ \s+/ /g ; - - &outahere($resp->as_string) - unless $xml ; - - my ($xml_ok, $whine) = &valid_xml($xml_p, $xml) ; - - $xml_ok || &outahere(qq(Failed. Bad XML finding $pub_app at eq $_->{Seq} in "$xml_disp".)) ; - - &{$_->{Ok}} || &outahere(qq(Failed. \"\&\$_->{Ok}\" false finding $pub_app at seq $_->{Seq} in "$xml_disp".)) ; - - # Ugly but alternative is $_->{Ok}->(). - # eval $_->{Ok} where $_->{Ok} is an - # expression returning a bool is possible. but - # sub { } prevent recompilation. - - } - - $app_reqs[5]{Content} = $app_req_tmp ; - - $app_location .= qq("$pub_app" => $svr, ) ; - -} - -substr($app_location, -2, 2) = '' ; -print qq(Ok. Citrix XML service located all published apps $app_location.\n) ; -exit $ERRORS{'OK'} ; - -sub outahere { - print "Citrix XML service $_[0]\n" ; - exit $ERRORS{CRITICAL} ; -} - -sub valid_xml { - my ($p, $input) = @_ ; - - %xml_tag = () ; - @tag_stack = () ; - - eval { - $p->parse($input) - } ; - - return (0, qq(XML::Parser->parse failed: Bad XML in "$input".!)) - if $@ ; - - if ( $xml_debug ) { - print STDERR pack('A4 A30 A40', ' ', $_, qq(-> "$xml_tag{$_}")), "\n" - foreach (keys %xml_tag) - } - - return (1, 'valid xml') - -} - - -sub handle_start { - push @tag_stack, $_[1] ; - - $xml_debug && print STDERR pack('A8 A30 A40', ' ', 'handle_start - tag', " -> '$_[1]'"), "\n" ; - $xml_debug && print STDERR pack('A8 A30 A60', ' ', 'handle_start - @tag_stack', " -> (@tag_stack)"), "\n" ; -} - -sub handle_char { - my $text = $_[1] ; - - !($text =~ /\S/ || $text =~ /^[ \t]$/) && return ; - - $text =~ s/\n//g ; - - my $tag = $tag_stack[-1] ; - - $xml_debug && print STDERR pack('A8 A30 A30', ' ', 'handle_char - tag', " -> '$tag'"), "\n" ; - $xml_debug && print STDERR pack('A8 A30 A40', ' ', 'handle_char - text', " -> '$text'"), "\n" ; - - $xml_tag{$tag} .= $text ; - -} - - -sub print_help() { - -# 1 2 3 4 5 6 7 8 -#12345678901234567890123456789012345678901234567890123456789012345678901234567890 - - print_revision($PROGNAME,'$Revision: 1097 $ '); - -my $help = <<EOHELP ; -Copyright (c) 2004 Karl DeBisschop/S Hopcroft - -$PROGNAME -P <pn_server> -S <svr1,svr2,..> -A <app1,app2,..> - -F <Farm> [-v -x -h -V] - -Check the Citrix Metaframe XP service by completing an HTTP dialogue with a Program -Neigbourhood server (pn_server) that returns an ICA server in the named Server farm -hosting the specified applications (an ICA server in a farm which runs some MS app). -EOHELP - - print $help ; - print "\n"; - print "\n"; - print_usage(); - print "\n"; - support(); -} - -sub print_usage () { - -# 1 2 3 4 5 6 7 8 -#12345678901234567890123456789012345678901234567890123456789012345678901234567890 - -my $usage = <<EOUSAGE ; -$PROGNAME -[-P | --pn_server] The name or address of the Citrix Metaframe XP - Program Neigbourhood server (required). -[-A | --pub_apps] The name or names of an application published by the - server farm (default 'Word 2003'). -[-F | --server_farm] The name of a Citrix Metaframe XP server farm. (required) -[-S | --app_servers] The _IP addresses_ of _all_ of the Farms ICA servers expected - to host the published application. - Enter as a comma separated string eg 'Srv1, Svr2, ..,Srvn'. - Since the PN servers round-robin the app servers to the clients, - _all_ the server farm addresses must be specified or the check - will fail (required). -[-v | --verbose] -[-h | --help] -[-x | --xml_debug] -[-V | --version] -EOUSAGE - - print $usage ; - -} - -sub usage { - &print_usage ; - exit $ERRORS{'OK'} ; -} - -sub version () { - print_revision($PROGNAME,'$Revision: 1097 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - -=begin comment - -This is the set of requests and responses transmitted between a Citrix Metaframe XP Program Neigbourhood (PN) client and a PN server. - -This dialogue was captured by and reconstructed from tcpdump. - -Citrix 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, ... -do not appear to do anything. - -req 0 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 220 -Connection: Keep-Alive - - -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"><RequestProtocolInfo><ServerAddress addresstype="dns-port" /></RequestProtocolInfo></NFuseProtocol> - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:40 GMT - - -resp 1 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:40 GMT -Content-type: text/xml -Content-length: 253 - - -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> - <ResponseProtocolInfo> - <ServerAddress addresstype="no-change"></ServerAddress> - </ResponseProtocolInfo> -</NFuseProtocol> - -req 2 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 191 -Connection: Keep-Alive - - -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"><RequestServerFarmData><Nil /></RequestServerFarmData></NFuseProtocol> - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:40 GMT - - -resp 3 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:40 GMT -Content-type: text/xml -Content-length: 293 - - -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> - <ResponseServerFarmData> - <ServerFarmData> - <ServerFarmName>FOOFARM01</ServerFarmName> - </ServerFarmData> - </ResponseServerFarmData> -</NFuseProtocol> - -req 4 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 220 -Connection: Keep-Alive - - -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"><RequestProtocolInfo><ServerAddress addresstype="dns-port" /></RequestProtocolInfo></NFuseProtocol> - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:55 GMT - - -resp 5 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:55 GMT -Content-type: text/xml -Content-length: 253 - - -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> - <ResponseProtocolInfo> - <ServerAddress addresstype="no-change"></ServerAddress> - </ResponseProtocolInfo> -</NFuseProtocol> - -req 6 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 442 -Connection: Keep-Alive - - -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> -<RequestAddress><Name>i - <UnspecifiedName>FOOFARM01*</UnspecifiedName> - </Name><ClientName>WS09535</ClientName> - <ClientAddress addresstype="dns-port" /> - <ServerAddress addresstype="dns-port" /> - <Flags /> - <Credentials> - <UserName>foo-user</UserName> - <Domain>some-domain</Domain> - </Credentials> -</RequestAddress></NFuseProtocol> - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:56 GMT - - -resp 7 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:12:56 GMT -Content-type: text/xml -Content-length: 507 - - -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> - <ResponseAddress> - <ServerAddress addresstype="dot-port">10.1.2.2:1494</ServerAddress> - <ServerType>win32</ServerType> - <ConnectionType>tcp</ConnectionType> - <ClientType>ica30</ClientType> - <TicketTag>10.1.2.2</TicketTag> - <SSLRelayAddress addresstype="dns-port">ica_svr01.some.domain:443</SSLRelayAddress> - </ResponseAddress> -</NFuseProtocol> - -req 8 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 220 -Connection: Keep-Alive - - -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"><RequestProtocolInfo><ServerAddress addresstype="dns-port" /></RequestProtocolInfo></NFuseProtocol> - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:13:29 GMT - - -resp 9 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:13:29 GMT -Content-type: text/xml -Content-length: 253 - - -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> - <ResponseProtocolInfo> - <ServerAddress addresstype="no-change"></ServerAddress> - </ResponseProtocolInfo> -</NFuseProtocol> - -req 10 -POST /scripts/WPnBr.dll HTTP/1.1 -Content-type: text/xml -Host: 10.1.2.2:80 -Content-Length: 446 -Connection: Keep-Alive - - -<?xml version="1.0" encoding="ISO-8859-1"?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> -<RequestAddress>i - <Name> - <UnspecifiedName>EXCEL#32;2003</UnspecifiedName> - </Name> - <ClientName>WS09535</ClientName> - <ClientAddress addresstype="dns-port" /> - <ServerAddress addresstype="dns-port" /> - <Flags /> - <Credentials><UserName>foo-user</UserName> - <Domain>some-domain</Domain> - </Credentials> -</RequestAddress>i -</NFuseProtocol> - -HTTP/1.1 100 Continue -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:13:29 GMT - - -resp 11 -HTTP/1.1 200 OK -Server: Citrix Web PN Server -Date: Thu, 30 Sep 2004 00:13:29 GMT -Content-type: text/xml -Content-length: 509 - - -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> - <ResponseAddress> - <ServerAddress addresstype="dot-port">10.1.2.14:1494</ServerAddress> - <ServerType>win32</ServerType> - <ConnectionType>tcp</ConnectionType> - <ClientType>ica30</ClientType> - <TicketTag>10.1.2.14</TicketTag> - <SSLRelayAddress addresstype="dns-port">ica_svr02.some.domain:443</SSLRelayAddress> - </ResponseAddress> -</NFuseProtocol> - -** One sees this XML on an error (there may well be other error XML also, but I haven't seen it) ** - -<?xml version="1.0" encoding="ISO-8859-1" ?> -<!DOCTYPE NFuseProtocol SYSTEM "NFuse.dtd"> -<NFuseProtocol version="1.1"> - <ResponseAddress> - <ErrorId>unspecified</ErrorId> - <BrowserError>0x0000000E</BrowserError> - </ResponseAddress> -</NFuseProtocol> - - -=end comment - -=cut - - -# You never know when you may be embedded ... - - diff --git a/contrib/check_inodes-freebsd.pl b/contrib/check_inodes-freebsd.pl deleted file mode 100644 index d66e5e3f..00000000 --- a/contrib/check_inodes-freebsd.pl +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/perl - -# check_inodes.pl for FreeBSD -# Designed on FreeBSD 4.6 (although this should not matter) -# parses df output, splits, and then takes variables -# df.pl -f mountpoint -w warningnumber -c critical number -# USE NUMBERS AND NOT PERCENTS FOR wanring and critical values -# -h is help -# -v is version -# Mountpoints: -# like / or /usr or /var (whatever you mount drives NOT the device names) -# Andrew Ryder - 20020804 - atr@mrcoffee.org - - -use strict; -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_w $opt_c $opt_f $verbose $PROGNAME); -use lib "/usr/local/libexec/nagios" ; -use utils qw($TIMEOUT %ERRORS &print_revision &support); - -my $df = "/bin/df"; -my $grep = "/usr/bin/grep"; - -$PROGNAME="df.pl"; - -sub print_help (); -sub print_usage (); - - -$ENV{'PATH'}=''; -$ENV{'BASH_ENV'}=''; -$ENV{'ENV'}=''; - -Getopt::Long::Configure('bundling'); -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "w=s" => \$opt_w, "warning=s" => \$opt_w, - "c=s" => \$opt_c, "critical=s" => \$opt_c, - "f=s" => \$opt_f, "filesystem=s" => \$opt_f); - - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 72 $ '); - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -($opt_w) || ($opt_w = shift) || ($opt_w = 50); -my $warning = $1 if ($opt_w =~ /([0-9]+)/); - -($opt_c) || ($opt_c = shift) || ($opt_c = 75); -my $critical = $1 if ($opt_c =~ /([0-9]+)/); - -if ($opt_c < $opt_w) { - print "Critical offset should be larger than warning offset\n"; - print_usage(); - exit $ERRORS{"UNKNOWN"}; -} - -($opt_f) || ($opt_f = "/"); - - -unless (-e $df) { - print "UNKNOWN: $df is not where df is\n"; - exit $ERRORS{'UNKNOWN'}; - } - -unless (-e $grep) { - print "UNKNOWN: $grep is not where grep is\n"; - exit $ERRORS{'UNKNOWN'}; - } - -unless (-d $opt_f) { - print "UNKNOWN: $opt_f is not a mount point\n"; - exit $ERRORS{'UNKNOWN'}; - } - - -my $state = $ERRORS{'UNKNOWN'}; -my $answer; - -open(DF, "$df -i $opt_f| $grep -v Filesystem |"); - -while (<DF>) { - - my ($fs,$onek,$used,$avail,$capacity,$iused,$ifree,$ipercent,$mounted) = split; - $ipercent =~ s/%//s; - - if ($ipercent > $opt_w) { - $state = $ERRORS{'WARNING'}; - $answer = "WARNING: $ipercent percent inodes free on $opt_f\n"; - } elsif ($ipercent > $opt_w) { - $state = $ERRORS{'CRITCAL'}; - $answer = "CRITICAL: $ipercent percent inodes free on $opt_f\n"; - } elsif ($ipercent < $opt_w) { - $state = $ERRORS{'OK'}; - $answer = "OK: $ipercent percent inodes free on $opt_f\n"; - } -} - -close(DF); - -print "$answer"; -exit $state; - -sub print_usage () { - print "Usage: $PROGNAME <filesystem> [-w <warn>] [-c <crit>]\n"; - print "Example: $PROGNAME /dev/ad0s1a -w 50 -c 75\n"; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 72 $'); - print "Copyright (c) 2002 Andrew Ryder\n"; - print "\n"; - print_usage(); - print "\n"; - print "<warn> = Inode Percent at which a warning message is returned. Defaults to 50.\n"; - print "<crit> = Inode Percent at which a critical message is returned..\n Defaults to 75.\n\n"; - support(); -} - - diff --git a/contrib/check_inodes.pl b/contrib/check_inodes.pl deleted file mode 100755 index 5767878f..00000000 --- a/contrib/check_inodes.pl +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/perl -############################################################################## -# This plugin uses df to gather filesystem statistics and check the percent # -# used of inodes. I've put a switch in here since i've got both aix and # -# linux systems...adjust for your syntax's results. # -# Note: the percentages passed in MUST NOT have % after them # -# No warranty is either implied, nor expressed herein. # -# # -############################################################################## - -$filesystem = $ARGV[0]; -$warnpercent = $ARGV[1]; -$critpercent = $ARGV[2]; - -#------Find out what kind of syntax to expect -$systype=`uname`; -chomp($systype); - -#------Make sure we got called with the right number of arguments -#------you could also put a check in here to make sure critical level is -#------greater than warning...but what the heck. -die "Usage: check_inodes filesystem warnpercent critpercent" unless @ARGV; - -if ($#ARGV < 2) { - die "Usage: check_inodes filesystem warnpercent critpercent"; -}#end if - -#------This gets the data from the df command -$inputline = `df -i $filesystem|grep -v "Filesystem"`; - -#------replaces all spaces with a single :, that way we can use split -$inputline =~ y/ /:/s; - -#------different oses give back different sets of columns from the df -i -#------(at least mine do). This way I can use this plugin on all my hosts -#------if neither of these work, add your own in, or if you've got one that -#------just flat out reports something different...well...perl is your friend. -SWITCH: { - if ($systype eq "Linux") { - ($fs,$inodes,$iused,$ifree,$ipercent,$mntpt) = split(/:/,$inputline); - last SWITCH; - }#end if - if ($systype eq "AIX") { - ($fs,$blks,$free,$percentused,$iused,$ipercent,$mntpt) = split(/:/,$inputline); - last SWITCH; - }#end if -}#end switch - -#------First we check for critical, since that is, by definition and convention -#------going to exceed the warning threshold -$ipercent =~ y/%//ds; - -if ($ipercent > $critpercent) { - print "CRITICAL: $filesystem inode use exceeds critical threshold $critpercent ($ipercent)"; - exit 1; -}# end if - -#------Next we check the warning threshold -if ($ipercent > $warnpercent) { - print "WARNING: $filesystem inode use exceeds warning threshold $warnpercent ($ipercent)"; - exit 2; -}# end if - - -#------thanks to the magic of procedural programming, we figure if we got here, -#------everything MUST be fine. -print "$filesystem inode use within limits ($ipercent)"; -exit 0; - diff --git a/contrib/check_ipxping.c b/contrib/check_ipxping.c deleted file mode 100644 index 937b921a..00000000 --- a/contrib/check_ipxping.c +++ /dev/null @@ -1,201 +0,0 @@ -/****************************************************************************************** - * - * CHECK_IPXPING.C - * - * Program: IPX ping plugin for Nagios - * License: GPL - * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) - * - * Last Modified: 09-24-1999 - * - * Command line: CHECK_IPXPING <dest_network> <dest_address> <wrtt> <crtt> - * - * Description: - * - * This plugin will use the /usr/bin/ipxping command to ping the specified host using the - * IPX protocol. Note: Linux users must have IPX support compiled into the kernerl and - * must have IPX configured correctly in order for this plugin to work. - * If the round trip time value is above the <wrtt> level, a STATE_WARNING is - * returned. If it exceeds the <crtt> level, a STATE_CRITICAL is returned. - * - * - * - * IMPORTANT!! - * - * This plugin will only work with the ipxping command that has been ported to Linux. - * The version for Sun takes different command line arguments and differs in its output. - * - *****************************************************************************************/ - -#include "config.h" -#include "common.h" -#include "netutils.h" -#include "popen.h" - -/* this should be moved out to the configure script! */ -#define IPXPING_COMMAND "/tmp/ipxping/ipxping" - -/* these should be moved to the common header file */ -#define MAX_IPXNET_ADDRESS_LENGTH 12 -#define MAX_IPXHOST_ADDRESS_LENGTH 18 - -int socket_timeout=DEFAULT_SOCKET_TIMEOUT; -char dest_network[MAX_IPXNET_ADDRESS_LENGTH]; -char dest_address[MAX_IPXHOST_ADDRESS_LENGTH]; -int wrtt; -int crtt; - -int process_arguments(int,char **); - -FILE * spopen(const char *); -int spclose(FILE *); - -int main(int argc, char **argv){ - char command_line[MAX_INPUT_BUFFER]; - int rtt; - int bytes_returned; - int result=STATE_OK; - FILE *fp; - char input_buffer[MAX_INPUT_BUFFER]; - char *substr; - int current_line; - - if(process_arguments(argc,argv)!=OK){ - printf("Incorrect arguments supplied\n"); - printf("\n"); - printf("IPX ping plugin for Nagios\n"); - printf("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n"); - printf("Last Modified: 09-24-1999\n"); - printf("License: GPL\n"); - printf("\n"); - printf("Usage: %s <dest_network> <dest_address> <wrtt> <crtt> [-to to_sec]\n",argv[0]); - printf("\n"); - printf("Options:\n"); - printf(" <dest_network> = IPX network that the remote host lies on. (Hex Format - 00:00:00:00)\n"); - printf(" <dest_address> = MAC address of the remote host. (Hex Format - 00:00:00:00:00:00)\n"); - printf(" <wrtt> = Round trip time in milliseconds necessary to result in a WARNING state\n"); - printf(" <crtt> = Round trip time in milliseconds necessary to result in a CRITICAL state\n"); - printf(" [to_sec] = Seconds before we should timeout waiting for ping result. Default = %d sec\n",DEFAULT_SOCKET_TIMEOUT); - printf("\n"); - printf("Notes:\n"); - printf("This plugin will use the /usr/bin/ipxping command to ping the specified host using\n"); - printf("the IPX protocol. IPX support must be compiled into the kernel and your host must\n"); - printf("be correctly configured to use IPX before this plugin will work! An RPM package of\n"); - printf("the ipxping binary can be found at...\n"); - printf("http://www.rpmfind.net/linux/RPM/contrib/libc5/i386/ipxping-0.0-2.i386.shtml\n"); - printf("\n"); - return STATE_UNKNOWN; - } - - /* create the command line to use... */ - sprintf(command_line,"%s %s %s",IPXPING_COMMAND,dest_network,dest_address); - - /* initialize alarm signal handling */ - signal(SIGALRM,socket_timeout_alarm_handler); - - /* set socket timeout */ - alarm(socket_timeout); - - /* run the command */ - fp = spopen(command_line); - if(fp==NULL){ - printf("Unable to open pipe: %s",command_line); - return STATE_UNKNOWN; - } - - current_line=0; - while(fgets(input_buffer,MAX_INPUT_BUFFER-1,fp)){ - - current_line++; - - /* skip the first line of the output */ - if(current_line==1) - continue; - - /* we didn't get the "is alive" */ - if(current_line==2 && !strstr(input_buffer,"is alive")) - result=STATE_CRITICAL; - - /* get the round trip time */ - if(current_line==3){ - substr=strtok(input_buffer,":"); - substr=strtok(NULL,"\n"); - rtt=atoi(substr); - } - - /* get the number of bytes returned */ - if(current_line==4 && strstr(input_buffer,"bytes returned")){ - bytes_returned=atoi(input_buffer); - } - } - - /* close the pipe */ - spclose(fp); - - /* reset the alarm */ - alarm(0); - - if(current_line==1 || result==STATE_CRITICAL) - printf("IPX Ping problem - No response from host\n"); - else{ - - if(rtt>crtt) - result=STATE_CRITICAL; - else if(rtt>wrtt) - result=STATE_WARNING; - - printf("IPX Ping %s - RTT = %d ms, %d bytes returned from %s %s\n",(result==STATE_OK)?"ok":"problem",rtt,bytes_returned,dest_network,dest_address); - } - - - return result; - } - - - -/* process all arguments passed on the command line */ -int process_arguments(int argc, char **argv){ - int x; - - /* no options were supplied */ - if(argc<5) - return ERROR; - - /* get the destination network address */ - strncpy(dest_network,argv[1],sizeof(dest_network)-1); - dest_network[sizeof(dest_network)-1]='\x0'; - - /* get the destination host address */ - strncpy(dest_address,argv[2],sizeof(dest_address)-1); - dest_address[sizeof(dest_address)-1]='\x0'; - - /* get the round trip time variables */ - wrtt=atoi(argv[3]); - crtt=atoi(argv[4]); - - /* process remaining arguments */ - for(x=6;x<=argc;x++){ - - /* we got the timeout to use */ - if(!strcmp(argv[x-1],"-to")){ - if(x<argc){ - socket_timeout=atoi(argv[x]); - if(socket_timeout<=0) - return ERROR; - x++; - } - else - return ERROR; - } - - /* else we got something else... */ - else - return ERROR; - } - - return OK; - } - - - - diff --git a/contrib/check_javaproc.pl b/contrib/check_javaproc.pl deleted file mode 100644 index b68764ef..00000000 --- a/contrib/check_javaproc.pl +++ /dev/null @@ -1,278 +0,0 @@ -#!/usr/bin/perl -w - -# -# Author: Wim Rijnders, 17-10-2002 -# -# Description: -# ----------- -# -# Nagios host script to check if any specified java processes are running. -# -# Implementation Notes: -# --------------------- -# -# check_disk_smb was used as a starting point, since it was written in perl. -# -# This script has been created and tested on Linux RH 7.1. -# -# I tried OS-X Darwin (BSD), but the ps command works differently. -# Notably, you can't get a combined list of child processes. The best approach -# appears to be to use 'ps -wwaxo command' combined with 'ps -M' (or suchlike) -# -######################################################################## -#### - -require 5.004; -use POSIX; -use strict; -use Getopt::Long; -use vars qw($opt_w $opt_c $verbose $classname); -use vars qw($PROGNAME); -use lib "utils.pm" ; -use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); - -$PROGNAME="check_javaprocs"; -sub getJavaList (); -sub check_ranges ($ $ $ $); - -Getopt::Long::Configure('bundling', 'no_ignore_case'); -GetOptions - ("V|version" => \&version, - "h|help" => \&help, - "v|verbose" => \$verbose, - "w|warning=s" => \$opt_w, - "c|critical=s" => \$opt_c, - "n|name=s" => \$classname - ); - - -my $state = 'OK'; -my $min_warn = undef -my $max_warn = undef; -my $min_crit = undef; -my $max_crit = undef; - - -($opt_w) || ($opt_w = shift); -check_ranges($opt_w,\$min_warn, \$max_warn, "warning"); -($opt_c) || ($opt_c = shift); -check_ranges($opt_c,\$min_crit, \$max_crit, "critical"); - - -# -# Determine # of running processes for the java programs that interest us. -# -my @javalist = getJavaList(); - -my $total = 0; -my $msgout = ""; -my @fields; - -if ( defined $classname ) { - - #filter out a single java process based on class name - foreach (@javalist) { - @fields = split(/\s+/, $_); - $total = $fields[-1] and last if $classname eq $fields[0]; - } - $msgout .= "$total processes for $classname\n"; -} else { - #Handle all java processes - $msgout .= "\n"; - foreach (@javalist) { - @fields = split(/\s+/, $_); - - $total += $fields[-1]; - $msgout .= " $fields[-1] processes for "; - $msgout .= (scalar @fields > 1)? $fields[0] : "unknown" ; - $msgout .= "\n"; - } - my $msgtotal = "$total java processes for ". scalar @javalist . " applications"; - - if ( defined $verbose ) { - $msgout = $msgtotal . $msgout; - } else { - $msgout = $msgtotal; - } - -} - -# -# Set the state with the data we now have accumulated -# Note that due to the order of testing, warnings have precedence over -# criticals. This is logical, since you should be able to create a criticals -# range which encompasses a warning range. eg. following should be possible: -# -# check_javaproc -w 5:10 -c 3:12 -# proper specification of the ranges is the responsibility of the script user. -# -$state = 'CRITICAL' if (defined $min_crit && $total < $min_crit); -$state = 'CRITICAL' if (defined $max_crit && $total > $max_crit); -$state = 'CRITICAL' if (!defined $min_crit && !defined $max_crit && $total==0 ); -$state = 'WARNING' if (defined $min_warn && $total < $min_warn); -$state = 'WARNING' if (defined $max_warn && $total > $max_warn); - -print $msgout; -print "$state\n" if ($verbose); -exit $ERRORS{$state}; - -################################### -# Support routines for Nagios -################################### -sub check_ranges($$$$) { - my ($opt, $min, $max, $rangename) = @_; - - if ( defined $opt ) { - if ( $opt =~ /^([0-9]*)\:([0-9]*)$/) { - $$min = $1 if $1 > 0; - $$max= $2 if $2 > 0; - } else { - usage("Invalid $rangename range: $opt\n"); - } - } - - if ( defined $$min && defined $$max ) { - usage("Min value of $rangename range larger than max value: $opt\n") if ( $$min > $$max); - } -} - -sub print_usage () { - print "Usage: $PROGNAME [-v] [-w <min:max>] [-c <min:max>] [ -n <classname>]\n"; -} - -sub print_help () { - revision(); - print "Copyright (c) 2002 by Wim Rijnders - -Perl Check java processes plugin for Nagios - -"; - print_usage(); - print " --v, --verbose - Return additional information. - Intended as a command-line aid, not recommended for Nagios script usage. - --w, --warning=INTEGER:INTEGER - Minimum and maximum number of processes outside of which a warning will be - generated. If omitted, no warning is generated. - --c, --critical=INTEGER:INTEGER - Minimum and maximum number of processes outside of which a critical will be - generated. If omitted, a critical is generated if no processes are running. - --n, --name=STRING - Name of class specified on the java command line (from which main() is run). - If omitted, all java processes are taken into account. - -"; - support(); -} - -sub revision() { - print_revision($PROGNAME,'$Revision: 211 $ '); -} - -sub version () { - revision(); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - -################################### -# Routines for delivering the data -################################### - -# -# Generate a formatted list of running java processes. -# -# Returns an array of strings having the following syntax: -# -# <java class running as main> <parameters if any> <#processes for this class> -# -sub getJavaList() { - - my @output; - - # Untaint - local $ENV{'PATH'} = '/bin:/usr/bin'; - local $ENV{'BASH_ENV'} = '~/.bashrc'; - - # We are only interested in the full command line - # The -H opstion is important for the order of the processes; - # this option ensures that all child processes are listed under - # their parents - @output=`ps -AHo \"\%a\" -ww`; - - #remove preceding whitespace and final EOL - foreach (@output) { - s/^\s*//; - chop; - } - - #Combine any consecutive processes with exactly the same command line - #into a single item - @output = checkSameLine(@output); - - #Filter out all java processes - my @javalist; - for (my $i = 0; $i < scalar @output; ++$i) { - push @javalist, $output[$i] if $output[$i] =~ /^\S*java/; - } - - foreach (@javalist) { - #The java statement at the beginning is redundant; remove it - s/^\S*java//; - - #remove all defines - s/\-D\S+//g; - - #remove classpath - s/\-(classpath|cp)\s+\S+//g; - - #remove any other parameters we don't want to see - s/\-server\s+//g; - s/\-X\S*\s+//g; - - #remove any redundant whitespaces at the beginning - s/^\s+//; - - } - - @javalist; -} - - -# -# Combine all consecutive lines with an identical command line -# to a signle line with a count at the end -# -sub checkSameLine { - my @input = @_; - my @output; - my $prevline= ""; - my $prevcount = 0; - - foreach my $a (@input) { - if ( $prevline eq $a) { - ++$prevcount; - } else { - push @output, $prevline . " " . ($prevcount + 1); - $prevcount = 0; - } - $prevline = $a; - } - - #don't forget the last item! - if ( $prevcount > 0 ) { - push @output, $prevline . " " . ($prevcount + 1); - } - - @output; -} - -#======= end check_javaproc ===== diff --git a/contrib/check_joy.sh b/contrib/check_joy.sh deleted file mode 100755 index 8783a59f..00000000 --- a/contrib/check_joy.sh +++ /dev/null @@ -1,69 +0,0 @@ -#! /bin/sh - -PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin - -PROGNAME=`basename $0` -PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'` -REVISION=`echo '$Revision: 2 $' | sed -e 's/[^0-9.]//g'` -STATUS="" - -. $PROGPATH/utils.sh - - -print_usage() { - echo "Usage: $PROGNAME /dev/js<#> <button #>" -} - -print_help() { - print_revision $PROGNAME $REVISION - echo "" - print_usage - echo "" - echo "This plugin checks a joystick button status using the " - echo "joyreadbutton utility from the joyd package." - echo "" - support - exit 0 -} - -if [ $# -ne 2 ]; then - print_usage - exit 0 -fi - -case "$1" in - --help) - print_help - exit 0 - ;; - -h) - print_help - exit 0 - ;; - --version) - print_revision $PROGNAME $REVISION - exit 0 - ;; - -V) - print_revision $PROGNAME $REVISION - exit 0 - ;; - /dev/js*) - joyreadbutton $1 $2 1>&1 1>/dev/null - STATUS=$? - if [ "$STATUS" -eq 0 ]; then - echo OK - exit 0 - elif [ "$STATUS" -eq 1 ];then - echo CRITICAL - exit 2 - else - echo UNKNOWN - exit -1 - fi - ;; - *) - print_usage - exit 0 - ;; -esac diff --git a/contrib/check_linux_raid.pl b/contrib/check_linux_raid.pl deleted file mode 100644 index 6650a42b..00000000 --- a/contrib/check_linux_raid.pl +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/perl -w - -# Copyright (c) 2002 ISOMEDIA, Inc. -# originally written by Steve Milton -# later updates by sean finney <seanius@seanius.net> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# Usage: check_raid [raid-name] -# Example: check_raid md0 -# WARNING md0 status=[UUU_U], recovery=46.4%, finish=123.0min - -use strict; -use lib "/usr/local/nagios/libexec"; -use utils qw(%ERRORS); - -# die with an error if we're not on Linux -if ($^O ne 'linux') { - print "This plugin only applicable on Linux.\n"; - exit $ERRORS{'UNKNOWN'}; -} - -sub max_state($$){ - my ($a, $b) = @_; - if ($a eq "CRITICAL" || $b eq "CRITICAL") { return "CRITICAL"; } - elsif ($a eq "WARNING" || $b eq "WARNING") { return "WARNING"; } - elsif ($a eq "OK" || $b eq "OK") { return "OK"; } - elsif ($a eq "UNKNOWN" || $b eq "UNKNOWN") { return "UNKNOWN"; } - elsif ($a eq "DEPENDENT" || $b eq "DEPENDENT") { return "DEPENDENT"; } - return "UNKNOWN"; -} - -my $nextdev; -if(defined $ARGV[0]) { $nextdev = shift; } -else { $nextdev = "md[0-9]+"; } - -my $code = "UNKNOWN"; -my $msg = ""; -my %status; -my %recovery; -my %resyncing; -my %finish; -my %active; -my %devices; - -while(defined $nextdev){ - open (MDSTAT, "< /proc/mdstat") or die "Failed to open /proc/mdstat"; - my $device = undef; - while(<MDSTAT>) { - if (defined $device) { - if (/(\[[_U]+\])/) { - $status{$device} = $1; - } elsif (/recovery =\s+(.*?)\s/) { - $recovery{$device} = $1; - ($finish{$device}) = /finish=(.*?min)/; - $device=undef; - } elsif (/resync =\s+(.*?)\s/) { - $resyncing{$device} = $1; - ($finish{$device}) = /finish=(.*?min)/; - $device=undef; - } elsif (/^\s*$/) { - $device=undef; - } - } elsif (/^($nextdev)\s*:/) { - $device=$1; - $devices{$device}=$device; - if (/\sactive/) { - $status{$device} = ''; # Shall be filled later if available - $active{$device} = 1; - } - } - } - $nextdev = shift; -} - -foreach my $k (sort keys %devices){ - if (!exists($status{$k})) { - $msg .= sprintf " %s inactive with no status information.", - $devices{$k}; - $code = max_state($code, "CRITICAL"); - } elsif ($status{$k} =~ /_/) { - if (defined $recovery{$k}) { - $msg .= sprintf " %s status=%s, recovery=%s, finish=%s.", - $devices{$k}, $status{$k}, $recovery{$k}, $finish{$k}; - $code = max_state($code, "WARNING"); - } else { - $msg .= sprintf " %s status=%s.", $devices{$k}, $status{$k}; - $code = max_state($code, "CRITICAL"); - } - } elsif ($status{$k} =~ /U+/) { - if (defined $resyncing{$k}) { - $msg .= sprintf " %s status=%s, resync=%s, finish=%s.", - $devices{$k}, $status{$k}, $resyncing{$k}, $finish{$k}; - $code = max_state($code, "WARNING"); - } else { - $msg .= sprintf " %s status=%s.", $devices{$k}, $status{$k}; - $code = max_state($code, "OK"); - } - } else { - if ($active{$k}) { - $msg .= sprintf " %s active with no status information.", - $devices{$k}; - $code = max_state($code, "OK"); - } else { - # This should't run anymore, but is left as a catch-all - $msg .= sprintf " %s does not exist.\n", $devices{$k}; - $code = max_state($code, "CRITICAL"); - } - } -} - -print $code, $msg, "\n"; -exit ($ERRORS{$code}); diff --git a/contrib/check_lmmon.pl b/contrib/check_lmmon.pl deleted file mode 100644 index bf4b4386..00000000 --- a/contrib/check_lmmon.pl +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/perl -# NetSaint Temp warning script -# Written by: Nathan LeSueur - -if ($#ARGV < 1) { -print "Usage: $0 <critical temp> <warning temp> <normal temp>\n"; -exit; } $crit = shift; $warn = shift; $norm = shift; if ($warn > -$crit) { print "Warning level cannot be greater than critical -level!\n"; exit; } @b = qx{/usr/local/bin/lmmon -s}; foreach(@b) { @c -= split(/ \/ /, $_); $d = $c[1]; } @e = split(/F/, $d); $f = $e[0]; - -$status = "$f degrees F\n"; - -if($f >= $crit) {print "CRITICAL - $status"; exit 2;} -if($f >= $warn) {print "WARNING - $status"; exit 1;} -if($f <= $norm && $f != 0) {print "OK - $status"; exit 0;} -else{print "UNKNOWN - unable to access smb\n"; exit (-1);} - - diff --git a/contrib/check_log2.pl b/contrib/check_log2.pl deleted file mode 100644 index f1533a0c..00000000 --- a/contrib/check_log2.pl +++ /dev/null @@ -1,202 +0,0 @@ -#!/usr/bin/perl -w -# -# $Id: check_log2.pl 1300 2005-12-16 18:41:45Z harpermann $ -# -# Log file regular expression detector for Nagios. -# Written by Aaron Bostick (abostick@mydoconline.com) -# Last modified: 05-02-2002 -# -# Thanks and acknowledgements to Ethan Galstad for Nagios and the check_log -# plugin this is modeled after. -# -# Usage: check_log2 -l <log_file> -s <seek_file> -p <pattern> [-n <negpattern>] -# -# Description: -# -# This plugin will scan arbitrary text files looking for regular expression -# matches. The text file to scan is specified with <log_file>. -# <log_seek_file> is a temporary file used to store the seek byte position -# of the last scan. This file will be created automatically on the first -# scan. <pattern> can be any RE pattern that perl's s/// syntax accepte. Be -# forewarned that a bad pattern will send this script into never never land! -# -# Output: -# -# This plugin returns OK when a file is successfully scanned and no pattern -# matches are found. WARNING is returned when 1 or more patterns are found -# along with the pattern count and the line of the last pattern matched. -# CRITICAL is returned when an error occurs, such as file not found, etc. -# -# Notes (paraphrased from check_log's notes): -# -# 1. The "max_attempts" value for the service should be 1, as this -# will prevent Nagios from retrying the service check (the -# next time the check is run it will not produce the same results). -# -# 2. The "notify_recovery" value for the service should be 0, so that -# Nagios does not notify you of "recoveries" for the check. Since -# pattern matches in the log file will only be reported once and not -# the next time, there will always be "recoveries" for the service, even -# though recoveries really don't apply to this type of check. -# -# 3. You *must* supply a different <log_Seek_file> for each service that -# you define to use this plugin script - even if the different services -# check the same <log_file> for pattern matches. This is necessary -# because of the way the script operates. -# -# Examples: -# -# Check for error notices in messages -# check_log2 -l /var/log/messages -s ./check_log2.messages.seek -p 'err' -# - - -BEGIN { - if ($0 =~ s/^(.*?)[\/\\]([^\/\\]+)$//) { - $prog_dir = $1; - $prog_name = $2; - } -} - -require 5.004; - -use lib $main::prog_dir; -use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); -use Getopt::Long; -my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks); - -sub print_usage (); -sub print_version (); -sub print_help (); - - # Initialize strings - $log_file = ''; - $seek_file = ''; - $critical = ''; - $re_pattern = ''; - $neg_re_pattern = ''; - $pattern_count = 0; - $pattern_line = ''; - $plugin_revision = '$Revision: 1300 $ '; - - # Grab options from command line - GetOptions - ("l|logfile=s" => \$log_file, - "s|seekfile=s" => \$seek_file, - "c|critical" => \$critical, - "p|pattern=s" => \$re_pattern, - "n|negpattern:s" => \$neg_re_pattern, - "v|version" => \$version, - "h|help" => \$help); - - !($version) || print_version (); - !($help) || print_help (); - - # Make sure log file is specified - ($log_file) || usage("Log file not specified.\n"); - # Make sure seek file is specified - ($seek_file) || usage("Seek file not specified.\n"); - # Make sure re pattern is specified - ($re_pattern) || usage("Regular expression not specified.\n"); - - # Open log file - open (LOG_FILE, $log_file) || die "Unable to open log file $log_file: $!"; - - # Try to open log seek file. If open fails, we seek from beginning of - # file by default. - if (open(SEEK_FILE, $seek_file)) { - chomp(@seek_pos = <SEEK_FILE>); - close(SEEK_FILE); - - # If file is empty, no need to seek... - if ($seek_pos[0] != 0) { - - # Compare seek position to actual file size. - # If file size is smaller - # then we just start from beginning i.e. file was rotated, etc. - ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat(LOG_FILE); - - if ($seek_pos[0] <= $size) { - seek(LOG_FILE, $seek_pos[0], 0); - } - } - } - - # Loop through every line of log file and check for pattern matches. - # Count the number of pattern matches and remember the full line of - # the most recent match. - while (<LOG_FILE>) { - if ($neg_re_pattern) { - if ((/$re_pattern/) && !(/$neg_re_pattern/)) { - $pattern_count += 1; - $pattern_line = $_; - } - } elsif (/$re_pattern/) { - $pattern_count += 1; - $pattern_line = $_; - } - } - - # Overwrite log seek file and print the byte position we have seeked to. - open(SEEK_FILE, "> $seek_file") || die "Unable to open seek count file $seek_file: $!"; - print SEEK_FILE tell(LOG_FILE); - - # Close seek file. - close(SEEK_FILE); - # Close the log file. - close(LOG_FILE); - - # Print result and return exit code. - if ($pattern_count) { - if ($critical) { - print "CRITICAL: "; - } else { - print "WARNING: "; - } - print "($pattern_count): $pattern_line"; - if ($critical) { - exit $ERRORS{'CRITICAL'}; - } else { - exit $ERRORS{'WARNING'}; - } - } else { - print "OK - No matches found.\n"; - exit $ERRORS{'OK'}; - } - -# -# Subroutines -# - -sub print_usage () { - print "Usage: $prog_name -l <log_file> -s <log_seek_file> -p <pattern> [-n <negpattern>] -c | --critical\n"; - print "Usage: $prog_name [ -v | --version ]\n"; - print "Usage: $prog_name [ -h | --help ]\n"; -} - -sub print_version () { - print_revision($prog_name, $plugin_revision); - exit $ERRORS{'OK'}; -} - -sub print_help () { - print_revision($prog_name, $plugin_revision); - print "\n"; - print "Scan arbitrary log files for regular expression matches.\n"; - print "\n"; - print_usage(); - print "\n"; - print "-l, --logfile=<logfile>\n"; - print " The log file to be scanned\n"; - print "-s, --seekfile=<seekfile>\n"; - print " The temporary file to store the seek position of the last scan\n"; - print "-p, --pattern=<pattern>\n"; - print " The regular expression to scan for in the log file\n"; - print "-n, --negpattern=<negpattern>\n"; - print " The regular expression to skip in the log file\n"; - print "-c, --critical\n"; - print " Return critical instead of warning on error\n"; - print "\n"; - support(); - exit $ERRORS{'OK'}; -} diff --git a/contrib/check_lotus.pl b/contrib/check_lotus.pl deleted file mode 100755 index 8bedced8..00000000 --- a/contrib/check_lotus.pl +++ /dev/null @@ -1,260 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: check_lotus.pl 1096 2005-01-25 09:04:26Z stanleyhopcroft $ - -# Revision 1.1 2005/01/25 09:04:26 stanleyhopcroft -# New plugin to check responsiveness of Louts Notes (v5 at least) servers -# -# Revision 1.10 2005-01-25 15:44:07+11 anwsmh -# 1 use packet_utils instead of hard coding subroutines (pdump and tethereal) -# 2 redo indentation using tabs (set at 4 spaces) -# - -use strict ; - -use IO::Socket; -use Getopt::Long ; - -my ($timeout, $debug, $lotus_host, $server, $indiv_dn, $packet_debug) ; - -use lib qw(/usr/local/nagios/libexec) ; -use utils qw($TIMEOUT %ERRORS &print_revision &support &usage) ; -use packet_utils qw(pdump &tethereal) ; - -my $PROGNAME = 'check_lotus_notes' ; - -sub print_help (); -sub print_usage (); -sub help (); -sub version (); - -my $TEST_COUNT = 2 ; - # Number of Lotus client hellos sent without reply -my $BUFFER_SIZE = 1500 ; - # buffer size used for 'recv' calls. -my $LOTUS_PORT = 1352 ; - -Getopt::Long::Configure('no_ignore_case'); -GetOptions - ("V|version" => \&version, - "h|help" => \&help, - "v|debug" => \$debug, - "vv|i_packet_debug" => \$packet_debug, - "H|lotus_host=s"=> \$lotus_host, - # "I|indivual_dn:s" => \$indiv_dn, - "S|server:s" => \$server, - "T|t_timeout:i" => \$timeout, -) ; - -usage("You must provide the DNS name or IP (v4) address of the Lotus server to be checked.\n") - unless $lotus_host and ( - $lotus_host =~ m#^\d+\.\d+\.\d+\.\d+$# or - $lotus_host =~ m#^[\w\._-]+$# - ) ; - -$server ||= $lotus_host - if $lotus_host =~ m#^[\w-]+$# ; - -usage("You must provide a server option unless the lotus_host option looks like an unqualified host name.\n") - unless $server ; - -$timeout ||= $TIMEOUT ; -$debug = 1 - if $packet_debug ; - -my $server_dn = "CN=\U$server" . '(?:/\w+=[\w -]+)*' ; - - # Definitions of query strings. Change at your own risk :) - # This info was gathered with tcpdump while using a Lotus Notes 5 client, - # so I'm not sure of what each value is. - -my $lotus_client_hello = &tethereal(<<'End_of_Tethereal_trace', '82') ; -0030 ff ff dc c5 00 00 82 00 00 00 77 00 00 00 02 00 ..........w..... -0040 00 40 02 0f 00 07 00 39 05 9e 45 54 ad ad 03 00 .@.....9..ET.... -0050 00 00 00 02 00 2f 00 00 00 00 00 00 00 00 00 40 ...../.........@ -0060 1f a0 af 19 d8 92 da 37 78 c9 ce 60 5e 35 b8 f7 .......7x..`^5.. -0070 4e 05 00 10 00 0d 00 00 00 00 00 00 00 00 00 00 N............... -0080 00 00 00 00 00 02 00 08 00 9c dc 22 00 7c 6f 25 ...........".|o% -0090 4a 08 00 10 00 00 00 00 00 00 00 00 00 00 00 00 J............... -00a0 00 00 00 00 00 04 00 10 00 ba ac 8c 49 67 ee a1 ............Ig.. -00b0 22 6f 63 bb 04 b4 75 0b 8f 00 "oc...u... -End_of_Tethereal_trace - - # XXXX - # Notes 5 accepts this - # _wrongly_ encoded DN - # but in general the - # server will reset - # the connection if - # it receives malformed - # packets. - -my $lotus_client_m1 = &tethereal(<<'End_of_Tethereal_trace', 'de') ; -0000 de 00 00 00 d4 00 00 00 13 00 00 40 01 00 9e 45 ...........@...E -0010 54 ad ad 03 00 00 00 00 02 00 29 13 23 00 b9 68 T.........).#..h -0020 25 00 9f 87 27 00 8f f4 25 00 00 00 88 00 24 00 %...'...%.....$. -0030 28 00 00 00 42 56 04 00 31 2e 30 00 42 43 01 00 (...BV..1.0.BC.. -0040 03 42 41 01 00 30 42 4c 02 00 76 02 4e 4e 50 00 .BA..0BL..v.NNP. -0050 cf ee 9d 19 99 ca e0 bf 97 d3 59 a1 c5 78 16 82 ..........Y..x.. -0060 76 09 8c 2c 96 ae 5a c1 15 bd 4e e9 b7 0f a9 d4 v..,..Z...N..... -0070 5a 03 d9 0d bc e4 7d 4f e0 f2 79 89 cf cd 23 19 Z.....}O..y...#. -0080 40 55 98 81 98 be d9 17 8d 69 8e 09 de c8 e8 92 @U.......i...... -0090 24 86 6f 5a 09 81 1f 71 be 29 b7 47 78 8c 2e 00 $.oZ...q.).Gx... -00a0 45 4e 04 00 95 63 00 00 4d 41 08 00 64 a1 b4 b3 EN...c..MA..d... -00b0 a1 01 45 c2 80 00 50 55 52 53 41 46 22 00 43 4e ..E...PURSAF".CN -00c0 3d 4d 72 20 46 6f 6f 2f 4f 55 3d 42 61 72 20 68 =Mr Foo/OU=Bar h -00d0 6f 74 65 6c 2f 4f 3d 42 61 7a 20 4a 75 6e 63 74 otel/O=Baz Junct -00e0 69 6f 6e ion -End_of_Tethereal_trace - -my $buff = ''; - -my $valid_resp_cr = sub { - my ($resp, $dn, $err_ind_sr) = @_ ; - if ( $resp =~ /($dn)/ ) { - return $1 - } else { - ($$err_ind_sr) = $resp =~ m#(CN=[\w -]+(?:/\w+=[\w -]+)*)# ; - return 0 ; - } -} ; - -my @send = ( - { Msg => 'Helo', Send => $lotus_client_hello, Ok => $valid_resp_cr }, - { Msg => 'm1', Send => $lotus_client_m1, Ok => $valid_resp_cr }, -) ; - -my $tcp ; - -eval { - - $tcp = IO::Socket::INET->new(Proto => 'tcp', PeerAddr => $lotus_host, PeerPort => $LOTUS_PORT, Timeout => $timeout) - # Some versions (eg 1.1603) croak on a connect failure .. -} ; - -&outahere("Connect to $lotus_host:$LOTUS_PORT failed:", $@) - if $@ || ! defined($tcp) ; - -my $found = '' ; - -foreach (@send) { - - print STDERR "Sending Lotus client $_->{Msg} to $lotus_host.\n" - if $debug ; - - &pdump($_->{Send}) - if $packet_debug ; - - eval { - - local $SIG{"ALRM"} = sub { die 'Alarm clock restart' } ; - - alarm($timeout) ; - - $tcp->send($_->{Send}, 0) || - &outahere("Send to $lotus_host failed: $!") ; - - defined( $tcp->recv($buff, $BUFFER_SIZE, 0 ) ) || - &outahere("Recv from $lotus_host failed: $!") - - } ; - - alarm(0) ; - - &outahere('Unexpected exception raised by eval:', $@) - if $@ and $@ !~ /Alarm clock restart/ ; - - &outahere("Timeout after $timeout secs - no response from $lotus_host") - if $@ and $@ =~ /Alarm clock restart/ ; - - &outahere("Lotus server $lotus_host reset connection - client protocol (malformed packet sent) error", $@) - if $@ and $@ =~ /reset/ ; - - &outahere("Empty recv buff after sending client $_->{Msg} and waiting $timeout secs. NB _no_ timeout exception.") - unless $buff ; - - &pdump($buff) - if $packet_debug ; - - my $err = '' ; - - &outahere(qq(Response from $lotus_host failed to match CN=$server/.. got "$err") ) - unless $found = $_->{Ok}->($buff, $server_dn, \$err) ; - - print STDERR "Received Ok reply from $lotus_host - found DN $found in response.\n" - if $debug ; - -} - -close $tcp; - -print "Ok. Lotus server $lotus_host responded with $found after ", scalar @send, " packet dialogue.\n" ; -exit $ERRORS{OK} ; - -=begin comment - -Normal response from Lotus Notes 5 server - -0000 74 00 00 00 69 00 00 00 03 00 00 40 02 0f 00 05 t...i......@.... -0010 00 3d 05 60 f0 3a 38 03 03 00 00 00 00 02 00 2f .=.`.:8......../ -0020 00 26 00 00 00 00 00 00 00 40 1f 3d 73 76 0e 57 .&.......@.=sv.W -0030 e0 d7 67 cd a3 50 10 e0 99 24 b4 43 4e 3d 43 42 ..g..P...$.CN=CB -0040 52 4e 4f 54 45 53 30 31 2f 4f 55 3d 53 45 52 56 RNOTES01/OU=SERV -0050 45 52 53 2f 4f 3d 49 50 41 75 73 74 72 61 6c 69 ERS/O=IPAustrali -0060 61 05 00 10 00 09 00 00 00 00 00 00 00 00 00 00 a............... -0070 00 00 00 00 00 00 - -=end comment - -=cut - -sub outahere { - print "Failed. @_.\n" ; - exit $ERRORS{CRITICAL} ; -} - -sub print_usage () { - print "Usage: $PROGNAME -H <lotus_host (name _or_ address)>..) [-S <lotus_server name> -T <timeout> -v ]\n"; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1096 $ '); - print "Copyright (c) 2004 Ed Rolison/S Hopcroft - -Perl Check Lotus Notes plugin for Nagios. - -Returns OK if the named server responds with its name. - -"; - print_usage(); - print ' --H, --lotus_host:STRING - Name or IP Address of Lotus server to be checked. --I, --individual_dn:NOT IMPLEMENTED - String of form CN=\w+(?:/OU=\w+)?/O=\w+ --S, --server:STRING - Alpha numeric string specifying the Lotus server name (the CN by which the server is known by - in the Domino directory). Defaults to host name if the host name does not look like an IP address. --T, --packet-timeout:INTEGER - Time to wait for TCP dialogue to complete = send + rcv times (default Nagios timeout [$TIMEOUT sec]). --v, --debug - Debugging output. --vv, --packet_debug - Packet dump. Please post to Nag users in the event of trouble with this plugin. --h, --help - This stuff. - -'; - support(); -} - -sub version () { - print_revision($PROGNAME,'$Revision: 1096 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - diff --git a/contrib/check_maxchannels.pl b/contrib/check_maxchannels.pl deleted file mode 100644 index a3ce525b..00000000 --- a/contrib/check_maxchannels.pl +++ /dev/null @@ -1,231 +0,0 @@ -#!/usr/bin/perl -w -# -# check_maxchannels.pl - nagios plugin -# -# -# Copyright (C) 2000 Christoph Kron -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# -# Report bugs to: ck@zet.net -# -# 11.01.2000 Version 1.0 - -use strict; - -use Net::SNMP; -use Getopt::Long; -&Getopt::Long::config('auto_abbrev'); - - -my $status; -my $TIMEOUT = 15; - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - - -my $state = "UNKNOWN"; -my $answer = ""; -my $snmpkey; -my $snmpoid; -my $key; -my $community = "public"; -my $port = 161; -my @snmpoids; -# free channels -my $snmpWanAvailableChannels = '1.3.6.1.4.1.529.4.23.0'; -# maximum channels -my $snmpWanSwitchedChannels = '1.3.6.1.4.1.529.4.24.0'; -my $snmpWanDisabledChannels = '1.3.6.1.4.1.529.4.25.0'; -my $snmpWanActiveChannels = '1.3.6.1.4.1.529.4.26.0'; -my $snmpWanNailedChannels = '1.3.6.1.4.1.529.4.27.0'; -my $snmpWanOutOfServiceChannels = '1.3.6.1.4.1.529.4.28.0'; -my $snmpEventCurrentActiveSessions = '1.3.6.1.4.1.529.10.6.0'; -# since startup -my $snmpEventTotalNoModems = '1.3.6.1.4.1.529.10.15.0'; -# lan modem -my $snmpDeadLanModem = '1.3.6.1.4.1.529.15.7.0'; -my $snmpDisabledLanModem = '1.3.6.1.4.1.529.15.5.0'; -my $snmpSuspectLanModem = '1.3.6.1.4.1.529.15.3.0'; -my $snmpAvailLanModem = '1.3.6.1.4.1.529.15.1.0'; -my $snmpBusyLanModem = '1.3.6.1.4.1.529.15.9.0'; -# max modems -my $snmpMdmNumber = '1.3.6.1.2.1.38.1.1.0'; -my $hostname; -my $session; -my $error; -my $response; -my %wanStatus; - - -my $WanAvailableChannels; -my $WanSwitchedChannels; -my $WanDisabledChannels; -my $WanActiveChannels; -my $WanNailedChannels; -my $WanOutOfServiceChannels; -my $EventCurrentActiveSessions; -my $EventTotalNoModems; -my $DeadLanModem; -my $DisabledLanModem; -my $SuspectLanModem; -my $AvailLanModem; -my $BusyLanModem; -my $MdmNumber; - - -sub usage { - printf "\nMissing arguments!\n"; - printf "\n"; - printf "Perl Check maxchannels plugin for Nagios\n"; - printf "monitors ISDN lines and modems on Ascend MAX 2000/4000/6000/TNT\n"; - printf "usage: \n"; - printf "check_maxchannel.pl -c <READCOMMUNITY> -p <PORT> <HOSTNAME>\n"; - printf "Copyright (C) 2000 Christoph Kron\n"; - printf "check_maxchannels.pl comes with ABSOLUTELY NO WARRANTY\n"; - printf "This programm is licensed under the terms of the "; - printf "GNU General Public License\n(check source code for details)\n"; - printf "\n\n"; - exit $ERRORS{"UNKNOWN"}; -} - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print ("ERROR: No snmp response from $hostname (alarm)\n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -$status = GetOptions("community=s",\$community, - "port=i",\$port); -if ($status == 0) -{ - &usage; -} - - #shift; - $hostname = shift || &usage; - - - -push(@snmpoids,$snmpWanAvailableChannels); -push(@snmpoids,$snmpWanSwitchedChannels); -push(@snmpoids,$snmpWanDisabledChannels); -push(@snmpoids,$snmpWanActiveChannels); -push(@snmpoids,$snmpWanNailedChannels); -push(@snmpoids,$snmpWanOutOfServiceChannels); - -push(@snmpoids,$snmpEventCurrentActiveSessions); - -push(@snmpoids,$snmpEventTotalNoModems); -push(@snmpoids,$snmpDeadLanModem); -push(@snmpoids,$snmpDisabledLanModem); -push(@snmpoids,$snmpSuspectLanModem); -push(@snmpoids,$snmpAvailLanModem); -push(@snmpoids,$snmpBusyLanModem); -push(@snmpoids,$snmpMdmNumber); - - ($session, $error) = Net::SNMP->session( - -hostname => $hostname, - -community => $community, - -port => $port - ); - - if (!defined($session)) { - $state='UNKNOWN'; - $answer=$error; - print ("$state: $answer"); - exit $ERRORS{$state}; - } - - if (!defined($response = $session->get_request(@snmpoids))) { - $answer=$session->error; - $session->close; - $state = 'CRITICAL'; - print ("$state: $answer,$community"); - exit $ERRORS{$state}; - } - - -$WanAvailableChannels = $response->{$snmpWanAvailableChannels}; -$WanSwitchedChannels = $response->{$snmpWanSwitchedChannels}; -$WanDisabledChannels = $response->{$snmpWanDisabledChannels}; -$WanActiveChannels = $response->{$snmpWanActiveChannels}; -$WanNailedChannels = $response->{$snmpWanNailedChannels}; -$WanOutOfServiceChannels = $response->{$snmpWanOutOfServiceChannels}; -$EventCurrentActiveSessions = $response->{$snmpEventCurrentActiveSessions}; -$EventTotalNoModems = $response->{$snmpEventTotalNoModems}; -$DeadLanModem = $response->{$snmpDeadLanModem}; -$DisabledLanModem = $response->{$snmpDisabledLanModem}; -$SuspectLanModem = $response->{$snmpSuspectLanModem}; -$AvailLanModem = $response->{$snmpAvailLanModem}; -$BusyLanModem = $response->{$snmpBusyLanModem}; -$MdmNumber = $response->{$snmpMdmNumber}; - -# less than 50% -> WARNING -if ( 0 < $WanOutOfServiceChannels - && $WanOutOfServiceChannels < ($snmpWanSwitchedChannels * 0.5) ) { - $state = 'WARNING'; -} -elsif ($WanOutOfServiceChannels > 0) { - $state = 'CRITICAL'; -} -elsif ($DeadLanModem > 0) { - $state = 'CRITICAL'; -} -elsif ($SuspectLanModem > 0) { - $state = 'WARNING'; -} -elsif ($AvailLanModem == 0) { - $state = 'WARNING'; -} -else { - $state = 'OK'; -} - - -$answer = sprintf("active sessions: %d (%d), active modems: %d (%d)<BR>", - $EventCurrentActiveSessions, - $WanSwitchedChannels, - $BusyLanModem, - $MdmNumber); - -$answer .= sprintf("channels available: %d, disabled: %d", - $WanAvailableChannels, - $WanDisabledChannels); - -$answer .= sprintf(", out of service: %d, nailed: %d<BR>", - $WanOutOfServiceChannels, - $WanNailedChannels); - -$answer .= sprintf("modems avail.: %d, disabled: %d, suspect: %d, dead: %d<BR>", - $AvailLanModem, - $DisabledLanModem, - $SuspectLanModem, - $DeadLanModem); - -$answer .= sprintf("unserviced modem calls: %d (since startup)\n", - $EventTotalNoModems); - -$session->close; - -print ("$state: $answer"); -exit $ERRORS{$state}; - diff --git a/contrib/check_maxwanstate.pl b/contrib/check_maxwanstate.pl deleted file mode 100644 index 4fbb9da2..00000000 --- a/contrib/check_maxwanstate.pl +++ /dev/null @@ -1,201 +0,0 @@ -#!/usr/bin/perl -w -# -# check_maxwanstate.pl - nagios plugin -# -# -# Copyright (C) 2000 Christoph Kron -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# -# Report bugs to: ck@zet.net -# -# 11.01.2000 Version 1.0 - -use strict; - -use Net::SNMP; -use Getopt::Long; -&Getopt::Long::config('auto_abbrev'); - - -my $status; -my $TIMEOUT = 1500; - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - -my %wanLineState = ( - 1,'ls-unknown', - 2,'ls-does-not-exist', - 3,'ls-disabled', - 4,'ls-no-physical', - 5,'ls-no-logical', - 6,'ls-point-to-point', - 7,'ls-multipoint-1', - 8,'ls-multipoint-2', - 9,'ls-loss-of-sync', - 10,'ls-yellow-alarm', - 11,'ls-ais-receive', - 12,'ls-no-d-channel', - 13,'ls-active', - 14,'ls-maintenance'); - -my %wanLineType = ( - '1.3.6.1.4.1.529.4.1','Any', - '1.3.6.1.4.1.529.4.2','T1', - '1.3.6.1.4.1.529.4.3','E1', - '1.3.6.1.4.1.529.4.4','Dpnss', - '1.3.6.1.4.1.529.4.5','Bri', - '1.3.6.1.4.1.529.4.6','S562', - '1.3.6.1.4.1.529.4.7','S564', - '1.3.6.1.4.1.529.4.8','Sdsl', - '1.3.6.1.4.1.529.4.9','AdslCap'); - -my $state = "UNKNOWN"; -my $answer = ""; -my $snmpkey; -my $snmpoid; -my $key; -my $community = "public"; -my $port = 161; -my @snmpoids; -my $snmpWanLineName = '1.3.6.1.4.1.529.4.21.1.2'; -my $snmpWanLineType = '1.3.6.1.4.1.529.4.21.1.3'; -my $snmpWanLineState = '1.3.6.1.4.1.529.4.21.1.5'; -my $snmpWanLineUsage = '1.3.6.1.4.1.529.4.21.1.8'; - -my $hostname; -my $session; -my $error; -my $response; -my %wanStatus; -my $ifup =0 ; -my $ifdown =0; -my $ifdormant = 0; -my $ifmessage; - -sub usage { - printf "\nMissing arguments!\n"; - printf "\n"; - printf "Perl Check maxwanstate plugin for Nagios\n"; - printf "monitors E1/T1 interface status\n"; - printf "usage: \n"; - printf "check_maxwanstate.pl -c <READCOMMUNITY> -p <PORT> <HOSTNAME>"; - printf "Copyright (C) 2000 Christoph Kron\n"; - printf "check_maxwanstate.pl comes with ABSOLUTELY NO WARRANTY\n"; - printf "This programm is licensed under the terms of the "; - printf "GNU General Public License\n(check source code for details)\n"; - printf "\n\n"; - exit $ERRORS{"UNKNOWN"}; -} - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print ("ERROR: No snmp response from $hostname (alarm)\n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -$status = GetOptions("community=s",\$community, - "port=i",\$port); -if ($status == 0) -{ - &usage; -} - - #shift; - $hostname = shift || &usage; - - - -push(@snmpoids,$snmpWanLineUsage); -push(@snmpoids,$snmpWanLineState); -push(@snmpoids,$snmpWanLineName); -push(@snmpoids,$snmpWanLineType); - -foreach $snmpoid (@snmpoids) { - - ($session, $error) = Net::SNMP->session( - -hostname => $hostname, - -community => $community, - -port => $port - ); - - if (!defined($session)) { - $state='UNKNOWN'; - $answer=$error; - print ("$state: $answer"); - exit $ERRORS{$state}; - } - - if (!defined($response = $session->get_table($snmpoid))) { - $answer=$session->error; - $session->close; - $state = 'CRITICAL'; - print ("$state: $answer,$community,$snmpkey"); - exit $ERRORS{$state}; - } - - foreach $snmpkey (keys %{$response}) { - $snmpkey =~ /.*\.(\d+)$/; - $key = $1; - $wanStatus{$key}{$snmpoid} = $response->{$snmpkey}; - } - $session->close; -} - - foreach $key (keys %wanStatus) { - # look only at active Interfaces lu-trunk(5) - if ($wanStatus{$key}{$snmpWanLineUsage} == 5 ) { - - # 13 -> active - if ($wanStatus{$key}{$snmpWanLineState} == 13 ) { - $ifup++; - } - else { - $ifdown++ ; - $ifmessage .= sprintf("%s interface status : %s (%s)<BR>", - $wanLineType{$wanStatus{$key}{$snmpWanLineType}}, - $wanLineState{$wanStatus{$key}{$snmpWanLineState}}, - $wanStatus{$key}{$snmpWanLineName}); - - } - } - } - - - if ($ifdown > 0) { - $state = 'CRITICAL'; - $answer = sprintf("host '%s', interfaces up: %d, down: %d<BR>", - $hostname, - $ifup, - $ifdown); - $answer = $answer . $ifmessage . "\n"; - } - else { - $state = 'OK'; - $answer = sprintf("host '%s', interfaces up: %d, down: %d\n", - $hostname, - $ifup, - $ifdown); - } - -print ("$state: $answer"); -exit $ERRORS{$state}; - diff --git a/contrib/check_mem.pl b/contrib/check_mem.pl deleted file mode 100644 index 3227ce24..00000000 --- a/contrib/check_mem.pl +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/perl -w -# $Id: check_mem.pl 2 2002-02-28 06:42:51Z egalstad $ - -# check_mem.pl Copyright (C) 2000 Dan Larsson <dl@tyfon.net> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty -# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# you should have received a copy of the GNU General Public License -# along with this program (or with Nagios); if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA - -# Tell Perl what we need to use -use strict; -use Getopt::Std; - -use vars qw($opt_c $opt_f $opt_u $opt_w - $free_memory $used_memory $total_memory - $crit_level $warn_level - %exit_codes @memlist - $percent $fmt_pct - $verb_err $command_line); - -# Predefined exit codes for Nagios -%exit_codes = ('UNKNOWN' ,-1, - 'OK' , 0, - 'WARNING' , 1, - 'CRITICAL', 2,); - -# Turn this to 1 to see reason for parameter errors (if any) -$verb_err = 0; - -# This the unix command string that brings Perl the data -$command_line = `vmstat | tail -1 | awk '{print \$4,\$5}'`; - -chomp $command_line; -@memlist = split(/ /, $command_line); - -# Define the calculating scalars -$used_memory = $memlist[0]; -$free_memory = $memlist[1]; -$total_memory = $used_memory + $free_memory; - -# Get the options -if ($#ARGV le 0) -{ - &usage; -} -else -{ - getopts('c:fuw:'); -} - -# Shortcircuit the switches -if (!$opt_w or $opt_w == 0 or !$opt_c or $opt_c == 0) -{ - print "*** You must define WARN and CRITICAL levels!" if ($verb_err); - &usage; -} -elsif (!$opt_f and !$opt_u) -{ - print "*** You must select to monitor either USED or FREE memory!" if ($verb_err); - &usage; -} - -# Check if levels are sane -if ($opt_w <= $opt_c and $opt_f) -{ - print "*** WARN level must not be less than CRITICAL when checking FREE memory!" if ($verb_err); - &usage; -} -elsif ($opt_w >= $opt_c and $opt_u) -{ - print "*** WARN level must not be greater than CRITICAL when checking USED memory!" if ($verb_err); - &usage; -} - -$warn_level = $opt_w; -$crit_level = $opt_c; - -if ($opt_f) -{ - $percent = $free_memory / $total_memory * 100; - $fmt_pct = sprintf "%.1f", $percent; - if ($percent <= $crit_level) - { - print "Memory CRITICAL - $fmt_pct% ($free_memory kB) free\n"; - exit $exit_codes{'CRITICAL'}; - } - elsif ($percent <= $warn_level) - { - print "Memory WARNING - $fmt_pct% ($free_memory kB) free\n"; - exit $exit_codes{'WARNING'}; - } - else - { - print "Memory OK - $fmt_pct% ($free_memory kB) free\n"; - exit $exit_codes{'OK'}; - } -} -elsif ($opt_u) -{ - $percent = $used_memory / $total_memory * 100; - $fmt_pct = sprintf "%.1f", $percent; - if ($percent >= $crit_level) - { - print "Memory CRITICAL - $fmt_pct% ($used_memory kB) used\n"; - exit $exit_codes{'CRITICAL'}; - } - elsif ($percent >= $warn_level) - { - print "Memory WARNING - $fmt_pct% ($used_memory kB) used\n"; - exit $exit_codes{'WARNING'}; - } - else - { - print "Memory OK - $fmt_pct% ($used_memory kB) used\n"; - exit $exit_codes{'OK'}; - } -} - -# Show usage -sub usage() -{ - print "\ncheck_mem.pl v1.0 - Nagios Plugin\n\n"; - print "usage:\n"; - print " check_mem.pl -<f|u> -w <warnlevel> -c <critlevel>\n\n"; - print "options:\n"; - print " -f Check FREE memory\n"; - print " -u Check USED memory\n"; - print " -w PERCENT Percent free/used when to warn\n"; - print " -c PERCENT Percent free/used when critical\n"; - print "\nCopyright (C) 2000 Dan Larsson <dl\@tyfon.net>\n"; - print "check_mem.pl comes with absolutely NO WARRANTY either implied or explicit\n"; - print "This program is licensed under the terms of the\n"; - print "GNU General Public License (check source code for details)\n"; - exit $exit_codes{'UNKNOWN'}; -} diff --git a/contrib/check_ms_spooler.pl b/contrib/check_ms_spooler.pl deleted file mode 100755 index 3a80a76a..00000000 --- a/contrib/check_ms_spooler.pl +++ /dev/null @@ -1,324 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: check_ms_spooler.pl 64 2002-07-16 00:04:42Z stanleyhopcroft $ - -# Revision 1.1 2002/07/16 00:04:42 stanleyhopcroft -# Primitive and in need of refinement test of MS spooler (with smbclient) -# -# Revision 2.5 2002-02-13 07:36:08+11 anwsmh -# Correct 'apostrophe' disaster. -# Apostrophes in plugin output cause Netsaint notification commands -# ( sh echo 'yada $PLUGINOUTPUT$ ..') to fail, usually mysteriously -# eg notify OK works but notify CRITICAL does not. -# Replace '$var' in print "output" with \"$var\". -# -# Revision 2.4 2001-11-21 21:36:05+11 anwsmh -# Minor corrections -# . replace 'die' by print .. exit $ERRORS{CRITICAL} -# . change concluding message to list the queues (sorted) if there are no enqueued docs. -# -# Revision 2.3 2001-11-20 11:00:58+11 anwsmh -# Major corrections. -# 1. to sub AUTOLOAD: coderef parms must be @_ (ie the parm when the new sub is called) -# 2. to processing of queue report (no inspection of $last_line; entire $queue_report is -# checked for errors) -# 3. cosmetic and debug changes in many places. -# -# Revision 2.2 2001-11-17 23:30:34+11 anwsmh -# After adapting two different queue reports resulting from -# different name resolution methods. -# -# Revision 2.1 2001-11-17 13:21:54+11 anwsmh -# Adapt to Netsaint ('use utils, Getopt::Long, and standard switch processing). -# Fix many peculiarities. -# - - -use strict ; - -use Getopt::Long ; -use utils ; - -use vars qw($opt_H $opt_s $opt_W $opt_u $opt_p $opt_w $opt_c $debug); -use vars '$AUTOLOAD' ; -use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); - -my $PROGNAME = 'check_ms_spooler' ; - -sub print_help (); -sub print_usage (); -sub help (); -sub version (); - -delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; - -use constant SMBCLIENT_PATH => '/usr/local/samba/bin/smbclient' ; -use constant MAX_QUEUES_TO_CHECK => 20 ; # So that the check doesn't take longer than $TIMEOUT - -use constant SMBCLIENT_SVC => sub { return `${\SMBCLIENT_PATH} -L //$_[0] -U $_[1]%$_[2]` } ; -use constant SMBCLIENT_QUEUE => sub { return `${\SMBCLIENT_PATH} //$_[0]/$_[1] -U $_[2]%$_[3] -c 'queue; quit' 2>/dev/null` } ; - - # The queue results depend on the name resolution method. - - # Forcing 'wins' or 'bcat' name resolution makes the queue results the - # same for all spoolers (those that are resolved with WINS have an extra line - # 'Got a positive name query response from <ip address of WINS> ..) - # but would fail if there is no WINS and when miscreant spoolers - # don't respond to broadcasts. - -use constant MIN => sub { my $min = $_[0] ; foreach (@_) { $min = $_ if $_ <= $min; } return $min ; } ; - -$SIG{"ALRM"} = sub { die "Alarm clock restart" } ; - -Getopt::Long::Configure('bundling', 'no_ignore_case'); -GetOptions - ("V|version" => \&version, - "h|help" => \&help, - "d|debug" => \$debug, - "p|password=s" => \$opt_p, - "u|username=s" => \$opt_u, - "H|hostname=s" => \$opt_H); - - - -($opt_H) || usage("MS Spooler name not specified\n"); -my $spooler = $1 if $opt_H =~ m#(\w+)# ; # MS host names allow __any__ characters (more than \w) -($spooler) || usage("Invalid MS spooler name: $opt_H\n"); - -($opt_u) || ($opt_u = 'guest'); -my $user = $1 if $opt_u =~ m#(\w+)# ; -($user) || usage("Invalid user: $opt_u\n"); - -($opt_p) || ($opt_p = 'guest'); -my $pass = $1 if ($opt_p =~ /(.*)/); -($pass) || usage("Invalid password: $opt_p\n"); - -my ($printer, $queue, @queues, $ms_spooler_status, @results, %junk) ; -my (@fault_messages, @queue_contents, @services, @prandom_queue_indices) ; -my ($queue_contents, $number_of_queues, $state, $queue_report) ; - -$state = "getting service list (${\SMBCLIENT_PATH} -L $spooler -U $user%$pass) from spooler\n" ; - -eval { - alarm($TIMEOUT) ; - @services = SMBCLIENT_SVC->( $spooler, $user, $pass ) ; -} ; -alarm(0) ; - -if ($@ and $@ !~ /Alarm clock restart/) { - print "Failed. $PROGNAME failed $state. Got \"$@\"\n" ; - exit $ERRORS{"CRITICAL"} ; -} - -if ($@ and $@ =~ /Alarm clock restart/) { - print "Failed. $PROGNAME timed out $state. Got \"@services\"\n" ; - exit $ERRORS{"CRITICAL"} ; -} - -# tsitc> /usr/local/samba/bin/smbclient //ipaprint1/tt03 -U blah%blah -P -c 'queue; quit' -# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0 -# Connection to ipaprint1 failed - -# tsitc> /usr/local/samba/bin/smbclient -L sna_spl1 -U blah%blah | & more -# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0 -# Got a positive name query response from 10.0.100.29 ( 10.0.6.20 ) -# session setup failed: ERRDOS - ERRnoaccess (Access denied.) - -if ( grep /Connection to $spooler failed|ERR/, @services ) { - print "Failed. $PROGNAME failed $state. Got \"@services\"\n" ; - # print "Failed. Request for services list to $spooler failed. Got \"@services\"\n" ; - exit $ERRORS{"CRITICAL"} ; -} - -# tsitc# /usr/local/samba/bin/smbclient -L ipaprint -U blah%blah -# Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0 -# Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0] -# -# Sharename Type Comment -# --------- ---- ------- -# TH02 Printer TH02 -# ADMIN$ Disk Remote Admin -# IPC$ IPC Remote IPC -# S431 Printer S431 -# S402 Printer S402 -# S401 Printer S401 -# C$ Disk Default share -# BW01 Printer BW01 -# BW02 Printer BW02 -# TL11 Printer TL11 -# TL07 Printer TL07 -# S225 Printer Discovery South - 2nd Floor - HP CLJ4500 -# S224 Printer S224 -# S223 Printer Discovery South 2nd Floor Trademarks Training -# S222 Printer S222 -# S203 Printer S203 -# S202 Printer S202 - -my @printers = map { my @junk = split; $junk[0] } - grep { my @junk = split; defined $junk[1] and $junk[1] eq 'Printer' } @services ; - # don't check IPC$, ADMIN$ etc. - -$ms_spooler_status = 0 ; -$number_of_queues = MIN->(MAX_QUEUES_TO_CHECK, (scalar(@services) >> 3) + 1) ; - -$state = "checking queues on $spooler" ; - -eval { - # foreach queues to check - # generate a pseudo-random int in 0 .. $#printers - # drop it if the index has already been generated ; - - %junk = () ; - @prandom_queue_indices = grep { ! $junk{$_}++ } - map { int( rand($#printers) ) } ( 1 .. $number_of_queues ) ; - - @queues = @printers[@prandom_queue_indices] ; - - # @queues = @printers[ map { int( rand($#printers) ) } ( 1 .. $number_of_queues ) ] ; - - alarm($TIMEOUT) ; - - @queue_contents = @fault_messages = () ; - - foreach $printer (sort @queues) { - - # Expect 3 lines from a queue report. - # If queue is empty, last line is null otherwise - # it will contain a queue report or an SMB error - - # Empty Queue. - # Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0 - # Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0] - - # Queue command from a spooler with a DNS name. - # Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0 - # Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0] - # 65 16307 Microsoft Word - Servicesweoffer2.doc - # 68 10410 Microsoft Word - Servicesweoffer.doc - # 143 24997 Microsoft Word - Miss Samantha Anne Craig.doc - # 182 15635 Microsoft Word - services we provide.doc - - # Error. - # Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0 - # Domain=[IPAUSTRALIA] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0] - # tree connect failed: ERRDOS - ERRnosuchshare (You specified an invalid share name) - - # Can't connect error. - # Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0 - # Connection to sna_spl2 failed - - - # Empty Queue from a spooler with no DNS name, NetBIOS name resolved by WINS. - # Added interface ip=10.0.100.252 bcast=10.255.255.255 nmask=255.0.0.0 - # Got a positive name query response from 10.0.100.29 ( 10.0.6.20 ) - # Domain=[SNA_PRINT] OS=[Windows NT 4.0] Server=[NT LAN Manager 4.0] - - # There are 3 lines of output from smbclient for those spoolers whose names are - # resolved by WINS (because those names are NetBIOS and therefore not in DNS); - # 4 lines for errors or enqueued jobs - - print STDERR "${\SMBCLIENT_PATH} //$spooler/$printer -U $user%$pass -c 'queue; quit' ==>\n" if $debug ; - - @results = SMBCLIENT_QUEUE->( $spooler, $printer, $user, $pass ) ; - - print STDERR "\"@results\"\n" if $debug ; - - # set $ms_spooler_status somehow - - chomp( @results ) ; - $queue_report = queue_report->(@results) ; - print STDERR '$queue_report for $printer ', "$printer: \"$queue_report\"\n\n" if $debug ; - - if ( defined $queue_report and ($queue_report !~ /ERR/ && $queue_report !~ /failed/) ) { - $ms_spooler_status = 1 ; - push @queue_contents, "$printer: $queue_report" if $queue_report ; - } else { - push @fault_messages, "$printer: $queue_report" ; - } - } - alarm(0) ; -} ; - -if ($@ and $@ !~ /Alarm clock restart/) { - print "Failed. $PROGNAME failed at $state. Got \"$@\"\n" ; - exit $ERRORS{"CRITCAL"} ; -} - -if ($@ and $@ =~ /Alarm clock restart/) { - my $i ; - foreach (@queues) { $i++ ; last if $_ eq $printer } - print "Failed. Timed out connecting to $printer ($i of $number_of_queues) on //$spooler after $TIMEOUT secs. Got \"@fault_messages\"\n" ; - exit $ERRORS{"CRITICAL"} ; -} - -if (! $ms_spooler_status) { - print "Failed. Couldn't connect to @queues on //$spooler as user $user. Got \"@fault_messages\"\n" ; - exit $ERRORS{"CRITICAL"} ; -} - -$queue_contents = ( @queue_contents != 0 ? join(" ", (@queue_contents == 1 ? "Queue" : "Queues"), @queue_contents) : - "All Queues empty" ) ; - -print "Ok. Connected to ", $queue_contents =~ /empty$/ ? "@{[sort @queues]}" : scalar @queues, " queues on //$spooler. $queue_contents\n" ; -exit $ERRORS{"OK"} ; - -sub print_usage () { - print "Usage: $PROGNAME -H <spooler> -u <user> -p <password>\n"; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 64 $ '); - print "Copyright (c) 2001 Karl DeBisschop/S Hopcroft - -Perl Check MS Spooler plugin for NetSaint. Display a subset of the queues on an SMB (Samba or MS) print spooler. - -"; - print_usage(); - print ' --H, --hostname=STRING - NetBIOS name of the SMB Print spooler (Either Samba or MS spooler) --u, --user=STRING - Username to log in to server. (Default: "guest") --p, --password=STRING - Password to log in to server. (Default: "guest") --d, --debug - Debugging output. --h, --help - This stuff. - -'; - support(); -} - -sub version () { - print_revision($PROGNAME,'$Revision: 64 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - -sub AUTOLOAD { - - my @queue_rep = @_ ; - - # 'Object Oriented Perl', D Conway, p 95 - - no strict 'refs' ; - - if ( $AUTOLOAD =~ /.*::queue_report/ ) { - - if ( grep /Got a positive name query response from/, @queue_rep ){ - *{$AUTOLOAD} = sub { return join ' ', splice(@_, 3) } ; - return join '', splice(@queue_rep, 3) ; - } else { - *{$AUTOLOAD} = sub { return join ' ',splice(@_, 2) } ; - return join '', splice(@queue_rep, 2) ; - } - } else { - die "No such subroutine: $AUTOLOAD" ; - } -} - diff --git a/contrib/check_mssql.sh b/contrib/check_mssql.sh deleted file mode 100755 index 77c4dcd2..00000000 --- a/contrib/check_mssql.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/sh -# This script is designed to be used by Nagios. It checks for the availability of both Microsoft SQL Server 7 and 2000. -# -# Requirements: -# -# FreeTDS 6.0+ (http://www.freetds.org/) -# -# It was written by Tom De Blende (tom.deblende@village.uunet.be) in 2003. -# -# Version 1.0. -# Version 1.1: Rewritten the initial script so that it not only works from the CLI but also from within Nagios. Always helpful... -# Version 1.2: Grouped output so things look a bit better. -# Version 2.0: Rewritten the plugin to support version 6.0+ of FreeTDS. -# Removed sqsh requirement as version 6.0+ of FreeTDS now offers its own CLI client: tsql. -# Older versions of FreeTDS are no longer supported. -# -# -# You might want to change these values: - -tsqlcmd=`which tsql` -catcmd=`which cat` -grepcmd=`which grep` -rmcmd=`which rm` -mktempcmd=`which mktemp` -wccmd=`which wc` -sedcmd=`which sed` -trcmd=`which tr` -uniqcmd=`which uniq` - -################################################################################################################### - -hostname=$1 -usr=$2 -pswd=$3 -srv=$4 - - -if [ ! "$#" == "4" ]; then - 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" - -elif [ $tsqlcmd == "" ]; then - 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" - -fi - -exit="3" - - -# Creating the command file that contains the sql statement that has to be run on the SQL server. - -tmpfile=`$mktempcmd /tmp/$hostname.XXXXXX` - -if [ $srv == "7" ]; then - spid=7 -elif [ $srv == "2000" ]; then - spid=50 -else - echo -e "$srv is not a supported MS SQL Server version!" && exit "3" -fi - -echo -e "select loginame from sysprocesses where spid > $spid order by loginame asc\ngo" > $tmpfile - - -# Running tsql to get the results back. - -resultfile=`$mktempcmd /tmp/$hostname.XXXXXX` -errorfile=`$mktempcmd /tmp/$hostname.XXXXXX` -$tsqlcmd -S $hostname -U $usr -P $pswd < $tmpfile 2>$errorfile > $resultfile - -$grepcmd -q "Login failed for user" $errorfile - -if [ "$?" == "0" ]; then - $rmcmd -f $tmpfile $resultfile $errorfile; - echo CRITICAL - Could not make connection to SQL server. Login failed.; - exit 2; -fi - -$grepcmd -q "There was a problem connecting to the server" $errorfile - -if [ "$?" == "0" ]; then - $rmcmd -f $tmpfile $resultfile $errorfile; - echo CRITICAL - Could not make connection to SQL server. Incorrect server name or SQL service not running.; - exit 2; -fi - -resultfileln=`$catcmd $resultfile | $wccmd -l | $sedcmd 's/ //g'` - -if [ "$resultfileln" == "2" ]; then - $rmcmd -f $tmpfile $resultfile $errorfile; - echo CRITICAL - Could not make connection to SQL server. No data received from host.; - exit 2; -else - nmbr=`$catcmd $resultfile | $grepcmd -v locale | $grepcmd -v charset| $grepcmd -v 1\> | $sedcmd '/^$/d' | $sedcmd 's/ //g' | $wccmd -l | sed 's/ //g'` - 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'` - $rmcmd -f $tmpfile $resultfile; - echo "OK - MS SQL Server $srv has $nmbr user(s) connected: $users" | sed 's/: $/./g'; - exit 0; -fi - -# Cleaning up. - -$rmcmd -f $tmpfile $resultfile $errorfile -echo $stdio -exit $exit diff --git a/contrib/check_nagios.pl b/contrib/check_nagios.pl deleted file mode 100644 index 7d15d4db..00000000 --- a/contrib/check_nagios.pl +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/perl -# denao - denao@uol.com.br - Systems Engineering -# Universo Online - http://www.uol.com.br -use DBI; -use Time::Local; - -my $t_lambuja = 5; # (expire_minutes) -my $databasename = ""; # The name of nagios database (i.e.: nagios) -my $table = "programstatus"; -my $where = "localhost"; # The machine where the database -my $port = "3306"; -my $base = "DBI:mysql:$databasename:$where:$port"; -my $user = ""; # the user to connect to the database - # (needs permission to "select at programstatus table only" -my $password = ""; # the password (if any) -my %results; -my @fields = qw( last_update ); -my $dbh = DBI->connect($base,$user,$password); -my $fields = join(', ', @fields); -my $query = "SELECT $fields FROM $table"; - -my $sth = $dbh->prepare($query); -$sth->execute(); - -@results{@fields} = (); -$sth->bind_columns(map { \$results{$_} } @fields); - -$sth->fetch(); -$sth->finish(); -$dbh->disconnect(); - -check_update(); - -sub check_update { -($yea,$mon,$day,$hou,$min,$sec)=($results{last_update}=~/(\d+)\-(\d+)\-(\d+)\s(\d+)\:(\d+)\:(\d+)/); -($sec_now, $min_now, $hou_now, $day_now, $mon_now, $yea_now) = (localtime(time))[0,1,2,3,4,5]; -$mon_now+=1; $yea_now+=1900; -$unixdate=timelocal($sec,$min,$hou,$day,$mon,$yea); -$unixdate_now=timelocal($sec_now,$min_now,$hou_now,$day_now,$mon_now,$yea_now); - if (scalar($unixdate_now - $unixdate) > scalar($t_lambuja * 60)) { - print "Nagios problem: nagios is down, for at least " . scalar($t_lambuja) . " minutes.\n"; - exit(1); - } else { - print "Nagios ok: status data updated " . scalar($unixdate_now - $unixdate) . " seconds ago\n"; - exit(0); - } -} - diff --git a/contrib/check_nagios_db.pl b/contrib/check_nagios_db.pl deleted file mode 100644 index 5811d7c6..00000000 --- a/contrib/check_nagios_db.pl +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/local/bin/perl -w - -use strict; -$|++; - -use vars qw/$opt_e $opt_c/; - -$ENV{"PATH"} = "/usr/bin:/usr/sbin:/bin"; - -use Getopt::Std; -use DBI; - -my $driver = "mysql"; - -my $CFG_DEF = "/opt/nagios/etc/cgi.cfg"; -my $QUERY = "select *, UNIX_TIMESTAMP(last_update) as ut from programstatus;"; -my $EXPIRE_DEF = 5; ## expressed in minutes -my $PROCCNT = 0; - -use constant OK => 1; -use constant WARN => 2; - -my $STAT = WARN; - -sub usage { - print STDERR "\n"; - print STDERR "$0 -F -e <expire time in minutes> -C <process string>\n"; - print STDERR "\n"; - exit -1; -} - -getopt("e:c:"); - -my $EXPIRE = $opt_e || $EXPIRE_DEF; -my $CFG = $opt_c || $CFG_DEF; - -( -f $CFG ) or die "Can't open config file '$CFG': $!\n"; - -my ($dbhost, $dbport, $dbuser, $dbpass, $dbname); - -open(F, "< $CFG"); -while ( <F> ) { - if (/^xsddb_host=(.+)/) { $dbhost = $1; next; }; - if (/^xsddb_port=(.+)/) { $dbport = $1; next; }; - if (/^xsddb_database=(.+)/) { $dbname = $1; next; }; - if (/^xsddb_username=(.+)/) { $dbuser = $1; next; }; - if (/^xsddb_password=(.+)/) { $dbpass = $1; next; }; -} -close(F); - -# print "($dbhost, $dbport, $dbuser, $dbpass, $dbname)\n"; - -my $dsn = "DBI:$driver:database=$dbname;host=$dbhost;port=$dbport"; -my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1}); - -my $sth = $dbh->prepare($QUERY); -if (!$sth) { die "Error:" . $dbh->errstr . "\n"; } -$sth->execute; -if (!$sth->execute) { die "Error:" . $sth->errstr . "\n"; } - -my %status = (); - -my $names = $sth->{'NAME'}; -my $numFields = $sth->{'NUM_OF_FIELDS'}; -my $ref = $sth->fetchrow_arrayref; -for (my $i = 0; $i < $numFields; $i++) { - $status{"$$names[$i]"} = $$ref[$i]; -} - -#foreach (keys(%status)) { -# print "$_: $status{$_}\n"; -#} - -my $lastupdated = time() - $status{"ut"}; -if ( $lastupdated < ($EXPIRE*60) ) { ## convert $EXPIRE to seconds - $STAT = OK; -} - -open(PS, "ps -eaf | grep $status{nagios_pid} | grep -v grep | "); -$PROCCNT = 0; -while(<PS>) { - $PROCCNT++; -} -close(PS); - -if ( $STAT == OK ) { - print "Nagios OK: located $PROCCNT processes, program status updated $lastupdated seconds ago\n"; -} - diff --git a/contrib/check_nagios_db_pg.pl b/contrib/check_nagios_db_pg.pl deleted file mode 100644 index 99e5d4ed..00000000 --- a/contrib/check_nagios_db_pg.pl +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -$|++; - -use vars qw/$opt_e $opt_c/; - -$ENV{"PATH"} = "/usr/bin:/usr/sbin:/bin"; - -use Getopt::Std; -use DBI; - -my $driver = "Pg"; - -my $CFG_DEF = "/etc/nagios/cgi.cfg"; -# this works only in mysql -# my $QUERY = "select *, UNIX_TIMESTAMP(last_update) as ut from programstatus;"; -# the following is the same for postgres -my $QUERY = "select *, round(date_part('epoch',last_update)) as ut from programstatus;"; -my $EXPIRE_DEF = 5; ## expressed in minutes -my $PROCCNT = 0; - -use constant OK => 1; -use constant WARN => 2; - -my $STAT = WARN; - -sub usage { - print STDERR "\n"; - print STDERR "$0 -F -e <expire time in minutes> -C <process string>\n"; - print STDERR "\n"; - exit -1; -} - -getopt("e:c:"); - -my $EXPIRE = $opt_e || $EXPIRE_DEF; -my $CFG = $opt_c || $CFG_DEF; - -( -f $CFG ) or die "Can't open config file '$CFG': $!\n"; - -my ($dbhost, $dbport, $dbuser, $dbpass, $dbname); - -open(F, "< $CFG"); -while ( <F> ) { - if (/^xsddb_host=(.+)/) { $dbhost = $1; next; }; - if (/^xsddb_port=(.+)/) { $dbport = $1; next; }; - if (/^xsddb_database=(.+)/) { $dbname = $1; next; }; - if (/^xsddb_username=(.+)/) { $dbuser = $1; next; }; - if (/^xsddb_password=(.+)/) { $dbpass = $1; next; }; -} -close(F); - -#print "($dbhost, $dbport, $dbuser, $dbpass, $dbname)\n"; - -my $dsn = "DBI:$driver:dbname=$dbname;host=$dbhost;port=$dbport"; -my $dbh = DBI->connect($dsn, $dbuser, $dbpass, {'RaiseError' => 1}); - -my $sth = $dbh->prepare($QUERY); -if (!$sth) { die "Error:" . $dbh->errstr . "\n"; } -$sth->execute; -if (!$sth->execute) { die "Error:" . $sth->errstr . "\n"; } - -my %status = (); - -my $names = $sth->{'NAME'}; -my $numFields = $sth->{'NUM_OF_FIELDS'}; -my $ref = $sth->fetchrow_arrayref; -for (my $i = 0; $i < $numFields; $i++) { - $status{"$$names[$i]"} = $$ref[$i]; -} - -#foreach (keys(%status)) { -# print "$_: $status{$_}\n"; -#} - -my $lastupdated = time() - $status{"ut"}; -if ( $lastupdated < ($EXPIRE*60) ) { ## convert $EXPIRE to seconds - $STAT = OK; -} - -open(PS, "ps -eaf | grep $status{nagios_pid} | grep -v grep | "); -$PROCCNT = 0; -while(<PS>) { - $PROCCNT++; -} -close(PS); - -if ( $STAT == OK ) { - print "Nagios OK: located $PROCCNT processes, program status updated $lastupdated seconds ago\n"; -} diff --git a/contrib/check_netapp.pl b/contrib/check_netapp.pl deleted file mode 100755 index d556e9da..00000000 --- a/contrib/check_netapp.pl +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/perl -wT -# check_netapp -# -# Copyright (C) 2000 Leland E. Vandervort <leland@mmania.com> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty -# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# you should have received a copy of the GNU General Public License -# along with this program (or with Nagios); if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA -#################################### -# checks for overtemperature, fans, psu, and nfs operations/second on -# Network Appliance Filers. -# Returns: -# OK if temp, fans, psu OK and Ops/Sec below warning and critical -# Thresholds (default is warning=3500, critical=5000) -# ** Note: See the specifications for your Filer model for -# the thresholds ! -# Returns Warning if NFS Ops/Sec is above warning threshold -# (default 3500, or specified by -o command line option) -# Returns Critical if NFS Ops/Sec is above critical threshold -# ( -m option, or default 5000), or if overtem, psufault, or -# fanfault detected. -# -#################################### -# Notes on operational limits for NetApp Filers: -# Platform Maximum Ops/Second (recommended) -# ------------------------------------------------------------- -# F230 1000 -# F740 5500 -# F760 9000 -#################################### - -use Net::SNMP; -use Getopt::Long; -&Getopt::Long::config('auto_abbrev'); - -my $status; -my $response = ""; -my $TIMEOUT = 10; -my $community = "public"; -my $port = 161; -my $opsthresh = "3500"; -my $critical = "5000"; - -my $status_string = ""; - -my %OIDLIST = ( - overtemp => '1.3.6.1.4.1.789.1.2.4.1.0', - failedfan => '1.3.6.1.4.1.789.1.2.4.2.0', - failedpsu => '1.3.6.1.4.1.789.1.2.4.4.0', - nfsops => '1.3.6.1.4.1.789.1.2.2.1.0' - ); - - - -my %STATUSCODE = ( 'UNKNOWN' => '-1', - 'OK' => '0', - 'WARNING' => '1', - 'CRITICAL' => '2'); - -my $state = "UNKNOWN"; - - -$SIG{'ALRM'} = sub { - print "ERROR: No snmp response from $hostname (sigALRM)\n"; - exit($STATUSCODE{"UNKNOWN"}); -}; - -alarm($TIMEOUT); - -sub get_nfsops { - my $nfsops_start = &SNMPGET($OIDLIST{nfsops}); - sleep(1); - my $nfsops_end = &SNMPGET($OIDLIST{nfsops}); - my $nfsopspersec = $nfsops_end - $nfsops_start; - return($nfsopspersec); -} - - -sub show_help { - printf("\nPerl NetApp filer plugin for Nagios\n"); - printf("Usage:\n"); - printf(" - check_netapp [options] <hostname> - Options: - -c snmp-community - -p snmp-port - -o Operations per second warning threshold - -m Operations per second critical threshold - -"); - printf("Copyright (C)2000 Leland E. Vandervort\n"); - printf("check_netapp comes with absolutely NO WARRANTY either implied or explicit\n"); - printf("This program is licensed under the terms of the\n"); - printf("GNU General Public License\n(check source code for details)\n\n\n"); - exit($STATUSCODE{"UNKNOWN"}); -} - - -$status = GetOptions( "community=s", \$community, - "port=i", \$port, - "opsthresh=i", \$opsthresh, - "maxops=i", \$critical ); - -if($status == 0) { - &show_help; -} - -sub SNMPGET { - $OID = shift; - ($session,$error) = Net::SNMP->session( - Hostname => $hostname, - Community => $community, - Port => $port - ); - if(!defined($session)) { - printf("$state %s\n", $error); - exit($STATUSCODE{$state}); - } - if(!defined($response = $session->get_request($OID))) { - printf("$state %s\n", $session->error()); - $session->close(); - exit($STATUSCODE{$state}); - } - $session->close(); - return($response->{$OID}); -} - -$hostname = shift || &show_help; - -my $tempcheck = &SNMPGET($OIDLIST{overtemp}); -if($tempcheck == 1) { - $state = "OK"; - $status_string .= "Temp OK "; -} -else { - $state = "CRITICAL"; - $status_string .= "Temp CRIT"; -} - -foreach $element ('failedfan','failedpsu') { - my $my_return = &SNMPGET($OIDLIST{$element}); - if(($my_return =~ /no/) || ($my_return == 0)) { - $status_string .= "$element = $my_return "; - $state = "OK"; - } - else { - $status_string .= "$element = $my_return "; - $state = "CRITICAL"; - } -} - -my $tmp_opssec = &get_nfsops(); - -if ($tmp_opssec >= $critical) { - $state = "CRITICAL"; -} -elsif ($tmp_opssec >= $opsthresh) { - $state = "WARNING"; -} -else { - $state = "OK"; -} - -$status_string .= "Ops\/Sec = $tmp_opssec "; - -print "$state $status_string\n"; -exit($STATUSCODE{$state}); diff --git a/contrib/check_nmap.py b/contrib/check_nmap.py deleted file mode 100644 index 481a62bf..00000000 --- a/contrib/check_nmap.py +++ /dev/null @@ -1,441 +0,0 @@ -#!/usr/bin/python -# Change the above line if python is somewhere else - -# -# check_nmap -# -# Program: nmap plugin for Nagios -# License: GPL -# Copyright (c) 2000 Jacob Lundqvist (jaclu@galdrion.com) -# -_version_ = '1.21' -# -# -# Description: -# -# Does a nmap scan, compares open ports to those given on command-line -# Reports warning for closed that should be open and error for -# open that should be closed. -# If optional ports are given, no warning is given if they are closed -# and they are included in the list of valid ports. -# -# Requirements: -# python -# nmap -# -# History -# ------- -# 1.21 2004-07-23 rippeld@hillsboroughcounty.org Updated parsing of nmap output to correctly identify closed ports -# 1.20 2000-07-15 jaclu Updated params to correctly comply to plugin-standard -# moved support classes to utils.py -# 1.16 2000-07-14 jaclu made options and return codes more compatible with -# the plugin developer-guidelines -# 1.15 2000-07-14 jaclu added random string to temp-file name -# 1.14 2000-07-14 jaclu added check for error from subproc -# 1.10 2000-07-14 jaclu converted main part to class -# 1.08 2000-07-13 jaclu better param parsing -# 1.07 2000-07-13 jaclu changed nmap param to -P0 -# 1.06 2000-07-13 jaclu make sure tmp file is deleted on errors -# 1.05 2000-07-12 jaclu in debug mode, show exit code -# 1.03 2000-07-12 jaclu error handling on nmap output -# 1.01 2000-07-12 jaclu added license -# 1.00 2000-07-12 jaclu implemented timeout handling -# 0.20 2000-07-10 jaclu Initial release - - -import sys, os, string, random - -import tempfile -from getopt import getopt - -# -# import generic Nagios-plugin stuff -# -import utils - -# Where temp files should be placed -tempfile.tempdir='/usr/local/nagios/var' - -# Base name for tempfile -tempfile.template='check_nmap_tmp.' - -# location and possibly params for nmap -nmap_cmd='/usr/bin/nmap -P0' - - - - - - -# -# the class that does all the real work in this plugin... -# -# -class CheckNmap: - - # Retcodes, so we are compatible with nagios - #ERROR= -1 - UNKNOWN= -1 - OK= 0 - WARNING= 1 - CRITICAL= 2 - - - def __init__(self,cmd_line=[]): - """Constructor. - arguments: - cmd_line: normaly sys.argv[1:] if called as standalone program - """ - self.tmp_file='' - self.host='' # host to check - self.timeout=10 - self.debug=0 # 1= show debug info - self.ports=[] # list of mandatory ports - self.opt_ports=[] # list of optional ports - self.ranges='' # port ranges for nmap - self.exit_code=0 # numerical exit-code - self.exit_msg='' # message to caller - - self.ParseCmdLine(cmd_line) - - def Run(self): - """Actually run the process. - This method should be called exactly once. - """ - - # - # Only call check_host if cmd line was accepted earlier - # - if self.exit_code==0: - self.CheckHost() - - self.CleanUp() - return self.exit_code,self.exit_msg - - def Version(self): - return 'check_nmap %s' % _version_ - - #----------------------------------------- - # - # class internal stuff below... - # - #----------------------------------------- - - # - # Param checks - # - def param2int_list(self,s): - lst=string.split(string.replace(s,',',' ')) - try: - for i in range(len(lst)): - lst[i]=int(lst[i]) - except: - lst=[] - return lst - - def ParseCmdLine(self,cmd_line): - try: - opt_list=getopt(cmd_line,'vH:ho:p:r:t:V',['debug','host=','help', - 'optional=','port=','range=','timeout','version']) - for opt in opt_list[0]: - if opt[0]=='-v' or opt[0]=='--debug': - self.debug=1 - elif opt[0]=='-H' or opt[0]=='--host': - self.host=opt[1] - elif opt[0]=='-h' or opt[0]=='--help': - doc_help() - self.exit_code=1 # request termination - break - elif opt[0]=='-o' or opt[0]=='--optional': - self.opt_ports=self.param2int_list(opt[1]) - elif opt[0]=='-p' or opt[0]=='--port': - self.ports=self.param2int_list(opt[1]) - elif opt[0]=='-r' or opt[0]=='--range': - r=string.replace(opt[1],':','-') - self.ranges=r - elif opt[0]=='-t' or opt[0]=='--timeout': - self.timeout=opt[1] - elif opt[0]=='-V' or opt[0]=='--version': - print self.Version() - self.exit_code=1 # request termination - break - else: - self.host='' - break - - except: - # unknown param - self.host='' - - if self.debug: - print 'Params:' - print '-------' - print 'host = %s' % self.host - print 'timeout = %s' % self.timeout - print 'ports = %s' % self.ports - print 'optional ports = %s' % self.opt_ports - print 'ranges = %s' % self.ranges - print - - # - # a option that wishes us to terminate now has been given... - # - # This way, you can test params in debug mode and see what this - # program recognised by suplying a version param at the end of - # the cmd-line - # - if self.exit_code<>0: - sys.exit(self.UNKNOWN) - - if self.host=='': - doc_syntax() - self.exit_code=self.UNKNOWN - self.exit_msg='UNKNOWN: bad params, try running without any params for syntax' - - - def CheckHost(self): - 'Check one host using nmap.' - # - # Create a tmp file for storing nmap output - # - # The tempfile module from python 1.5.2 is stupid - # two processes runing at aprox the same time gets - # the same tempfile... - # For this reason I use a random suffix for the tmp-file - # Still not 100% safe, but reduces the risk significally - # I also inserted checks at various places, so that - # _if_ two processes in deed get the same tmp-file - # the only result is a normal error message to nagios - # - self.tmp_file=tempfile.mktemp('.%s') % random.randint(0,100000) - if self.debug: - print 'Tmpfile is: %s'%self.tmp_file - # - # If a range is given, only run nmap on this range - # - if self.ranges<>'': - global nmap_cmd # needed, to avoid error on next line - # since we assigns to nmap_cmd :) - nmap_cmd='%s -p %s' %(nmap_cmd,self.ranges) - # - # Prepare a task - # - t=utils.Task('%s %s' %(nmap_cmd,self.host)) - # - # Configure a time-out handler - # - th=utils.TimeoutHandler(t.Kill, time_to_live=self.timeout, - debug=self.debug) - # - # Fork of nmap cmd - # - t.Run(detach=0, stdout=self.tmp_file,stderr='/dev/null') - # - # Wait for completition, error or timeout - # - nmap_exit_code=t.Wait(idlefunc=th.Check, interval=1) - # - # Check for timeout - # - if th.WasTimeOut(): - self.exit_code=self.CRITICAL - self.exit_msg='CRITICAL - Plugin timed out after %s seconds' % self.timeout - return - # - # Check for exit status of subprocess - # Must do this after check for timeout, since the subprocess - # also returns error if aborted. - # - if nmap_exit_code <> 0: - self.exit_code=self.UNKNOWN - self.exit_msg='nmap program failed with code %s' % nmap_exit_code - return - # - # Read output - # - try: - f = open(self.tmp_file, 'r') - output=f.readlines() - f.close() - except: - self.exit_code=self.UNKNOWN - self.exit_msg='Unable to get output from nmap' - return - - # - # Store open ports in list - # scans for lines where first word contains '/' - # and stores part before '/' - # - self.active_ports=[] - try: - for l in output: - if len(l)<2: - continue - s=string.split(l)[0] - if string.find(s,'/')<1: - continue - p=string.split(s,'/')[0] - if string.find(l,'open')>1: - self.active_ports.append(int(p)) - except: - # failure due to strange output... - pass - - if self.debug: - print 'Ports found by nmap: ',self.active_ports - # - # Filter out optional ports, we don't check status for them... - # - try: - for p in self.opt_ports: - self.active_ports.remove(p) - - if self.debug and len(self.opt_ports)>0: - print 'optional ports removed:',self.active_ports - except: - # under extreame loads the remove(p) above failed for me - # a few times, this exception hanlder handles - # this bug-alike situation... - pass - - opened=self.CheckOpen() - closed=self.CheckClosed() - - if opened <>'': - self.exit_code=self.CRITICAL - self.exit_msg='PORTS CRITICAL - Open:%s Closed:%s'%(opened,closed) - elif closed <>'': - self.exit_code=self.WARNING - self.exit_msg='PORTS WARNING - Closed:%s'%closed - else: - self.exit_code=self.OK - self.exit_msg='PORTS ok - Only defined ports open' - - - # - # Compares requested ports on with actually open ports - # returns all open that should be closed - # - def CheckOpen(self): - opened='' - for p in self.active_ports: - if p not in self.ports: - opened='%s %s' %(opened,p) - return opened - - # - # Compares requested ports with actually open ports - # returns all ports that are should be open - # - def CheckClosed(self): - closed='' - for p in self.ports: - if p not in self.active_ports: - closed='%s %s' % (closed,p) - return closed - - - def CleanUp(self): - # - # If temp file exists, get rid of it - # - if self.tmp_file<>'' and os.path.isfile(self.tmp_file): - try: - os.remove(self.tmp_file) - except: - # temp-file colition, some other process already - # removed the same file... - pass - - # - # Show numerical exits as string in debug mode - # - if self.debug: - print 'Exitcode:',self.exit_code, - if self.exit_code==self.UNKNOWN: - print 'UNKNOWN' - elif self.exit_code==self.OK: - print 'OK' - elif self.exit_code==self.WARNING: - print 'WARNING' - elif self.exit_code==self.CRITICAL: - print 'CRITICAL' - else: - print 'undefined' - # - # Check if invalid exit code - # - if self.exit_code<-1 or self.exit_code>2: - self.exit_msg=self.exit_msg+' - undefined exit code (%s)' % self.exit_code - self.exit_code=self.UNKNOWN - - - - - -# -# Help texts -# -def doc_head(): - print """ -check_nmap plugin for Nagios -Copyright (c) 2000 Jacob Lundqvist (jaclu@galdrion.com) -License: GPL -Version: %s""" % _version_ - - -def doc_syntax(): - print """ -Usage: check_nmap.py [-v|--debug] [-H|--host host] [-V|--version] [-h|--help] - [-o|--optional port1,port2,port3 ...] [-r|--range range] - [-p|--port port1,port2,port3 ...] [-t|--timeout timeout]""" - - -def doc_help(): - 'Help is displayed if run without params.' - doc_head() - doc_syntax() - print """ -Options: - -h = help (this screen ;-) - -v = debug mode, show some extra output - -H host = host to check (name or IP#) - -o ports = optional ports that can be open (one or more), - no warning is given if optional port is closed - -p ports = ports that should be open (one or more) - -r range = port range to feed to nmap. Example: :1024,2049,3000:7000 - -t timeout = timeout in seconds, default 10 - -V = Version info - -This plugin attempts to verify open ports on the specified host. - -If all specified ports are open, OK is returned. -If any of them are closed, WARNING is returned (except for optional ports) -If other ports are open, CRITICAL is returned - -If possible, supply an IP address for the host address, -as this will bypass the DNS lookup. -""" - - -# -# Main -# -if __name__ == '__main__': - - if len (sys.argv) < 2: - # - # No params given, show syntax and exit - # - doc_syntax() - sys.exit(-1) - - nmap=CheckNmap(sys.argv[1:]) - exit_code,exit_msg=nmap.Run() - - # - # Give Nagios a msg and a code - # - print exit_msg - 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 7ce90c8f..00000000 --- a/contrib/check_ora_table_space.pl +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/perl -# -# Program check_ora_table_space -# Written by: Erwan Arzur (erwan@netvalue.com) -# License: GPL -# -# Last Modified: $Date: 2002-02-28 01:42:51 -0500 (Thu, 28 Feb 2002) $ -# Revisiin: $Revision: 2 $ -# -# "check_ora_table_space.pl" plugin to check the state of Oracle -# table spaces. Scarce documentation. -# -# you need DBD-Oracle-1.03.tar.gz and DBI-1.13.tar.gz from CPAN.org as -# well as some Oracle client stuff to use it. -# -# The SQL request comes from www.dbasupport.com -# - -use DBI; -$ENV{"ORACLE_HOME"}="/intranet/apps/oracle"; - -my $host = shift || &usage ("no host specified"); -my $sid = shift || &usage ("no sid specified"); -my $port = shift || &usage ("no port specified"); -my $dbuser = shift || &usage ("no user specified"); -my $dbpass = shift || &usage ("no password specified"); -my $tablespace = shift || &usage ("no table space specified"); - -my $alertpct = int(shift) || &usage ("no warning state percentage specified"); -my $critpct = int(shift) || &usage ("no critical state percentage specified"); - -my $dbh = DBI->connect( "dbi:Oracle:host=$host;port=$port;sid=$sid", $dbuser, $dbpass, { PrintError => 0, AutoCommit => 1, RaiseError => 0 } ) - || &error ("cannot connect to $dbname: $DBI::errstr\n"); - -#$sth = $dbh->prepare(q{SELECT tablespace_name, SUM(BYTES)/1024/1024 FreeSpace FROM dba_free_space group by tablespace_name}) -my $exit_code = -1; -$sth = $dbh->prepare(<<EOF -select a.TABLESPACE_NAME, a.total,nvl(b.used,0) USED, -nvl((b.used/a.total)*100,0) PCT_USED -from (select TABLESPACE_NAME, sum(bytes)/(1024*1024) total -from sys.dba_data_files group by TABLESPACE_NAME) a, -(select TABLESPACE_NAME,bytes/(1024*1024) used from sys.SM\$TS_USED) b -where a.TABLESPACE_NAME='$tablespace' and - a.TABLESPACE_NAME=b.TABLESPACE_NAME(+) -EOF -) - || &error("Cannot prepare request : $DBI::errstr\n"); -$sth->execute - || &error("Cannot execute request : $DBI::errstr\n"); - -while (($tbname, $total, $used, $pct_used) = $sth->fetchrow) -{ - $pct_used=int($pct_used); - print STDOUT "size: " . $total . " MB Used:" . int($used) . " MB (" . int($pct_used) . "%)\n"; - #print "table space $answer\n"; - if ($pct_used > $alertpct) { - if ($pct_used > $critpct) { - $exit_code = 2 - } else { - $exit_code = 1; - } - } else { - $exit_code = 0; - } -} - -$rc = $dbh->disconnect - || &error ("Cannot disconnect from database : $dbh->errstr\n"); - -exit ($exit_code); - -sub usage { - print "@_\n" if @_; - print "usage : check_ora_table_space.pl <host> <sid> <port> <user> <passwd> <tablespace> <pctwarn> <pctcrit>\n"; - exit (-1); -} - -sub error { - print "@_\n" if @_; - exit (2); -} - diff --git a/contrib/check_oracle_instance.pl b/contrib/check_oracle_instance.pl deleted file mode 100644 index 3ba8d57a..00000000 --- a/contrib/check_oracle_instance.pl +++ /dev/null @@ -1,470 +0,0 @@ -#!/usr/bin/perl -# $Id: check_oracle_instance.pl 10 2002-04-03 02:58:47Z sghosh $ - -# Copyright (c) 2002 Sven Dolderer -# some pieces of Code adopted from Adam vonNieda's oracletool.pl -# (http://www.oracletool.com) -# -# You may distribute under the terms of either the GNU General Public -# License or the Artistic License, as specified in the Perl README file, -# with the exception that it cannot be placed on a CD-ROM or similar media -# for commercial distribution without the prior approval of the author. - -# This software is provided without warranty of any kind. - -require 5.003; - -use strict; -use Getopt::Long; - -# We need the DBI and DBD-Oracle Perl modules: -require DBI || die "It appears that the DBI module is not installed! aborting...\n"; -require DBD::Oracle || die "It appears that the DBD::Oracle module is not installed! aborting...\n"; - -use 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); - -'$Revision: 10 $' =~ /^.*(\d+.\d+) \$$/; # Use The Revision from RCS/CVS -$VERSION = $1; -$0 =~ m!^.*/([^/]+)$!; -$PROGNAME = $1; -#$debug="true"; -$logfile = "/tmp/check_oracle_instance.log"; -my %ERRORS = (UNKNOWN => -1, OK => 0, WARNING => 1, CRITICAL => 2); - -# Read cmdline opts: -Getopt::Long::Configure('bundling', 'no_ignore_case'); -GetOptions ( - "V|version" => \&version, - "h|help" => \&usage, - "u|user=s" => \$username, - "p|passwd=s" => \$password, - "c|connect=s" => \$database, - "a|active-sessions:s" => \$opt_asession, - "s|num-sessions:s" => \$opt_nsession, - "t|tablespaces:s" => \$opt_tablespace, - "n|num-extents:s" => \$opt_nextents, - "f|free-extents:s" => \$opt_fextents, - "x|allocate-extents" => \$opt_aextents - ); -($database && $username && $password) || die "mandatory parameters missing (try -h)\n"; -logit(" \$opt_asession = \"$opt_asession\""); -logit(" \$opt_nsession = \"$opt_nsession\""); -logit(" \$opt_tablespace = \"$opt_tablespace\""); -logit(" \$opt_nextents = \"$opt_nextents\""); -logit(" \$opt_fextents = \"$opt_fextents\""); -logit(" \$opt_aextents = \"$opt_aextents\""); - -# so let's connect to the instance... -$dbh = dbConnect($database,$username,$password); - -$message="$database: "; -check_sessions($opt_nsession) if ($opt_nsession && $privsok); -check_sessions($opt_asession,"active") if ($opt_asession && $privsok); -check_tablespaces($opt_tablespace) if ($opt_tablespace && $privsok); -check_nextents($opt_nextents) if ($opt_nextents && $privsok); -check_fextents($opt_fextents) if ($opt_fextents && $privsok); -check_aextents() if ($opt_aextents && $privsok); - -$message=$message . "ok. " . getDbVersion($dbh) unless ($state); -print "$message\n"; -exit $state; - - -sub usage { - copyright(); - print " -This plugin will check various things of an oracle database instance. - -Prerequisties are: a local oracle client, - perl > v5.003, and DBI and DBD::Oracle perl modules. - -Usage: $PROGNAME -u <user> -p <passwd> -c <connectstring> - [-a <w>/<c>] [-s <w>/<c>] [-t <w>/<c>] [-n <w>/<c>] [-f <w>/<c>] [-x] - $PROGNAME [-V|--version] - $PROGNAME [-h|--help] -"; - print " -Options: - -u, --user=STRING - the oracle user - -p, --passwd=STRING - the oracle password - -c, --connect=STRING - the oracle connectstring as defined in tnsnames.ora - -a, --active-sessions=WARN/CRITICAL - check the number of active (user-)sessions - WARN(Integer): number of sessions to result in warning status, - CRITICAL(Integer): number of sessions to result in critical status - -s, --num-sessions=WARN/CRITICAL - check the total number of (user-)sessions - WARN(Integer): number of sessions to result in warning status, - CRITICAL(Integer): number of sessions to result in critical status - -t, --tablespaces=WARN/CRITICAL - check the percent of used space in every tablespace - WARN(Integer): percentage to result in warning status, - CRITICAL(Integer): percentage to result in critical status - -n, --num-extents=WARN/CRITICAL - check the number of extents of every object (excluding SYS schema) - WARN(Integer): number of extents to result in warning status, - CRITICAL(Integer): number of extents to result in critical status - -f, --free-extents=WARN/CRITICAL - check the number of free extents of every object: max_extents - #extents - WARN(Integer): number of free extents to result in warning status, - CRITICAL(Integer): number of free extents to result in critical status - -x, --allocate-extents - warn if an object cannot allocate a next extent. -"; - exit $ERRORS{"UNKNOWN"}; -} - - -sub version { - copyright(); - print " -$PROGNAME $VERSION -"; - exit $ERRORS{"UNKNOWN"}; -} - - -sub copyright { - print "The netsaint plugins come with ABSOLUTELY NO WARRANTY. You may redistribute -copies of the plugins under the terms of the GNU General Public License. -For more information about these matters, see the file named COPYING. -Copyright (c) 2002 Sven Dolderer\n"; -} - - -sub logit { - my $text = shift; - if ($debug) { - open (LOG,">>$logfile") || die "Cannot open log file \"$logfile\"!"; - print LOG "$text\n"; - close (LOG); - } -} - - -sub dbConnect { - logit("Enter subroutine dbConnect"); - - my $database = shift; - my $username = shift; - my $password = shift; - -# Attempt to make connection to the database.. - my $data_source = "dbi:Oracle:$database"; - $dbh = DBI->connect($data_source,$username,$password,{PrintError=>0}); - -# Show an error message for these errors. -# ORA-12224 - "The connection request could not be completed because the listener is not running." -# ORA-01034 - "Oracle was not started up." -# ORA-01090 - "Shutdown in progress - connection is not permitted"" -# ORA-12154 - "The service name specified is not defined correctly in the TNSNAMES.ORA file." -# ORA-12505 - "TNS:listener could not resolve SID given in connect descriptor." -# ORA-12545 - "TNS:name lookup failure." - - unless ($dbh) { - logit(" Error message is ~$DBI::errstr~"); - if ( $DBI::errstr =~ /ORA-01017|ORA-1017|ORA-01004|ORA-01005/ ) { - $message="Login error: ~$DBI::errstr~"; - $state=$ERRORS{"UNKNOWN"}; - } elsif ( $DBI::errstr =~ /ORA-12224/ ) { - $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."; - $state=$ERRORS{"CRITICAL"}; - } elsif ( $DBI::errstr =~ /ORA-01034/ ) { - $message= "You received an ORA-01034, which usually means the database is down. Check to be sure the database is up and try again."; - $state=$ERRORS{"CRITICAL"}; - } elsif ( $DBI::errstr =~ /ORA-01090/ ) { - $message= "You received an ORA-01090, which means the database is in the process of coming down."; - $state=$ERRORS{"CRITICAL"}; - } elsif ( $DBI::errstr =~ /ORA-12154/ ) { - $message= "You received an ORA-12154, which probably means you have a mistake in your TNSNAMES.ORA file for the database that you chose."; - $state=$ERRORS{"UNKNOWN"}; - } elsif ( $DBI::errstr =~ /ORA-12505/ ) { - $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."; - $state=$ERRORS{"UNKNOWN"}; - } elsif ( $DBI::errstr =~ /ORA-12545/ ) { - $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)."; - $state=$ERRORS{"UNKNOWN"}; - } else { - $message="Unable to connect to Oracle ($DBI::errstr)\n"; - $state=$ERRORS{"UNKNOWN"}; - } - - } else { - logit(" Login OK."); - - # check to be sure this user has "SELECT ANY TABLE" privilege. - logit(" checking for \"SELECT ANY TABLE\" privilege"); - if (checkPriv("SELECT ANY TABLE") < 1) { - $message="user $username needs \"SELECT ANY TABLE\" privilege."; - $state=$ERRORS{"UNKNOWN"}; - } else { - $privsok="yep"; - $state=$ERRORS{"OK"}; - } - } - return ($dbh); -} - - -sub getDbVersion { - - logit("Enter subroutine getDbVersion"); - - my $dbh = shift; - my $oraversion; - -# Find out if we are dealing with Oracle7 or Oracle8 - logit(" Getting Oracle version"); - $sql = "select banner from v\$version where rownum=1"; - - $cursor = $dbh->prepare($sql) or logit("Error: $DBI::errstr"); - $cursor->execute; - (($oraversion) = $cursor->fetchrow_array); - $cursor->finish; - logit(" Oracle version = $oraversion"); - return $oraversion; -} - - -sub checkPriv { - logit("Enter subroutine checkPriv"); - my ($privilege,$yesno); - $privilege = shift; - logit(" Checking for privilege \"$privilege\""); - - $sql = "SELECT COUNT(*) FROM SESSION_PRIVS WHERE PRIVILEGE = '$privilege'"; - $cursor=$dbh->prepare($sql); - $cursor->execute; $yesno = $cursor->fetchrow_array; - $cursor->finish; - - return($yesno); -} - - -sub get_values { - logit("Enter subroutine get_values"); - my ($args, $inverse, $abort); - $args = shift; - $inverse = shift; - if ($args =~ m!^(\d+)/(\d+)$!) { - $warn = $1; - $critical = $2; - - # TODO: check for positive numbers! - - if (! $inverse && $warn >= $critical) { - print "\"$args\": warning threshold must be less than critical threshold. aborting...\n"; - $abort="yep"; - } - if ($inverse && $warn <= $critical) { - print "\"$args\": warning threshold must be greater than critical threshold. aborting...\n"; - $abort="yep"; - } - } else { - print "\"$args\": invalid warn/critical thresholds. aborting...\n"; - $abort="yep"; - } - exit $ERRORS{"UNKNOWN"} if $abort; - logit (" args=$args, warn=$warn, critical=$critical"); -} - - -sub check_sessions { - logit("Enter subroutine check_sessions"); - my ($args, $add, $sqladd, $count); - $args = shift; - $add = shift || '#'; # Default: Number of sessions - $sqladd = "AND STATUS = 'ACTIVE'" if ($add eq "active"); - - get_values($args); - - $sql = "SELECT COUNT(*) FROM V\$SESSION WHERE TYPE <> 'BACKGROUND' $sqladd"; - $cursor=$dbh->prepare($sql); - $cursor->execute; - $count = $cursor->fetchrow_array; - $cursor->finish; - logit (" $add sessions is $count"); - - if ($count >= $critical) { - $message = $message . "$add sessions critical ($count) "; - $state=$ERRORS{"CRITICAL"}; - } elsif ($count >= $warn) { - $message = $message . "$add sessions warning ($count) "; - $state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"}; - } -} - - -sub check_tablespaces { - logit("Enter subroutine check_tablespaces"); - my ($args, $tablespace, $pctused, $mymsg, $mywarn, $mycritical); - $args = shift; - $mymsg = "Tablespace usage "; - - get_values($args); - - $sql = "SELECT - DF.TABLESPACE_NAME \"Tablespace name\", - NVL(ROUND((DF.BYTES-SUM(FS.BYTES))*100/DF.BYTES),100) \"Percent used\" - FROM DBA_FREE_SPACE FS, - (SELECT TABLESPACE_NAME, SUM(BYTES) BYTES FROM DBA_DATA_FILES GROUP BY - TABLESPACE_NAME ) DF - WHERE FS.TABLESPACE_NAME (+) = DF.TABLESPACE_NAME - GROUP BY DF.TABLESPACE_NAME, DF.BYTES - ORDER BY 2 DESC"; - - $cursor=$dbh->prepare($sql); - $cursor->execute; - while (($tablespace, $pctused) = $cursor->fetchrow_array) { - logit (" $tablespace - $pctused% used"); - if ($pctused >= $critical) { - unless ($mycritical) { - $mymsg = $mymsg . "critical: "; - $mycritical="yep"; - } - $mymsg = $mymsg . "$tablespace ($pctused%) "; - $state=$ERRORS{"CRITICAL"}; - } elsif ($pctused >= $warn) { - unless ($mywarn) { - $mymsg = $mymsg . "warning: "; - $mywarn="yep"; - } - $mymsg = $mymsg . "$tablespace ($pctused%) "; - $state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"}; - } - } - $cursor->finish; - $message = $message . $mymsg . " " if ($mycritical || $mywarn); -} - - -sub check_nextents { - logit("Enter subroutine check_nextents"); - my ($args, $owner, $objname, $objtype, $extents, $mymsg, $mywarn, $mycritical); - $args = shift; - $mymsg = "#Extents "; - - get_values($args); - - $sql = "SELECT - OWNER \"Owner\", - SEGMENT_NAME \"Object name\", - SEGMENT_TYPE \"Object type\", - COUNT(*) \"Extents\" - FROM DBA_EXTENTS WHERE OWNER <> 'SYS' - GROUP BY SEGMENT_TYPE, SEGMENT_NAME, TABLESPACE_NAME, OWNER - HAVING COUNT(*) >= $warn - ORDER BY 4 DESC"; - - $cursor=$dbh->prepare($sql); - $cursor->execute; - while (($owner, $objname, $objtype, $extents) = $cursor->fetchrow_array) { - if ($extents >= $critical) { - unless ($mycritical) { - $mymsg = $mymsg . "critical: "; - $mycritical="yep"; - } - $mymsg = $mymsg . "$owner.$objname($objtype)=$extents "; - $state=$ERRORS{"CRITICAL"}; - } elsif ($extents >= $warn) { - unless ($mywarn) { - $mymsg = $mymsg . "warning: "; - $mywarn="yep"; - } - $mymsg = $mymsg . "$owner.$objname($objtype)=$extents "; - $state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"}; - } - } - $cursor->finish; - $message = $message . $mymsg . " " if ($mycritical || $mywarn); -} - - -sub check_fextents { - logit("Enter subroutine check_fextents"); - my ($args, $owner, $objname, $objtype, $extents, $maxextents, $freextents, $mymsg, $mywarn, $mycritical); - $args = shift; - $mymsg = "Free extents "; - - get_values($args, "inverse"); - - $sql = "SELECT - OWNER \"Owner\", - SEGMENT_NAME \"Object name\", - SEGMENT_TYPE \"Object type\", - EXTENTS \"Extents\", - MAX_EXTENTS \"Max extents\", - MAX_EXTENTS - EXTENTS \"Free extents\" - FROM DBA_SEGMENTS - WHERE (EXTENTS + $warn) >= MAX_EXTENTS - AND SEGMENT_TYPE != 'CACHE' - ORDER BY 6"; - - $cursor=$dbh->prepare($sql); - $cursor->execute; - while (($owner, $objname, $objtype, $extents, $maxextents, $freextents) = $cursor->fetchrow_array) { - if ($freextents <= $critical) { - unless ($mycritical) { - $mymsg = $mymsg . "critical: "; - $mycritical="yep"; - } - $mymsg = $mymsg . "$owner.$objname($objtype)=$extents "; - $state=$ERRORS{"CRITICAL"}; - } elsif ($freextents <= $warn) { - unless ($mywarn) { - $mymsg = $mymsg . "warning: "; - $mywarn="yep"; - } - $mymsg = $mymsg . "$owner.$objname($objtype)=$extents/$maxextents "; - $state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"}; - } - } - $cursor->finish; - $message = $message . $mymsg . " " if ($mycritical || $mywarn); -} - - -sub check_aextents { - logit("Enter subroutine check_aextents"); - my ($args, $owner, $objname, $objtype, $tablespace_name, $mymsg, $mywarn); - my (@tablespaces); - - # Get a list of all tablespaces - $sql = "SELECT TABLESPACE_NAME - FROM DBA_TABLESPACES ORDER BY TABLESPACE_NAME"; - $cursor = $dbh->prepare($sql); - $cursor->execute; - while ($tablespace_name = $cursor->fetchrow_array) { - push @tablespaces, $tablespace_name; - } - $cursor->finish; - - # Search every tablespace for objects which cannot allocate a next extent. - foreach $tablespace_name(@tablespaces) { - logit (" checking tablespace $tablespace_name"); - $sql = "SELECT - OWNER \"Owner\", - SEGMENT_NAME \"Object name\", - SEGMENT_TYPE \"Object type\" - FROM DBA_SEGMENTS - WHERE TABLESPACE_NAME = '$tablespace_name' - AND NEXT_EXTENT > (SELECT NVL(MAX(BYTES),'0') FROM DBA_FREE_SPACE - WHERE TABLESPACE_NAME = '$tablespace_name')"; - $cursor = $dbh->prepare($sql); - $cursor->execute; - while (($owner, $objname, $objtype) = $cursor->fetchrow_array) { - logit (" found: $owner.$objname($objtype)"); - unless ($mywarn) { - $mymsg = $mymsg . "warning: "; - $mywarn="yep"; - } - $mymsg = $mymsg . "$owner.$objname($objtype) "; - $state=$ERRORS{"WARNING"} if $state < $ERRORS{"WARNING"}; - } - $cursor->finish; - } - $message = $message . $mymsg . "cannot allocate a next extent. " if $mywarn; -} diff --git a/contrib/check_oracle_tbs b/contrib/check_oracle_tbs deleted file mode 100644 index 8281a4e2..00000000 --- a/contrib/check_oracle_tbs +++ /dev/null @@ -1,218 +0,0 @@ -#!/usr/local/bin/perl -w - -# (c)2004 John Koyle, RFP Depot, LLC. -# This is free software use it however you would like. - -use strict; -use DBI; -use Getopt::Long 2.16; -use lib "/usr/local/nagios/libexec"; -use utils qw(%ERRORS); - - -#******************************************************************************* -# Set user configureable options here. -# -# Global Oracle info set here rather than command line to avoid output in ps -ef -# Make sure this script is mode 700 and owner of the nrpe user -# -#******************************************************************************* -my $orasid = ""; -my $orauser = ""; -my $orapwd = ""; - - -if (!$ENV{ORACLE_HOME}) { - $ENV{ORACLE_HOME} = '/u01/app/oracle/product/9.2'; -} - -#******************************************************************************* -my $state = $ERRORS{'UNKNOWN'}; -my $answer = undef; - -my ($MAJOR_VERSION, $MINOR_VERSION) = q$Revision: 1134 $ =~ /(\d+)\.(\d+)/; -my $VERSION = sprintf("%d.%02d", $MAJOR_VERSION - 1, $MINOR_VERSION); - -my $opt_debug; # -d|--debug -my $opt_help; # -h|--help -my $opt_version; # -V|--version -my $opt_warn_space; # -w|--warn-space -my $opt_crit_space; # -c|--crit-space - - - -my $help = <<MARK; # help statement - -check_oracle_tbs v$VERSION - -Checks the tablespaces in an Oracle database for available free space. -Usage: check_oracle_tbs [-w <warn>] [-c <crit>] - - -d, --debug Output debug to screen. - -h, --help Displays this help and exits. - -w, --warn-space=... Warning threshold % free (default 15) - -c, --crit-space=... Critical threshold % free (default 10) - -V, --version Output version information and exit. - -MARK - -## We want exact matches to the switches - -Getopt::Long::config('no_auto_abbrev', 'no_ignore_case'); - - -my $rc = GetOptions( - "debug|d" => \$opt_debug, - "help|h" => \$opt_help, - "w|warn-space=s" => \$opt_warn_space, - "c|crit-space=s" => \$opt_crit_space, - "V|version" => \$opt_version, - ); - - -#*********************************************************************** -# Process command-line switches -#*********************************************************************** - -if (! $rc || defined $opt_help) -{ - print STDERR $help; - exit (defined $opt_help ? 0 : 1); -} - -if (defined $opt_version) -{ - print STDERR "check_oracle_tbs v$VERSION\n"; - exit 0; -} - -if (! defined $opt_warn_space) -{ - if(defined $opt_debug) { - print STDOUT "Warn space not defined, using 80%\n\n"; - } - $opt_warn_space = 15; -} - -if (! defined $opt_crit_space) -{ - if(defined $opt_debug) { - print STDOUT "Crit space not defined, using 90%\n\n"; - } - $opt_crit_space = 10; -} - -my $array_ref = executeSQL(); - -# Don't match certain tablespaces. -foreach my $row (@$array_ref) { - my ( $tbs_name, $free_mb, $tot_mb, $free_pct) = @$row; - if ($opt_debug) { print STDOUT "Output: $tbs_name\t$tot_mb\t$free_mb\t$free_pct\n\n"; } - if ($free_pct < $opt_crit_space && $tbs_name !~ /RBS/ && $tbs_name !~ /PERFSTAT/ && $tbs_name !~ /UNDOTBS/) { - $state = $ERRORS{'CRITICAL'}; - $answer .= "Critical: $tbs_name = $free_pct\% "; - last; - } - if ($free_pct < $opt_warn_space && $tbs_name !~ /RBS/ && $tbs_name !~ /PERFSTAT/ && $tbs_name !~ /UNDOTBS/) { - $state = $ERRORS{'WARNING'}; - $answer .= "Warning: $tbs_name = $free_pct\% "; - } -} - -if ($state != $ERRORS{'CRITICAL'} && $state != $ERRORS{'WARNING'}) { - $state = $ERRORS{'OK'}; - $answer = "All Tablespaces OK"; -} - -if ($opt_debug && $state != $ERRORS{'OK'}) { print STDOUT "The following tablespaces are in question: $answer\n\n"; } - -foreach my $key (keys %ERRORS) { - if ($state==$ERRORS{$key}) { - print ("$key: $answer"); - last; - } -} -exit $state; - -#------------------SUBS------------------------------------------------------- -sub executeSQL -{ - my ($dbh, $sth, $results); - - $dbh = openOracle(); - - eval { - $dbh->{RaiseError} = 1; - $sth = $dbh->prepare(q{ - select ts.tablespace_name, - trunc(sum(ts.free_b)/1024/1024) free, - trunc(sum(ts.max_b)/1024/1024) total, - trunc( sum(ts.free_b)/sum(ts.max_b)*1000) / 10 as pct_free - from - (select a.file_id, - a.tablespace_name, - decode(a.autoextensible,'YES',a.maxsize-a.bytes+b.free,'NO',b.free) free_b, - a.maxsize max_b - from (select file_id, - tablespace_name, - autoextensible, - bytes, - decode(autoextensible,'YES',maxbytes,bytes) maxsize - from dba_data_files) a, - (select file_id, - tablespace_name, - sum(bytes) free - from dba_free_space - group by file_id, tablespace_name) b - where a.file_id=b.file_id(+)) ts - group by tablespace_name - }); - - $sth->execute(); - $results = $sth->fetchall_arrayref(); - $sth->finish; - $dbh->{RaiseError} = 0; - }; - - if ($@) { - closeOracle($dbh); - if($opt_debug) { print STDOUT "DB Failed Query: $@\n"; } - CleanupAndExit($ERRORS{'UNKNOWN'}); - } - - closeOracle($dbh); - - return $results; -} - -#------ Open the connection to the database and return the handle -sub openOracle -{ - my ($dbh); - - $dbh = DBI->connect("$orasid", "$orauser", "$orapwd", "Oracle"); - - if (!$dbh) { - if ($opt_debug) { print "ERROR: Could not connect to Oracle!\n\n"; } - CleanupAndExit($ERRORS{'UNKNOWN'}); - } - if ($opt_debug) { print "Connected to Oracle SID $orasid\n\n"; } - return $dbh; -} - -#------- Close the database connection -sub closeOracle() -{ - my ($dbh) = @_; - - $dbh->disconnect; -} - -#------ Exit with the current return code -sub CleanupAndExit -{ - my ($rc) = @_; - - exit($rc); -} - diff --git a/contrib/check_pcpmetric.py b/contrib/check_pcpmetric.py deleted file mode 100644 index 71d816d4..00000000 --- a/contrib/check_pcpmetric.py +++ /dev/null @@ -1,106 +0,0 @@ -#! /usr/bin/env python -# -# Nagios client for checking Performance Co-Pilot metrics -# -# - -from sys import argv,exit -import popen2, getopt, string, types - -DEBUG=0 - -nagios_pcpclient_version = 0.01 -PMVAL='/usr/bin/pmval' -COMMANDLINE=PMVAL + " -s 1" -METRIC='undefined' -CRITICAL=0 -WARNING=0 - -def usage(): - print "Usage:", argv[0], "[options]" - print "Options:" - print "\t[-H host]\tHostname to contact" - print "\t[-m metric]\tPCP metric to check" - print "\t[-i instance]\tPCP metric instance" - print "\t[-w warn]\tIssue warning alert if value is larger than this" - print "\t[-c critical]\tIssue critical alert value is larger than this" - print "\t[-V]\t\tProgram version" - print "\t[-h]\t\tThis helptext" - print "" - print "F.ex. to check 5 minute loadaverage, warn if the load is above 2," - print "and give critical warning if it's above 10:" - print "\n\t%", argv[0], " -i 5 -m kernel.all.load -w 2 -c 10" - print "" - print "A list of all PCP metrics can be found with the command 'pminfo'." - print "A list of all instances within a metric can be found with 'pminfo -f metric'." - print "F.ex. to see all available instances of 'filesys.full' execute:" - print "\n\t% pminfo -f filesys.full" - print "\tfilesys.full" - print """\t\tinst [0 or "/dev/root"] value 45.35514044640914""" - print """\t\tinst [1 or "/dev/sda1"] value 46.74285959344712""" - print """\t\tinst [2 or "/dev/sdb1"] value 0.807766570678168""" - print "" - print "And the command to have nagios monitor the /dev/sda1 filesystem would be:" - print "\n\t", argv[0], " -i /dev/sda1 -m filesys.full -w 70 -c 90" - - -opts, args = getopt.getopt(argv[1:],'hH:c:w:m:i:V') -for opt in opts: - key,value = opt - if key == '-H': - COMMANDLINE = COMMANDLINE + " -h " + value - elif key == '-m': - METRIC=value - elif key == '-i': - COMMANDLINE = COMMANDLINE + " -i " + value - elif key == '-c': - CRITICAL = value - elif key == '-w': - WARNING = value - elif key == '-h': - usage() - exit(0) - elif key == '-V': - print "Nagios Performance CoPilot client v%.2f" % nagios_pcpclient_version - print "Written by Jan-Frode Myklebust <janfrode@parallab.uib.no>" - exit(0) - -if METRIC == 'undefined': - usage() - exit(3) - -COMMANDLINE = COMMANDLINE + " " + METRIC -if DEBUG: print COMMANDLINE -p=popen2.Popen4(COMMANDLINE) -exitcode=p.wait() - -# Get the last line of output from 'pmval': -buffer = p.fromchild.readline() -while (buffer != ''): - output=buffer - buffer = p.fromchild.readline() - -returndata = string.split(output)[0] - - -# Confirm that we have gotten a float, and not -# some errormessage in the returndata. If not, -# print the error, and give the UNKNOWN exit code: - -try: - retval = string.atof(returndata) -except ValueError, e: - print e - exit(3) - -if (retval < WARNING): - EXITCODE=0 -elif (retval > CRITICAL): - EXITCODE=2 -elif (retval > WARNING): - EXITCODE=1 -else: - EXITCODE=3 - -print retval -exit(EXITCODE) diff --git a/contrib/check_pfstate b/contrib/check_pfstate deleted file mode 100644 index 57dde3f6..00000000 --- a/contrib/check_pfstate +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/perl - -use strict; -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_P $opt_H $opt_w $opt_c $PROGNAME); -use lib "/usr/local/nagios/libexec" ; -use utils qw(%ERRORS &print_revision &support &usage); - -my $remote_user = "root"; -my $path_to_ssh = "/usr/bin/ssh"; -my $path_to_grep = "/usr/bin/grep"; -my $path_to_awk = "/usr/bin/awk"; -my $warn = 50000; -my $crit = 60000; - -$PROGNAME = "check_pfstate"; -$ENV{'PATH'}=''; -$ENV{'BASH_ENV'}=''; -$ENV{'ENV'}=''; - -Getopt::Long::Configure('bundling'); -GetOptions - ("V" => \$opt_V, "version" => \$opt_V, - "h" => \$opt_h, "help" => \$opt_h, - "H=s" => \$opt_H, "hostname=s" => \$opt_H, - "w=s" => \$opt_w, "warning=s" => \$opt_w, - "c=s" => \$opt_c, "critical=s" => \$opt_c); - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1112 $'); - exit $ERRORS{'OK'}; -} -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} -if ($opt_w) { - if ($opt_w =~ /(\d+)/) { - $warn = $1; - } else { - usage("Invalid values: $opt_w\n"); - exit $ERRORS{'OK'}; - } -} -if ($opt_c) { - if ($opt_c =~ /(\d+)/) { - $crit = $1; - } else { - usage("Invalid values: $opt_c\n"); - exit $ERRORS{'OK'}; - } -} -($opt_H) || usage("Host name/address not specified\n"); -my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); -($host) || usage("Invalid host: $opt_H\n"); - -my $result = `$path_to_ssh -l $remote_user $host '/sbin/pfctl -s info' | $path_to_grep entries`; -chomp $result; -$result =~ /(\d+)/; -$result = $1; - -print "$result PF state entries\n"; - -exit $ERRORS{'CRITICAL'} if ($result >= $crit); -exit $ERRORS{'WARNING'} if ($result >= $warn); -exit $ERRORS{'OK'}; - - -sub print_help { - print_revision($PROGNAME,'$Revision: 1112 $'); - print "Copyright (c) 2002 Jason Dixon\n\nThis plugin checks the number of state table entries on a PF-enabled OpenBSD system.\n\n"; - print "Usage:\t-H, --hostname=<HOST> [-w, --warning=<WARNING>] [-c, --critical=<CRITICAL>]\n\n\tDefault warning is 50000 and critical is 60000.\n\n"; - support(); -} - diff --git a/contrib/check_qmailq.pl b/contrib/check_qmailq.pl deleted file mode 100755 index 4c3f68ff..00000000 --- a/contrib/check_qmailq.pl +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/perl -# -# check_qmailq.pl - nagios plugin -# This plugin allows you to check the number of Mails in a qmail- -# queue. PLUGIN NEEDS CONFIGURATION ! (see below) -# -# Copyright 2000 Benjamin Schmid -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# -# Emergency E-Mail :) blueshift@gmx.net -# - -### CONFIGURATION SECTION #################### - -my $statcommand = "/var/qmail/bin/qmail-qstat"; -my $queuewarn = 5; # Warning, if more than x mail in Queue -my $queuecrit = 10; # Critical if "--" -my $prewarn = 1; # Warning, if more than x unhandled mails - # (not in Queue -my $precrit = 5; # Critical, if "--" - -### CONFIURATION SECTION END ################ - -use strict; -use Carp; - -#use Getopt::Long; -#&Getopt::Long::config('auto_abbrev'); - - - -my $TIMEOUT = 15; - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); - -my $state = "UNKNOWN"; -my $answer = ""; - -#sub usage { -# printf "\nMissing arguments!\n"; -# printf "\n"; -# printf "Printer Server Queue Nagios Plugin\n"; -# printf "monitors jobs in lpr queues\n"; -# printf "usage: \n"; -# printf "check_lpq.pl \n"; -# printf "Copyright (C) 2000 Benjamin Schmid\n"; -# printf "check_lpq.pl comes with ABSOLUTELY NO WARRANTY\n"; -# printf "This programm is licensed under the terms of the "; -# printf "GNU General Public License\n(check source code for details)\n"; -# printf "\n\n"; -# exit $ERRORS{"UNKNOWN"}; -#} - -# Just in case of problems, let's not hang Nagios -$SIG{'ALRM'} = sub { - print ("ERROR: check_lpq.pl Time-Out $TIMEOUT s \n"); - exit $ERRORS{"UNKNOWN"}; -}; -alarm($TIMEOUT); - - -#$status = GetOptions("community=s",\$community, -# "port=i",\$port); -#if ($status == 0) -#{ -# &usage; -#} - -# $hostname = shift || &usage; - -if (! open STAT, "$statcommand|") { - print ("$state: $statcommand returns no result!"); - exit $ERRORS{$state}; -} -my @lines = <STAT>; -close STAT; - -# Mails in Queues -if ($lines[0]=~/^messages in queue: (\d+)/) { - my $anzq = $1; - $answer = $answer . "$anzq"; - $state='WARNING' if ($anzq >= $queuewarn); - $state='CRITICAL' if ($anzq >= $queuecrit); -} else { - $state='CRITICAL'; - $answer="Keine gueltigte Antwort (Zeile #1) von $statcommand\n"; -} - -# Unverarbeite Mails -if ($lines[1]=~/^messages in queue but not yet preprocessed: (\d+)/) { - my $anzp = $1; - $answer = $answer . " E-Mail(s) nicht ausgeliefert, $anzp unverarbeitet."; - $state='WARNING' if ($anzp >= $prewarn && $state eq 'UNKNOWN'); - $state='CRITICAL' if ($anzp >= $precrit); -} else { - $state='CRITICAL'; - $answer=$answer . "Keine gueltigte Antwort (Zeile #2) von $statcommand\n"; -} - -$state = 'OK' if ($state eq 'UNKNOWN'); - -print ("$state: $answer\n"); -exit $ERRORS{$state}; - diff --git a/contrib/check_rbl.c b/contrib/check_rbl.c deleted file mode 100644 index eec84ad8..00000000 --- a/contrib/check_rbl.c +++ /dev/null @@ -1,328 +0,0 @@ -/****************************************************************************** -* -* check_rbl.c -* -* Modified by Tim Bell <bhat@trinity.unimelb.edu.au> 2002-06-05 -* based on: -* -* * check_dig.c -* * -* * Program: dig plugin for NetSaint -* * License: GPL -* * Copyright (c) 2000 -* * -* * $Id: check_rbl.c 970 2004-12-02 00:30:32Z opensides $ -* -*****************************************************************************/ - -#include "config.h" -#include "common.h" -#include "utils.h" -#include "popen.h" -#include "string.h" - -const char progname = "check_rbl"; -const char *revision = "$Revision: 970 $"; -//const char *copyright = "2000-2003"; -//const char *email = "nagiosplug-devel@lists.sourceforge.net"; - -int process_arguments(int, char **); -int call_getopt(int, char **); -int validate_arguments(void); -int check_disk(int usp,int free_disk); -void print_help(void); -void print_usage(void); -char *reverse_ipaddr(char *ipaddr); - -char *query_address=NULL; -char *query_address_rev=NULL; -char *dns_server=NULL; -char *rbl_name=NULL; -int verbose=FALSE; - -int main(int argc, char **argv){ - char input_buffer[MAX_INPUT_BUFFER]; - char *command_line=NULL; - char *output=NULL; - int result=STATE_OK; - - /* Set signal handling and alarm */ - if (signal(SIGALRM,popen_timeout_alarm_handler)==SIG_ERR) - usage("Cannot catch SIGALRM\n"); - - if (process_arguments(argc,argv)!=OK) - usage (_("check_rbl: could not parse arguments\n")); - - /* reverse the octets in the IP address */ - query_address_rev = reverse_ipaddr(query_address); - - /* build the command to run */ - if (dns_server) { - command_line=ssprintf(command_line,"%s @%s %s.%s", - PATH_TO_DIG,dns_server, - query_address_rev, rbl_name); - } else { - command_line=ssprintf(command_line,"%s %s.%s", - PATH_TO_DIG, - query_address_rev, rbl_name); - } - alarm(timeout_interval); - time(&start_time); - - if (verbose) - printf("%s\n",command_line); - /* run the command */ - child_process=spopen(command_line); - if (child_process==NULL) { - printf("Could not open pipe: %s\n",command_line); - return STATE_UNKNOWN; - } - - child_stderr=fdopen(child_stderr_array[fileno(child_process)],"r"); - if(child_stderr==NULL) - printf("Could not open stderr for %s\n",command_line); - - output=strscpy(output,""); - - while (fgets(input_buffer,MAX_INPUT_BUFFER-1,child_process)) { - - /* the server is responding, we just got the host name... */ - if (strstr(input_buffer,";; ANSWER SECTION:")) { - - /* get the host address */ - if (!fgets(input_buffer,MAX_INPUT_BUFFER-1,child_process)) - break; - - if (strpbrk(input_buffer,"\r\n")) - input_buffer[strcspn(input_buffer,"\r\n")] = '\0'; - - if (strstr(input_buffer,query_address_rev)==input_buffer) { - output=strscpy(output,input_buffer); - /* we found it, which means it's listed! */ - result=STATE_CRITICAL; - } else { - strcpy(output,"Server not RBL listed."); - result=STATE_OK; - } - - continue; - } - - } - - /* - if (result!=STATE_OK) { - strcpy(output,"No ANSWER SECTION found"); - } - */ - - while (fgets(input_buffer,MAX_INPUT_BUFFER-1,child_stderr)) { - /* If we get anything on STDERR, at least set warning */ - result=error_set(result,STATE_WARNING); - printf("%s",input_buffer); - if (!strcmp(output,"")) - strcpy(output,1+index(input_buffer,':')); - } - - (void)fclose(child_stderr); - - /* close the pipe */ - if (spclose(child_process)) { - result=error_set(result,STATE_WARNING); - if (!strcmp(output,"")) - strcpy(output,"nslookup returned an error status"); - } - - (void)time(&end_time); - - if (result==STATE_OK) - printf("RBL check okay - not listed.\n"); - else if (result==STATE_WARNING) - printf("RBL WARNING - %s\n",!strcmp(output,"")?" Probably a non-existent host/domain":output); - else if (result==STATE_CRITICAL) - printf("RBL CRITICAL - %s is listed on %s\n",query_address, rbl_name); - else - printf("DNS problem - %s\n",!strcmp(output,"")?" Probably a non-existent host/domain":output); - - return result; -} - - - -/* reverse the ipaddr */ -char *reverse_ipaddr(char *ipaddr) -{ - static char revip[MAX_HOST_ADDRESS_LENGTH]; - int a, b, c, d; - - if (strlen(ipaddr) >= MAX_HOST_ADDRESS_LENGTH || - sscanf(ipaddr, "%d.%d.%d.%d", &a, &b, &c, &d) != 4) { - usage("IP address invalid or too long"); - } - sprintf(revip, "%d.%d.%d.%d", d, c, b, a); - - return revip; -} - - - -/* process command-line arguments */ -int process_arguments(int argc, char **argv) -{ - int c; - - if(argc<2) - return ERROR; - - - c=0; - while((c+=(call_getopt(argc-c,&argv[c])))<argc){ - - if (is_option(argv[c])) - continue; - - if (query_address==NULL) { - if (is_host(argv[c])) { - query_address=argv[c]; - } else { - usage("Invalid host name"); - } - } - } - - return validate_arguments(); -} - - - -int call_getopt(int argc, char **argv) -{ - int c,i=0; - -#ifdef HAVE_GETOPT_H - int option_index = 0; - static struct option long_options[] = - { - {"hostname", required_argument,0,'H'}, - {"server", required_argument,0,'s'}, - {"rblname", required_argument,0,'r'}, - {"verbose", no_argument, 0,'v'}, - {"version", no_argument, 0,'V'}, - {"help", no_argument, 0,'h'}, - {0,0,0,0} - }; -#endif - - while (1){ -#ifdef HAVE_GETOPT_H - c = getopt_long(argc,argv,"+hVvt:s:H:r:",long_options,&option_index); -#else - c = getopt(argc,argv,"+?hVvt:s:H:r:"); -#endif - - i++; - - if(c==-1||c==EOF||c==1) - break; - - switch (c) - { - case 't': - case 'l': - case 'H': - i++; - } - - switch (c) - { - case 'H': /* hostname */ - if (is_host(optarg)) { - query_address=optarg; - } else { - usage("Invalid host name (-H)\n"); - } - break; - case 's': /* server */ - if (is_host(optarg)) { - dns_server=optarg; - } else { - usage("Invalid host name (-s)\n"); - } - break; - case 'r': /* rblname */ - rbl_name=optarg; - break; - case 'v': /* verbose */ - verbose=TRUE; - break; - case 't': /* timeout */ - if (is_intnonneg(optarg)) { - timeout_interval=atoi(optarg); - } else { - usage("Time interval must be a nonnegative integer\n"); - } - break; - case 'V': /* version */ - print_revision(progname,"$Revision: 970 $"); - exit(STATE_OK); - case 'h': /* help */ - print_help(); - exit(STATE_OK); - case '?': /* help */ - printf (_("%s: Unknown argument: %s\n\n"), progname, optarg); - print_usage (); - exit (STATE_UNKNOWN); - } - } - return i; -} - - - -int validate_arguments(void) -{ - if (query_address == NULL || rbl_name == NULL) - return ERROR; - else - return OK; -} - - - -void print_help(void) -{ - print_revision(progname,"$Revision: 970 $"); - printf - ("Copyright (c) 2000 Karl DeBisschop\n\n" - "This plugin uses dig to test whether the specified host is on any RBL lists.\n\n"); - print_usage(); - printf - ("\nOptions:\n" - " -H, --hostname=IPADDRESS\n" - " Check status of indicated host\n" - " -s, --server=STRING or IPADDRESS\n" - " DNS server to use\n" - " -r, --rblname=STRING\n" - " RBL domain name to use (e.g. relays.ordb.org)\n" - " -t, --timeout=INTEGER\n" - " Seconds before connection attempt times out (default: %d)\n" - " -v, --verbose\n" - " Print extra information (command-line use only)\n" - " -h, --help\n" - " Print detailed help screen\n" - " -V, --version\n" - " Print version information\n\n", - DEFAULT_SOCKET_TIMEOUT); - support(); -} - - - -void print_usage(void) -{ - printf - ("Usage: %s -H hostip -r rblname [-s server] [-t timeout] [-v]\n" - " %s --help\n" - " %s --version\n", - progname, progname, progname); -} diff --git a/contrib/check_remote_nagios_status.pl b/contrib/check_remote_nagios_status.pl deleted file mode 100644 index dc99705e..00000000 --- a/contrib/check_remote_nagios_status.pl +++ /dev/null @@ -1,666 +0,0 @@ -#!/usr/bin/perl -w - -# check_status.pl Nagios Plugin - Version 1.3 -# Last Updated: 1/9/2003 -# -# Report any bugs/questions to Russell Scibetti at russell@quadrix.com -# -# check_status Change Log: -# -# To do for 1.4 -# - Better help and documentation (separate doc?) -# - Take argument (patterns to match) from a separate spec file -# -# New Addition to 1.3 -# - Added ChangeLog information and updated --help output -# - hostdown (hd) argument for how a service check should respond -# when its host is Down/Unreachable -# (--hostdown="ok|warning|critical|unknown") -# - Changed name from check_state to check_status -# - Set hostdown to default to OK when the argument isn't specified -# - Number of Hosts checked is now output in OK result -# -# Version 1.2 additions: -# -# - Added ability to handle ack'd and downtimed services differently -# depending on argument provided -# (--ack="ok|warning|critical|unknown|down|unreachable" -# --dt="ok|warning|critical|unknown|down|unreachable") -# -# Version 1.1 additions: -# -# - Added --host=<regex>, --servhost=<regex> to allow for specific field -# matching (host for matching hostname in host checks, servhost for -# matching the hostname in service checks, service for matching the -# service name in service checks) -# - Output the number of OK services for an OK output -# -# Version 1.0 features: -# -# - Freshness check of status.log (timestamp) -# - Match service or host checks -# - Can ignore acknowledged or downtimes services/hosts (--ack, --dt) -# - Can output different levels of detail dependent on # of problems -# - Can check for number of critical, warning, or unknowns -# -############################################################# - -use Getopt::Long; -use File::stat; - -Getopt::Long::Configure('bundling'); - -GetOptions - ("V" => \$version, "version" => \$version, - "h" => \$help, "help" => \$help, - "v" => \$verbose, "verbose" => \$verbose, - "w=s" => \$warning, "warning=s" => \$warning, - "c=s" => \$critical, "critical=s" => \$critical, - "u=s" => \$unknown, "unknown=s" => \$unknown, - "p=s" => \$pattern, "pattern=s" => \$pattern, - "S:s" => \$service, "service:s" => \$service, - "s=s" => \$status, "status=s" => \$status, - "d=s" => \$dir, "dir=s" => \$dir, - "D=s" => \$details, "details=s" => \$details, - "H:s" => \$host, "host:s" => \$host, - "f=s" => \$freshness, "freshness=s" => \$freshness, - "servhost=s" => \$servhost, - "a:s" => \$ack, "ack:s" => \$ack, - "dt:s"=> \$dt, "downtime:s" => \$dt, - "hd:s"=> \$hdown, "hostdown:s" => \$hdown, - "ok" => \$ok); - -#Constants: -my $OK = 0; -my $WARNING = 1; -my $CRITICAL = 2; -my $UNKNOWN = 3; - -my $crit="CRITICAL"; -my $warn="WARNING"; -my $unk="UNKNOWN"; -my $down="DOWN"; -my $unreach="UNREACHABLE"; - -# Print out Help information -if ($help) { - printVersion(); - printHelp(); - exitcheck($UNKNOWN); -} - -# Print out version information -if ($version) { - printVersion(); - exitcheck($UNKNOWN); -} - -# Check for status log or directory argument or print usage -if (!$status) { - if (!$dir) { - print "Usage: $0 -s <status file> | -d <Nagios log dir>\n"; - print "Use the --help option for full list of arguments\n"; - exitcheck($UNKNOWN); - } - elsif ($dir =~ m#[^/]/$#) { - $status = $dir . "status.log"; - } - else { - $status = $dir . "/status.log"; - } -} - -if (defined $host) { - if (!$host) { - $host="[^\\s]*"; - } -} - -if (!$host && !$servhost) { - $servhost="[^\\s]*"; -} - -if (!$host && !$service) { - $service="[^\\s]*"; -} - -if (defined $ack) { - if (!$ack) { - $ack="ok"; - } - elsif (!($ack =~ "ok|critical|warning|unknown|down|unreachable")) { - print "Invalid value for ack\n"; - exitcheck($UNKNOWN); - } -} - -if (defined $dt) { - if (!$dt) { - $dt="ok"; - } - elsif (!($dt =~ "ok|critical|warning|unknown|down|unreachable")) { - print "Invalid value for dt\n"; - exitcheck($UNKNOWN); - } -} - -if (defined $hdown) { - if (!$hdown) { - $hdown="ok"; - } - elsif (!($hdown =~ "ok|critical|warning|unknown|down|unreachable")) { - print "Invalid value for hostdown\n"; - exitcheck($UNKNOWN); - } -} - -my $much_details = 0; - -my $ServiceNotOK = "CRITICAL|WARNING|UNKNOWN"; -my $HostNotOK = "DOWN|UNREACHABLE"; - -my %numprob = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0,"DOWN",0,"UNREACHABLE",0); - -my $CritOnly = 0; -my $WarnOnly = 0; -my $UnkOnly = 0; - -my @wlev; -my @clev; -my @ulev; -my %warnlevel = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0); -my %critlevel = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0); -my %unklevel = ("WARNING",0,"CRITICAL",0,"UNKNOWN",0); -my %hostlevel = ("DOWN",0,"UNREACHABLE",0); - -# Store Hosts in downtime -my @hostdowntime; -my $numdowntime = 0; - -# Store Hosts in a Down/Unreachable state -my @hostdown; -my $numdown = 0; - -# Hash for storing state-change to OK times for hosts: -my %hostoktimes; - -# Number of matches in parsing -my $nummatch = 0; - -if ($warning) { - if ($warning =~ /,/) { - @wlev = split /,/,$warning; - $warnlevel{"WARNING"} = $wlev[0]; - $warnlevel{"CRITICAL"} = $wlev[1]; - if ($wlev[2] ) { - $warnlevel{"UNKNOWN"} = $wlev[2]; - } - } - else { - $WarnOnly = $warning; - } -} -else { - $WarnOnly = 1; -} - -if ($critical) { - if ($critical =~ /,/) { - @clev = split /,/,$critical; - $critlevel{"WARNING"} = $clev[0]; - $critlevel{"CRITICAL"} = $clev[1]; - if ($clev[2] ) { - $critlevel{"UNKNOWN"} = $clev[2]; - } - } - else { - $CritOnly = $critical; - } -} -else { - $CritOnly = 1; -} - -if ($unknown) { - if ($unknown =~ /,/) { - @ulev = split /,/,$unknown; - $unklevel{"WARNING"} = $ulev[0]; - $unklevel{"CRITICAL"} = $ulev[1]; - if ($ulev[2] ) { - $unklevel{"UNKNOWN"} = $ulev[2]; - } - } - else { - $UnkOnly = $unknown; - } -} -else { - $UnkOnly = 1; -} - - -if (!$freshness) { - $freshness = 30 * 60; -} -else { - $freshness = $freshness * 60; -} - -my %ct = ("CRITICAL",0,"WARNING",0,"UNKNOWN",0,"DOWN",0,"UNREACHABLE",0); -my %much_ct = ("CRITICAL",0,"WARNING",0,"UNKNOWN",0,"DOWN",0,"UNREACHABLE",0); - -my %output = ("CRITICAL","","WARNING","","UNKNOWN","","DOWN","","UNREACHABLE",""); -my %much_output = ("CRITICAL","","WARNING","","UNKNOWN","","DOWN","","UNREACHABLE",""); - -if ($details) { - if ($details =~ /,/) { - my @tempv = split /,/,$details; - $much_details = $tempv[0]; - $details = $tempv[1]; - } -} - -open("sta","$status") || die "Cannot open status file $status!"; - -$curr_time = time; -$file_time = stat($status)->mtime; - -if ($curr_time - $file_time > $freshness) { - printf "State CRITICAL - Status file is stale!!!\n"; - exitcheck($CRITICAL); -} - -while(<sta>) { - chomp; - if (/^[^\s]+[\s]+HOST;/) { - @hdata = split /;/,$_; - -# If you care about matching hosts (not services): - if ($host && $hdata[1] =~ /$host/) { - $nummatch++; - if ( $hdata[2] =~ /$HostNotOK/ ) { - addproblem($_,$hdata[2]); - } - } - -# If you are matching services, gather host information: - else { - if ( $hdata[2] =~ /$HostNotOK/ ) { - $hostdown[$numdown] = $hdata[1]; - $numdown++; - } - else { - $hostoktimes{$hdata[1]} = $hdata[4]; - } - if ( $hdata[17] ne "0" ) { - $hostdowntime[$numdowntime] = $hdata[1]; - $numdowntime++; - } - } - } - elsif (!$host && /^[^\s]+[\s]+SERVICE;/) { - @servdata = split /;/,$_; - if ( ( $pattern && ($_ =~ /$pattern/)) || - (($servdata[1] =~ /$servhost/) && ($servdata[2] =~ /$service/)) ){ - $nummatch++; - if (($servdata[5] eq "HARD") && ($servdata[3] =~ /$ServiceNotOK/)) { - addproblem($_,$servdata[3]); - } - } - } -} - -close("sta"); - -if ($nummatch==0) { - print "Nothing Matches your criteria!\n"; - exitcheck($UNKNOWN); -} - -# Count the number of problems (for reference): -if ($host) { - $total = $numprob{"DOWN"} + $numprob{"UNREACHABLE"}; -} -else { - $total = $numprob{"WARNING"} + $numprob{"CRITICAL"} + $numprob{"UNKNOWN"}; -} - -my $numok = $nummatch - $total; - -# If this is a host state check: -if ($host) { - if ($numprob{"DOWN"}>0 || $numprob{"UNREACHABLE"}>0 ) { - if ($details && ($total <= $details)) { - print "State CRITICAL - $total Host Problems: $output{$down} $output{$unreach}\n"; - exitcheck($CRITICAL); - } - else { - print "State CRITICAL - $numprob{$down} Hosts Down, $numprob{$unreach} Hosts Unreachable\n"; - exitcheck($CRITICAL); - } - } - else { - print "State OK - $numok Hosts Up, $total Problems\n"; - exitcheck($OK); - } -} - -#If you only defined a Critical level in terms of # of criticals... -elsif ($CritOnly && ($numprob{"CRITICAL"} >= $CritOnly)) { - countAndPrint($crit,$numprob{$crit},0); - exitcheck($CRITICAL); -} - -#Critical in terms on # criticals and # warnings... -elsif (!$CritOnly && ($numprob{"WARNING"} >= $critlevel{"WARNING"} || - $numprob{"CRITICAL"} >= $critlevel{"CRITICAL"} || - $numprob{"UNKNOWN"} >= $critlevel{"UNKNOWN"} )) { - countAndPrint($crit,$total,1); - exitcheck($CRITICAL); -} - -#Warning in terms of # warnings only... -elsif ($WarnOnly && ($numprob{"WARNING"} >= $WarnOnly)) { - countAndPrint($warn,$numprob{$warn},0); - exitcheck($WARNING); -} - -#Warning in terms of # warnings and # criticals... -elsif (!$WarnOnly && ($numprob{"WARNING"} >= $warnlevel{"WARNING"} || - $numprob{"CRITICAL"} >= $warnlevel{"CRITICAL"} || - $numprob{"UNKNOWN"} >= $warnlevel{"UNKNOWN"})) { - countAndPrint($warn,$total,1); - exitcheck($WARNING); -} - -#Unknown in terms on # unknown only... -elsif ( $UnkOnly && ($numprob{"UNKNOWN"}>=$UnkOnly) ) { - countAndPrint($unk,$numprob{$unk},0); - exitcheck($UNKNOWN); -} - -#Unknown in terms of # warning, critical, and unknown... -elsif (!$UnkOnly && ($numprob{"WARNING"} >= $unklevel{"WARNING"} || - $numprob{"CRITICAL"} >= $unklevel{"CRITICAL"} || - $numprob{"UNKNOWN"} >= $unklevel{"UNKNOWN"})) { - countAndPrint($unk,$total,1); - exitcheck($UNKNOWN); -} - -# Everything is OK! -else { - print "State OK - $numok OK, $total problems\n"; - exitcheck($OK); -} - - - -############################ -# Subroutines -############################ - -# Return the proper exit code for Critical, Warning, Unknown, or OK -sub exitcheck { - if ($ok) { - exit 0; - } - else { - exit $_[0]; - } -} - -# Decide what to print for services: -sub countAndPrint { - my $state = $_[0]; - my $count = $_[1]; - my $alltypes = $_[2]; - my $output = "State $state - "; - - if ($details) { - if ($count<=$much_details) { - if ($alltypes) { - $output .= "$count problems: $much_output{$crit} $much_output{$warn} $much_output{$unk}"; - } - else { - $output .= "$count \L$state\E: $much_output{$state}"; - } - } - elsif ($count<=$details) { - if ($alltypes) { - $output .= "$count problems: $output{$crit} $output{$warn} $output{$unk}"; - } - else { - $output .= "$count \L$state\E: $output{$state}"; - } - } - else { - if ($alltypes) { - $output .= "$numprob{$crit} critical, $numprob{$warn} warning, $numprob{$unk} unknown"; - } - else { - $output .= "$count \L$state\E"; - } - } - } - else { - $output .= "$count problems"; - } - - print "$output\n"; -} - - -# Add-in the problem found in the status log -sub addproblem { - - $test = 1; - $type = $_[1]; - my $diffout = ""; - - my @values = split /;/,$_[0]; - - if (!$host) { - my $namehold = $values[1]; - if ($ack && ($values[13] eq "1")) { - if ($ack =~ "ok") { - $test = 0; - } - else { - $type = "\U$ack"; - } - } - elsif ($hdown && grep /$namehold/, @hostdown) { - if ($hdown =~ "ok") { - $test = 0; - } - else { - $type = "\U$hdown"; - $diffout = "$values[1] is down"; - } - } - elsif ($dt && (($values[27] ne "0") || (grep /$namehold/, @hostdowntime))){ - if ($dt =~ "ok") { - $test = 0; - } - else { - $type = "\U$dt"; - } - } - elsif (exists $hostoktimes{$namehold}) { - # If the state change time of the host is more recent than the last - # service check, must wait until the next service check runs! - if ($hostoktimes{$namehold} > $values[6]) { - $test = 0; - } - } - } - else { - if ($ack && $values[5]) { - if ($ack =~ "ok") { - $test = 0; - } - else { - $type = "\U$ack"; - } - } - elsif ($dt && ($values[17] ne "0")) { - if ($dt =~ "ok") { - $test = 0; - } - else { - $type = "\U$dt"; - } - } - } - - if ($details && $test) { - if (!$host) { - if ($diffout) { - $much_output{$type} .= " $diffout;"; - $output{$type} .= "$diffout;"; - $much_ct{$type}++; - $ct{$type}++; - } - else { - if ($much_details && $much_ct{$type}<$much_details) { - $much_output{$type} .= " $values[2] on $values[1] $values[31];"; - $much_ct{$type}++; - } - if ($ct{$type} < $details) { - $output{$type} .= " $values[2] on $values[1];"; - $ct{$type}++; - } - } - } - else { - $much_output{$type} .= " $values[1] $_[1] $values[20],"; - $much_ct{type}++; - $output{$type} .= " $values[1] HOST $_[1],"; - $ct{$type}++; - } - } - if ($test) { - $numprob{$type}++; - } -} - -################################ -# -# Version and Help Information -# -################################ - -sub printVersion { - printf <<EndVersion; -$0 (nagios-plugins) 1.3 -The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute -copies of the plugins under the terms of the GNU General Public License. -For more information about these matters, see the file named COPYING. -EndVersion -} - -sub printHelp { - printf <<EOF; - -This plugin parses through the Nagios status log and will return a -Critical, Warning, or Unknown state depending on the number of -Critical, Warning, and/or Unknown services found in the log -(or Down/Unreachable hosts when matching against hosts) - -Usage: $0 -s <Status File> | -d <Nagios Log Directory> - [-w #[,#][,#]] [-c #[,#][,#]] [-u #[,#][,#]] - [--service=<RegEx> | --servhost=<RegEx> | --pattern=<RegEx> | - --host | --host=<RegEx>] - [--ack[=string]] [--dt[=string]] [--hostdown[=string]] - [-D #[,#]] [--ok] [-f <Log freshness in # minutes>] - $0 --help - $0 --version -NOTE: One of -s and -d must be specified - -Options: - -s, --status=FILE_NAME - Location and name of status log (e.g. /usr/local/nagios/var/status.log) - -d, --dir=DIRECTORY_NAME - Directory that contains the nagios logs (e.g. /usr/local/nagios/var/) - -w, --warning=INTEGER[,INTEGER][,INTEGER] - #: Number of warnings to result in a WARNING state - OR - #,#: Warning,Criticals to result in a WARNING state - OR - #,#,#: Warning,Critical,Unknown to result in a WARNING state - Default: -w=1 - -c, --critical=INTEGER[,INTEGER][,INTEGER] - #: Number of criticals to result in a CRITICAL state - OR - #,#: Warning,Criticals to result in a CRITICAL state - OR - #,#,#: Warning,Critical,Unknown to result in a CRITICAL state - Default: -c=1 - -u, --unknown=INTEGER[,INTEGER][,INTEGER] - #: Number of unknowns to result in a UNKNOWN state - OR - #,#: Warning,Criticals to result in a UNKNOWN state - OR - #,#,#: Warning,Critical,Unknown to result in a UNKNOWN state - Default: -u=1 - -r, --service[=REGEX] - Only match services [that match the RegEx] - (--service is default setting if no other matching arguments provided) - --servhost=REGEX - Only match services whose host match the RegEx - -p, --pattern=REGEX - Only parse for this regular expression (services only, not hosts) - --host[=REGEX] - Report on the state of hosts (whose name matches the RegEx if provided) - -a, --ack[=ok|warning|critical|unknown|down|unreachable] - Handle Acknowledged problems [--ack defaults to ok] - --dt, --downtime[=ok|warning|critical|unknown|down|unreachable] - Handle problems in scheduled downtime [--dt defaults to ok] - --hd, --hostdown[=ok|warning|critical|unknown|down|unreachable] - Handle services whose Host is down [--hd defaults to ok] - -D, --details=INTEGER[,INTEGER] - Amount of verbosity to output - If # problems: - <= 1st integer, return full details (each plugin's output) - <= 2nd integer, return some details (list each service host pair) - > 2nd integer, return the # of problems - -f, --freshness=INTEGER - Number of minutes old the log can be to make sure Nagios is running - (Default = 30 minutes) - --ok - Return an OK exit code, regardless of number of problems found - -h, --help - Print detailed help screen - -V, --version - Print version information - -For service checking (use --service and/or --servhost): -1. The values of warning, critical, and unknown default to 1, i.e. -$0 will return CRITICAL if there is at least 1 critical service, -WARNING if there is at least 1 warning service, and UNKNOWN if there is -at least one unknown service. - -2. If a service's host is DOWN or UNREACHABLE, $0 will use the -value of --hostdown to determine how to treat the service. Without that -argument, $0 will count the service as OK. - -3. If a service's host is OK, but the last host-state change occurred more -recently than the last service check, $0 will ignore that service -(want to wait until the service has been checked after a host has recovered -or you may get service alert for services that still need to be checked) - -4. If the --dt, --ack, or --hd tags are used, $0 will use the value -of the arguments to determine how to handle services in downtime, acknowledged, -or with down hosts (default=OK). For service checks, --dt will also check -if the service's host is in a downtime. - -For host checking (use --host): -1. Using the --host argument, $0 will look for DOWN and UNREACHABLE -hosts. If any are found, $0 will return a CRITICAL. You can provide -an REGEX for --host to only check hosts with matching host names. - -2. If the --dt or --ack tags are used, $0 will use the value of the ---dt/--ack arguments to determine the state of the host (default is OK) - -EOF -} diff --git a/contrib/check_rrd_data.pl b/contrib/check_rrd_data.pl deleted file mode 100644 index 0ff8750b..00000000 --- a/contrib/check_rrd_data.pl +++ /dev/null @@ -1,129 +0,0 @@ -#!/usr/bin/perl -wT - -# check_rrd_data plugin for nagios -# -# usage: -# check_rrd machine_id perlexp_warn perlexp_crit perlexp_default [ds] -# -# Checks data from a RRD file. machine_id is normally an IP address, that has -# to be mapped to a RRD file, by means of the config file (by default -# /var/spool/nagios/rrd-files, a file with pairs of (machine_id,rrd_file), -# separated by whitespace). It can be a RRD file, too. -# -# The Perl expressions are expressions to be evaluated in the following cases: -# -# - perlexp_crit. The first one, to check if there is a critical situation. If -# it returns other than "", it will be a critical message. -# - perlexp_warn. The second one to be evaluated. If returns other than "", a -# warning will be issued to Nagios. -# - perlexp_default. If both of the above return "", it will be evaluated, and -# wathever returns this expression will be returned by the script. NOTE that -# this is different from the other two cases, to allow the user issue a -# warning or critical failure even if the other two don't return it. -# -# Use these hosts.cfg entries as examples -# -# command[check_ping]=$USER1$/check_rrd_data.pl $HOSTADDRESS$ \ -# 'return "CHECK_CRICKET_PING: Warning\n" if ($value > 10);' 'return \ -# "CHECK_CRICKET_PING: Critical\n" if ($value > 100);' 'printf \ -# "PING OK - RTA = %.2fms\n", $value; return 0;' 1 -# service[machine]=PING;0;24x7;3;5;1;router-admins;240;24x7;1;1;1;;check_ping -# -# initial version: 28 Nov 2000 by Esteban Manchado Velázquez -# current status: 0.1 -# -# Copyright Notice: GPL -# - -# Doesn't work! Why? -# BEGIN { - # my $runtimedir = substr($0,0,rindex($0,'/')); - # require "$runtimedir/utils.pm"; -# } - -require '/usr/libexec/nagios/plugins/utils.pm'; -use RRD::File; -# use strict; # RRD:File and utils.pm don't like this - -my $configfilepath = "/var/spool/nagios/rrd-files"; # Change if needed -my %hostfile; # For storing config -my $rrdfile; # RRD file to open - -$ENV{'PATH'} = "/bin:/usr/bin"; -$ENV{'ENV'} = ""; - -if (scalar @ARGV != 4 && scalar @ARGV != 5) { - print STDERR join "' '", @ARGV, "\n"; - my $foo = 'check_rrd_data'; - print STDERR $foo, " <file.rrd> <perl_exp_warn> <perl_exp_crit> <perl_exp_default> [<ds>]\n\n"; - print STDERR "<perl_exp_*> is an expression that gets evaluated with \$_ at the current\n"; - print STDERR "value of the data source. If it returns something other than \"\", there\n"; - print STDERR "will be a warning or a critical failure. Else, the expression\n"; - print STDERR "<perl_exp_default> will be evaluated\n"; - exit; -} - -# Check configuration file -open F, $configfilepath or do { - print "Can't open config file $configfilepath\n"; - return $ERRORS{'UNKNOWN'}; -}; -while (<F>) { - next unless /(.+)\s+(.+)/; - $hostfile{$1} = $2; -} -close F; - -# Default -my $ds = defined $ARGV[4]?$ARGV[4]:0; - # print "\$ds = " . $ds . ":"; - # print "\$ARGV[4] = " . $ARGV[4] . ":"; -$ds =~ s/\$//g; # Sometimes Nagios gives 1$ as the last parameter - -# Guess which RRD file have to be opened -$rrdfile = $ARGV[0] if (-r $ARGV[0]); # First the parameter -$rrdfile = $hostfile{$ARGV[0]} unless $rrdfile; # Second, the config file - # print "$ARGV[0]:"; - -if (! $rrdfile) { - print "Can't open data file for $ARGV[0]\n"; # Aaaargh! - return $ERRORS{'UNKNOWN'}; # Unknown -} - - # print "Opening file $rrdfile:"; -my $rrd = new RRD::File ( -file => $rrdfile ); -$rrd->open(); -if (! $rrd->loadHeader()) { - print "Couldn't read header from $rrdfile\n"; - exit $ERRORS{'UNKNOWN'}; # Unknown -} -my $value = $rrd->getDSCurrentValue($ds); -$rrd->close(); - -# Perl expressions to evaluate -my ($perl_exp_warn, $perl_exp_crit, $perl_exp_default) = - ($ARGV[1], $ARGV[2], $ARGV[3]); -my $result; # Result of the expressions (will be printed) -my @data; # Special data reserved for the expressions, to pass data - -# First check for critical errors -$perl_exp_crit =~ /(.*)/; -$perl_exp_crit = $1; -$result = eval $perl_exp_crit; -if ($result) { - print $result; - exit 2; # Critical -} - -# Check for warnings -$perl_exp_warn =~ /(.*)/; -$perl_exp_warn = $1; -$result = eval $perl_exp_warn; -if ($result) { - print $result; - exit 1; # Warning -} - -$perl_exp_default =~ /(.*)/; -$perl_exp_default = $1; -eval $perl_exp_default; # Normally returns 0 (OK) diff --git a/contrib/check_sap.sh b/contrib/check_sap.sh deleted file mode 100755 index 726d7502..00000000 --- a/contrib/check_sap.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/sh -################################################################################ -# -# CHECK_SAP plugin for Nagios -# -# Originally Written by Karel Salavec (karel.salavec@ct.cz) -# -# Last Modified: 26 May 2003 by Tom De Blende (tom.deblende@village.uunet.be) -# -# Version 1.1 (Tom De Blende) -# - Added output to feed to Nagios instead of just an exit code. -# - Changed info on where to get the SAP client tools for Linux. -# -# Version 1.0 (Karel Salavec) -# -# Command line: check_sap.sh <typ_of_check> <param1> <param2> [<param3>] -# -# Description: -# This plugin will attempt to open an SAP connection with the message -# server or application server. -# It need the sapinfo program installed on your server (see Notes). -# -# Notes: -# - This plugin requires that the sapinfo program is installed. -# - Sapinfo is part of a client package that can be found -# at ftp://ftp.sap.com/pub/linuxlab/contrib/. -# -# -# Parameters: -# $1 - type of checking - valid values: "ms" = message server -# "as" = application server -# $2 - SAP server identification - can be IP address, DNS name or SAP -# connect string (for example: /H/saprouter/S/sapdp01/H/sapserv3) -# $3 - for $1="ms" - SAP system name (for example: DEV, TST, ... ) -# for $1="as" - SAP system number - note: central instance have sysnr=00 -# $4 - valid only for $1="ms" - logon group name - default: PUBLIC -# -# Example of command definitions for nagios: -# -# command[check_sap_ms]=/usr/local/nagios/libexec/check_sap ms $HOSTADDRESS$ $ARG1$ $ARG2$ -# command[check_sap_as]=/usr/local/nagios/libexec/check_sap as $HOSTADDRESS$ $ARG1$ -# command[check_sap_ex]=/usr/local/nagios/libexec/check_sap as $ARG1$ $ARG2$ -# (for ARG1 see SAP OOS1 transaction) -# -############################################################################## - -sapinfocmd='/usr/sap/rfcsdk/bin/sapinfo' -grepcmd=`which grep` -wccmd=`which wc` -cutcmd=`which cut` -awkcmd=`which awk` - -############################################################################## - -if [ $# -lt 3 ]; then -echo "Usage: $0 <typ_of_check> <param1> <param2> [<param3>]" -exit 2 -fi - -case "$1" - in - ms) - if [ $4 ] - then - params="r3name=$3 mshost=$2 group=$4" - else - params="r3name=$3 mshost=$2" - fi - ;; - as) - params="ashost=$2 sysnr=$3" - ;; - *) - echo "The first parameter must be ms (message server) or as (application server)!" - exit 2 - ;; -esac - -output="$($sapinfocmd $params)" -error="$(echo "$output" | $grepcmd ERROR | $wccmd -l)" -if [ "$error" -gt "0" ]; then - output="$(echo "$output" | $grepcmd Key | $cutcmd -dy -f2)" - echo "CRITICAL - SAP server not ready: " $output. - exit 2 -else - output="$(echo "$output" | $grepcmd Destination | $awkcmd '{ print $2 }')" - echo "OK - SAP server $output available." - exit 0 -fi diff --git a/contrib/check_smart.pl b/contrib/check_smart.pl deleted file mode 100644 index 3f9104d8..00000000 --- a/contrib/check_smart.pl +++ /dev/null @@ -1,180 +0,0 @@ -#!/usr/bin/perl -w - -# chec_smart -# Check S.M.A.R.T. enabled disks status. -# -# This uses smartmontools to check for disk status. -# This is NOT compatible with smartsuite -# Please use smartctl --smart=on --offlineauto=on --saveauto=on /dev/something -# or similar to enable automatic data collection, and RTFM about it. -# -# this uses sudo to access the smartctl program, so please add a line in sudoers -# nagios computername = NOPASSWD:/usr/sbin/smartctl -# -# CopyLeft Roy Sigurd Karlsbakk <roy@karlsbakk.net> -# Developed under Debian/SID -# No warranties what so ever. If this toasts your PC, or your wife -# runs away with your girlfriend, or even me, don't blame me. -# -# Licenced under GPL -# - -use strict; -use Getopt::Long; - -my ( - $s, $i, $out, $retcode, $errtxt, $exitcode, - $device, $text_mode, $exitcode_mode, $help, $verbose, $type, -); -my $smartctl = "sudo /usr/sbin/smartctl"; -my $e_commandline = 0; -my $e_devopen = 0; -my $e_chksum = 0; -my $e_disk_failing = 0; -my $e_prefail = 0; -my $e_mayprefail = 0; -my $e_errlog = 0; -my $e_selftestlog = 0; - -sub end { - $s = shift; - $i = shift; - if ($i == 0) { - $s = "OK: $s"; - } elsif ($i == 1) { - $s = "WARNNG: $s"; - } elsif ($i == 2) { - $s = "CRITICAL: $s"; - } elsif ($i == 3) { - $s = "UNKNOWN: $s"; - } else { - $s = "OUT OF RANGE: $s"; - } - print "$s\n"; - exit($i); -} - -sub syntax { - $s = shift or $s = 'Unknown'; - printf STDERR ("Error: $s\n") unless ($help); - printf STDERR ("Syntax: %s (-t|-e) -d <device> [-vh]\n", $0); - printf STDERR (" --text-mode -t check by parsing smartctl's output\n"); - printf STDERR (" --exitcode-mode -e check smartctl's exitcode (only works on IDE)\n"); - printf STDERR (" --device -d disk device to check\n"); - printf STDERR (" --type -T drive type. See the -d flag in the smartctl manual\n"); - printf STDERR (" --verbose -v verbose\n"); - printf STDERR (" --help -h this help\n"); - exit(0) if $help; - exit(3); -} - -Getopt::Long::Configure('bundling'); -GetOptions( - "d=s" => \$device, "device=s" => \$device, - "T=s" => \$type, "type=s" => \$type, - "t" => \$text_mode, "text-mode" => \$text_mode, - "e" => \$exitcode_mode, "exitcode-mode" => \$exitcode_mode, - "h" => \$help, "help" => \$help, - "v" => \$verbose, "verbose" => \$verbose -) || syntax("RTFM!"); - -syntax if ($help); -syntax("Need device to check") unless ($device); -syntax("Conflicting modes") if ($text_mode && $exitcode_mode); -syntax("Need test mode") unless ($text_mode || $exitcode_mode); -syntax("Exitcode mode only works on ATA drives") if ($exitcode_mode && ! ($device =~ /\/dev\/hd./)); - -if ($type) { - $type =~ s/[\r\n]*?//g; - print "type: '$type'\n" if ($verbose); - syntax("Valid --type entries include ata, scsi and 3ware,n") - unless (($type =~ /^ata$/) || ($type =~ /^scsi$/) || ($type =~ /^3ware,\d+$/)); -} -if (defined($type)) { - $type = "--device=$type"; -} else { - $type = ""; -} - -if ($text_mode) { - print "running $smartctl $type -H $device" if ($verbose); - unless (open SMARTCTL,"$smartctl $type -H $device|") { - print STDERR "Can't execute $smartctl: $!\n"; - exit(3); - } - while (<SMARTCTL>) { - last if (/=== START OF READ SMART DATA SECTION ===/); - } - $out = <SMARTCTL>; - print $out; - exit(0) if ($out =~ /PASSED/); - exit(2) if ($out =~ /SAVE ALL DATA/ || $out =~ /FAILED/); - exit(3); -} elsif ($exitcode_mode) { - print "Running $smartctl $type -q silent $device\n" if ($verbose); - system("$smartctl $type -q silent $device"); - $retcode = $?; - $e_commandline = 1 if ($retcode & 0x0100); - $e_devopen = 1 if ($retcode & 0x0200); - $e_chksum = 1 if ($retcode & 0x0400); - $e_disk_failing = 1 if ($retcode & 0x0800); - $e_prefail = 1 if ($retcode & 0x1000); - $e_mayprefail = 1 if ($retcode & 0x2000); - $e_errlog = 1 if ($retcode & 0x4000); - $e_selftestlog = 1 if ($retcode & 0x8000); - - print "$e_commandline $e_devopen $e_chksum $e_disk_failing $e_prefail $e_mayprefail $e_errlog $e_selftestlog\n" - if ($verbose); - - $exitcode = 0; - $errtxt = ""; - if ($exitcode) { - if ($e_commandline) { - $errtxt .= "Commandline didn't parse, "; - $exitcode = 3 if ($exitcode == 0); - } - if ($e_devopen) { - $errtxt .= "Device could not be opened, "; - $exitcode = 3 if ($exitcode == 0); - } - if ($e_chksum) { - $errtxt .= "Checksum failure somewhere, "; - $exitcode = 1 if ($exitcode != 2); - } - if ($e_disk_failing) { - $errtxt .= "Disk is failing!, "; - $exitcode = 2; - } - if ($e_prefail) { - $errtxt .= "Disk is in prefail, "; - $exitcode = 1 if ($exitcode != 2); - } - if ($e_mayprefail) { - $errtxt .= "Disk is close to prefail. Please check manually, "; - $exitcode = 1 if ($exitcode != 2); - } - if ($e_errlog) { - $errtxt .= "The device error log contains records of errors, "; - $exitcode = 1 if ($exitcode != 2); - } - if ($e_selftestlog) { - $errtxt .= "The device self-test log contains records of errors, "; - $exitcode = 1 if ($exitcode != 2); - } - if ($exitcode == 1) { - $errtxt = "WARNNG: $errtxt"; - } elsif ($exitcode == 2) { - $errtxt = "CRITICAL: $errtxt"; - } else { - $errtxt = "UNKNOWN: $errtxt"; - } - } else { - $errtxt = "OK"; - } - print "$errtxt\n"; - exit($exitcode); -} else { - print STDERR "Something's strange is going on :~|\n"; - exit(3); -} -# vim:ts=4:sw=4:cindent diff --git a/contrib/check_smb.sh b/contrib/check_smb.sh deleted file mode 100644 index 9d0da726..00000000 --- a/contrib/check_smb.sh +++ /dev/null @@ -1,111 +0,0 @@ -#!/bin/bash -# -# Program : check_smb -# : -# Author : Cal Evans <cal@calevans.com> -# : -# Purpose : Nagios plugin to return the number of users logged into a smb -# : server and the number of files open. -# : -# Parameters : --help -# : --version -# : -# Returns : Standard Nagios status_* codes as defined in utils.sh -# : -# Notes : -#============:============================================================== -# 1.0 : 06/27/2002 -# : Initial coding -# : -# 1.1 : 06/28/2002 -# : Re-wrote the user counter to match the file-lock counter. -# : - -# -# Shamelessly stolen from other Nagios plugins. -# -PROGNAME=`basename $0` -PROGPATH=`echo $0 | /bin/sed -e 's,[\\/][^\\/][^\\/]*$,,'` -REVISION=`echo '$Revision: 71 $' | sed -e 's/[^0-9.]//g'` - - -. $PROGPATH/utils.sh - -print_usage() { - echo "Usage: $PROGNAME --help" - echo "Usage: $PROGNAME --version" -} - -print_help() { - print_revision $PROGNAME $REVISION - echo "" - print_usage - echo "" - echo "Samba status check." - echo "" - support -} - -# No command line arguments are required for this script. We accept only 2, -# --help and --version. If more than 1 is passed in then we have an error -# condition. - -if [ $# -gt 1 ]; then - print_usage - exit $STATE_UNKNOWN -fi - - -# -# If we have arguments, process them. -# -exitstatus=$STATE_WARNING #default -while test -n "$1"; do - case "$1" in - --help) - print_help - exit $STATE_OK - ;; - -h) - print_help - exit $STATE_OK - ;; - --version) - print_revision $PROGNAME $REVISION - exit $STATE_OK - ;; - -V) - print_revision $PROGNAME $REVISION - exit $STATE_OK - ;; - - *) - echo "Unknown argument: $1" - print_usage - exit $STATE_UNKNOWN - ;; - esac - shift -done - -# -# No arguments. Let's kick this pig. -# -total_users=$(smbstatus -b | grep "^[0-9]" | wc -l) - -# -# Ok, now let's grab a count of the files. -# -total_files=$(smbstatus | grep "^[0-9]" | wc -l) - -# -# now for the dismount. -# -echo "Total Users:$total_users Total Files:$total_files" - -# -# let Nagios know that everything is ok. -# -exit $STATE_OK - - diff --git a/contrib/check_snmp_disk_monitor.pl b/contrib/check_snmp_disk_monitor.pl deleted file mode 100644 index 9a2edaae..00000000 --- a/contrib/check_snmp_disk_monitor.pl +++ /dev/null @@ -1,185 +0,0 @@ -#!/usr/local/bin/perl -# author: Al Tobey <albert.tobey@priority-health.com> -# what: monitor diskspace using the host-resources mib -# license: GPL - http://www.fsf.org/licenses/gpl.txt -# -# Todo: - -use strict; -require 5.6.0; -use lib qw( /opt/nagios/libexec ); -use utils qw(%ERRORS $TIMEOUT &print_revision &support &usage); -use SNMP 5.0; -use Getopt::Long; -use 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 ); - -$PROGNAME = "snmp_disk_monitor.pl"; -$opt_verbose = undef; -$opt_host = undef; -$opt_community = 'public'; -$opt_command = undef; -$opt_warning = 99; -$opt_critical = 100; -$opt_port = 161; -$opt_stats = undef; -$message = undef; -$exit = 'OK'; -%mounts = (); - -sub process_options { - my( $opt_crit, $opt_warn ) = (); - Getopt::Long::Configure( 'bundling' ); - GetOptions( - 'V' => \$opt_version, 'version' => \$opt_version, - 'v' => \$opt_verbose, 'verbose' => \$opt_verbose, - 'h' => \$opt_help, 'help' => \$opt_help, - 's' => \$opt_stats, 'statistics' => \$opt_stats, - 'H:s' => \$opt_host, 'hostname:s' => \$opt_host, - 'p:i' => \$opt_port, 'port:i' => \$opt_port, - 'C:s' => \$opt_community, 'community:s' => \$opt_community, - 'c:i' => \$opt_crit, 'critical:i' => \$opt_crit, - 'w:i' => \$opt_warn, 'warning:i' => \$opt_warn, - 't:i' => \$TIMEOUT, 'timeout:i' => \$TIMEOUT, - 'm:s' => \$opt_mountpoint, 'mountpoint:s'=> \$opt_mountpoint - ); - if ( defined($opt_version) ) { local_print_revision(); } - if ( defined($opt_verbose) ) { $SNMP::debugging = 1; } - if ( !defined($opt_host) || defined($opt_help) || !defined($opt_mountpoint) ) { - print_help(); - exit $ERRORS{UNKNOWN}; - } - $opt_mountpoint = [ split(/,/, $opt_mountpoint) ]; -} - -sub local_print_revision { - print_revision( $PROGNAME, '$Revision: 82 $ ' ) -} - -sub print_usage { - print "Usage: $PROGNAME -H <host> -C <snmp_community> [-s] [-w <low>,<high>] [-c <low>,<high>] [-t <timeout>] -m <mountpoint>\n"; -} - -sub print_help { - local_print_revision(); - print "Copyright (c) 2002 Al Tobey <albert.tobey\@priority-health.com>\n\n", - "SNMP Disk Monitor plugin for Nagios\n\n"; - print_usage(); - print <<EOT; --v, --verbose - print extra debugging information --h, --help - print this help message --H, --hostname=HOST - name or IP address of host to check --C, --community=COMMUNITY NAME - community name for the host's SNMP agent --m, --mountpoint=MOUNTPOINT - a mountpoint, or a comma delimited list of mountpoints --w, --warning=INTEGER - percent of disk used to generate WARNING state (Default: 99) --c, --critical=INTEGER - percent of disk used to generate CRITICAL state (Default: 100) --s, --statistics - output statistics in Nagios format -EOT -} - -sub verbose (@) { - return if ( !defined($opt_verbose) ); - print @_; -} - -sub check_for_errors { - if ( $snmp_session->{ErrorNum} ) { - print "UNKNOWN - error retrieving SNMP data: $snmp_session->{ErrorStr}\n"; - exit $ERRORS{UNKNOWN}; - } -} - -# =========================================================================== # -# =====> MAIN -# =========================================================================== # -process_options(); - -alarm( $TIMEOUT ); # make sure we don't hang Nagios - -$snmp_session = new SNMP::Session( - DestHost => $opt_host, - Community => $opt_community, - RemotePort => $opt_port, - Version => '2c' -); - -# retrieve the data from the remote host -my( $mps, $alloc, $size, $used ) = $snmp_session->bulkwalk( 0, 4, [['hrStorageDescr'],['hrStorageAllocationUnits'],['hrStorageSize'],['hrStorageUsed']] ); -check_for_errors(); - -alarm( 0 ); # all done with the network connection - -# move all the data into a nice, convenient hash for processing -foreach my $mp ( @$mps ) { $mounts{$mp->iid}->{mountpoint} = $mp->val; } -foreach my $a ( @$alloc ) { $mounts{$a->iid}->{alloc_units} = $a->val; } -foreach my $si ( @$size ) { - if ( exists($mounts{$si->iid}->{alloc_units}) ) { - $mounts{$si->iid}->{size} = $si->val * $mounts{$si->iid}->{alloc_units}; - } - else { - $mounts{$si->iid}->{size} = $si->val; - } -} -foreach my $us ( @$used ) { - if ( exists($mounts{$us->iid}->{alloc_units}) ) { - $mounts{$us->iid}->{used} = $us->val * $mounts{$us->iid}->{alloc_units}; - } - else { - $mounts{$us->iid}->{used} = $us->val; - } -} - -# now find the mountpoint or mountpoints that were actually requested and push onto an array for output -my @matches = (); -foreach my $mp ( @$opt_mountpoint ) { - my $found = scalar(@matches); # count all matches - foreach my $key ( keys(%mounts) ) { - if ( $mounts{$key}->{mountpoint} eq $mp ) { - - # find the percentate - eval to avoid divide by zero errors - eval { $mounts{$key}->{percent_used} = $mounts{$key}->{used} / $mounts{$key}->{size} }; - $mounts{$key}->{percent_used} =~ s/^0\.([0-9]{1,2})([0-9]?).*/\1/; # truncate - if ( $2 >= 5 ) { $mounts{$key}->{percent_used}++ }; # round the number number - - verbose "mountpoint $mp has ", $mounts{$key}->{percent_used}, "% used, ", - $mounts{$key}->{size}, " bytes and ",$mounts{$key}->{used}, " used\n"; - - push( @matches, $mounts{$key} ); - } - } - if ( scalar(@matches) == $found ) { - print "UNKNOWN - could not locate mountpoint $mp on host\n"; - exit $ERRORS{UNKNOWN}; - } -} - -# now run through and check the thresholds -foreach my $mp ( @matches ) { - if ( $mp->{percent_used} >= $opt_warning ) { - $exit = 'WARNING'; - if ( $mp->{percent_used} >= $opt_critical ) { $exit = 'CRITICAL'; } - } - $message .= $mp->{percent_used}.'% used on '.$mp->{mountpoint}.', '; -} -$message =~ s/,\s*$//; - -# append statistics if requested -if ( defined($opt_stats) ) { - my @tmp = (); - foreach my $mp ( @matches ) { - push( @tmp, join(',',$mp->{mountpoint},$mp->{size},$mp->{used}) ); - } - $message .= '|'.join( ':', @tmp ); -} - -print "Disk $exit - $message\n"; -exit $ERRORS{$exit}; - - diff --git a/contrib/check_snmp_printer.pl b/contrib/check_snmp_printer.pl deleted file mode 100755 index cc7943bf..00000000 --- a/contrib/check_snmp_printer.pl +++ /dev/null @@ -1,605 +0,0 @@ -#!/usr/local/bin/perl -w - -# check_snmp_printer - check for printer status via snmp -# Supports both standard PRINT-MIB (RFC-1759) and HP Enterprise print-mib -# that is supported by some of the older JetDirect interfaces - -# Acknowledgements: -# the JetDirect code is taken from check_hpjd.c by Ethan Galstad -# -# The idea for the plugin (as well as some code) were taken from Jim -# Trocki's pinter alert script in his "mon" utility, found at -# http://www.kernel.org/software/mon -# - -# Notes: -# 'JetDirect' is copyrighted by Hewlett-Packard -# -# -# License Information: -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -############################################################################ -# -# TODO: Query HOST-RESOURCE MIB for a quick status -# -# hrPrinterStatus = .1.3.6.1.2.1.25.3.5.1; -# hrPrinterDetectedErrorState = .1.3.6.1.2.1.25.3.5.1.2 -# -# hrPrinterStatus OBJECT-TYPE -# SYNTAX INTEGER { -# other(1), -# unknown(2), -# idle(3), -# printing(4), -# warmup(5) -# } -# -# hrPrinterDetectedErrorState OBJECT-TYPE -# SYNTAX OCTET STRING -# MAX-ACCESS read-only -# STATUS current -# DESCRIPTION -# "This object represents any error conditions detected -# by the printer. The error conditions are encoded as -# bits in an octet string, with the following -# definitions: -# -# Condition Bit # -# -# lowPaper 0 -# -# noPaper 1 -# lowToner 2 -# noToner 3 -# doorOpen 4 -# jammed 5 -# offline 6 -# serviceRequested 7 -# inputTrayMissing 8 -# outputTrayMissing 9 -# markerSupplyMissing 10 -# outputNearFull 11 -# outputFull 12 -# inputTrayEmpty 13 -# overduePreventMaint 14 -# -# -# -use strict; -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_H $opt_P $opt_t $opt_d $session $error $answer $key - $response $PROGNAME $port $hostname ); -use lib "utils.pm"; -use utils qw(%ERRORS &print_revision &support &usage ); -use Net::SNMP; - -sub print_help (); -sub print_usage (); - -$ENV{'PATH'}=''; -$ENV{'BASH_ENV'}=''; -$ENV{'ENV'}=''; - -# defaults -my $ptype = 1; # to standard RFC printer type -my $state = $ERRORS{'UNKNOWN'}; -my $community = "public"; -my $snmp_version = 1; -my $port = 161; - -Getopt::Long::Configure('bundling'); -GetOptions - ("d" => \$opt_d, "debug" => \$opt_d, - "V" => \$opt_V, "version" => \$opt_V, - "P=s" => \$opt_P, "Printer=s" => \$opt_P, # printer type - HP or RFC - "v=i" => \$snmp_version, "snmp_version=i" => \$snmp_version, - "p=i" => \$port, "port=i" => \$port, - "C=s" => \$community,"community=s" => \$community, - "h" => \$opt_h, "help" => \$opt_h, - "H=s" => \$opt_H, "hostname=s" => \$opt_H); - - - -$PROGNAME = "check_snmp_printer"; - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 795 $'); - exit $ERRORS{'OK'}; -} - -if ($opt_h) {print_help(); exit $ERRORS{'OK'};} - -unless (defined $opt_H) { - print "No target hostname specified\n"; - exit $ERRORS{"UNKNOWN"}; -} -$hostname = $opt_H; -if (! utils::is_hostname($hostname)){ - usage(" $hostname did not match pattern\n"); - exit $ERRORS{"UNKNOWN"}; -} - -if (defined $opt_P) { - if ($opt_P eq "HP" ) { - $ptype = 2; - }elsif ($opt_P eq "RFC" ) { - $ptype = 1; - }else{ - print "Only \"HP\" and \"RFC\" are supported as printer options at this time.\n"; - exit $ERRORS{"UNKNOWN"}; - } -} - - -if ( $snmp_version =~ /[12]/ ) { - - ($session, $error) = Net::SNMP->session( - -hostname => $hostname, - -community => $community, - -port => $port, - -version => $snmp_version - ); - - if (!defined($session)) { - $state='UNKNOWN'; - $answer=$error; - print ("$state: no session - $answer\n"); - exit $ERRORS{$state}; - } - - print "Opened session|" if (defined ($opt_d)); - -}elsif ( $snmp_version =~ /3/ ) { - $state='UNKNOWN'; - print ("$state: No support for SNMP v3 yet\n"); - exit $ERRORS{$state}; -}else{ - $state='UNKNOWN'; - print ("$state: No support for SNMP v$snmp_version yet\n"); - exit $ERRORS{$state}; -} - - - - - - -### main logic - -if ( $ptype == 1 ) { # STD MIB - print "STD-MIB|" if (defined ($opt_d)); - - my %snmp_response; - my $snmp_index; - my $col_oid; - my %std_mib_inst_count ; - my %std_mib_instances; - my $display; - my $inst; - my $group; - - - #### RFC1759 MIB OIDS - - # sub-unit status - textual convention - my $subunit_status; # integer from 0-126 - - - # column oid - not instances - my %std_mib = ( - std_mib_input_status => ".1.3.6.1.2.1.43.8.2.1.11", # 2 element index - std_mib_input_name => ".1.3.6.1.2.1.43.8.2.1.13", - std_mib_output_remaining_capacity => ".1.3.6.1.2.1.43.9.2.1.5", - std_mib_output_status => ".1.3.6.1.2.1.43.9.2.1.6", - std_mib_marker_tech => ".1.3.6.1.2.1.43.10.2.1.2", - std_mib_marker_counter_unit => ".1.3.6.1.2.1.43.10.2.1.3", - std_mib_marker_life_count => ".1.3.6.1.2.1.43.10.2.1.4", - std_mib_marker_status => ".1.3.6.1.2.1.43.10.2.1.15", - std_mib_supplies_type => ".1.3.6.1.2.1.43.11.1.1.5", - std_mib_supplies_level => ".1.3.6.1.2.1.43.11.1.1.9", - std_mib_media_path_type => ".1.3.6.1.2.1.43.13.4.1.9", - std_mib_media_path_status => ".1.3.6.1.2.1.43.13.4.1.11", - - std_mib_status_display => ".1.3.6.1.2.1.43.16.5.1.2", # 2 element index - - std_mib_alert_sev_level => ".1.3.6.1.2.1.43.18.1.1.2", - std_mib_alert_grp => ".1.3.6.1.2.1.43.18.1.1.4", - std_mib_alert_location => ".1.3.6.1.2.1.43.18.1.1.5", - - ); - - my %std_mib_marker_tech = ( - 1 => "other", - 2 => "unknown", - 3 => "electrophotographicLED", - 4 => "electrophotographicLaser", - 5 => "electrophotographicOther", - 6 => "impactMovingHeadDotMatrix9pin", - 7 => "impactMovingHeadDotMatrix24pin", - 8 => "impactMovingHeadDotMatrixOther", - 9 => "impactMovingHeadFullyFormed", - 10 => "impactBand", - 11 => "impactOther", - 12 => "inkjectAqueous", - 13 => "inkjetSolid", - 14 => "inkjetOther", - 15 => "pen", - 16 => "thermalTransfer", - 17 => "thermalSensitive", - 18 => "thermalDiffusion", - 19 => "thermalOther", - 20 => "electroerosion", - 21 => "electrostatic", - 22 => "photographicMicrofiche", - 23 => "photographicImagesetter", - 24 => "photographicOther", - 25 => "ionDeposition", - 26 => "eBeam", - 27 => "typesetter", - ); - - my %std_mib_marker_counter_units = ( - 3 => "tenThousandthsOfInches", - 4 => "micrometers", - 5 => "characters", - 6 => "lines", - 7 => "impressions", - 8 => "sheets", - 9 => "dotRow", - 11 => "hours", - 16 => "feet", - 17 => "meters", - ); - - my %std_mib_alert_groups = ( - 1 => "unspecifiedOther", - 3 => "printerStorageMemory", # hostResourcesMIBStorageTable - 4 => "internalDevice", # hostResourcesMIBDeviceTable - 5 => "generalPrinter", - 6 => "cover", - 7 => "localization", - 8 => "input", - 9 => "output", - 10 => "marker", - 11 => "markerSupplies", - 12 => "markerColorant", - 13 => "mediaPath", - 14 => "connectionChannel", - 15 => "interpreter", - 16 => "consoleDisplayBuffer", - 17 => "consoleLights", - ); - - - my %std_mib_prt_alert_code = ( - 1 => "other", # ok if on power save - 2 => "unknown", - # -- codes common to serveral groups - 3 => "coverOpen", - 4 => "coverClosed", - 5 => "interlockOpen", - 6 => "interlockClosed", - 7 => "configurationChange", - 8 => "jam", # critical - # -- general Printer group - 501 => "doorOpen", - 502 => "doorClosed", - 503 => "powerUp", - 504 => "powerDown", - # -- Input Group - 801 => "inputMediaTrayMissing", - 802 => "inputMediaSizeChange", - 803 => "inputMediaWeightChange", - 804 => "inputMediaTypeChange", - 805 => "inputMediaColorChange", - 806 => "inputMediaFormPartsChange", - 807 => "inputMediaSupplyLow", - 808 => "inputMediaSupplyEmpty", - # -- Output Group - 901 => "outputMediaTrayMissing", - 902 => "outputMediaTrayAlmostFull", - 903 => "outputMediaTrayFull", - # -- Marker group - 1001 => "markerFuserUnderTemperature", - 1002 => "markerFuserOverTemperature", - # -- Marker Supplies group - 1101 => "markerTonerEmpty", - 1102 => "markerInkEmpty", - 1103 => "markerPrintRibbonEmpty", - 1104 => "markerTonerAlmostEmpty", - 1105 => "markerInkAlmostEmpty", - 1106 => "markerPrintRibbonAlmostEmpty", - 1107 => "markerWasteTonerReceptacleAlmostFull", - 1108 => "markerWasteInkReceptacleAlmostFull", - 1109 => "markerWasteTonerReceptacleFull", - 1110 => "markerWasteInkReceptacleFull", - 1111 => "markerOpcLifeAlmostOver", - 1112 => "markerOpcLifeOver", - 1113 => "markerDeveloperAlmostEmpty", - 1114 => "markerDeveloperEmpty", - # -- Media Path Device Group - 1301 => "mediaPathMediaTrayMissing", - 1302 => "mediaPathMediaTrayAlmostFull", - 1303 => "mediaPathMediaTrayFull", - # -- interpreter Group - 1501 => "interpreterMemoryIncrease", - 1502 => "interpreterMemoryDecrease", - 1503 => "interpreterCartridgeAdded", - 1504 => "interpreterCartridgeDeleted", - 1505 => "interpreterResourceAdded", - 1506 => "interpreterResourceDeleted", - ); - - ## Need multiple passes as oids are all part of tables - foreach $col_oid (sort keys %std_mib ){ - - if ( !defined( $response = $session->get_table($std_mib{$col_oid}) ) ) { - print "Error col_oid $col_oid|" if (defined ($opt_d)); - - if (! ($col_oid =~ m/std_mib_alert/ ) ) { # alerts don't have to exist all the time! - $answer=$session->error; - $session->close; - $state = 'CRITICAL'; - print ("$state: $answer for $std_mib{$col_oid}\n"); - exit $ERRORS{$state}; - } - } - - print "NoError col_oid $col_oid|" if (defined ($opt_d)); - - foreach $key (keys %{$response}) { - $key =~ /.*\.(\d+)\.(\d+)$/; # all oids have a two part index appended - $snmp_index = $1 . "." . $2; - print "\n$key => $col_oid.$snmp_index = $response->{$key} \n" if (defined ($opt_d)); - $snmp_response{$key} = $response->{$key} ; - - $std_mib_inst_count{$col_oid} += 1 ; # count how many instances - $std_mib_instances{$col_oid} .= $snmp_index .":" ; - - } - - } - - #foreach $key ( keys %std_mib_inst_count) { - # print "$key = $std_mib_inst_count{$key} $std_mib_instances{$key} \n"; - #} - # get (total) "page count" - perfdata - #print "\n \n $std_mib_instances{'std_mib_marker_tech'} \n"; - # how many marker technologies are in use? - my ($pg, $pt, $pfd); - my @mark_tech = split(/:/, $std_mib_instances{'std_mib_marker_tech'}); - foreach $inst (sort @mark_tech){ - $pfd = $std_mib_marker_tech{$snmp_response{$std_mib{'std_mib_marker_tech'}."." .$inst}} ; - $pfd .= ",".$snmp_response{$std_mib{'std_mib_marker_life_count'}.".".$inst}; - $pfd .= ",".$std_mib_marker_counter_units{$snmp_response{$std_mib{'std_mib_marker_counter_unit'}.".".$inst}}; - $pfd .= ";"; #perf data separator for multiple marker tech - - - print "pfd = $pfd\n" if (defined ($opt_d)); - }; - - # combine all lines of status display into one line - #$std_mib_instances{'std_mib_status_display'} = substr($std_mib_instances{'std_mib_status_display'}, 1); - my @display_index = split(/:/, $std_mib_instances{'std_mib_status_display'} ); - - foreach $inst ( sort @display_index) { - $display .= $snmp_response{$std_mib{'std_mib_status_display'} . "." . $inst} . " "; - } - - - - # see if there are any alerts - if (defined ( $std_mib_inst_count{'std_mib_alert_sev_level'} ) ) { - - if ( ( lc($display) =~ /save/ || lc($display) =~ /warm/ ) && $std_mib_inst_count{'std_mib_alert_sev_level'} == 1 ) { - $state='OK'; - $answer = "Printer ok - $display"; - print $answer . "|$pfd\n"; - exit $ERRORS{$state}; - } - - # sometime during transitions from power save to warming there are 2 alerts - # if the 2nd alert is for something else it should get caught in the - # next call since warmup typically is much smaller than check time - # interval. - if ( lc($display) =~ /warm/ && $std_mib_inst_count{'std_mib_alert_sev_level'} == 2 ) { - $state='OK'; - $answer = "$state: Printer - $display"; - print $answer . "|$pfd\n"; - exit $ERRORS{$state}; - } - - - # We have alerts and the display does not say power save or warming up - $std_mib_instances{'std_mib_alert_sev_level'} = substr($std_mib_instances{'std_mib_alert_sev_level'}, 1); - @display_index = split(/:/, $std_mib_instances{'std_mib_alert_sev_level'} ); - $answer = "Alert location(s): "; - - for $inst (@display_index) { - $state = 'WARNING'; - if ( $snmp_response{$std_mib{'std_mib_alert_location'} . "." . $inst} < 1) { - $answer .= "unknown location "; - }else{ - $answer .= $std_mib_prt_alert_code{$snmp_response{$std_mib{'std_mib_alert_location'} . "." . $inst} } . " "; - - #print $std_mib_prt_alert_code{$snmp_response{$std_mib{'std_mib_alert_location'}. "." . $inst}} ; - } - } - - print "$state: $answer|$pfd\n"; - exit $ERRORS{$state}; - - }else{ - $state='OK'; - $answer = "$state: Printer ok - $display "; - print $answer . "|$pfd\n"; - exit $ERRORS{$state}; - - } - - - - -} -elsif( $ptype == 2 ) { # HP MIB - JetDirect - - #### HP MIB OIDS - instance OIDs - my $HPJD_LINE_STATUS= ".1.3.6.1.4.1.11.2.3.9.1.1.2.1.0"; - my $HPJD_PAPER_STATUS= ".1.3.6.1.4.1.11.2.3.9.1.1.2.2.0"; - my $HPJD_INTERVENTION_REQUIRED= ".1.3.6.1.4.1.11.2.3.9.1.1.2.3.0"; - my $HPJD_GD_PERIPHERAL_ERROR= ".1.3.6.1.4.1.11.2.3.9.1.1.2.6.0"; - my $HPJD_GD_PAPER_JAM= ".1.3.6.1.4.1.11.2.3.9.1.1.2.8.0"; - my $HPJD_GD_PAPER_OUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.9.0"; - my $HPJD_GD_TONER_LOW= ".1.3.6.1.4.1.11.2.3.9.1.1.2.10.0"; - my $HPJD_GD_PAGE_PUNT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.11.0"; - my $HPJD_GD_MEMORY_OUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.12.0"; - my $HPJD_GD_DOOR_OPEN= ".1.3.6.1.4.1.11.2.3.9.1.1.2.17.0"; - my $HPJD_GD_PAPER_OUTPUT= ".1.3.6.1.4.1.11.2.3.9.1.1.2.19.0"; - my $HPJD_GD_STATUS_DISPLAY= ".1.3.6.1.4.1.11.2.3.9.1.1.3.0"; - #define ONLINE 0 - #define OFFLINE 1 - - my @hp_oids = ( $HPJD_LINE_STATUS,$HPJD_PAPER_STATUS,$HPJD_INTERVENTION_REQUIRED,$HPJD_GD_PERIPHERAL_ERROR, - $HPJD_GD_PAPER_JAM,$HPJD_GD_PAPER_OUT,$HPJD_GD_TONER_LOW,$HPJD_GD_PAGE_PUNT,$HPJD_GD_MEMORY_OUT, - $HPJD_GD_DOOR_OPEN,$HPJD_GD_PAPER_OUTPUT,$HPJD_GD_STATUS_DISPLAY); - - - - - $state = $ERRORS{'OK'}; - - if (!defined($response = $session->get_request(@hp_oids))) { - $answer=$session->error; - $session->close; - $state = 'CRITICAL'; - print ("$state: $answer \n"); - exit $ERRORS{$state}; - } - - # cycle thru the responses and set the appropriate state - - if($response->{$HPJD_GD_PAPER_JAM} ) { - $state='WARNING'; - $answer = "Paper Jam"; - } - elsif($response->{$HPJD_GD_PAPER_OUT} ) { - $state='WARNING'; - $answer = "Out of Paper"; - } - elsif($response->{$HPJD_LINE_STATUS} ) { - if ($response->{$HPJD_LINE_STATUS} ne "POWERSAVE ON" ) { - $state='WARNING'; - $answer = "Printer Offline"; - } - } - elsif($response->{$HPJD_GD_PERIPHERAL_ERROR} ) { - $state='WARNING'; - $answer = "Peripheral Error"; - } - elsif($response->{$HPJD_INTERVENTION_REQUIRED} ) { - $state='WARNING'; - $answer = "Intervention Required"; - } - elsif($response->{$HPJD_GD_TONER_LOW} ) { - $state='WARNING'; - $answer = "Toner Low"; - } - elsif($response->{$HPJD_GD_MEMORY_OUT} ) { - $state='WARNING'; - $answer = "Insufficient Memory"; - } - elsif($response->{$HPJD_GD_DOOR_OPEN} ) { - $state='WARNING'; - $answer = "Insufficient Memory"; - } - elsif($response->{$HPJD_GD_PAPER_OUTPUT} ) { - $state='WARNING'; - $answer = "OutPut Tray is Full"; - } - elsif($response->{$HPJD_GD_PAGE_PUNT} ) { - $state='WARNING'; - $answer = "Data too slow for Engine"; - } - elsif($response->{$HPJD_PAPER_STATUS} ) { - $state='WARNING'; - $answer = "Unknown Paper Error"; - } - else # add code to parse STATUS DISPLAY here - { - $state='OK'; - $answer = "Printer ok - $response->{$HPJD_GD_STATUS_DISPLAY} "; - } - - # print and exit - - print "$state: $answer \n"; - exit $ERRORS{$state}; - - -} -else{ # 3rd printer type - not yet supported - - print "Printer type $opt_P has not been implemented\n"; - $state='UNKNOWN'; - exit $ERRORS{$state}; - -} - - - -#### subroutines -sub unit_status { - my $stat = shift; - - -} - -sub print_usage () { - print "Usage: $PROGNAME -H <host> [-C community] [-P HP or RFC] [-p port] [-v snmp_version] [-h help] [-V version]\n"; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 795 $'); - print "Copyright (c) 2002 Subhendu Ghosh/Ethan Galstad. - -This plugin reports the status of an network printer with an SNMP management -module. - -"; - print_usage(); - print " --H, --hostname=HOST - Name or IP address of host to check --C --community - snmp community string (default: public) --P --Printer - supported values are \"HP\" for Jetdirect printers and - \"RFC\" for RFC 1759 Print MIB based implementations (default: RFC) --p --port - Port where snmp agent is listening (default: 161) --v --snmp_version - SNMP version to use (default: version 1) --h --help - This screen --V --version - Plugin version - -"; - support(); -} - - - diff --git a/contrib/check_snmp_process_monitor.pl b/contrib/check_snmp_process_monitor.pl deleted file mode 100644 index 0f445970..00000000 --- a/contrib/check_snmp_process_monitor.pl +++ /dev/null @@ -1,331 +0,0 @@ -#!/usr/local/bin/perl -# author: Al Tobey <albert.tobey@priority-health.com> -# what: monitor a process using the host-resources mib -# license: GPL - http://www.fsf.org/licenses/gpl.txt -# -# Todo: -# * implement memory and cpu utilization checks -# * maybe cache pids in DBM files if snmp agents get overworked -############################################################################### -# to get a list of processes over snmp try this command: -# snmptable -v2c -c public hostname hrSWRunTable -# for just a list of valid arguments for the '-e' option: -# snmpwalk -v2c -c public hostname hrSWRunName |perl -pe 's:.*/::' -############################################################################### - -use strict; -require 5.6.0; -use lib qw( /opt/nagios/libexec /usr/local/libexec ); -use utils qw(%ERRORS $TIMEOUT &print_revision &support &usage); -use SNMP 5.0; -use Getopt::Long; -use Storable; -use 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 ); - -$PROGNAME = "snmp_process_monitor.pl"; -$opt_verbose = undef; -$opt_host = undef; -$opt_community = 'public'; -$opt_command = undef; -$opt_warning = [ 1, -1 ]; -$opt_critical = [ 1, -1 ]; -$opt_memory = undef; -$opt_cpu = undef; -$opt_port = 161; -$opt_cache = 1; -$opt_nocache = undef; -$cache_exp = 600; -$exit = $ERRORS{OK}; -$interpreters = '(perl|/bin/sh|/usr/bin/sh|/bin/bash|/bin/ksh|python)'; -our $cachefile = '/var/opt/nagios/tmp/'; # completed later -our %processes = (); - -sub process_options { - my( $opt_crit, $opt_warn ) = (); - Getopt::Long::Configure( 'bundling' ); - GetOptions( - 'V' => \$opt_version, 'version' => \$opt_version, - 'v' => \$opt_verbose, 'verbose' => \$opt_verbose, - 'h' => \$opt_help, 'help' => \$opt_help, - 's' => \$opt_stats, 'statistics' => \$opt_stats, - 'nocache' => \$opt_nocache, - 'H:s' => \$opt_host, 'hostname:s' => \$opt_host, - 'p:i' => \$opt_port, 'port:i' => \$opt_port, - 'C:s' => \$opt_community, 'community:s' => \$opt_community, - 'c:s' => \$opt_crit, 'critical:s' => \$opt_crit, - 'w:s' => \$opt_warn, 'warning:s' => \$opt_warn, - 't:i' => \$TIMEOUT, 'timeout:i' => \$TIMEOUT, - 'e:s' => \$opt_command, 'command:s' => \$opt_command, - 'r:s' => \$opt_regex, 'regex:s' => \$opt_regex, - 'cpu:i' => \$opt_cpu, 'memory:i' => \$opt_memory, - ); - if ( defined($opt_version) ) { local_print_revision(); } - if ( defined($opt_verbose) ) { $SNMP::debugging = 1; } - if ( !defined($opt_host) || defined($opt_help) || (!defined($opt_command) && !defined($opt_regex)) ) { - print_help(); - exit $ERRORS{UNKNOWN}; - } - - if ( defined($opt_crit) ) { - if ( $opt_crit =~ /,/ ) { - $opt_critical = [ split(',', $opt_crit) ]; - } - else { - $opt_critical = [ $opt_crit, -1 ]; - } - } - if ( defined($opt_warn) ) { - if ( $opt_warn =~ /,/ ) { - $opt_warning = [ split(',', $opt_warn) ]; - } - else { - $opt_warning = [ $opt_crit, -1 ]; - } - } - if ( defined($opt_memory) ) { $opt_memory = 0 } - if ( defined($opt_cpu) ) { $opt_cpu = 0 } - if ( defined($opt_nocache)) { $opt_cache = 0 } - - # complete the cachefile's name - $cachefile .= $opt_host . '.proc'; -} - -sub local_print_revision { - print_revision( $PROGNAME, '$Revision: 84 $ ' ) -} - -sub print_usage { - print "Usage: $PROGNAME -H <host> -C <snmp_community> -e <command> [-w <low>,<high>] [-c <low>,<high>] [-t <timeout>] [-s|--statistics] [--memory] [--cpu] [--nocache]\n"; -} - -sub print_help { - local_print_revision(); - print "Copyright (c) 2002 Al Tobey <albert.tobey\@priority-health.com>\n\n", - "SNMP Process Monitor plugin for Nagios\n\n"; - print_usage(); - print <<EOT; --v, --verbose - print extra debugging information --h, --help - print this help message --H, --hostname=HOST - name or IP address of host to check --C, --community=COMMUNITY NAME - community name for the host's SNMP agent --e, --command=COMMAND NAME (ps -e style) - what command should be monitored? --r, --regex=Perl RE - use a perl regular expression to find your process --w, --warning=INTEGER[,INTEGER] - minimum and maximum number of processes before a warning is issued (Default 1,-1) --c, --critical=INTEGER[,INTEGER] - minimum and maximum number of processes before a critical is issued (Default 1,-1) ---memory - combined with '-s', will print the number of bytes of real memory used by process ---cpu - combined with '-s', will print the number of seconds of cpu time consumed by process -EOT -} - -sub verbose (@) { - return if ( !defined($opt_verbose) ); - print @_; -} - -sub check_for_errors { - if ( $snmp_session->{ErrorNum} ) { - %processes = (); - print "UNKNOWN - error retrieving SNMP data: $snmp_session->{ErrorStr}\n"; - exit $ERRORS{UNKNOWN}; - } -} - -sub init_cache { - if ( !defined($opt_cache) ) { - %processes = (); - return; - } - if ( -r $cachefile ) { - eval { - verbose "loading cache from $cachefile\n"; - %processes = %{ retrieve( $cachefile ) }; - }; - if ( $@ ) { - verbose "cache loading failed - using blank cache: $@\n"; - %processes = () - } - } - else { - %processes = (); - } -} - -sub snmpget { - my $tmpvar = SNMP::Varbind->new( shift ); - $snmp_session->get( $tmpvar ); - check_for_errors(); - return $tmpvar->val; -} - -sub update_cache { - # expire the cache after $cache_exp seconds - if ( $opt_cache != 0 && exists($processes{__last_update}) - && $processes{__last_update} >= time - $cache_exp ) { - verbose "cache file is recent enough - using it\n"; - return 1; - } - - verbose "retrieving full listing of processes from $opt_host\n"; - my $process_count = snmpget( ['hrSystemProcesses', 0] ); - - # retrieve the data from the remote host - my ($names) = $snmp_session->bulkwalk( 0, $process_count + 1, [['hrSWRunName']] ); - check_for_errors(); - - # make sure the number of processes from the bulkwalk is close to hrSystemProcesses - if ( scalar(@$names) + 10 < $process_count ) { - print "UNKNOWN - only ", scalar(@$names), " of ",$process_count, " processes returned\n";; - exit $ERRORS{UNKNOWN}; - } - - # sort through the process names and create a nice hash of processes - foreach my $row ( @$names ) { - my %hash = {}; - $hash{name} = $row->val; - $hash{abs_name} = $row->val; - $hash{name} =~ s#.*/##; # strip path - - if ( defined($opt_regex) || - ($row->val =~ m#$interpreters$# - && $opt_command !~ m#$interpreters$#) ) { - - # fetch the runtime parameters of the process - my $parameters = snmpget( ['hrSWRunParameters', $row->iid] ); - - # only strip if we're looking for a specific command - if ( defined($opt_command) ) { - verbose "process ",$row->iid," uses $1 as an interpreter - getting parameters\n"; - $hash{name} = $parameters; - $hash{name} =~ s#.*/##; # strip path name off the front - $hash{name} =~ s/\s+.*$//; # strip everything from the first space to the end - } - else { - # use the full 'ps -efl' style listing for regular expression matching - my $path = snmpget( ['hrSWRunPath', $row->iid] ); - $hash{name} = "$path $parameters"; - } - } - # store in the global hash - $processes{$row->iid} = \%hash; - } - - # update the timestamp so the cache can expire - $processes{__last_update} = time; - return 0; -} - -# process the %processes hash and see if there any matches for our command or regex -sub check_for_matches { - my $ret_match = 0; - foreach my $key ( keys(%processes) ) { - next if ( $key eq '__last_update' ); - my $match = 0; - - # static matches are letter-for-letter (-e) - if ( defined($opt_command) && $processes{$key}->{name} eq $opt_command ) { $match++; } - # use /o to make sure the user-supplied regex (-r) is only compiled once - elsif ( defined($opt_regex) && $processes{$key}->{name} =~ /$opt_regex/o ) { $match++; } - - # verify the cache's entry by doing an snmpget - if ( $match > 0 && $opt_cache != 0 ) { - my $proc = snmpget( ['hrSWRunName', $key] ); - --$match if ( !$proc || $proc ne $processes{$key}->{abs_name} ); - } - # get the process memory usage if requested - if ( $match > 0 && defined($opt_memory) ) { - $opt_memory += snmpget( ['hrSWRunPerfMem', $key] ); - } - # get the process cpu usage if requested - if ( $match > 0 && defined($opt_cpu) ) { - $opt_cpu += snmpget( ['hrSWRunPerfCPU', $key] ); - } - - verbose "process '$processes{$key}->{name}' has pid $processes{$key}->{pid} and index $key\n" - if ( $match > 0 ); - - $ret_match += $match; - } - return $ret_match; -} -# =========================================================================== # -# =====> MAIN -# =========================================================================== # -process_options(); - -alarm( $TIMEOUT ); # make sure we don't hang Nagios - -# intialize the cache, if it's enabled -init_cache(); - -# create a session for conversing with the remote SNMP agent -$snmp_session = new SNMP::Session( - DestHost => $opt_host, - Community => $opt_community, - RemotePort => $opt_port, - Version => '2c' -); - -my $usage = update_cache(); -my $count = check_for_matches(); - -# always try twice if caching is enabled - once with cache and once without -if ( $usage != 0 && $opt_cache != 0 && $count <= 0 ) { - verbose "did not find process in cache - trying a refresh\n"; - %processes = (); - update_cache(); - $count = check_for_matches(); -} - - -# the default, OK message -my $message = "OK - $count process(es) found resembling '". ($opt_command || $opt_regex); - -# warning, critical -if ( ($opt_warning->[0] > 0 && $opt_warning->[0] > $count) - || ($opt_warning->[1] > 0 && $opt_warning->[1] <= $count) ) { - $message = "WARNING - no processes found resembling '". ($opt_command || $opt_regex); - $exit = $ERRORS{WARNING}; -} -if ( ($opt_critical->[0] > 0 && $opt_critical->[0] > $count) - || ($opt_critical->[1] > 0 && $opt_critical->[1] <= $count) ) { - $message = "CRITICAL - no processes found resembling '". ($opt_command || $opt_regex); - $exit = $ERRORS{CRITICAL}; -} - -# output the status message -print $message, "'"; - -# print the number of processes if statistics are requested -if ( defined($opt_stats) ) { - print "|count=$count"; - if ( defined($opt_memory) ) { - print ":memory=", $opt_memory; - } - if ( defined($opt_cpu) ) { - $opt_cpu = $opt_cpu / 100; - printf ":cpu=%.2f", $opt_cpu; - } -} - -# store a copy of the %processes hash if we're using caching -if ( $exit == $ERRORS{OK} && $opt_cache != 0 ) { - eval { - unlink( $cachefile ) if ( -e $cachefile ); - store( \%processes, $cachefile ); - }; -} - -print "\n"; -exit $exit; - - diff --git a/contrib/check_snmp_procs.pl b/contrib/check_snmp_procs.pl deleted file mode 100644 index 4d19ff17..00000000 --- a/contrib/check_snmp_procs.pl +++ /dev/null @@ -1,590 +0,0 @@ -#!/usr/bin/perl -w -# -# check_snmp_procs.pl -# Nagios script to check processes on remote host via snmp -# -# -# Copyright (c) 2003 David Alden -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# -# History -# ------- -# 02-25-2003 - Dave Alden <alden@math.ohio-state.edu> -# Initial creation -# -# -# TODO -# ---- -# make it work with snmp version 3 -# Suggestions??? -# -#use strict; -use Getopt::Long; -use Net::SNMP qw (oid_lex_sort oid_base_match SNMP_VERSION_1); -use lib "/usr/local/nagios/libexec"; -use utils qw(%ERRORS &print_revision &support &usage); - -my $PROGNAME="check_snmp_procs"; -my $REVISION="1.0"; - -# -my $opt_authprotocol; -my $opt_authpassword; -my $opt_community = 'ma4read'; -my $opt_critical; -my $opt_help; -my $opt_host = 'euler'; -my $opt_oidname = 'hrSWRunName'; -my $opt_port = 161; -my $opt_privpassword; -my $opt_regexp = 0; -my $opt_snmp_version = '2c'; -my $opt_timeout = $utils::TIMEOUT; -my $opt_username; -my $opt_verbose; -my $opt_version; -my $opt_wanted_procs; -my $opt_warning; - -# -my $max_no_processes = 999999; -my $session; -my $error; -my $no_procs; -my $exit_status; - -# -my @wanted_procs; -my %current_process_list; - -# -my %OIDS = (hrSWRunName => '1.3.6.1.2.1.25.4.2.1.2', - hrSWRunPath => '1.3.6.1.2.1.25.4.2.1.4'); - -my %OIDS_L = (hrSWRunName => length($OIDS{hrSWRunName}), - hrSWRunPath => length($OIDS{hrSWRunPath})); - -# -$ENV{'PATH'}=''; -$ENV{'BASH_ENV'}=''; -$ENV{'ENV'}=''; - -# -Getopt::Long::Configure('bundling'); -if (GetOptions( - "a:s" => \$opt_authprotocol, "authprotocol:s" => \$opt_authprotocol, - "A:s" => \$opt_authpassword, "authpassword:s" => \$opt_authpassword, - "C:s" => \$opt_community, "community:s" => \$opt_community, - "c:s" => \$opt_critical, "critical:s" => \$opt_critical, - "h" => \$opt_help, "help" => \$opt_help, - "H:s" => \$opt_host, "hostname:s" => \$opt_host, - "o:s" => \$opt_oidname, "oidname:s" => \$opt_oidname, - "P=s" => \$opt_password, "password=s" => \$opt_password, - "p=i" => \$opt_port, "port=i" => \$opt_port, - "r" => \$opt_regexp, "regexp" => \$opt_regexp, - "S" => \$opt_snmp_version, "snmpversion" => \$opt_snmp_version, - "t=i" => \$opt_timeout, "timeout=i" => \$opt_timeout, - "U=s" => \$opt_username, "username=s" => \$opt_username, - "v" => \$opt_verbose, "verbose" => \$opt_verbose, - "V" => \$opt_version, "version" => \$opt_version, - "N=s" => \$opt_wanted_procs, "names=s" => \$opt_wanted_procs, - "w:s" => \$opt_warning, "warning:s" => \$opt_warning) - == 0) { - print_usage(); - exit $ERRORS{'UNKNOWN'}; -} - -if ($opt_version) { - print_revision($PROGNAME, "\$Revision: 1771 $REVISION \$"); - exit $ERRORS{'OK'}; -} - -if ($opt_help) { - print_help(); - exit $ERRORS{'OK'}; -} - -if (! utils::is_hostname($opt_host)){ - usage(); - exit $ERRORS{'UNKNOWN'}; -} - -($longest_wanted, @wanted_procs) = parse_wanted_procs($opt_verbose, $opt_wanted_procs, $opt_warning, $opt_critical); - -$SIG{'ALRM'} = sub { - print "Timeout: No Answer from Client\n"; - exit $ERRORS{'UNKNOWN'}; -}; -alarm($opt_timeout); - -($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); - -$exit_status = compare_process_list($opt_regexp, \%current_process_list, @wanted_procs); - -if ($opt_verbose) { - print_info($longest_current, \%current_process_list, $longest_wanted, @wanted_procs); -} - -exit($exit_status); - - -# -sub compare_process_list { - - my($regexp, $current_process_list, @wanted_procs) = @_; - my($proc, $i, $no_running_procs, @warning, @critical); - my $exit = $ERRORS{'OK'}; - - for ($i = 0; $i <= $#wanted_procs; $i++) { - - $proc = $wanted_procs[$i]; - - $no_running_procs = get_running_procs($regexp, $$proc{name}, $current_process_list); - - $$proc{no_matches} += $no_running_procs; - - if (($no_running_procs >= $$proc{warn_low}) && - ($no_running_procs <= $$proc{warn_high})) { - - push(@warning, $$proc{name} . "($no_running_procs)"); - - if ($exit != $ERRORS{'CRITICAL'}) { - $exit = $ERRORS{'WARNING'}; - } - - } elsif (($no_running_procs < $$proc{minimum}) || - ($no_running_procs >= $$proc{critical_low}) && - ($no_running_procs <= $$proc{critical_high})) { - - push(@critical, $$proc{name} . "($no_running_procs)"); - - $exit = $ERRORS{'CRITICAL'}; - } - } - - print "SNMPPROC "; - - if ($#critical >= 0) { - print "CRITICAL:"; - } elsif ($#warning >= 0) { - print "WARNING:"; - } else { - print "OK"; - } - - foreach $i (@critical) { - print " $i"; - } - - if (($#critical >= 0) && - ($#warning >= 0)) { - print " WARNING:"; - } - - foreach $i (@warning) { - print " $i"; - } - - print "\n"; - - return $exit; -} - - -# -sub get_running_procs { - - my($regex, $name, $process_list) = @_; - my $count = 0; - my $process; - - $count = 0; - - if ($regex) { - - foreach $process (keys %{$process_list}) { - - if ($process =~ /$name/) { - $count += $$process_list{$process}; - } - } - - - } else { - - if (!defined($count = $$process_list{$name})) { - $count = 0; - } - } - - return $count; -} - - -# -sub get_process_list { - - my($verbose, $host, $username, $privpassword, $authprotocol, $authpassword, $community, $port, $oidname, $snmp_version) = @_; - my(%process_list, %process_pid_list, $result); - my $process_list_longest = 1, $not_done = 1; - my(@args, @oids, $oid, $name); - - ($session, $error) = Net::SNMP->session( - -hostname => $host, - -community => $community, - -port => $port, - -version => $snmp_version, - defined($privpassword) ? (-privpassword => $privpassword) : (), - defined($authpassword) ? (-authpassword => $authpassword) : (), - defined($authprotocol) ? (-authprotocol => $authprotocol) : (), - defined($username) ? (-username => $username) : ()); - - if (!defined($session)) { - print ("UNKNOWN: $error\n"); - exit $ERRORS{'UNKNOWN'}; - } - - @args = (-varbindlist => [$OIDS{$oidname}]); - - if ($session->version == SNMP_VERSION_1) { - - while (defined($session->get_next_request(@args))) { - - $oid = (keys(%{$session->var_bind_list}))[0]; - - last if (!oid_base_match($OIDS{$oidname}, $oid)); - - $name = $session->var_bind_list->{$oid}; - $process_list{$name}++; - - if ($verbose && ($process_list_longest < length($name))) { - $process_list_longest = length($name); - } - - @args = (-varbindlist => [$oid]); - } - - } else { - - push(@args, -maxrepetitions => 25); - - while ($not_done && defined($session->get_bulk_request(@args))) { - - @oids = oid_lex_sort(keys(%{$session->var_bind_list})); - - foreach $oid (@oids) { - if (!oid_base_match($OIDS{$oidname}, $oid)) { - - $not_done = 0; - - } else { - - $name = $session->var_bind_list->{$oid}; - $process_list{$name}++; - - if ($verbose && ($process_list_longest < length($name))) { - $process_list_longest = length($name); - } - - if ($session->var_bind_list->{$oid} eq 'endOfMibView') { - $not_done = 0; - } - } - } - - if ($not_done) { - @args = (-maxrepetitions => 25, -varbindlist => [pop(@oids)]); - } - } - } - - if ($session->error() ne '') { - print ("UNKNOWN: " . $session->error() . "\n"); - exit $ERRORS{'UNKNOWN'}; - } - - $session->close; - - return($process_list_longest, %process_list); -} - - -# -sub parse_wanted_procs { - - my($verbose, $wanted_procs, $warning, $critical) = @_; - - my(@procs, $process, $i, $critical_low, $critical_high, $warn_low, $warn_high, $process_name, $process_min); - my(@process_array, @warn_array, @critical_array); - my $exit = 0; - my $longest_name = 1; - - if (defined($wanted_procs)) { - @process_array = split(/,/, $wanted_procs); - } - - if (defined($warning)) { - @warn_array = split(/,/, $warning); - } - - if (defined($critical)) { - @critical_array = split(/,/, $critical); - } - - if( defined($warning) && $#process_array != $#warn_array ) { - - print "Error: Number of entries in process list($#process_array) and warn list($#warn_array) don't match\n"; - exit $ERRORS{'UNKNOWN'}; - } - - if( defined($critical) && $#process_array != $#critical_array ) { - - print "Error: Number of entries in process list and critical list don't match\n"; - exit $ERRORS{'UNKNOWN'}; - } - - for ($i = 0; $i <= $#process_array; $i++) { - - if ((($process_name, $process_min) = split(/:/, $process_array[$i])) != 2) { - - $process_min = 1; - } - - if ($verbose && ($longest_name < length($process_name))) { - - $longest_name = length($process_name); - } - - if (defined($critical_array[$i])) { - if ((($critical_low, $critical_high) = split(/:/, $critical_array[$i])) != 2) { - - $critical_high = $critical_low; - - } else { - - if ($critical_high eq "") { - $critical_high = $max_no_processes; - } - - if ($critical_low eq "") { - $critical_low = 0; - } - } - } else { - - $critical_low = -1; - $critical_high = -1; - } - - if (defined($warn_array[$i])) { - if ((($warn_low, $warn_high) = split(/:/, $warn_array[$i])) != 2) { - - $warn_high = $warn_low; - - } else { - - if ($warn_high eq "") { - $warn_high = $max_no_processes; - } - - if ($warn_low eq "") { - $warn_low = 0; - } - } - } else { - - $warn_low = -1; - $warn_high = -1; - } - - if ($critical_low > $critical_high) { - print "Error: $process_name critical low($critical_low) is larger than high($critical_high)\n"; - $exit = 1; - } - - if ($warn_low > $warn_high) { - print "Error: $process_name warn low($warn_low) is larger than high($warn_high)\n"; - $exit = 1; - } - - if (@critical_array && - ($process_min > $critical_low)) { - print "Error: $process_name minimum($process_min) is larger than critical low($critical_low)\n"; - $exit = 1; - } - - if (@warn_array && - ($process_min > $warn_low)) { - print "Error: $process_name minimum($process_min) is larger than warn low($warn_low)\n"; - $exit = 1; - } - - if (@warn_array && @critical_array && - ((($warn_low >= $critical_low) && ($warn_low <= $critical_high)) || - (($warn_high >= $critical_low) && ($warn_high <= $critical_high)))) { - - print "Error: $process_name warn levels($warn_low:$warn_high) overlap with critical levels($critical_low:$critical_high)\n"; - $exit = 1; - } - - push(@procs,{ - name => $process_name, - critical => defined($critical), - critical_low => $critical_low, - critical_high => $critical_high, - minimum => $process_min, - warning => defined($warning), - warn_low => $warn_low, - warn_high => $warn_high}); - } - - if ($exit) { - exit $ERRORS{'UNKNOWN'}; - } - - return($longest_name, @procs); -} - - -# -sub print_info { - - my ($longest_current, $current_process_list, $longest_wanted, @wanted_procs) = @_; - - if ($longest_wanted < 7) { - $longest_wanted = 7; - } else { - $longest_wanted++; - } - - printf("%s---------------------------------------------\n", "-" x $longest_wanted); - printf("|%-" . $longest_wanted . "s | | Min | Warn | Critical |\n", "Process"); - printf("|%-" . $longest_wanted . "s | Qty | Procs| Low | High | Low | High |\n", "Name"); - printf("%s---------------------------------------------\n", "-" x $longest_wanted); - - for (my $temp=0; $temp <= $#wanted_procs; $temp++) { - - printf("|%-" . $longest_wanted . "s |%6d|%6d|%6d|%6d|%6d|%6d|\n", - $wanted_procs[$temp]{name}, - $wanted_procs[$temp]{no_matches}, - $wanted_procs[$temp]{minimum}, - $wanted_procs[$temp]{critical_low}, - $wanted_procs[$temp]{critical_high}, - $wanted_procs[$temp]{warn_low}, - $wanted_procs[$temp]{warn_high}); - } - - printf("%s---------------------------------------------\n\n", "-" x $longest_wanted); - - if ($longest_current < 7) { - $longest_current = 7; - } else { - $longest_current++; - } - - printf("%s----------\n", "-" x $longest_current); - printf("|%-" . $longest_current . "s | Qty |\n", "Process"); - printf("%s----------\n", "-" x $longest_current); - - foreach my $result (sort keys %{$current_process_list}) { - - printf("|%-" . $longest_current . "s |%6d|\n", $result, - $current_process_list{$result}); - } - printf("%s----------\n", "-" x $longest_current); - - return; -} - - -# -sub print_usage { - print "Usage: - $PROGNAME -H <host> [-r] [-v] - -N <processname>[:minimum][,<processname>[:minimum] ...] - [-a <authprotocol>] [-A <authpassword>] - [-U <username>] [-P <password>] - [-o <oidname>] [ -S <snmpversion> ] - [-C <snmp_community>] [-p <port>] [-t <timeout>] - [-w <low>:<high>[,<low>:<high> ...] - [-c <low>:<high>[,<low>:<high> ...] - $PROGNAME (-h | --help) for detailed help - $PROGNAME (-V | --version) for version information\n"; -} - - -# -sub print_help { - print_revision($PROGNAME, "\$Revision: 1771 $REVISION \$"); - print "Copyright (c) 2003 David Alden - -Check if processes are running on a host via snmp - -"; - - print_usage(); - - print " --a, --authprotocol=<authprotocol> - Set the authentication protocol used for authenticated SNMPv3 messages --A, --authpassword=<authpassword> - Set the authentication pass phrase used for authenticated SNMPv3 messages --c, --critical=<low>:<high>[,<low>:<high> ...] - exit with CRITICAL status if number of processes is between <low> and <high> --C, --community=<snmp_community> - SNMP read community (default: $opt_community) --h, --help - Show this help screen --H, --host=<host> - Check processes on the indiciated host --o, --oidname=<oidname> - Which oid tree to search, hrSWRunName or hrSWRunPath (default: $opt_oidname) --p, --port=<port> - Make connection on the indicated port (default: $opt_port) --N, --names=<processname>[:<minimum>][,<processname>[:<minimum>] ...] - Process names to check, (optional) minimum number of processes (default: 1) --P, --password=<privpassword> - Set the privacy pass phrase used for encrypted SNMPv3 messages --r, --regex - Use regular expression match for <process> --S, --snmpversion - Use snmp version specified (values: 1|2c|3, default: $opt_snmp_version) --t, --timeout - Plugin time out in seconds (default: $opt_timeout) --U, --username=<securityname> - Set the securityname used for encrypted SNMPv3 messages --v, --verbose - Print some extra debugging information (not advised for normal operation) --V, --version - Show version and license information --w, --warning=<low>:<high>[,<low>:<high> ...] - exit with WARNING status if number of processes is between <low> and <high> - - -A CRITICAL error will be indicated unless there are at least <minimum> number -of processes running (unless <minimum> is set to 0 -- useful if you don't -mind that there are none of the processes running). - -If no processes are specified, the program will still connect to the remote -host and download the current list of running processes. It will then exit -with an OK (unless it wasn't able to connect) -- useful if you want to make -sure that the remote snmpd process is running and returning a list of procs. - - -"; - support(); -} diff --git a/contrib/check_sockets.pl b/contrib/check_sockets.pl deleted file mode 100644 index b8ae24a2..00000000 --- a/contrib/check_sockets.pl +++ /dev/null @@ -1,145 +0,0 @@ -#! /usr/bin/perl -# ------------------------------------------------------------------------------ -# File Name: check_sockets.pl -# Author: Richard Mayhew - South Africa -# Date: 2000/07/11 -# Version: 1.0 -# Description: This script will check to see how may open sockets -# a server has and waron respectivly -# Email: netsaint@splash.co.za -# ------------------------------------------------------------------------------ -# Copyright 1999 (c) Richard Mayhew -# Credits go to Ethan Galstad for coding Nagios -# If any changes are made to this script, please mail me a copy of the -# changes :) -# Some code taken from Charlie Cook (check_disk.pl) -# License GPL -# -# ------------------------------------------------------------------------------ -# Date Author Reason -# ---- ------ ------ -# 1999/09/20 RM Creation -# 1999/09/20 TP Changed script to use strict, more secure by -# specifying $ENV variables. The bind command is -# still insecure through. Did most of my work -# with perl -wT and 'use strict' -# -# ------------------------------------------------------------------------------ - -# -----------------------------------------------------------------[ Require ]-- -require 5.004; -# --------------------------------------------------------------------[ Uses ]-- -use Socket; -use strict; -# --------------------------------------------------------------[ Enviroment ]-- -$ENV{'PATH'}='/bin:/sbin:/usr/bin:/usr/sbin'; -$ENV{BASH_ENV} = ""; -# ------------------------------------------------------------------[ Global ]-- -my $TIMEOUT = 20; -my %ERRORS = ( - 'UNKNOWN', '-1', - 'OK', '0', - 'WARNING', '1', - 'CRITICAL', '2'); -# --------------------------------------------------------------[ connection ]-- -sub connection -{ - my ($in_total,$in_warn,$in_crit,$in_high) = @_; - my $state; - my $answer; - - $in_total =~ s/\ //g; - if ($in_total >= 0) { - - if ($in_total > $in_crit) { - $state = "CRITICAL"; - $answer = "Critical Number Of Sockets Connected : $in_total (Limit = $in_crit)\n"; - - } elsif ($in_total > $in_warn) { - $state = "WARNING"; - $answer = "Warning Number Of Sockets Connected : $in_total (Limit = $in_warn)\n"; - - } else { - if ($in_high ne "") { - $answer = "Sockets OK - Current Sockets: $in_total : $in_high\n"; - } - if ($in_high eq "") { - $answer = "Sockets OK - Current Sockets: $in_total\n"; - } - $state = "OK"; - } - - } else { - $state = "UNKNOWN"; - $answer = "Something is Really WRONG! Sockets Is A Negative Figure!\n"; - } - - print $answer; - exit $ERRORS{$state}; -} - -# -------------------------------------------------------------------[ usage ]-- -sub usage -{ - print "Minimum arguments not supplied!\n"; - print "\n"; - print "Perl Check Sockets plugin for Nagios\n"; - print "Copyright (c) 2000 Richard Mayhew\n"; - print "\n"; - print "Usage: check_sockets.pl <type> <warn> <crit>\n"; - print "\n"; - print "<type> = TOTAL, TCP, UDP, RAW.\n"; - print "<warn> = Number of sockets connected at which a warning message will be generated.[Default = 256]\n"; - print "<crit> = Number of sockets connected at which a critical message will be generated.[Default = 512]\n"; - exit $ERRORS{"UNKNOWN"}; - -} - -# ====================================================================[ MAIN ]== -MAIN: -{ - my $type = shift || &usage; - my $warn = shift || 256; - my $crit = shift || 512; - my $data; - my @data; - my $line; - my $data1; - my $data2; - my $data3; - my $junk; - my $total1; - my $total2; - $type = uc $type; - if ($type eq "TOTAL") { - $type = "sockets"; - } - - # Just in case of problems, let's not hang Nagios - $SIG{'ALRM'} = sub { - print "Somthing is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n"; - exit $ERRORS{"UNKNOWN"}; - }; - - $data = `/bin/cat /proc/net/sockstat`; - @data = split("\n",$data); - alarm($TIMEOUT); - my $output = ""; - my $high; - - - foreach $line (@data) { - if ($line =~ /$type/) { - ($data1,$data2,$data3) = split(" ",$line,3); - - if ($data3 =~ /highest/){ - ($total1,$junk,$total2) = split(" ",$data3,3); - $output = $total1; - $high = $total2; - } - else {$output = $data3;} - alarm(0); - connection($output,$warn,$crit,$high); - } - } -} diff --git a/contrib/check_temp_cpq b/contrib/check_temp_cpq deleted file mode 100644 index 6edae6ef..00000000 --- a/contrib/check_temp_cpq +++ /dev/null @@ -1,162 +0,0 @@ -#!/usr/bin/perl -# -# -# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical] -# -# NetSaint host script to get the disk usage from NT snmp -# -# Changes and Modifications -# ========================= -# 3-Aug-2000 - Xavier Dusart -# Created -# 2003 - Rainer Duffner -# Note: CPQ starts numbering sensors etc. with "1" - -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} - - - -require 5.004; -use POSIX; -#use strict; -use Getopt::Std ; -use BER; -require 'SNMP_Session.pm'; -use vars qw($opt_H $opt_p $opt_C $opt_s $opt_w $opt_c $opt_h $PROGNAME); -use lib $main::runtimedir; -use utils qw($TIMEOUT %ERRORS &print_revision &usage &support ); - -use snmputil qw(%CPQ_LOCALE %CPQ_FAN_PRESENT %CPQ_FAN_OVERALL_COND %CPQ_FAN_SPEED); - -delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer - - -getopts('H:p:C:s:w:c:hV') ; - -my $ip_address=undef ; - -if ($opt_h) {&help();} - -if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA --Z0-9]*)*)$/) { - $ip_address = $opt_H ; - } -else { - usage(); - print "IP-Address format wrong\n"; - exit $ERRORS{'UNKNOWN'}; - } - -#if ($opt_p =~ m/^[0-9] - -my $port = $opt_p; - -my $community = $opt_C; - -my $sensor = $opt_s ; - -my $warning = $opt_w; - -my $critical = $opt_c; - - - my $temperature_locale_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,3,0,$sensor ); -# not used for the moment - gives no usable output -# if reused, enter at end of list to avoid renumbering ! - my $temperature_celsius_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,4,0,$sensor ); - my $temperature_threshold_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,5,0,$sensor ); - my $temperature_condition_oid = encode_oid (1,3,6,1,4,1,232,6,2,6,8,1,6,0,$sensor ); - my $count=1 ; - my $label ; - my @r_array=(); - my $q ; - my $diff ; - $warning=$warning/100 ; - $crititcal=$critical/100 ; - - -# get temperature, temperature_threshold bfore shutdown - my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ; - - if ($session->get_request_response ($temperature_celsius_oid, $temperature_threshold_oid, $temperature_condition_oid, $temperature_locale_oid )) { - (my $bindings) = $session->decode_get_response ($session->{pdu_buffer}); - while ($bindings ne '') { - ($binding, $bindings) = &decode_sequence ($bindings) ; - ($oid,$value) = &decode_by_template ($binding,"%O%@"); - $r_array[$count]=&pretty_print($value); - $count++; - } - } else { - print "No response from agent\n"; - exit $ERRORS{'CRITICAL'}; - } - $result_celsius=$r_array[1]; - $result_threshold=$r_array[2]; - $result_condition=$r_array[3]; - $result_locale=$r_array[4]; - - if ($result_celsius < 0) { - print "Result is negative - Sensor unavailable ?\n"; - exit $ERRORS{'UNKNOWN'}; - } - if ($result_threshold==0) { - print "Division by zero \n"; - exit $ERRORS{'CRITICAL'}; - } - - if ($result_condition=="2") { - $result_condition="OK"; - } - else { - $result_condition=$result_condition." (other)"; - } - $q=$result_celsius/$result_threshold ; - $diff=$result_threshold-$result_celsius ; - - - if ( $q > $critical ) { - 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" ; - exit $ERRORS{'CRITICAL'} ; - } - elsif ( $q > $warning ) { - 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" ; - exit $ERRORS{'WARNING'} ; - } - else { - 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" ; - exit $ERRORS{'OK'} ; - } - - -sub print_usage () { - print "Usage: $PROGNAME -H <host> -p <port> -C <community> -s <sensornumber> [-w <warn>] [-c <crit>]\n"; - } - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1113 $\n '); - print "Copyright (c) 2003 Rainer Duffner\n "; - print_usage(); - print "\n"; - print "<host> = IP-Address or DNS-Name of the W2K-Server\n"; - print "<port> = SNMP-Port (normaly 161)\n"; - print "<community> = SNMP v1 community\n"; - print "<sensornumber> = Sensornumber (1, 2, 3 etc.)\n"; - print "<warn> = report warning when more than <warn> % of the temperature is reached defaults to 80\n"; - print "<crit> = report critical when more than <crit> % of the temperature is reached defaults to 90\n"; - } - -sub version () { - print_revision($PROGNAME,'$Revision: 1113 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - diff --git a/contrib/check_temp_fsc b/contrib/check_temp_fsc deleted file mode 100644 index 33470ea1..00000000 --- a/contrib/check_temp_fsc +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/perl -# -# -# check_most.pl -i <ip address> -p <port> -c community -o <oid> [warn] [critical] -# -# NetSaint host script to get the disk usage from NT snmp -# -# Changes and Modifications -# ========================= -# 3-Aug-2000 - Xavier Dusart -# Created -# 2003 - Rainer Duffner - -BEGIN { - if ($0 =~ m/^(.*?)[\/\\]([^\/\\]+)$/) { - $runtimedir = $1; - $PROGNAME = $2; - } -} - - - -require 5.004; -use POSIX; -#use strict; -use Getopt::Std ; -use BER; -require 'SNMP_Session.pm'; -use vars qw($opt_H $opt_p $opt_C $opt_s $opt_w $opt_c $opt_h $PROGNAME); -use lib $main::runtimedir; -use utils qw($TIMEOUT %ERRORS &print_revision &usage &support); -use snmputil qw(%FSC_LOCALE %FSC_TEMP_CONDITION); - -delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer - - -getopts('H:p:C:s:w:c:hV') ; - -my $ip_address=undef ; - -if ($opt_h) {&help();} - -if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]*(\.[a-zA-Z][-a-zA --Z0-9]*)*)$/) { - $ip_address = $opt_H ; - } -else { - usage(); - print "IP-Address format wrong\n"; - exit $ERRORS{'UNKNOWN'}; - } - -#if ($opt_p =~ m/^[0-9] - -my $port = $opt_p; - -my $community = $opt_C; - -my $sensor = $opt_s ; - -#my $warning = $opt_w; - -#my $critical = $opt_c; - - - 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 ); -# not used for the moment - gives no usable output -# if reused, enter at end of list to avoid renumbering ! - 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 ); - 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 ); - 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 ); - 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 ); - my $count=1 ; - my $label ; - my @r_array=(); - my $q ; - my $diff ; - $warning=$warning/100 ; - $crititcal=$critical/100 ; - - -# get temperature, temperature_threshold bfore shutdown - my $session=SNMP_Session->open ($ip_address, $community, $port) || die "couldn't open SNMP-session to host" ; - - if ($session->get_request_response ($temperature_celsius_oid, $temperature_warning_oid, $temperature_critical_oid, $temperature_condition_oid, $temperature_locale_oid )) { - (my $bindings) = $session->decode_get_response ($session->{pdu_buffer}); - while ($bindings ne '') { - ($binding, $bindings) = &decode_sequence ($bindings) ; - ($oid,$value) = &decode_by_template ($binding,"%O%@"); - $r_array[$count]=&pretty_print($value); - $count++; - } - } else { - print "No response from agent\n"; - exit $ERRORS{'CRITICAL'}; - } - $result_celsius=$r_array[1]; - $result_warning=$r_array[2]; - $result_critical=$r_array[3]; - $result_condition=$r_array[4]; - $result_locale=$r_array[5]; - - if ($result_celsius < 0) { - print "Result is negative - Sensor unavailable ?\n"; - exit $ERRORS{'UNKNOWN'}; - } - if ($result_warning==0) { - print "Division by zero \n"; - exit $ERRORS{'CRITICAL'}; - } - - if ($result_critical==0) { - print "Division by zero \n"; - exit $ERRORS{'CRITICAL'}; - } - - -# $q=$result_celsius/$result_threshold ; - $diff=$result_critical-$result_celsius ; - - - if ( $result_celsius > $result_critical ) { - 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" ; - exit $ERRORS{'CRITICAL'} ; - } - elsif ( $result_celsius > $result_warning ) { - 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" ; - exit $ERRORS{'WARNING'} ; - } - else { - 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" ; - exit $ERRORS{'OK'} ; - } - - -sub print_usage () { - print "Usage: $PROGNAME -H <host> -p <port> -C <community> -s <sensornumber> \n"; - } - -sub print_help () { - print_revision($PROGNAME,'$Revision: 1113 $\n '); - print "Copyright (c) 2003 Rainer Duffner\n "; - print_usage(); - print "\n"; - print "<host> = IP-Address or DNS-Name of the W2K-Server\n"; - print "<port> = SNMP-Port (normaly 161)\n"; - print "<community> = SNMP v1 community\n"; - print "<drvnumber> = Sensornumber (1, 2, 3 etc.)\n"; - } - -sub version () { - print_revision($PROGNAME,'$Revision: 1113 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - diff --git a/contrib/check_timeout.c b/contrib/check_timeout.c deleted file mode 100644 index 858bdfe9..00000000 --- a/contrib/check_timeout.c +++ /dev/null @@ -1,55 +0,0 @@ -/***************************************************************************** - * - * CHECK_TIMEOUT.C - * - * Program: Plugin timeout tester for Nagios - * License: GPL - * Copyright (c) 1999 Ethan Galstad (nagios@nagios.org) - * - * Last Modified: 01-10-2000 - * - * Command line: CHECK_TIMEOUT <something..> - * - * Description: - * This 'plugin' - if you want to call it that - doesn't do anything. It - * just stays in a loop forever and never exits, and is therefore useful for - * testing service and host check timeouts in Nagios. You must supply at - * least one argument on the command line in order to activate the loop. - * - ****************************************************************************/ - -#include <stdio.h> -#include <unistd.h> - - -int main(int argc, char **argv){ - - if(argc==1){ - printf("Incorrect arguments supplied\n"); - printf("\n"); - printf("Plugin timeout tester for Nagios\n"); - printf("Copyright (c) 1999 Ethan Galstad (nagios@nagios.org)\n"); - printf("Last Modified: 01-10-2000\n"); - printf("License: GPL\n"); - printf("\n"); - printf("Usage: %s <something>\n",argv[0]); - printf("\n"); - printf("Options:\n"); - printf(" <something> = Anything at all...\n"); - printf("\n"); - printf("Notes:\n"); - printf("This 'plugin' doesn't do anything. It is designed to never exit and therefore\n"); - printf("provides an easy way of testing service and host check timeouts in Nagios.\n"); - printf("\n"); - return 0; - } - - /* let's never leave here, okay? */ - while(1) - sleep(1); - - return 0; - } - - - diff --git a/contrib/check_traceroute-pure_perl.pl b/contrib/check_traceroute-pure_perl.pl deleted file mode 100644 index 96d1ff82..00000000 --- a/contrib/check_traceroute-pure_perl.pl +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/perl -Wall -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# -# check_traceroute is designed to generate and alarm if a traceroute exceeds -# a certain number of hops. This is useful in cases where a multi-homed -# network looses a connection and can still ping the remote end because -# traffic is being re-routed out through the redundent connection. -# -# check_traceroute v0.1 -# By mp@xmission.com -# -# Thanks to Sebastian Hetze, Linux Information Systems AG who wrote the -# excellent check_apache plugin, which this plugin was modeled after. -# -############################################################################# - -use strict; -use Net::Traceroute; -use Getopt::Long; - -my $version = "v0.1"; -my $opt_v; -my $opt_t=undef; #for usage () unless ($opt_t) to work right -my $opt_help; -my $opt_w; -my $opt_c; - -my %ERRORS = ('UNKNOWN' , '-1', - 'OK' , '0', - 'WARNING', '1', - 'CRITICAL', '2'); -# Set this to whatever you like, but make sure you don't hang Nagios -# for too long. -my $timeout = "30"; - -GetOptions - ("v" => \$opt_v, "t=s" => \$opt_t, - "help" => \$opt_help, "h" => \$opt_help, - "w=i" => \$opt_w, "c=i" => \$opt_c - ); - -if ($opt_v) { - print "\nThis is check_traceroute version $version\n"; - print "\n"; - print "Please report errors to mp\@xmission\.com"; - print "\n\n"; - } - -#subs -sub print_help () { - print "\n\nThis is check_traceroute.pl. It is designed to send an alert\n"; - print "to Nagios if a route to a particular destination exceeds a\n"; - print "certain number of hops.\n\n"; - print "Usage:\n"; - print "\n"; - print "--help Display this help.\n"; - print "-v Display the version number of check_traceroute.\n"; - print "-t Host that you wish to traceroute to.\n"; - print "-w Number of hops before Nagios generates a WARNING.\n"; - print "-c Number of hops before Nagios generates a CRITICAL.\n"; - } - -sub usage() { - print "check_traceroute -t <host> [-w <warning>] [-c <critical>]\n"; - } - -sub do_check() { - if ($opt_t) { - unless ($opt_w && $opt_c) {die "You must specify thresholds using -c and -w\n";} - my $tr = Net::Traceroute->new(host=>"$opt_t") || die "Can't init traceroute!\n"; - if($tr->found) { - my $hops = $tr->hops; - if($hops > $opt_w) { - print "Warning: $opt_t is $hops hops away!\n"; - exit $ERRORS{'WARNING'}; - } - elsif($hops > $opt_c) { - print "Critical: $opt_t is $hops hops away!\n"; - exit $ERRORS{'CRITICAL'}; - } - else { - print "OK: $opt_t is $hops hops away\n"; - exit $ERRORS{'OK'}; - } - } - else { - print "Couldn't locate host $opt_t!\n"; - exit $ERRORS{'UNKNOWN'}; - } - } - } - -# Must be placed at the end for -Wall to compile cleanly, blech -if ($opt_help) { - print_help(); - } -usage() unless ($opt_t); -#timeoutes -$SIG{'ALRM'} = sub { - print ("ERROR: No response from $opt_t (timeout) in $timeout seconds\n"); - exit $ERRORS{"UNKNOWN"}; - }; - alarm($timeout); -do_check(); - diff --git a/contrib/check_traceroute.pl b/contrib/check_traceroute.pl deleted file mode 100755 index 569dc532..00000000 --- a/contrib/check_traceroute.pl +++ /dev/null @@ -1,209 +0,0 @@ -#!/usr/bin/perl - -# $Id: check_traceroute.pl 1115 2005-01-27 10:34:16Z stanleyhopcroft $ - -# Revision 1.1 2005/01/27 10:34:16 stanleyhopcroft -# Jon Meek's check_traceroute for Mon hacked by YT for Nagios. Prob pretty weak -# - -use strict ; - -use vars qw(%ERRORS $TIMEOUT) ; -use utils qw(%ERRORS $TIMEOUT &print_revision &support &usage) ; - -sub print_help (); -sub print_usage (); - -$ENV{'PATH'}='/bin:/usr/bin:/usr/sbin'; - -my $PROGNAME = 'check_traceroute' ; - # delay units are millisecs. -my $MAX_INTERHOP_DELAY = 200 ; -my $MAX_HOPS = 30 ; - -use Getopt::Std; - -use vars qw($opt_H $opt_N $opt_r $opt_R $opt_T $opt_d $opt_h $opt_i $opt_v $opt_V) ; - -getopts('i:H:N:R:T:dhrvV'); - # H, N, R, T, and i take parms, others are flags - -do { print_help ; exit $ERRORS{OK}; } - if $opt_h ; - -do { print_revision($PROGNAME, '$Revision: 1115 $'); exit $ERRORS{OK}; } - if $opt_V ; - -do { print_help; exit $ERRORS{OK}; } - unless $opt_R || $opt_r ; - -do { print_help; exit $ERRORS{OK}; } - unless $opt_R =~ m| - (?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}-)+ - \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} - |x - || $opt_r ; - -my $should_be = $opt_R ; - # Set default timeout in seconds -my $TimeOut = $opt_T || $TIMEOUT; - -my $max_interhop_delay = $opt_i || $MAX_INTERHOP_DELAY ; -my $max_hops = $opt_N || $MAX_HOPS ; - -my $TRACEROUTE = '/usr/sbin/traceroute'; - -my $TargetHost = $opt_H ; - -print_help - unless $TargetHost ; - -my ($route, $pid, $rta_list) = ( '', '', '' ); -my %ResultString = () ; - -$SIG{ALRM} = sub { die "timeout" }; - -eval { - - alarm($TimeOut); - # XXXX Discarding STDERR _should_ reduce the risk - # of unexpected output but consequently, results for - # non existent hosts are stupid. However, why would you - # specify a route to a NX host, other than a typo ... - - $pid = open(TR, "$TRACEROUTE -n $TargetHost 2>/dev/null |") - or do { - "Failed. Cannot fork \"$TRACEROUTE\": $!" ; - $ERRORS{UNKNOWN} ; - } ; - - my $hops = 0 ; - while (<TR>) { - - print $_ - if $opt_d; - - if ( m|#\*\s+\*\s+\*| ) { - # Get * * * then give up - $route .= '*'; - # 13 = PIPE, prevents Broken Pipe Error, at least on Solaris - kill 13, $pid; - last; - } - # We will only pick up the first IP address listed on a line for now - # traceroute to csg.citec.com.au (203.9.184.12), 64 hops max, 44 byte packets - # 1 10.254.254.254 0.868 ms 0.728 ms 0.705 ms - # 2 192.168.9.1 1.240 ms 1.165 ms 1.191 ms - - my ($ThisHopIP) = m|\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+|; - my ($max_rta) = m|\d{1,3}\.\d{1,3}\.\d{1,3}\s+ (\d+\.\d+) ms| ; - - $route .= $ThisHopIP . '-'; - $rta_list .= sprintf("%.1f", $max_rta) . '-' ; - - if ( $opt_v ) { - chomp $_ ; - print $_, ' ' x (58 - length), $route, "\n"; - } - - $hops++ ; - - if ( ($hops >= $max_hops) && ! $opt_r ) { - kill 13, $pid ; - print qq(Failed. Max hops ($max_hops) exceeeded: incomplete after $hops hops, "$route".\n) ; - exit $ERRORS{CRITICAL} ; - } - if ( ($hops %2 == 0) && ($hops >= 4) && ! $opt_r ) { - - # Check for 2 cycles at end of path ie -(a-b)-(a-b)$ - # where a and b are IP v4 addresses of IS (routers). - - 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})-$/ ; - if ( $route =~ /$last_2_is-$last_2_is-$/ ) { - kill 13, $pid ; - print qq(Failed. Last 2 routers ($last_2_is) repeated, "$route".\n) ; - exit $ERRORS{CRITICAL} ; - } - - } - - } -}; - -alarm(0); - -if ( $@ and $@ =~ /timeout/ ) { - $route .= '*'; - # It was a traceroute timeout - kill 13, $pid; -} elsif ( $@ and $@ !~ /timeout/ ) { - close TR ; - print "Failed. Somethings gone wrong with \"$TRACEROUTE\": $!" ; - exit $ERRORS{UNKNOWN} ; -} - -close TR; - # Remove trailing '-'s -# $route =~ s/\-$//; -chop($route) ; -chop($rta_list) ; - -print "$route\n" - if $opt_d; - -if ( $opt_r ) { - print qq(Ok. Traceroute to host "$TargetHost" via route "$route".\n) ; - exit $ERRORS{OK}; -} - -if ( &RouteEqual($should_be, $route) ) { - print qq(Ok. Traceroute to "$TargetHost" via expected route "$route" ($rta_list).\n) ; - exit $ERRORS{OK}; -} else { - print qq(Failed. Route "$route" ne expected "$should_be".\n) ; - exit $ERRORS{CRITICAL}; -} - - -sub RouteEqual { - my ($current_route, $prev_route) = @_; - return $current_route eq $prev_route ; -} - -sub print_usage () { - print "Usage: $PROGNAME [ -R <route_string>|-r ] [ -d -T timeout -v -h -i ] -H <host>\n"; -} - -sub print_help () { - print_revision($PROGNAME, '$Revision: 1115 $') ; - print "Copyright (c) 2004 J Meek/Karl DeBisschop - -This plugin checks whether traceroute to the destination succeeds and if so that the route string option (-R) matches the list of routers -returned by traceroute. - -"; -print_usage(); - print " --d - Debug --h - Help --i - _TODO_ - Max inter-hop delay (msec). --H - Host. --N - Max number of hops. --r - Record current route (and output to STDOUT). Useful for getting the value of -R option ... --v - Greater verbosity. --R - Mandatory route string ie r1-r2-... where ri is the ip address of the ith router. --T - Maximum time (seconds) to wait for the traceroute command to complete. Defaults to $TIMEOUT seconds. - -"; - support(); -} diff --git a/contrib/check_uptime.c b/contrib/check_uptime.c deleted file mode 100644 index 7afeb232..00000000 --- a/contrib/check_uptime.c +++ /dev/null @@ -1,99 +0,0 @@ -/****************************************************************************** - * - * CHECK_UPTIME.C - * - * Program: Uptime plugin for Nagios - * License: GPL - * Copyright (c) 2000 Teresa Ramanan (teresa@redowl.org) - * - * Based on CHECK_LOAD.C - * Copyright (c) 1999 Felipe Gustavo de Almeida <galmeida@linux.ime.usp.br> - * - * Last Modified: $Date: 2002-02-28 21:42:56 -0500 (Thu, 28 Feb 2002) $ - * - * Command line: CHECK_UPTIME <host_address> - * - * Description: - * - * This plugin parses the output from "uptime", tokenizing it with ',' as the - * delimiter. Returning only the number of days and/or the hours and minutes - * a machine has been up and running. - * - *****************************************************************************/ - -#include "config.h" -#include "common.h" -#include "utils.h" -#include "popen.h" - -int main(int argc, char **argv) -{ - - int result; - char input_buffer[MAX_INPUT_BUFFER]; - int ct; - int i; - char *tok1 = NULL; - char *daytok = NULL; - char *hrmintok = NULL; - char *runstr = NULL; - char tempp; - char ch; - char delim[] = ","; - - if(argc != 2){ - printf("Incorrect number of arguments supplied\n"); - printf("\n"); - print_revision(argv[0],"$Revision: 6 $"); - printf("Copyright (c) 2000 Teresa Ramanan (tlr@redowl.org)\n"); - printf("\n"); - printf("Usage: %s <host_address>\n",argv[0]); - printf("\n"); - return STATE_UNKNOWN; - } - - child_process = spopen(PATH_TO_UPTIME); - if(child_process==NULL){ - printf("Error opening %s\n",PATH_TO_UPTIME); - return STATE_UNKNOWN; - } - child_stderr=fdopen(child_stderr_array[fileno(child_process)],"r"); - if(child_stderr==NULL){ - printf("Could not open stderr for %s\n",PATH_TO_UPTIME); - } - fgets(input_buffer,MAX_INPUT_BUFFER-1,child_process); - i = 0; - ct = 0; - - /* Let's mark the end of this string for parsing purposes */ - input_buffer[strlen(input_buffer)-1]='\0'; - - tempp = input_buffer[0]; - while(ch != '\0'){ - ch = (&tempp)[i]; - if (ch == ',') { ct++; } - i++; - } - runstr = input_buffer; - tok1 = strsep(&runstr, delim); - if (ct > 4) { - hrmintok = strsep(&runstr, delim); - hrmintok++; - daytok = strstr(tok1,"up"); - } - else { - hrmintok = strstr(tok1, "up"); - } - - result = spclose(child_process); - if(result){ - printf("Error code %d returned in %s\n",result,PATH_TO_UPTIME); - return STATE_UNKNOWN; - } - if (hrmintok == NULL) { - printf("Problem - unexpected data returned\n"); - return STATE_UNKNOWN; - } - printf("%s%s%s\n",(daytok == NULL)?"":daytok,(daytok == NULL)?"":",",hrmintok); - return STATE_OK; -} diff --git a/contrib/check_vcs.pl b/contrib/check_vcs.pl deleted file mode 100644 index 38afdae2..00000000 --- a/contrib/check_vcs.pl +++ /dev/null @@ -1,165 +0,0 @@ -#!/usr/bin/perl -# -# Veritas Cluster System monitor for Nagios. -# Written by Aaron Bostick (abostick@mydoconline.com) -# Last modified: 05-22-2002 -# -# Usage: check_vcs {-g <vcs_group> | -r <vcs_resource> } -s <vcs_system> [-n] -# -# Description: -# -# This plugin is just a perl wrapper to the vcs commands hagrp and hares. -# You specify what group/resource and system you want the status for, and -# the plugin returns a status code based on the output of either hagrp or -# hares. -# -# Normal hagrp/hares status codes are ONLINE and OFFLINE depending on where the -# cluster service currently lives. I have added an option, -n, which makes -# the expected state to be OFFLINE rather than ONLINE so you can run the -# plugin on both sides of the cluster and will receive critical alerts when -# the cluster fails over i.e. a proper failover will make the standby node -# go from OFFLINE to ONLINE for the group, so an ONLINE status should alert -# you! (You do want to know when the cluster fails over, right? :)) -# -# Output: -# -# This plugin returns OK when hagrp/hares -state <grp> -sys <system> returns -# ONLINE (or OFFLINE if -n is specified). Any other hagrp/hares string returns -# CRITICAL... Would a WARNING ever be justified??? UNKNOWN is returned if -# hagrp/hares cannot run for some reason. -# -# Examples: -# -# Make sure group oracle is ONLINE on server dbserver1: -# check_vcs -g oracle -s dbserver1 -# -# Make sure group oracle is OFFLINE on server dbserver2: -# check_vcs -g oracle -s dbserver2 -n -# -# Make sure resource oraip is ONLINE on server dbserver1: -# check_vcs -r oraip -s dbserver1 -# -# Make sure resource oraip is OFFLINE on server dbserver2: -# check_vcs -r oraip -s dbserver2 -n -# - - -BEGIN { - if ($0 =~ s/^(.*?)[\/\\]([^\/\\]+)$//) { - $prog_dir = $1; - $prog_name = $2; - } -} - -require 5.004; - -use lib $main::prog_dir; -use utils qw($TIMEOUT %ERRORS &print_revision &support); -use Getopt::Long; - -sub print_usage (); -sub print_version (); -sub print_help (); - - # Initialize strings - $vcs_bin = '/opt/VRTSvcs/bin'; - $vcs_command = ''; - $vcs_arg = ''; - $vcs_group = ''; - $vcs_resource = ''; - $vcs_system = ''; - $vcs_negate = ''; - $vcs_result = ''; - $vcs_expected_result = 'ONLINE'; - $plugin_revision = '$Revision: 33 $ '; - - # Grab options from command line - GetOptions - ("g|group:s" => \$vcs_group, - "r|resouce:s" => \$vcs_resource, - "s|system=s" => \$vcs_system, - "n|negate" => \$vcs_negate, - "v|version" => \$version, - "h|help" => \$help); - - (!$version) || print_version (); - (!$help) || print_help (); - (!$vcs_negate) || ($vcs_expected_result = 'OFFLINE'); - - # Make sure group and resource is not specified - !($vcs_group && $vcs_resource) || usage("Please specify either a group or a resource, but not both.\n"); - # Make sure group or resource is specified - ($vcs_group || $vcs_resource) || usage("HA group or resource not specified.\n"); - # Make sure system is specified - ($vcs_system) || usage("HA system not specified.\n"); - - # Specify proper command - if ($vcs_group) { - $vcs_command = 'hagrp'; - $vcs_arg = $vcs_group; - } else { - $vcs_command = 'hares'; - $vcs_arg = $vcs_resource; - } - - # Run command and save output - $vcs_result = `$vcs_bin/$vcs_command -state $vcs_arg -sys $vcs_system`; - chomp ($vcs_result); - - # If empty result, return UNKNOWN - if (!$vcs_result) { - print "UNKNOWN: Problem running $vcs_command...\n"; - exit $ERRORS{'UNKNOWN'}; - } - - # If result is expected, return OK - # If result is not expected, return CRITICAL - if ($vcs_result eq $vcs_expected_result) { - print "OK: $vcs_command $vcs_arg is $vcs_result\n"; - exit $ERRORS{'OK'}; - } else { - print "CRITICAL: $vcs_command $vcs_arg is $vcs_result\n"; - exit $ERRORS{'CRITICAL'}; - } - - -# -# Subroutines -# - -sub usage () { - print @_; - print_usage(); - exit $ERRORS{'OK'}; -} - -sub print_usage () { - print "\nUsage: $prog_name { -g <vcs_group> | -r <vcs_resource> } -s <vcs_system> [-n]\n"; - print "Usage: $prog_name [ -v | --version ]\n"; - print "Usage: $prog_name [ -h | --help ]\n"; -} - -sub print_version () { - print_revision($prog_name, $plugin_revision); - exit $ERRORS{'OK'}; -} - -sub print_help () { - print_revision($prog_name, $plugin_revision); - print "\n"; - print "Validate output from hagrp/hares command.\n"; - print "\n"; - print_usage(); - print "\n"; - print "-g, --group=<vcs_group>\n"; - print " The HA group to be validated\n"; - print "-r, --resource=<vcs_resource>\n"; - print " The HA resource to be validated\n"; - print "-s, --system=<vcs_system>\n"; - print " The HA system where the group/resource lives\n"; - print "-n, --negate=<negate>\n"; - print " Set expected result to OFFLINE instead of ONLINE\n"; - print "\n"; - support(); - exit $ERRORS{'OK'}; -} diff --git a/contrib/check_wave.pl b/contrib/check_wave.pl deleted file mode 100644 index 56b59fe0..00000000 --- a/contrib/check_wave.pl +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/perl - -# CHECK_WAVE.PL -# Plugin to test signal strength on Speedlan wireless equipment -# Contributed by Jeffry Blank - -$Host=$ARGV[0]; -$sig_crit=$ARGV[1]; -$sig_warn=$ARGV[2]; - - - - -$low1 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; -@test=split(/ /,$low1); -$low1=@test[2]; - - -$med1 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; -@test=split(/ /,$med1); -$med1=@test[2]; - - -$high1 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; -@test=split(/ /,$high1); -$high1=@test[2]; - -sleep(2); - - - -$snr = `snmpget $Host public .1.3.6.1.4.1.762.2.5.2.1.17.1`; -@test=split(/ /,$snr); -$snr=@test[2]; -$snr=int($snr*25); -$low2 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.8.1`; -@test=split(/ /,$low2); -$low2=@test[2]; - - -$med2 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.9.1`; -@test=split(/ /,$med2); -$med2=@test[2]; - - -$high2 = `snmpget $Host public .1.3.6.1.4.1.74.2.21.1.2.1.10.1`; -@test=split(/ /,$high2); -$high2=@test[2]; - - - -$low=$low2-$low1; -$med=$med2-$med1; -$high=$high2-$high1; - -$tot=$low+$med+$high; - - -if ($tot==0) - { - $ss=0; - } -else - { - $lowavg=$low/$tot; - $medavg=$med/$tot; - $highavg=$high/$tot; - $ss=($medavg*50)+($highavg*100); - } -printf("Signal Strength at: %3.0f%, SNR at $snr%",$ss); -#print "Signal Strength at: $ss%, SNR at $snr%"; -if ($ss<$sig_crit) - {exit(2)} -if ($ss<$sig_warn) - {exit(1)} - -exit(0); diff --git a/contrib/check_wins.pl b/contrib/check_wins.pl deleted file mode 100755 index f11f8645..00000000 --- a/contrib/check_wins.pl +++ /dev/null @@ -1,247 +0,0 @@ -#!/usr/bin/perl -w - -# $Id: check_wins.pl 940 2004-11-25 04:46:16Z stanleyhopcroft $ - -# Revision 1.3 2004/11/25 04:46:16 stanleyhopcroft -# Non functional tidy ups to check_wins -# -# Revision 1.2 2003/08/20 08:31:49 tonvoon -# Changed netsaint to nagios in use lib -# -# Revision 1.1 2003/02/09 14:16:28 sghosh -# more contribs -# - -use strict ; - -use Getopt::Long ; -use vars qw($opt_H $opt_D $opt_W $opt_T $debug @my_dcs); - -use lib '/usr/local/nagios/libexec/' ; -use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); - -my $PROGNAME = 'check_wins' ; - -use constant SAMBA_DEBUG_LVL => 2 ; -use constant MY_DCS => ('dc1','dc2') ; - -my $NMBLOOKUP_PATH = '/usr/bin/nmblookup' ; -my $NMBLOOKUP = sub { return `$NMBLOOKUP_PATH $_[2] -R -U $_[0] $_[1]` } ; -my $NMBLOOKUP_CMD = $NMBLOOKUP_PATH . ' -R -U' ; - -sub print_help (); -sub print_usage (); -sub help (); -sub version (); - -delete @ENV{'PATH', 'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; - -$SIG{"ALRM"} = sub { die "Alarm clock restart" } ; - -Getopt::Long::Configure('bundling', 'no_ignore_case'); -GetOptions - ("V|version" => \&version, - "h|help" => \&help, - "d|debug" => \$debug, - "C|controllers:s" => \@my_dcs, - "T|timeout:i" => \$opt_T, - "W|wins=s" => \$opt_W, - "D|domain=s" => \$opt_D); - - -($opt_D) || usage("MS Domain name not specified\n"); -my $domain = $1 if $opt_D =~ m#(\w+)# ; # NetBIOS names allow __any__ characters (more than \w) -($domain) || usage("Invalid MS D name: $opt_D\n"); - -($opt_W) || usage("WINS hostname or address not specified\n"); -my $wins = $1 if $opt_W =~ m#((?:^\w+$)|(?:\d+(?:\.\d+){3,3}$))# ; -($wins) || usage("Invalid WINS hostname or address: $opt_W\n"); - -usage("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") - unless (@my_dcs or MY_DCS) ; - -@my_dcs = MY_DCS unless defined $my_dcs[0] ; -$TIMEOUT = $opt_T if defined $opt_T ; - -my ($netbios_name, @dcs_of_domain, @dc_addresses) ; -my (@addr_dcs_of_domain, @found_dcs, %address2dc) ; -my (@dc_query) ; - -# tsitc> /usr/local/samba/bin/nmblookup -R -U wins ipa01 -# Sending queries to 192.168.1.29 -# 192.168.1.16 ipa01<00> - -eval { - alarm($TIMEOUT) ; - @dc_query = $debug ? map { $NMBLOOKUP->($wins, "$_#20", '-d ' . SAMBA_DEBUG_LVL) } @my_dcs : - map { ( $NMBLOOKUP->($wins, "$_#20", '') )[1] } @my_dcs ; - alarm(0) ; -} ; - -if ($@ and $@ =~ /Alarm clock restart/) { - print qq(Failed. Timeout while waiting for response from (one of) "$NMBLOOKUP_CMD $wins @my_dcs"\n) ; - exit $ERRORS{"CRITICAL"} ; -} - -if ($@ and $@ !~ /Alarm clock restart/) { - print qq(Failed. "$@" in response to "NMBLOOKUP_CMD $wins @my_dcs"\n) ; - exit $ERRORS{"UNKNOWN"} ; -} - -chomp @dc_query ; -if ( scalar grep(/name_query failed/, @dc_query) ) { - 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) ; - exit $ERRORS{"CRITICAL"} ; -} - -=begin comment - -the results of looking up the DCs (by their name) in the WINS - -192.168.1.16 ipa01<20> -192.168.1.1 ipa02<20> -192.168.1.104 ipa03<20> - -=end comment - -=cut - -@dc_addresses = () ; -foreach (@dc_query) { - next unless /^(\S+)\s+(\S+?)<\S+?>$/ ; - $address2dc{$1} = $2 ; - push @dc_addresses, $1 ; -} - -$netbios_name = "$domain#1C" ; - -eval { - alarm($TIMEOUT) ; - @dcs_of_domain = $NMBLOOKUP->($wins, $netbios_name, defined $debug ? '-d ' . SAMBA_DEBUG_LVL : '') ; - alarm(0) ; - -} ; - -if ($@ and $@ =~ /Alarm clock restart/) { - print qq(Failed. Timeout while waiting for response from "$NMBLOOKUP_CMD $wins $netbios_name"\n) ; - exit $ERRORS{"CRITICAL"} ; -} - -if ($@ and $@ !~ /Alarm clock restart/) { - print qq(Failed. "$@" in response to "$NMBLOOKUP_CMD $wins $netbios_name"\n) ; - exit $ERRORS{"UNKNOWN"} ; -} - -shift @dcs_of_domain ; -chomp @dcs_of_domain ; -@addr_dcs_of_domain = map /^(\S+)/, @dcs_of_domain ; - -=begin comment - -tsitc> /usr/local/samba/bin/nmblookup -R -U wins ipaustralia#1c -Sending queries to 192.168.1.29 -192.168.1.114 ipaustralia<1c> -192.168.1.221 ipaustralia<1c> -192.168.1.61 ipaustralia<1c> -192.168.1.129 ipaustralia<1c> -192.168.1.128 ipaustralia<1c> -192.168.1.214 ipaustralia<1c> -192.168.1.67 ipaustralia<1c> -tsitc> - -=end comment - -=cut - - -my %x ; -@found_dcs = grep { ! $x{$_}++ } @address2dc{ grep exists $address2dc{$_}, @addr_dcs_of_domain} ; -# @found_dcs = grep { defined $_} @address2dc{ grep exists $address2dc{$_}, @addr_dcs_of_domain} ; - # Gotcha. - # 'exists' is necessary to prevent autovivificatiton - # of keys in %address2dc - -if ( &set_eq( \@found_dcs, [ values %address2dc ] ) ) { - 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) : - qq(Ok. Found controllers named "@my_dcs" in response to "$domain#1C" name query from WINS named "$wins".\n) ; - exit $ERRORS{"OK"} ; -} elsif ( scalar @found_dcs == 0 ) { - print qq(Failed. Found __no__ controllers named "@my_dcs" in response to "$domain#1C" query from WINS named "$wins". Got "@dcs_of_domain"\n) ; - exit $ERRORS{"CRITICAL"} ; -} elsif ( scalar @found_dcs < scalar keys %address2dc ) { - 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) ; - exit $ERRORS{"WARNING"} ; -} - -sub set_eq { - - return 0 unless scalar @{$_[0]} == scalar @{$_[1]} ; - foreach my $a ( @{$_[0]} ) { - return 0 unless scalar grep { $a eq $_ } @{$_[1]} ; - } - return 1 ; - -} - - -sub print_usage () { - print "Usage: $PROGNAME -W <wins> -D <domain>\n"; -} - -sub print_help () { - print_revision($PROGNAME,'$Revision: 940 $ '); - print "Copyright (c) 2001 Karl DeBisschop/S Hopcroft - -Perl Check WINS plugin for NetSaint. - -Returns 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' - -Why would you want to do this ? - -MS File server clients insist on connecting to file servers using NetBIOS names. -If they __don't__ resolve NetBIOS names with a WINS (NBNS) then they'll either fail to logon and connect to shares or they will -broadcast requsts for names. -Both problems are eliminated by a healthy WINS. -Also, you may have a MS domain spanning a number of WAN connected sites, with domain controllers far away from powerful local -domain controllers. -In this case, you want your local clients to have their logon requests validated by the local controllers. - -The plugin works by - asking the WINS to resolve the addresses of the domain controllers (supplied by -C or from the constant MY_DCS) - asking the WINS to return the list of addresses of the domain controllers able to validate requests for the domain - whose name is given by -D - returning Ok if all controller addresses are in that list (of addresses of domain controllers) or - returning WARNING if not all the controller addresses are in the list or - returning CRITICAL if there is no reply from the WINS or the list contains none of the contoller addresses - -"; - print_usage(); - print ' --W, --wins=STRING - Hostname or address of the WINS (Either Samba/nmbd or MS product) --D, --domain=STRING - MS Domain name to find the Domain controllers of. --C, --controllers:STRING - Optional __name(s)__ of domain controller that __must__ be found in the response to a domain controller name query. - If not defined, then use the constant value MY_DCS. You must use either -C or make sure that MY_DCS contains the names - of __your__ domain controllers. --T, --timeout:INTEGER --d, --debug - Debugging output. --h, --help - This stuff. - -'; - support(); -} - -sub version () { - print_revision($PROGNAME,'$Revision: 940 $ '); - exit $ERRORS{'OK'}; -} - -sub help () { - print_help(); - exit $ERRORS{'OK'}; -} - diff --git a/contrib/checkciscotemp.pl b/contrib/checkciscotemp.pl deleted file mode 100644 index 8fdc4294..00000000 --- a/contrib/checkciscotemp.pl +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/perl -wT -# check_ciscotemp.pl -# -# Copyright (C) 2000 Leland E. Vandervort <leland@mmania.com> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty -# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# you should have received a copy of the GNU General Public License -# along with this program (or with Nagios); if not, write to the -# Free Software Foundation, Inc., 59 Temple Place - Suite 330, -# Boston, MA 02111-1307, USA -#################################### -# Nagios pluging to check inlet and outlet temperatures on -# Cisco router platforms which support environmental monitoring -# (7200, 7500, GSR12000...) -#################################### -# default temperature thresholds are 30C for inlet, 40C outlet. -# if input or output is less than thresholds, returns OK -# if equal to (the temps don't change that rapidly) returns WARNING -# if greater than threshold, returns CRITICAL -# if undetermined, or cannot access environmental, returns UNKNOWN -# (in accordance with the plugin coding guidelines) -#################################### - -use Net::SNMP; -use Getopt::Long; -&Getopt::Long::config('auto_abbrev'); - -my $status; -my $response = ""; -my $timeout = 10; -my $community = "public"; -my $port = 161; -my $INTAKE_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.1"; -my $OUTLET_TEMP = "1.3.6.1.4.1.9.9.13.1.3.1.3.3"; -my $in_temp; -my $out_temp; -my $inlet_thresh = 30; -my $outlet_thresh = 40; - -my %STATUSCODE = ( 'UNKNOWN' => '-1', - 'OK' => '0', - 'WARNING' => '1', - 'CRITICAL' => '2'); - -my $state = "UNKNOWN"; - - -$SIG{'ALRM'} = sub { - print "ERROR: No snmp response from $hostname (sigALRM)\n"; - exit($STATUSCODE{"UNKNOWN"}); -}; - -Getopt::Long::Configure('bundling'); -$status = GetOptions - ("community=s", \$community, - "C=s", \$community, - "H=s", \$hostname, - "hostname=s", \$hostname, - "port=i", \$port, - "timeout=i", \$timeout, - "c=s", \$critical_vals, - "w=s", \$warning_vals, - "ithresh=i", \$inlet_thresh, - "othresh=i", \$outlet_thresh); - -if($status == 0) { - &show_help; -} - -unless (defined($hostname)) { - $hostname = shift || &show_help; -} - -if (defined($critical_vals)) { - if ($critical_vals =~ m/^([0-9]+)[,:]([0-9]+)$/) { - ($inlet_thresh,$outlet_thresh) = ($1, $2); - } else { - die "Cannot Parse Critical Thresholds\n"; - } -} - -if (defined($warning_vals)) { - if ($warning_vals =~ m/^([0-9]+)[:,]([0-9]+)$/) { - ($inlet_warn,$outlet_warn) = ($1, $2); - } else { - die "Cannot Parse Warning Thresholds\n"; - } -}else{ - $inlet_warn=$inlet_thresh; - $outlet_warn=$outlet_thresh; -} - -alarm($timeout); - -$in_temp = &SNMPGET($INTAKE_TEMP); -$out_temp = &SNMPGET($OUTLET_TEMP); - -if (($in_temp < $inlet_thresh) && ($out_temp < $outlet_thresh)) { - $state = "OK"; -} -elsif (($in_temp == $inlet_thresh) || ($out_temp == $outlet_thresh)) { - if(($in_temp > $inlet_thresh) || ($out_temp > $outlet_thresh)) { - $state = "CRITICAL"; - } - else { - $state = "WARNING"; - } -} -elsif (($in_temp > $inlet_thresh) || ($out_temp > $outlet_thresh)) { - $state = "CRITICAL"; -} -else { - $state = "WARNING"; -} - -print "$state Inlet Temp: $in_temp Outlet Temp: $out_temp\n"; -exit($STATUSCODE{$state}); - -sub show_help { - printf("\nPerl envmon temperature plugin for Nagios\n"); - printf("Usage:\n"); - printf(" - check_ciscotemp [options] <hostname> - Options: - -C snmp-community - -p snmp-port - -i input temperature threshold - -o output temperature threshold - -"); - printf("Copyright (C)2000 Leland E. Vandervort\n"); - printf("check_ciscotemp comes with absolutely NO WARRANTY either implied or explicit\n"); - printf("This program is licensed under the terms of the\n"); - printf("GNU General Public License\n(check source code for details)\n\n\n"); - exit($STATUSCODE{"UNKNOWN"}); -} - -sub SNMPGET { - $OID = shift; - ($session,$error) = Net::SNMP->session( - Hostname => $hostname, - Community => $community, - Port => $port - ); - if(!defined($session)) { - printf("$state %s\n", $error); - exit($STATUSCODE{$state}); - } - if(!defined($response = $session->get_request($OID))) { - printf("$state %s\n", $session->error()); - $session->close(); - exit($STATUSCODE{$state}); - } - $session->close(); - return($response->{$OID}); -} - diff --git a/contrib/mrtgext.pl b/contrib/mrtgext.pl deleted file mode 100644 index b9e9f6b9..00000000 --- a/contrib/mrtgext.pl +++ /dev/null @@ -1,291 +0,0 @@ -#!/usr/bin/perl -w -# -# mrtgext.pl v0.3 -# (c)2000 Cliff Woolley, Washington and Lee University -# jwoolley@wlu.edu -# -# A UNIX counterpart to Jim Drews' MRTG Extension for netware servers -# Mimics output of mrtgext.nlm using output of various standard UNIX -# programs (df, uptime, and uname) -# -# Dependencies: I make some assumptions about the output format of -# your df and uptime commands. If you have nonstandard outputs for -# any of these, either pick a different command that gives more -# standard output or modify the script below. Example: use /usr/bin/bdf -# on HP-UX instead of /usr/bin/df, because bdf follows the output format -# I expect while df does not. This was written on Linux and tested on -# HP-UX 10.20 (with changes to the subroutines at the bottom of the -# program to reflect HP's command parameters); similar tweaking could -# well be required to port this to other platforms. If you get it -# working on your platform, please send me any changes you had to -# make so I can try to incorporate them. -# -# -# Following is what I expect the programs' outputs to look like: -# -# ======= df ======== -# Filesystem 1k-blocks Used Available Use% Mounted on -# /dev/sda1 1014696 352708 609612 37% / -# /dev/sda2 2262544 586712 1559048 27% /apps -# /dev/sda3 4062912 566544 3286604 15% /share -# /dev/sr0 651758 651758 0 100% /cdrom -# =================== -# -# ===== uptime ====== -# 3:17pm up 15 days, 4:40, 5 users, load average: 0.12, 0.26, 0.33 -# =================== -# - -############################################################### -# Configuration section -############################################################### - -$dfcmd = "/bin/df 2>/dev/null"; -$uptimecmd = "/usr/bin/uptime"; -%customcmds = ( "PROCS" => "numprocesses", - "ZOMBIES" => "numzombies", - "MEMFREE" => "memfree", - "SWAPUSED" => "swapused", - "TCPCONNS" => "tcpconns", - "CLIENTS" => "ipclients" ); - # These are functions that you can - # define and customize for your system. - # You probably need to change the provided - # subroutines to work on your system (if - # not Linux). - -$rootfsnickname = "root"; # this is necessary as a kludge to - # better match the netware behavior. - # if you already have a _filesystem_ - # mounted as /root, then you'll need - # to change this to something else -$DEBUG = 0; -$recvtimeout = 30; - - -############################################################### -# Program section -############################################################### - -require 5.004; - -use Sys::Hostname; - - -$DEBUG = $ARGV[0] unless ($DEBUG); -$SIG{'ALRM'} = sub { exit 1; }; - -# some things never change -$hostname = hostname; - - -if ( $DEBUG ) { - $| = 1; - print scalar localtime,": mrtgext.pl started\n"; -} - -# timeout period -alarm($recvtimeout); -my $items = <STDIN>; -alarm(0); - -$items =~ s/[\r\n]//g; -( $DEBUG ) && print scalar localtime,": request: \"$items\"\n"; -my @items = split (/\s+/,"$items"); -( $DEBUG ) && print scalar localtime,": ",scalar @items," item(s) to process\n"; - -my $uptime = `$uptimecmd`; -my @df = grep {/^\//} `$dfcmd`; - -my $processed = 1; - -foreach $_ (@items) { - ( $DEBUG ) && print scalar localtime,": processing item #$processed: \"$_\"\n"; - $_ = uc; #convert $_ to upper case - if ( /^UTIL1$/ ) { - $uptime =~ /load average: ([^,]+),/; - print $1 * 100,"\n"; - } - elsif ( /^UTIL5$/ ) { - $uptime =~ /load average: [^,]+, ([^,]+)/; - print $1 * 100,"\n"; - } - elsif ( /^UTIL15$/ ) { - $uptime =~ /load average: [^,]+, [^,]+, ([^,]+)/; - print $1 * 100,"\n"; - } - elsif ( /^CONNECT$/ ) { - $uptime =~ /(\d+) users?,/; - print "$1\n"; - } - elsif ( /^NAME$/ ) { - print "$hostname\n"; - } - elsif ( /^UPTIME$/ ) { - $uptime =~ /up (.*),\s+\d+\s+users?,/; - print "$1\n"; - } - elsif ( /^VOLUMES$/ ) { - foreach $dfline (@df) { - my $volname = (split(/\s+/, "$dfline"))[5]; - $volname =~ s/^\/$/$rootfsnickname/; - $volname =~ s/^\///; - $volname =~ s/\//_/g; - print "$volname\n"; - } - } - elsif ( /^VF(\w*)$/ ) { - my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1"; - foreach $dfline (@df) { - my @dfline = split(/\s+/, "$dfline"); - if ($dfline[5] =~ /^\/?$volname$/i ) { - print (($dfline[1]-$dfline[2]) * 1024,"\n"); - goto done; - } - } - ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n"; - print "-1\n"; - } - elsif ( /^VU(\w*)$/ ) { - my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1"; - foreach $dfline (@df) { - my @dfline = split(/\s+/, "$dfline"); - if ($dfline[5] =~ /^\/?$volname$/i ) { - print ($dfline[2] * 1024,"\n"); - goto done; - } - } - ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n"; - print "-1\n"; - } - elsif ( /^VS(\w*)$/ ) { - my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1"; - foreach $dfline (@df) { - my @dfline = split(/\s+/, "$dfline"); - if ($dfline[5] =~ /^\/?$volname$/i ) { - print ($dfline[1] * 1024,"\n"); - goto done; - } - } - ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n"; - print "-1\n"; - } - elsif ( /^VKF(\w*)$/ ) { - my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1"; - foreach $dfline (@df) { - my @dfline = split(/\s+/, "$dfline"); - if ($dfline[5] =~ /^\/?$volname$/i ) { - print (($dfline[1]-$dfline[2]),"\n"); - goto done; - } - } - ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n"; - print "-1\n"; - } - elsif ( /^VKU(\w*)$/ ) { - my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1"; - foreach $dfline (@df) { - my @dfline = split(/\s+/, "$dfline"); - if ($dfline[5] =~ /^\/?$volname$/i ) { - print ($dfline[2],"\n"); - goto done; - } - } - ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n"; - print "-1\n"; - } - elsif ( /^VKS(\w*)$/ ) { - my $volname = ("$1" eq uc("$rootfsnickname")) ? "/" : "$1"; - foreach $dfline (@df) { - my @dfline = split(/\s+/, "$dfline"); - if ($dfline[5] =~ /^\/?$volname$/i ) { - print ($dfline[1],"\n"); - goto done; - } - } - ( $DEBUG ) && print scalar localtime,": ERROR: volume not found.\n"; - print "-1\n"; - } - elsif ( /^ZERO$/ ) { - print "0\n"; - } - elsif (exists( $customcmds{"$_"} )) { - my $cmdsub = "$customcmds{$_}"; - print &$cmdsub."\n"; - } - else { - print "-1\n"; - } - done: $processed++; -} -( $DEBUG ) && print scalar localtime,": done.\n"; - - -############################################################### -# CUSTOMIZED PROCEDURES -############################################################### - -sub numprocesses { - - my $num = `/bin/ps -eaf | /usr/bin/tail -n +2 | /usr/bin/wc -l`; - chomp ($num); - $num =~ s/\s+//g; - - $num; -} - -sub numzombies { - - my $num = `/bin/ps -afx | /usr/bin/awk '{print \$3}' | /usr/bin/grep Z | /usr/bin/tail -n +2 | /usr/bin/wc -l`; - chomp ($num); - $num =~ s/\s+//g; - - $num; -} - -sub tcpconns { - - my $num = `/bin/netstat -nt | /usr/bin/tail -n +3 | /usr/bin/wc -l`; - chomp ($num); - $num =~ s/\s+//g; - - $num; -} - -sub ipclients { - - 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`; - chomp ($num); - $num =~ s/\s+//g; - - $num; -} - -sub memfree { - - open( FP, "/proc/meminfo" ); - my @meminfo = <FP>; - close(FP); - - # total: used: free: shared: buffers: cached: - # Mem: 994615296 592801792 401813504 91193344 423313408 93118464 - # Swap: 204791808 0 204791808 - my ($total,$free,$buffers,$cache) = (split(/ +/,$meminfo[1]))[1,3,5,6]; - - int(($free+$buffers+$cache)/$total*100); -} - -sub swapused { - - open( FP, "/proc/meminfo" ); - my @meminfo = <FP>; - close(FP); - - # total: used: free: shared: buffers: cached: - # Mem: 994615296 592424960 402190336 89821184 423313408 93077504 - # Swap: 204791808 0 204791808 - - my ($total,$used) = (split(/ +/,$meminfo[2]))[1,2]; - - int($used/$total*100); -} diff --git a/contrib/nagios_sendim.pl b/contrib/nagios_sendim.pl deleted file mode 100644 index 02870a6d..00000000 --- a/contrib/nagios_sendim.pl +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/perl -w -# -# SENDIM 1.0 by Sergio Freire (sergio-s-freire@ptinovacao.pt) -# Nagios plugin to send notifications using instant messages through a jabber server -# -# Note: a) you can send messages to several different IM systems like ICQ,AIM,MSN,etc... -# b) to test this plugin you can execute it with the arguments needed and write the message followed by a CTRL+D -# -# Please check http://www.jabber.org and http://www.jabberstudio.org for more information on Jabber Instant Messaging - - -use Net::Jabber qw(Client); -use Getopt::Std; - -my $tmp; -my $mensagem=""; -getopts("u:p:t:"); -if ( (!defined($opt_u)) || (!defined($opt_p)) || (!defined($opt_t))) - { - print "USE: sendim -u user_JID -p password -t destination_JID\n"; - print 'EXAMPLE: sendim -u nagios@jabber.org -p nagios -t bitcoder@nagios.org'."\n"; - print " (send an instant message as user nagios\@jabber.org to bitcoder\@jabber.org)\n"; - exit; - } - -my @buf=split('@',$opt_u); -my $login=$buf[0]; -@buf=split('/',$buf[1]); -my $server=$buf[0]; -my $resource=$buf[1] || "nagios"; -my $password=$opt_p; -my $jid_dest=$opt_t; -my $debug=0; # Set debug=1 to enable output of debug information - -while ($tmp=<STDIN>) -{ - $mensagem.=$tmp; -} - -print "LOGIN: $login\nSERVER: $server\nRESOURCE: $resource\n" if $debug; -print "TO: $jid_dest\n" if $debug; - -$Con1 = new Net::Jabber::Client(); -$Con1->Connect(hostname=>$server); - - if ($Con1->Connected()) { - print "CON1: We are connected to the server...\n" if $debug; - } - - @result1 = $Con1->AuthSend(username=>$login, - password=>$password, - resource=>$resource); - - -$Con1->PresenceSend(); -$Con1->Process(1); - -@result1=$Con1->MessageSend( to=>$jid_dest, - subject=>"nagios", - body=>$mensagem, - type=>"chat", - priority=>1); - -$Con1->Process(1); -$Con1->Disconnect(); -exit; diff --git a/contrib/packet_utils.pm b/contrib/packet_utils.pm deleted file mode 100755 index 783b3333..00000000 --- a/contrib/packet_utils.pm +++ /dev/null @@ -1,119 +0,0 @@ -package packet_utils; - -# $Id: packet_utils.pm 1100 2005-01-25 09:12:47Z stanleyhopcroft $ - -# Revision 1.1 2005/01/25 09:12:47 stanleyhopcroft -# packet creation and dumping hacks used by check_ica* and check_lotus -# -# Revision 1.1 2005-01-25 15:28:58+11 anwsmh -# Initial revision -# - -require Exporter; -@ISA = qw(Exporter); -@EXPORT_OK = qw(tethereal pdump); - -sub tethereal { - my ($tethereal_dump, $start_byte) = @_ ; - - # Return a string or array (depending on context) containing the characters from a tethereal trace. - # Skip all stuff until the first byte given by $start_byte in the first row .. - - &outahere("Invalid tethereal dump:", substr($tethereal_dump, 0, 71), 'fails to match m#\d\d\d\d \S\S(?: \S\S){1,15}#') - unless $tethereal_dump =~ m#\d\d\d\d \S\S(?: \S\S){1,15}# ; - - my @tethereal_dump = split(/\n/, $tethereal_dump) ; - my $first_line = shift @tethereal_dump ; - $first_line = unpack('x6 a48', $first_line) ; - # Take one extra space (after hex bytes) to use a template of 'a2 x' x 16 - # instead of 'a2 x' x 15 . 'a2' - my $last_line = pop @tethereal_dump ; - $last_line = unpack('x6 a48', $last_line) ; - - my $idx = index($first_line, $start_byte) ; - - &outahere(qq(Invalid tethereal dump: "$start_byte" not found in first line - "$first_line")) - if $idx == -1 ; - - $first_line = substr($first_line, $idx) ; - - my ($dump, @dump) = ('', ()) ; - - my $bytes = 0 ; - $bytes++ - while $first_line =~ m#\b\S\S#g ; - push @dump, unpack('a2x' x $bytes, $first_line) ; - - push @dump, unpack('x6 ' . 'a2x' x 16, $_) - foreach @tethereal_dump ; - - $bytes = 0 ; - $bytes++ - while $last_line =~ m#\b\S\S#g ; - - # Be more cautious with the last line; the ASCII decode may - # have been omitted. - - push @dump, unpack(('a2x' x ($bytes - 1)) . 'a2', $last_line) ; - - return wantarray ? map pack('H2', $_), @dump : pack('H2' x scalar @dump, @dump) ; - # return wantarray ? map hex($_), @dump : pack('H2' x scalar @dump, @dump) ; - -} - -sub pdump { - my ($x) = shift @_ ; - my (@bytes_in_row, $row, $dump) ; - - my $number_in_row = 16 ; - my $number_of_bytes = length $x ; - my $full_rows = int( $number_of_bytes / $number_in_row ) ; - my $bytes_in_last_row = $number_of_bytes % $number_in_row ; - my $template = "a$number_in_row " x $full_rows ; - my $nr = 0 ; - # Output format styled on tethereal. - foreach $row ( unpack($template, $x) ) { - @bytes_in_row = unpack('C*', $row) ; - $row =~ tr /\x00-\x1f\x80-\xff/./ ; - $dump .= join(' ', sprintf('%4.4x', $nr * 0x10), join(' ', map { sprintf "%2.2x", $_} @bytes_in_row), $row) ; - $dump .= "\n" ; - $nr++ ; - } - - if ( $bytes_in_last_row ) { - my $number_of_spaces = ($number_in_row - $bytes_in_last_row)*3 - 2 ; - - # 3 spaces (2 digts + 1 space) for each digit printed - # minus two spaces for those added by the join(' ',) below. - - $row = substr($x, -$bytes_in_last_row) ; - @bytes_in_row = unpack('C*', $row) ; - $row =~ tr /\x00-\x1f\x80-\xff/./ ; - # my $bytes = join(' ', map { sprintf "%2.2x", $_} @bytes_in_row) ; - # See comment below. - my $spaces = ' ' x $number_of_spaces ; - $dump .= join(' ', sprintf("%4.4x", $nr * 0x10 ), join(' ', map { sprintf "%2.2x", $_} @bytes_in_row), $spaces, $row) ; - $dump .= "\n" ; - } - - print STDERR $dump, "\n" ; - -=begin comment - -tsitc> 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 -.2x %2.2x %2.2x\n", 61, 62, 63; print $x>} )' | perl -ne 'print if /intf/' - -Benchmark: timing 100000 iterations of printf, sprintf... - printf: 1 wallclock secs ( 0.55 usr + 0.00 sys = 0.55 CPU) - sprintf: 0 wallclock secs ( 0.11 usr + 0.00 sys = 0.11 CPU) - -so having sprintf in a loop seems more rational than a printf for the line ... - -=comment - -=cut - -} - - - diff --git a/contrib/rblcheck-dns b/contrib/rblcheck-dns deleted file mode 100755 index 5e96195f..00000000 --- a/contrib/rblcheck-dns +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/perl -# Multi-RBL Query tool, developer Vikram <vr@udel.edu> -use strict; -use Socket; -my $suspect = $ARGV[1]; - -die "Syntax: $0 -H <ip address>\n" unless $suspect; - -my @rblservers=qw[ - 3y.spam.mrs.kithrup.com - block.blars.org - bl.redhatgate.com - blackholes.five-ten-sg.com - blackholes.intersil.net - blackholes.mail-abuse.org - blackholes.wirehub.net - blacklist.spambag.org - dev.null.dk - dews.qmail.org - dialup.blacklist.jippg.org - dialups.mail-abuse.org - dnsbl.njabl.org - dul.maps.vix.com - dul.orca.bc.ca - dynablock.wirehub.net - formmail.relays.monkeys.com - ipwhois.rfc-ignorant.org - list.dsbl.org - multihop.dsbl.org - okrelays.nthelp.com - pm0-no-more.compu.net - proxies.relays.monkeys.com - rbl-plus.mail-abuse.org - rbl.maps.vix.com - rbl.spam.org.tr - relays.mail-abuse.org - relays.nthelp.com - relays.ordb.org - relays.radparker.com - relays.visi.com - sbl.spamhaus.org - spamguard.leadmon.net - spammers.v6net.org - spamsources.fabel.dk - spews.org - unconfirmed.dsbl.org - xbl.selwerd.cx -]; - - -my $spam = 0; -foreach ( @rblservers ) { - my @s = split('\.',$suspect); - my $req = "$s[3].$s[2].$s[1].$s[0].".$_; - - my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname($req); - next unless (@addrs); - - my $result = inet_ntoa($addrs[0]); - #next unless (substr($result, 7) eq '127.0.0'); - - print "$suspect is listed in the following RBLS: " if ( $spam == 0 ); - print $_, " "; - $spam = 1; -} - -print "$suspect is not listed in any RBLS" if ( $spam == 0 ); -print "\n"; -exit( $spam ); diff --git a/contrib/rblcheck-web b/contrib/rblcheck-web deleted file mode 100755 index eb4fcdec..00000000 --- a/contrib/rblcheck-web +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/perl -# Multi-RBL Query tool, developer Vikram <vr@udel.edu> -use IO::Socket::INET; - -die "Syntax: $0 -H <ip address>\n" unless $ARGV[1]; - -$soc = new IO::Socket::INET->new(PeerPort=>80, -Proto=>'tcp', -PeerAddr=>"rbls.org") or die("Cannot connect to CERT"); - -$ip = $ARGV[1]; -$uri = '/?q='.$ip; - -$soc->send("GET $uri HTTP/1.1\nHost: rbls.org\n\n"); -@buff = <$soc>; -delete @buff[0..7]; -$len = @buff; - -$alert = 0; - - -for( $i=0;$i<$len;$i++ ) { - next unless( defined $buff[$i] ); - chomp($buff[$i]); - #print "$buff[$i]\n"; - - if ( $buff[$i] eq "<tr bgcolor=#ffc0c0>" ) { - $rbl = substr($buff[$i+1], 5, index($buff[$i], "</tr>") - 5); - next if ( index($rbl, '.') == -1 ); - print "$ip is listed in the following RBLS: " if ( $alert == 0 ); - print "$rbl "; - $alert = 1; - } -} -print "$ip is not listed in any RBLS" if ( $alert == 0 ); -print "\n"; -exit($alert); diff --git a/contrib/restrict.pl b/contrib/restrict.pl deleted file mode 100755 index 75ea5698..00000000 --- a/contrib/restrict.pl +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/perl - -eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' - if 0; - -# Set this to your local Nagios plugin path -my $pluginpath = "/usr/libexec/nagios/plugins/"; - -# Put all the legal commands (i.e. the commands that are -# not Nagios checks but are allowed to be executed anyway) -# in the following associative array. -my %legal_cmds = ("nc" => "/usr/sbin/nc"); - -# This will not work on OpenSSH -# It does work on ssh-1.2.27-1i -@arg = split ' ',$ENV{'SSH_ORIGINAL_COMMAND'}; - -$arg[0] =~ s/.*\///; # strip leading path -$arg[0] =~ tr/-_.a-zA-Z0-9/X/c; # change atypical chars to X - -if (!defined ($cmd = $legal_cmds{$arg[0]})) -{ - $cmd = $pluginpath . $arg[0]; -} - -exec { $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 b46b482c..00000000 --- a/contrib/sched_downtime.pl +++ /dev/null @@ -1,47 +0,0 @@ -#! /usr/bin/perl -w -# -# Marko Riedel, EDV Neue Arbeit gGmbH, mriedel@neuearbeit.de -# -# -# -# -use POSIX qw(strtol); - -my $command_file = '/usr/local/nagios/var/rw/nagios.cmd'; - -my $hour = (60*60); -my $next_day = (24*60*60); - -my $downtimes = - [ - { - host => 'somehost', - service => 'SERVICE', - times => [ ["00:00", 9], ["18:00", 6] ] - } - ]; - -foreach my $entry (@$downtimes) { - my ($secstart, $secend, $cmd, $current); - - $current = `/bin/date +"%s"`; - chomp $current; - - foreach my $tperiod (@{ $entry->{times} }){ - $secstart = strtol(`/bin/date -d "$tperiod->[0]" +"%s"`); - $secend = $secstart+$tperiod->[1]*$hour; - - $secstart += $next_day; - $secend += $next_day; - - $cmd = "[$current] SCHEDULE_SVC_DOWNTIME;"; - $cmd .= "$entry->{host};$entry->{service};"; - $cmd .= "$secstart;$secend;"; - $cmd .= "1;0;$0;automatically scheduled;\n"; - - print STDERR $cmd; - - system "echo \"$cmd\" >> $command_file"; - } -} - diff --git a/contrib/tarballs/bowen-langley_plugins.tar.gz b/contrib/tarballs/bowen-langley_plugins.tar.gz Binary files differdeleted file mode 100644 index a9ad1e8c..00000000 --- a/contrib/tarballs/bowen-langley_plugins.tar.gz +++ /dev/null diff --git a/contrib/tarballs/check_bgp-1.0.tar.gz b/contrib/tarballs/check_bgp-1.0.tar.gz Binary files differdeleted file mode 100644 index 0496ddb6..00000000 --- a/contrib/tarballs/check_bgp-1.0.tar.gz +++ /dev/null diff --git a/contrib/tarballs/check_radius.tar.gz b/contrib/tarballs/check_radius.tar.gz Binary files differdeleted file mode 100644 index cca6338a..00000000 --- a/contrib/tarballs/check_radius.tar.gz +++ /dev/null diff --git a/contrib/tarballs/check_traffic-0.91b.tar.gz b/contrib/tarballs/check_traffic-0.91b.tar.gz Binary files differdeleted file mode 100644 index 0d8ab798..00000000 --- a/contrib/tarballs/check_traffic-0.91b.tar.gz +++ /dev/null diff --git a/contrib/tarballs/fetchlog-0.94.tar.gz b/contrib/tarballs/fetchlog-0.94.tar.gz Binary files differdeleted file mode 100644 index 029e1199..00000000 --- a/contrib/tarballs/fetchlog-0.94.tar.gz +++ /dev/null diff --git a/contrib/urlize.pl b/contrib/urlize.pl deleted file mode 100644 index 5acb52de..00000000 --- a/contrib/urlize.pl +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/perl -# -# urlize.pl -# jcw, 5/12/00 -# -# A wrapper around Nagios plugins that provides a URL link in the output -# -# -# Pay close attention to quoting to ensure that the shell passes the -# expected data to the plugin. For example, in: -# -# urlize http://example.com/ check_http -H example.com -r 'two words' -# -# the shell will remove the single quotes and urlize will see: -# -# urlize http://example.com/ check_http -H example.com -r two words -# -# You probably want: -# -# urlize http://example.com/ \"check_http -H example.com -r 'two words'\" -# -($#ARGV < 1) && die "Incorrect arguments"; -my $url = shift; - -chomp ($result = `@ARGV`); -print "<A HREF=\"$url\">$result</A>\n"; - -# exit with same exit value as the child produced -exit ($? >> 8); diff --git a/contrib/utils.py b/contrib/utils.py deleted file mode 100644 index db0f1c90..00000000 --- a/contrib/utils.py +++ /dev/null @@ -1,310 +0,0 @@ -# -# -# Util classes for Nagios plugins -# -# - - - -#========================================================================== -# -# Version: = '$Id: utils.py 2 2002-02-28 06:42:51Z egalstad $' -# -# (C) Rob W.W. Hooft, Nonius BV, 1998 -# -# Contact r.hooft@euromail.net for questions/suggestions. -# See: <http://starship.python.net/crew/hooft/> -# Distribute freely. -# -# jaclu@galdrion.com 2000-07-14 -# Some changes in error handling of Run() to avoid error garbage -# when used from Nagios plugins -# I also removed the following functions: AbortableWait() and _buttonkill() -# since they are only usable with Tkinter - -import sys,os,signal,time,string - -class error(Exception): - pass - -class _ready(Exception): - pass - -def which(filename): - """Find the file 'filename' in the execution path. If no executable - file is found, return None""" - for dir in string.split(os.environ['PATH'],os.pathsep): - fn=os.path.join(dir,filename) - if os.path.exists(fn): - if os.stat(fn)[0]&0111: - return fn - else: - return None - -class Task: - """Manage asynchronous subprocess tasks. - This differs from the 'subproc' package! - - 'subproc' connects to the subprocess via pipes - - 'task' lets the subprocess run autonomously. - After starting the task, we can just: - - ask whether it is finished yet - - wait until it is finished - - perform an 'idle' task (e.g. Tkinter's mainloop) while waiting for - subprocess termination - - kill the subprocess with a specific signal - - ask for the exit code. - Summarizing: - - 'subproc' is a sophisticated os.popen() - - 'task' is a sophisticated os.system() - Another difference of task with 'subproc': - - If the Task() object is deleted, before the subprocess status - was retrieved, the child process will stay. - It will never be waited for (i.e., the process will turn into - a zombie. Not a good idea in general). - - Public data: - None. - - Public methods: - __init__, __str__, Run, Wait, Kill, Done, Status. - """ - def __init__(self,command): - """Constructor. - arguments: - command: the command to run, in the form of a string, - or a tuple or list of words. - """ - if type(command)==type(''): - self.cmd=command - self.words=string.split(command) - elif type(command)==type([]) or type(command)==type(()): - # Surround each word by ' '. Limitation: words cannot contain ' chars - self.cmd="'"+string.join(command,"' '")+"'" - self.words=tuple(command) - else: - raise error("command must be tuple, list, or string") - self.pid=None - self.status=None - - def Run(self,usesh=0,detach=0,stdout=None,stdin=None,stderr=None): - """Actually run the process. - This method should be called exactly once. - optional arguments: - usesh=0: if 1, run 'sh -c command', if 0, split the - command into words, and run it by ourselves. - If usesh=1, the 'Kill' method might not do what - you want (it will kill the 'sh' process, not the - command). - detach=0: if 1, run 'sh -c 'command&' (regardless of - 'usesh'). Since the 'sh' process will immediately - terminate, the task created will be inherited by - 'init', so you can safely forget it. Remember that if - detach=1, Kill(), Done() and Status() will manipulate - the 'sh' process; there is no way to find out about the - detached process. - stdout=None: filename to use as stdout for the child process. - If None, the stdout of the parent will be used. - stdin= None: filename to use as stdin for the child process. - If None, the stdin of the parent will be used. - stderr=None: filename to use as stderr for the child process. - If None, the stderr of the parent will be used. - return value: - None - """ - if self.pid!=None: - raise error("Second run on task forbidden") - self.pid=os.fork() - if not self.pid: - for fn in range(3,256): # Close all non-standard files in a safe way - try: - os.close(fn) - except os.error: - pass - # - # jaclu@galdrion.com 2000-07-14 - # - # I changed this bit somewhat, since Nagios plugins - # should send only limited errors to the caller - # The original setup here corupted output when there was an error. - # Instead the caller should check result of Wait() and anything - # not zero should be reported as a failure. - # - try: - if stdout: # Replace stdout by file - os.close(1) - i=os.open(stdout,os.O_CREAT|os.O_WRONLY|os.O_TRUNC,0666) - if i!=1: - sys.stderr.write("stdout not opened on 1!\n") - if stdin: # Replace stdin by file - os.close(0) - i=os.open(stdin,os.O_RDONLY) - if i!=0: - sys.stderr.write("stdin not opened on 0!\n") - if stderr: # Replace stderr by file - os.close(2) - i=os.open(stderr,os.O_CREAT|os.O_WRONLY|os.O_TRUNC,0666) - if i!=2: - sys.stdout.write("stderr not opened on 2!\n") - #try: - if detach: - os.execv('/bin/sh',('sh','-c',self.cmd+'&')) - elif usesh: - os.execv('/bin/sh',('sh','-c',self.cmd)) - else: - os.execvp(self.words[0],self.words) - except: - #print self.words - #sys.stderr.write("Subprocess '%s' execution failed!\n"%self.cmd) - sys.exit(1) - else: - # Mother process - if detach: - # Should complete "immediately" - self.Wait() - - def Wait(self,idlefunc=None,interval=0.1): - """Wait for the subprocess to terminate. - If the process has already terminated, this function will return - immediately without raising an error. - optional arguments: - idlefunc=None: a callable object (function, class, bound method) - that will be called every 0.1 second (or see - the 'interval' variable) while waiting for - the subprocess to terminate. This can be the - Tkinter 'update' procedure, such that the GUI - doesn't die during the run. If this is set to - 'None', the process will really wait. idlefunc - should ideally not take a very long time to - complete... - interval=0.1: The interval (in seconds) with which the 'idlefunc' - (if any) will be called. - return value: - the exit status of the subprocess (0 if successful). - """ - if self.status!=None: - # Already finished - return self.status - if callable(idlefunc): - while 1: - try: - pid,status=os.waitpid(self.pid,os.WNOHANG) - if pid==self.pid: - self.status=status - return status - else: - idlefunc() - time.sleep(interval) - except KeyboardInterrupt: - # Send the interrupt to the inferior process. - self.Kill(signal=signal.SIGINT) - elif idlefunc: - raise error("Non-callable idle function") - else: - while 1: - try: - pid,status=os.waitpid(self.pid,0) - self.status=status - return status - except KeyboardInterrupt: - # Send the interrupt to the inferior process. - self.Kill(signal=signal.SIGINT) - - def Kill(self,signal=signal.SIGTERM): - """Send a signal to the running subprocess. - optional arguments: - signal=SIGTERM: number of the signal to send. - (see os.kill) - return value: - see os.kill() - """ - if self.status==None: - # Only if it is not already finished - return os.kill(self.pid,signal) - - def Done(self): - """Ask whether the process has already finished. - return value: - 1: yes, the process has finished. - 0: no, the process has not finished yet. - """ - if self.status!=None: - return 1 - else: - pid,status=os.waitpid(self.pid,os.WNOHANG) - if pid==self.pid: - #print "OK:",pid,status - self.status=status - return 1 - else: - #print "NOK:",pid,status - return 0 - - def Status(self): - """Ask for the status of the task. - return value: - None: process has not finished yet (maybe not even started). - any integer: process exit status. - """ - self.Done() - return self.status - - def __str__(self): - if self.pid!=None: - if self.status!=None: - s2="done, exit status=%d"%self.status - else: - s2="running" - else: - s2="prepared" - return "<%s: '%s', %s>"%(self.__class__.__name__,self.cmd,s2) - - -#========================================================================== -# -# -# Class: TimeoutHandler -# License: GPL -# Copyright (c) 2000 Jacob Lundqvist (jaclu@galdrion.com) -# -# Version: 1.0 2000-07-14 -# -# Description: -# On init, suply a call-back kill_func that should be called on timeout -# -# Make sure that what ever you are doing is calling Check periodically -# -# To check if timeout was triggered call WasTimeOut returns (true/false) -# - -import time,sys - -class TimeoutHandler: - def __init__(self,kill_func,time_to_live=10,debug=0): - 'Generic time-out handler.' - self.kill_func=kill_func - self.start_time=time.time() - self.stop_time=+self.start_time+int(time_to_live) - self.debug=debug - self.aborted=0 - - def Check(self): - 'Call this periodically to check for time-out.' - if self.debug: - sys.stdout.write('.') - sys.stdout.flush() - if time.time()>=self.stop_time: - self.TimeOut() - - def TimeOut(self): - 'Trigger the time-out callback.' - self.aborted=1 - if self.debug: - print 'Timeout, aborting' - self.kill_func() - - def WasTimeOut(self): - 'Indicates if timeout was triggered 1=yes, 0=no.' - if self.debug: - print '' - print 'call duration: %.2f seconds' % (time.time()-self.start_time) - return self.aborted |