diff --git a/src/check_oreon_dell_temperature b/src/check_oreon_dell_temperature new file mode 100644 index 000000000..624b09a29 --- /dev/null +++ b/src/check_oreon_dell_temperature @@ -0,0 +1,182 @@ +#! /usr/bin/perl -w +# +# $Id: check_graph_dell_temperature.pl,v 1.1 2005/07/27 22:22:48 wistof Exp $ +# +# Oreon's plugins are developped with GPL Licence : +# http://www.fsf.org/licenses/gpl.txt +# Developped by : Wistof +# +# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf +# +# The Software is provided to you AS IS and WITH ALL FAULTS. +# OREON makes no representation and gives no warranty whatsoever, +# whether express or implied, and without limitation, with regard to the quality, +# safety, contents, performance, merchantability, non-infringement or suitability for +# any particular or intended purpose of the Software found on the OREON web site. +# In no event will OREON be liable for any direct, indirect, punitive, special, +# incidental or consequential damages however they may arise and even if OREON has +# been previously advised of the possibility of such damages. + +# based on "graph plugins" developped by Oreon Team. See http://www.oreon.org. +## +## Plugin init +## +use strict; +use Net::SNMP qw(:snmp oid_lex_sort); +use FindBin; +use lib "$FindBin::Bin"; +use lib "/srv/nagios/libexec"; +use utils qw($TIMEOUT %ERRORS &print_revision &support); + +if (eval "require oreon" ) { + use oreon qw(get_parameters); + use vars qw($VERSION %oreon); + %oreon=get_parameters(); +} else { + print "Unable to load oreon perl module\n"; + exit $ERRORS{'UNKNOWN'}; +} + +use vars qw($PROGNAME $VERSION); +use Getopt::Long; +use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_s $opt_t $sensor $OID $OID_DESC); + +## +## Plugin var init +## + + +$VERSION = '$Revision: 1.1 $'; +$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/; + +$PROGNAME = $0; +sub print_help (); +sub print_usage (); + +Getopt::Long::Configure('bundling'); +GetOptions + ("h" => \$opt_h, "help" => \$opt_h, + "V" => \$opt_V, "version" => \$opt_V, + "v=s" => \$opt_v, "snmp=s" => \$opt_v, + "C=s" => \$opt_C, "community=s" => \$opt_C, + "s" => \$opt_s, "show" => \$opt_s, + "t=s" => \$opt_t, "sensor=s" => \$opt_t, + "H=s" => \$opt_H, "hostname=s" => \$opt_H); + +if ($opt_V) { + print_revision($PROGNAME,'$Revision: 1.1 $'); + exit $ERRORS{'OK'}; +} + +if ($opt_h) { + print_help(); + exit $ERRORS{'OK'}; +} + +$opt_H = shift unless ($opt_H); +(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); + +($opt_v) || ($opt_v = shift) || ($opt_v = "1"); +my $snmp = $1 if ($opt_v =~ /(\d)/); + +($opt_t) || ($opt_t = shift) || ($opt_t = "1"); +my $sensor = $1 if ($opt_t =~ /(\d)/); + +($opt_C) || ($opt_C = shift) || ($opt_C = "public"); + +my $start=time; +my $name = $0; +$name =~ s/\.pl.*//g; + +## +## Plugin snmp requests +## +my $OID = ".1.3.6.1.4.1.674.10892.1.700.20.1.6.1"; +my $OID_DESC = ".1.3.6.1.4.1.674.10892.1.700.20.1.8.1"; + + +# create a SNMP session +my ( $session, $error ) = Net::SNMP->session(-hostname => $opt_H,-community => $opt_C, -version => $snmp); +if ( !defined($session) ) { + print("UNKNOWN: $error"); + exit $ERRORS{'UNKNOWN'}; +} + +if ($opt_s) { + # Get desctiption table + my $result = $session->get_table( + Baseoid => $OID_DESC + ); + + if (!defined($result)) { + printf("ERROR: Description Table : %s.\n", $session->error); + $session->close; + exit $ERRORS{'UNKNOWN'}; + } + + foreach my $key ( oid_lex_sort(keys %$result)) { + my @oid_list = split (/\./,$key); + my $index = pop (@oid_list) ; + print "Temperature Sensor $index :: $$result{$key}\n"; + } +exit $ERRORS{'OK'}; +} + + +my $result = $session->get_request( + -varbindlist => [$OID.".".$sensor, + $OID_DESC.".".$sensor] + ); +if (!defined($result)) { + printf("UNKNOWN: %s.\n", $session->error); + $session->close; + exit $ERRORS{'UNKNOWN'}; +} + +my $return_result = $result->{$OID.".".$sensor}; +my $un = 0; +if ($return_result =~ /(\d+)/ ) { + $un = $1; +} else { + printf("UNKNOWN: Unable to parse SNMP Output :: %s", $return_result ); + $session->close; + exit $ERRORS{'UNKNOWN'}; +} + +$un = sprintf("%02.2f", $un / 10); + +## +## Plugin return code +## +if ($un || ( $un == 0) ){ + print "OK - ". $result->{$OID_DESC.".".$sensor} ." : $un\n"; + exit $ERRORS{'OK'}; +} +else{ + print "CRITICAL Host unavailable\n"; + exit $ERRORS{'CRITICAL'}; +} + + +sub print_usage () { + print "\nUsage:\n"; + print "$PROGNAME\n"; + print " -H (--hostname) Hostname to query - (required)\n"; + print " -C (--community) SNMP read community (defaults to public,\n"; + print " used with SNMP v1 and v2c\n"; + print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; + print " 2 for SNMP v2c\n"; + print " -t (--sensor) Set the sensor number (1 by default)\n"; + print " -s (--show) Describes all sensors \n"; + print " -V (--version) Plugin version\n"; + print " -h (--help) usage help\n"; + +} + +sub print_help () { + print "Copyright (c) 2005 Oreon\n"; + print "Bugs to http://www.oreon.org/\n"; + print "\n"; + print_usage(); + print "\n"; +} diff --git a/src/check_oreon_http b/src/check_oreon_http new file mode 100644 index 000000000..208085e2e --- /dev/null +++ b/src/check_oreon_http @@ -0,0 +1,195 @@ +#! /usr/bin/perl -w +# +# $Id: check_graph_http,v 1.3 2005/08/01 18:03:52 gollum123 Exp $ +# +# This plugin is developped under GPL Licence: +# http://www.fsf.org/licenses/gpl.txt + +# Developped by Linagora SA: http://www.linagora.com + +# Modified for Oreon Project by : Sugumaran Mathavarajan - Mathieu Chateau - Christophe Coraboeuf + +# The Software is provided to you AS IS and WITH ALL FAULTS. +# LINAGORA makes no representation and gives no warranty whatsoever, +# whether express or implied, and without limitation, with regard to the quality, +# safety, contents, performance, merchantability, non-infringement or suitability for +# any particular or intended purpose of the Software found on the LINAGORA web site. +# In no event will LINAGORA be liable for any direct, indirect, punitive, special, +# incidental or consequential damages however they may arise and even if LINAGORA has +# been previously advised of the possibility of such damages. + +# based on "graph plugins" developped by Oreon Team. See http://www.oreon.org. + +## +## Plugin init +## +use strict; +use FindBin; +use lib "$FindBin::Bin"; +use lib "/srv/nagios/libexec"; +use utils qw($TIMEOUT %ERRORS &print_revision &support); + +if (eval "require oreon" ) { + use oreon qw(get_parameters); + use vars qw($VERSION %oreon); + %oreon=get_parameters(); +} else { + print "Unable to load oreon perl module\n"; + exit $ERRORS{'UNKNOWN'}; +} + +use Getopt::Long; +use vars qw($opt_h $opt_V $opt_g $opt_D $opt_S $opt_H $opt_I $opt_e $opt_s $opt_u $opt_p $opt_P $opt_w $opt_c + $opt_t $opt_a $opt_L $opt_f $opt_l $opt_r $opt_R $opt_z $opt_C $opt_step $step); +use vars qw($PROGNAME); + +## +## Plugin var init +## +my $pathtolibexechttp = $oreon{GLOBAL}{ NAGIOS_LIBEXEC}."check_http"; + +$PROGNAME = "$0"; +sub print_help (); +sub print_usage (); + +Getopt::Long::Configure('bundling'); +GetOptions + ("h" => \$opt_h, "help" => \$opt_h, + "V" => \$opt_V, "version" => \$opt_V, + "H=s" => \$opt_H, "hostname=s" => \$opt_H, + "I=s" => \$opt_I, "IP-address=s" => \$opt_I, + "e=s" => \$opt_e, "expect=s" => \$opt_e, + "s=s" => \$opt_s, "string=s" => \$opt_s, + "u=s" => \$opt_u, "url=s" => \$opt_u, + "p=s" => \$opt_p, "port=s" => \$opt_p, + "P=s" => \$opt_P, "post=s" => \$opt_P, + "w=s" => \$opt_w, "warning=s" => \$opt_w, + "c=s" => \$opt_c, "critical=s" => \$opt_c, + "t=s" => \$opt_t, "timeout=s" => \$opt_t, + "a=s" => \$opt_a, "authorization=s" => \$opt_a, + "L=s" => \$opt_L, "link=s" => \$opt_L, + "f=s" => \$opt_f, "onredirect=s" => \$opt_f, + "l=s" => \$opt_l, "linespan=s" => \$opt_l, + "r=s" => \$opt_r, "regex=s" => \$opt_r, + "R=s" => \$opt_R, "eregi=s" => \$opt_R, + "C=s" => \$opt_C, "certificate=s" => \$opt_C, + "z" => \$opt_R, "ssl" => \$opt_z + + ); + +if ($opt_V) { + print_revision($PROGNAME,'$Revision: 1.3 $'); + exit $ERRORS{'OK'}; +} + +if ($opt_h) { + print_help(); + exit $ERRORS{'OK'}; +} + +$opt_H = shift unless ($opt_H); +(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); + +($opt_step) || ($opt_step = shift) || ($opt_step = "300"); +$step = $1 if ($opt_step =~ /(\d+)/); + +my $args_check_http = ""; +if ( $opt_H ) { + $args_check_http .= " -H $opt_H"; +} +if ( $opt_I ) { + $args_check_http .= " -I $opt_I"; +} +if ( $opt_e ) { + $args_check_http .= " -e $opt_e"; +} +if ( $opt_s ) { + $args_check_http .= " -s $opt_s"; +} +if ( $opt_u ) { + $args_check_http .= " -u $opt_u"; +} +if ( $opt_p ) { + $args_check_http .= " -p $opt_p"; +} +if ( $opt_P ) { + $args_check_http .= " -P $opt_P"; +} +if ( $opt_I ) { + $args_check_http .= " -I $opt_I"; +} +if ( $opt_e ) { + $args_check_http .= " -e $opt_e"; +} +if ( $opt_w ) { + $args_check_http .= " -w $opt_w"; +} +if ( $opt_c ) { + $args_check_http .= " -c $opt_c"; +} +if ( $opt_t ) { + $args_check_http .= " -t $opt_t"; +} +if ( $opt_a ) { + $args_check_http .= " -a $opt_a"; +} +if ( $opt_L ) { + $args_check_http .= " -L $opt_L"; +} +if ( $opt_f ) { + $args_check_http .= " -f $opt_f"; +} +if ( $opt_l ) { + $args_check_http .= " -l $opt_l"; +} +if ( $opt_r ) { + $args_check_http .= " -r $opt_r"; +} +if ( $opt_R ) { + $args_check_http .= " -R $opt_R"; +} +if ( $opt_C ) { + $args_check_http .= " -C $opt_C"; +} +if ( $opt_z ) { + $args_check_http .= " --ssl"; +} + + + +my $start=time; +my $name = $0; +$name =~ s/\.pl.*//g; + +## +## Plugin requests +## +# print "args: $args_check_http \n"; +my $result = `$pathtolibexechttp $args_check_http`; +my $return_code = $? / 256; + +$_ = $result; +m/time=\s*(\d*\.\d*)/; +my $time = $1; + + +print "$result"; +exit $return_code; + +## +## Plugin return code +## +sub print_usage () { + my $screen = `$pathtolibexechttp -h`; + $screen =~ s/check_http/check_graph_http/g; + $screen =~ s/-S/-Z/; + print $screen; +} + +sub print_help () { + print "Copyright (c) 2005 LINAGORA SA\n"; + print "Bugs to http://www.linagora.com/\n"; + print "\n"; + print_usage(); + print "\n"; +} diff --git a/src/check_oreon_nt b/src/check_oreon_nt new file mode 100644 index 000000000..ad77ae291 --- /dev/null +++ b/src/check_oreon_nt @@ -0,0 +1,338 @@ +#! /usr/bin/perl -w +# +# $Id: check_graph_nt.pl,v 1.3 2005/08/01 18:04:00 gollum123 Exp $ +# +# Oreon's plugins are developped with GPL Licence : +# http://www.fsf.org/licenses/gpl.txt +# Developped by : Julien Mathis - Mathieu Mettre +# Under control of Flavien Astraud, Jerome Landrieu for Epitech. +# Oreon's plugins are developped in partnership with Linagora company. +# +# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf +# Modified for Oreon Project by : Sugumaran Mathavarajan - mat.sugumaran@merethis.com +# +# The Software is provided to you AS IS and WITH ALL FAULTS. +# OREON makes no representation and gives no warranty whatsoever, +# whether express or implied, and without limitation, with regard to the quality, +# safety, contents, performance, merchantability, non-infringement or suitability for +# any particular or intended purpose of the Software found on the OREON web site. +# In no event will OREON be liable for any direct, indirect, punitive, special, +# incidental or consequential damages however they may arise and even if OREON has +# been previously advised of the possibility of such damages. + +## +## Plugin init +## +use strict; +use FindBin; +use lib "$FindBin::Bin"; +use lib "/srv/nagios/libexec"; +use utils qw($TIMEOUT %ERRORS &print_revision &support); + + +if (eval "require oreon" ) { + use oreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid); + use vars qw($VERSION %oreon); + %oreon=get_parameters(); +} else { + print "Unable to load oreon perl module\n"; + exit $ERRORS{'UNKNOWN'}; +} + +use vars qw($PROGNAME); +use Getopt::Long; +use vars qw($opt_H $opt_p $opt_s $opt_v $opt_V $opt_h $opt_w $opt_c $opt_S $opt_g $opt_t $opt_l $opt_d $opt_D $opt_step $step $opt_f); + +## +## Plugin var init +## +my $pathtolibexecnt = $oreon{GLOBAL}{NAGIOS_LIBEXEC}."check_nt"; + +my($op_v, $op_d, $op_s, $op_t, $op_l, $port, @values, @test, @test2, @test3, @test4, @test5, $warning, $critical, @w, @c, $uptime); +my($warning2, $critical2, $warning3, $critical3, $warning4, $critical4, @output); +$PROGNAME = "$0"; +sub print_help (); +sub print_usage (); + +Getopt::Long::Configure('bundling'); +GetOptions + ("h" => \$opt_h, "help" => \$opt_h, + "p=s" => \$opt_p, "port=s" => \$opt_p, + "V" => \$opt_V, "version" => \$opt_V, + "s=s" => \$opt_s, "password=s" => \$opt_s, + "d=s" => \$opt_d, "showall=s" => \$opt_d, + "v=s" => \$opt_v, "variable=s" => \$opt_v, + "D=s" => \$opt_D, "directory=s" => \$opt_D, + "t=s" => \$opt_t, "timeout=s" => \$opt_t, + "l:s" => \$opt_l, "parameter:s" => \$opt_l, + "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_h) { + print_help(); + exit $ERRORS{'OK'}; +} + +if ($opt_V) { + $_ = `$pathtolibexecnt -V`; + print "$_"; + exit $ERRORS{'OK'}; +} + +if ($opt_p) { + if ($opt_p =~ /([0-9]+)/){ + $port = $1; + } + else{ + print "Unknown -p number expected... or it doesn't exist, try another port - number\n"; + exit $ERRORS{'UNKNOWN'}; + } +} + +$opt_H = shift unless ($opt_H); +(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); + + +if ($opt_c) { + ($opt_c) || ($opt_c = shift); + $critical = $1 if ($opt_c =~ /([0-9]+)/); +} + +if ($opt_w) { + ($opt_w) || ($opt_w = shift); + $warning = $1 if ($opt_w =~ /([0-9]+)/); +} + +if (($critical && $warning) && ($critical <= $warning)) { + print "(--crit) must be superior to (--warn)"; + print_usage(); + exit $ERRORS{'OK'}; +} + + +if ($opt_t) { + ($opt_t) || ($opt_t = shift); + $op_t = $1 if ($opt_t =~ /([-\.,\w]+)/); +} + +if ($opt_l) { + ($opt_l) || ($opt_l = shift); + $op_l = $1 if ($opt_l =~ /(.+)/); +} + +if ($opt_s) { + ($opt_s) || ($opt_s = shift); + $op_s = $1 if ($opt_s =~ /([-.,A-Za-z0-9]+)/); +} + +if ($opt_d) { + ($opt_d) || ($opt_d = shift); + $op_d = $1 if ($opt_d =~ /([-.,A-Za-z0-9]+)/); +} + +if ($opt_v) { + ($opt_v) || ($opt_v = shift); + $op_v = $1 if ($opt_v =~ /([-.,A-Za-z0-9]+)/); +} + +($opt_step) || ($opt_step = shift) || ($opt_step = 300); +$step = $1 if ($opt_step =~ /(\d+)/); + +my $name = $0; +$name =~ s/\.pl.*//g; +my $return_code; +## +## Plugin requests +## +my $start=time; +if ($op_v) { + if ($op_v) {$op_v = "-v ".$op_v;} + if ($port) {$port = "-p ".$port;} else { $port = " ";} + if ($warning) {$warning = "-w ".$warning;} else { $warning = " ";} + if ($critical) {$critical = "-c ".$critical;} else { $critical = " ";} + if ($op_l) {$op_l = "-l \"".$op_l ."\"";} else { $op_l = " ";} + if ($op_t) {$op_t = "-t ".$op_t;} else { $op_t = " ";} + if ($op_s) {$op_s = "-s ".$op_s;} else { $op_s = " ";} + if ($op_d) {$op_d = "-d ".$op_d;} else { $op_d = " ";} +# print "$pathtolibexecnt -H $opt_H $op_v $port $warning $critical $op_l $op_t $op_s $op_d\n"; + $_ = `$pathtolibexecnt -H $opt_H $op_v $port $warning $critical $op_l $op_t $op_s $op_d 2>/dev/null`; + my $return = $_; + $return =~ s/\\//g; + $return_code = $? / 256; + + ## + ## CLIENTVERSION + ## + if ($op_v =~ /CLIENTVERSION/){ + print "CLIENTVERSION impossible to Graph!\n"; + exit $ERRORS{'UNKNOWN'}; + } + + if (($op_v =~ /CPULOAD/) && ($op_l =~ /([-\.,\w]+)/)){ ## CPULOAD + @output = split(/\|/,$_); + @values = $output[0] =~ /(\d*)\%/g ; + $start=time; + ## Print Plugins Output + $return =~ s/\n/ /g; + if (@values){ + if (defined($opt_c) && defined($opt_w)){ + print $return . "|cpu=@values;$opt_w;$opt_c\n"; + } else { + print $return . "|cpu=@values\n"; + } + } else { + print $return . "\n"; + } + exit $return_code; + } elsif ($op_v =~ /UPTIME/){ ## UPTIME + if ($_ =~ /.*[-:]+\s(\d+)\s.*$/ ) { + $uptime = $1; + } else { + print "unable to parse check_nt output: $_\n" ; + exit $ERRORS{'UNKNOWN'}; + } + $_ =~ s/\n/ /g; + if (defined($uptime)){ + print $_ . "|uptime=".$uptime."d\n"; + } else { + print $_ . "\n"; + } + exit $return_code; + } elsif (($op_v =~ /USEDDISKSPACE/) && ($op_l =~ /([-\.,\w]+)/)){ ## USEDDISKSPACE + my @test = split(/ /,$_); + if (defined($test[9]) && defined($test2[1])){ + @test2 = split(/\(/, $test[9]); + @test3 = split(/\%/, $test2[1]); + } + @c = split(/ /, $critical); + $critical = $c[1]; + @w = split(/ /, $warning); + $warning = $w[1]; + ## Print Plugins Output + $return =~ s/\n/ /g; + $return =~ s/%/ pct/g; + if (defined($test[3]) && defined($test[7]) && defined($test[12])){ + print $return . "|total=".$test[3]."Mo used=".$test[7]."Mo free=".$test[12]."Mo\n"; + } else { + print $return . "\n"; + } + exit $return_code; + } elsif ($op_v =~ /MEMUSE/){ ## MEMUSE + $start=time; + my @test = split(/ /,$_); + if (defined($test[2])){ + @test4 = split(/:/, $test[2]); + } + @c = split(/ /, $critical); + $critical = $c[1]; + @w = split(/ /, $warning); + $warning = $w[1]; + ## Print Plugins Output + $return =~ s/\n/ /g; + $return =~ s/%/ pct/g; + if ($test4[1] && $test[6] && $test[11]){ + print $return . "|total=".$test4[1]." used=".$test[6]." free=".$test[11]."\n"; + } else { + print $return . "\n"; + } + exit $return_code; + } elsif ($op_v =~ /SERVICESTATE/){## SERVICESTATE + my (@tab, $process, $nom, $etat); + @tab = split (' - ',$_); + foreach $process (@tab) { + ($nom,$etat) = split (': ', $process); + if (defined($etat)) { + $etat =~ s/\n//; + } else { + $etat = "Unknow"; + } + if ($etat =~ /Started/) + {$etat=1;} + elsif ($etat =~ /Stopped/) + {$etat=0;} + elsif ($etat =~ /Unknown/) + {$etat=-1;} + else { + print "Unable to get $nom status [$etat]: \n\t$_\n"; + exit $ERRORS{'UNKNOWN'}; + } + } + $return =~ s/%/ pct/g; + print $return; + exit $return_code; + } elsif ($op_v =~ /PROCSTATE/){## PROCSTATE + print "PROCSTATE not graphed\n"; + exit $ERRORS{'UNKNOWN'}; + } elsif (($op_v =~ /COUNTER/) && ($op_l =~ /(.+)/)) { ## COUNTER + @output = split(/\|/,$_); + @values = $output[0] =~ /([,\.\d]*)\s?\%/ ; + if (!@values) {@values = $output[0] =~ /([\d]*)/;} + $start=time; + ## Print Plugins Output + $return =~ s/\n/ /g; + $return =~ s/%/ pct/g; + print $return . "|counter=".@values."\n"; + exit $return_code; + } +} else { + print "Could not parse arguments\n"; + exit $ERRORS{'UNKNOWN'}; +} + +## +## Plugin return code +## + +sub print_usage () { + print "\nUsage:\n"; + print "$PROGNAME\n"; + print " Usage: check_graph_nt -H host -v variable [-p port] [-s password] [-w warning] [-c critical] [-l params] [-d SHOWALL] [-t timeout] \n"; + print " Options:\n"; + print " -H, --hostname=HOST\n"; + print " Name of the host to check\n"; + print " -p, --port=INTEGER\n"; + print " Optional port number (default: 1248)\n"; + print " -s \n"; + print " Password needed for the request\n"; + print " -v, --variable=STRING\n"; + print " Variable to check. Valid variables are:\n"; + print " CLIENTVERSION = Not Graphed. Get the NSClient version\n"; + print " CPULOAD = Average CPU load on last x minutes. Request a -l parameter with the following syntax:\n"; + print " -l ,,. should be less than 24*60.\n"; + print " Thresholds are percentage and up to 10 requests can be done in one shot. ie: -l 60,90,95,120,90,95\n"; + print " and 4 requests can be graphed.\n"; + print " UPTIME = Only Days are graphed. Get the uptime of the machine. No specific parameters. No warning or critical threshold.\n"; + print " USEDDISKSPACE = Size and percentage of disk use. Request a -l parameter containing the drive letter only.\n"; + print " Warning and critical thresholds can be specified with -w and -c.\n"; + print " MEMUSE = Memory use. Warning and critical thresholds can be specified with -w and -c.\n"; + print " SERVICESTATE = Check and graph the state of one service. Request a -l parameters with the following syntax:\n"; + print " -l ... You MUST specify -d SHOWALL in the input command.\n"; + print " 1: Service Started - 0: Service Stopped - -1: Service Unknown.\n"; +# print " SERVICESTATE = Not Graphed. Check the state of one or several services. Request a -l parameters with the following syntax:\n"; +# print " -l ,,,... You can specify -d SHOWALL in case you want to see working services\n"; +# print " in the returned string.\n"; + print " PROCSTATE = Not Graphed. Check if one or several process are running. Same syntax as SERVICESTATE.\n"; + print " COUNTER = Check any performance counter of Windows NT/2000. Request a -l parameters with the following syntax:\n"; + print " -l \"counter\",\"\" The parameter is optional and\n"; + print " is given to a printf output command which require a float parameters. Some examples:\n"; + print " \"Paging file usage is %.2f %%\" or \"%.f %% paging file used.\"\n"; + print " -w, --warning=INTEGER\n"; + print " Threshold which will result in a warning status\n"; + print " -c, --critical=INTEGER\n"; + print " Threshold which will result in a critical status\n"; + print " -t, --timeout=INTEGER\n"; + print " Seconds before connection attempt times out (default: 10)\n"; + print " -h, --help\n"; + print " Print this help screen\n"; + print " -V, --version\n"; + print " Print version information\n"; +} + +sub print_help () { + print "Copyright (c) 2004 OREON\n"; + print "Bugs to http://www.oreon.org/\n"; + print "\n"; + print_usage(); + print "\n"; +} diff --git a/src/check_oreon_ping b/src/check_oreon_ping index b20789009..2e24a1cb7 100644 --- a/src/check_oreon_ping +++ b/src/check_oreon_ping @@ -1,172 +1,201 @@ -#! /usr/bin/perl -w -################################################################### -# Oreon is developped with GPL Licence 2.0 -# -# GPL License: http://www.gnu.org/licenses/gpl.txt -# -# Developped by : Julien Mathis - Romain Le Merlus -# Christophe Coraboeuf -# -################################################################### -# 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. -# -# For information : contact@merethis.com -#################################################################### -# -# Script init -# - -use strict; -use FindBin; -use lib "$FindBin::Bin"; -use lib "@NAGIOS_PLUGINS@"; -use utils qw($TIMEOUT %ERRORS &print_revision &support); - -use vars qw($PROGNAME); -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_H $opt_D $opt_w $opt_c $opt_n $rta_critical $rta_warning $pl_critical $pl_warning $opt_s); - -# Plugin var init - -my $ping = `whereis -b ping`; -$ping =~ /^.*:\s(.*)$/; -$ping = $1; - -$PROGNAME = "check_graph_ping"; -sub print_help (); -sub print_usage (); - -Getopt::Long::Configure('bundling'); -GetOptions - ("h" => \$opt_h, "help" => \$opt_h, - "V" => \$opt_V, "version" => \$opt_V, - "w=s" => \$opt_w, "warning=s" => \$opt_w, - "c=s" => \$opt_c, "critical=s" => \$opt_c, - "n=s" => \$opt_n, "number=s" => \$opt_n, - "H=s" => \$opt_H, "hostname=s" => \$opt_H); - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1.2 $'); - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -$opt_H = shift unless ($opt_H); -(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); - -($opt_c) || ($opt_c = shift) || ($opt_c = "500,40%"); -if ($opt_c =~ /([0-9]+),([0-9]+)%/) { - $rta_critical = $1; - $pl_critical = $2; -} - -($opt_w) || ($opt_w = shift) || ($opt_w = "200,20%"); -if ($opt_w =~ /([0-9]+),([0-9]+)%/) { - $rta_warning = $1; - $pl_warning = $2; -} - -if ( ($rta_critical <= $rta_warning) || ($pl_critical <= $pl_warning) ) { - print "critical must be superior to warning\n"; - print_usage(); - exit $ERRORS{'OK'}; -} - -($opt_n) || ($opt_n = shift) || ($opt_n = 1); -my $NbPing; -if ($opt_n =~ /([0-9]+)/){ - $NbPing = $1; -} else { - print "Unknown ping number\n"; - exit $ERRORS{'UNKNOWN'}; -} - -# Plugin requests - -$_ = `$ping -n -c $NbPing $opt_H 2>/dev/null`; -my $return = $? / 256; - -# Get Data From Ping Result - -my $ping_result = $_; -my @ping_result_array = split(/\n/,$ping_result); -my @ping_subresult1_array; -my @ping_subresult2_array; -my $rta = 0; -my $pl; -my $time_answer; - -if( ( $return != 0 ) || $ping_result_array[@ping_result_array -2 ] =~ /100% packet loss/) { - $rta = -1; - $time_answer = 0; -} else { - @ping_subresult1_array = split(/=/,$ping_result_array[@ping_result_array -1 ]); - @ping_subresult2_array = split(/,/,$ping_result_array[@ping_result_array -2 ]); - @ping_subresult1_array = split(/\//,$ping_subresult1_array[1]); - @ping_subresult2_array = split(/ /,$ping_subresult2_array[2]); - $rta = $ping_subresult1_array[1]; - $pl = $ping_subresult2_array[1]; - $time_answer = $ping_subresult1_array[1]; - $pl =~ /([0-9]+)\%/; - $pl = $1; -} - -# Plugin return code - -my $result_str = ""; - -if( $rta == -1 ) { - $ping_result_array[@ping_result_array -2 ] =~ s/\%/percent/g; - print "GPING CRITICAL - ".$ping_result_array[@ping_result_array -2 ]."|time=0 ok=0\n"; - exit $ERRORS{'CRITICAL'}; -} elsif ( ($pl >= $pl_critical) || ($rta >= $rta_critical) ) { - $ping_result_array[@ping_result_array -1 ] =~ s/\%/percent/g; - my @tab = split(/,/,$ping_result_array[@ping_result_array -1 ]); - print "GPING CRITICAL - ". $tab[1] ."|time=".$time_answer."ms;$pl_warning;$pl_critical;; ok=1\n"; - exit $ERRORS{'CRITICAL'}; -} elsif (($pl >= $pl_warning) || ($rta >= $rta_warning) ) { - $ping_result_array[@ping_result_array -1 ] =~ s/\%/percent/g; - my @tab = split(/,/,$ping_result_array[@ping_result_array -1 ]); - print "GPING WARNING - ".$tab[0]."|time=".$time_answer."ms;$pl_warning;$pl_critical;; ok=1\n"; - exit $ERRORS{'WARNING'}; -} else { - $ping_result_array[@ping_result_array -1 ] =~ s/\%/percent/g; - my @tab = split(/,/,$ping_result_array[@ping_result_array -1 ]); - print "GPING OK - ".$tab[0]."|time=".$time_answer."ms;$pl_warning;$pl_critical;; ok=1\n"; - exit $ERRORS{'OK'}; -} - -sub print_usage () { - print "Usage:\n"; - print "$PROGNAME\n"; - print " -H (--hostname) Hostname to query (Required)\n"; - print " -g (--rrdgraph) Create a rrd base if necessary and add datas into this one\n"; - print " --rrd_step Specifies the base interval in seconds with which data will be fed into the RRD (300 by default)\n"; - print " -S (--ServiceId) Oreon Service Id\n"; - print " -w (--warning) Threshold pair (Default: 200,20%)\n"; - print " -c (--critical) Threshold pair (Default: 500,40%)\n"; - print " -n (--number) number of ICMP ECHO packets to send (Default: 1)\n"; - print " -V (--version) Plugin version\n"; - print " -h (--help) usage help\n"; -} - -sub print_help () { - print "######################################################\n"; - print "# Copyright (c) 2004-2007 Oreon-project #\n"; - print "# Bugs to http://www.oreon-project.org/ #\n"; - print "######################################################\n"; - print_usage(); - print "\n"; -} +#! /usr/bin/perl -w +# +# $Id: check_oreon_ping,v 1.2 2006/04/28 10:21:49 Julien Mathis $ +# +# Oreon's plugins are developped with GPL Licence : +# http://www.fsf.org/licenses/gpl.txt +# Developped by : Julien Mathis - Mathieu Mettre - Romain Le Merlus +# +# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf +# Modified By Julien Mathis - Sugumaran Mathavarajan For Merethis Company +# +# The Software is provided to you AS IS and WITH ALL FAULTS. +# OREON makes no representation and gives no warranty whatsoever, +# whether express or implied, and without limitation, with regard to the quality, +# safety, contents, performance, merchantability, non-infringement or suitability for +# any particular or intended purpose of the Software found on the OREON web site. +# In no event will OREON be liable for any direct, indirect, punitive, special, +# incidental or consequential damages however they may arise and even if OREON has +# been previously advised of the possibility of such damages. + +# +# Plugin init +# + +use strict; +use FindBin; +use lib "$FindBin::Bin"; +use lib "/srv/nagios/libexec"; +use utils qw($TIMEOUT %ERRORS &print_revision &support); + +if (eval "require oreon" ) { + use oreon qw(get_parameters); + use vars qw($VERSION %oreon); + %oreon=get_parameters(); +} else { + print "Unable to load oreon perl module\n"; + exit $ERRORS{'UNKNOWN'}; +} + +use vars qw($PROGNAME); +use Getopt::Long; +use vars qw($opt_V $opt_h $opt_g $opt_H $opt_D $opt_w $opt_c $opt_n $opt_f $opt_S $rta_critical $rta_warning $pl_critical $pl_warning $opt_s $opt_step $step ); + +# +# Plugin var init +# + +my $ping = `whereis -b ping`; +$ping =~ /^.*:\s(.*)$/; +$ping = $1; + +$PROGNAME = "$0"; +sub print_help (); +sub print_usage (); + +Getopt::Long::Configure('bundling'); +GetOptions + ("h" => \$opt_h, "help" => \$opt_h, + "V" => \$opt_V, "version" => \$opt_V, + "rrd_step=s" => \$opt_step,"f" => \$opt_f, + "w=s" => \$opt_w, "warning=s" => \$opt_w, + "c=s" => \$opt_c, "critical=s" => \$opt_c, + "n=s" => \$opt_n, "number=s" => \$opt_n, + "H=s" => \$opt_H, "hostname=s" => \$opt_H); + +if ($opt_V) { + print_revision($PROGNAME,'$Revision: 1.2 $'); + exit $ERRORS{'OK'}; +} + +if ($opt_h) { + print_help(); + exit $ERRORS{'OK'}; +} + +$opt_H = shift unless ($opt_H); +(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); + +($opt_c) || ($opt_c = shift) || ($opt_c = "500,40%"); +if ($opt_c =~ /([0-9]+),([0-9]+)%/) { + $rta_critical = $1; + $pl_critical = $2; +} + +($opt_w) || ($opt_w = shift) || ($opt_w = "200,20%"); +if ($opt_w =~ /([0-9]+),([0-9]+)%/) { + $rta_warning = $1; + $pl_warning = $2; +} +if (!$rta_warning || !$rta_critical || !$pl_warning || !$pl_critical) { + print "bad initialisation of Treshholds\n"; + exit $ERRORS{'OK'}; +} + +if ( ($rta_critical <= $rta_warning) || ($pl_critical <= $pl_warning) ) { + print "critical must be superior to warning\n"; + print_usage(); + exit $ERRORS{'OK'}; +} + +($opt_n) || ($opt_n = shift) || ($opt_n = 1); +my $NbPing; +if ($opt_n =~ /([0-9]+)/){ + $NbPing = $1; +} else{ + print "Unknown ping number\n"; + exit $ERRORS{'UNKNOWN'}; +} + +my $start=time; + +# +# RRDTools create rrd +# + +# +# Plugin requests +# + +$_ = `$ping -n -c $NbPing $opt_H 2>/dev/null`; +my $return = $? / 256; + +# +# Get Data From Ping Result +# +if (!$_) { + print "no value returned by ping\n"; + exit $ERRORS{'UNKNOWN'}; +} +my $ping_result = $_; +my @ping_result_array = split(/\n/,$ping_result); +my @ping_subresult1_array; +my @ping_subresult2_array; +my $rta = 0; +my $pl; +my $time_answer; + +if( ( $return != 0 ) || $ping_result_array[@ping_result_array -2 ] =~ /100% packet loss/) { + $rta = -1; + $time_answer = 0; +} else { + @ping_subresult1_array = split(/=/,$ping_result_array[@ping_result_array -1 ]); + @ping_subresult2_array = split(/,/,$ping_result_array[@ping_result_array -2 ]); + @ping_subresult1_array = split(/\//,$ping_subresult1_array[1]); + @ping_subresult2_array = split(/ /,$ping_subresult2_array[2]); + $rta = $ping_subresult1_array[1]; + $pl = $ping_subresult2_array[1]; + $time_answer = $ping_subresult1_array[1]; + $pl =~ /([0-9]+)\%/; + $pl = $1; +} + +# +# Plugin return code +# + +my $result_str = ""; + +if( $rta == -1 ) { + $ping_result_array[@ping_result_array -2 ] =~ s/\%/percent/g; + print "GPING CRITICAL - ".$ping_result_array[@ping_result_array -2 ]."|time=0 ok=0\n"; + exit $ERRORS{'CRITICAL'}; +} elsif ( ($pl >= $pl_critical) || ($rta >= $rta_critical) ) { + $ping_result_array[@ping_result_array -1 ] =~ s/\%/percent/g; + my @tab = split(/,/,$ping_result_array[@ping_result_array -1 ]); + print "GPING CRITICAL - ". $tab[1] ."|time=".$time_answer."ms;$pl_warning;$pl_critical;; ok=1\n"; + exit $ERRORS{'CRITICAL'}; +} elsif ( ($pl >= $pl_warning) || ($rta >= $rta_warning) ) { + $ping_result_array[@ping_result_array -1 ] =~ s/\%/percent/g; + my @tab = split(/,/,$ping_result_array[@ping_result_array -1 ]); + print "GPING WARNING - ".$tab[0]."|time=".$time_answer."ms;$pl_warning;$pl_critical;; ok=1\n"; + exit $ERRORS{'WARNING'}; +} else { + $ping_result_array[@ping_result_array -1 ] =~ s/\%/percent/g; + my @tab = split(/,/,$ping_result_array[@ping_result_array -1 ]); + print "GPING OK - ".$tab[0]."|time=".$time_answer."ms;$pl_warning;$pl_critical;; ok=1\n"; + exit $ERRORS{'OK'}; +} + +sub print_usage () { + print "Usage:\n"; + print "$PROGNAME\n"; + print " -H (--hostname) Hostname to query (Required)\n"; + print " -g (--rrdgraph) Create a rrd base if necessary and add datas into this one\n"; + print " --rrd_step Specifies the base interval in seconds with which data will be fed into the RRD (300 by default)\n"; + print " -S (--ServiceId) Oreon Service Id\n"; + print " -w (--warning) Threshold pair (Default: 200,20%)\n"; + print " -c (--critical) Threshold pair (Default: 500,40%)\n"; + print " -n (--number) number of ICMP ECHO packets to send (Default: 1)\n"; + print " -V (--version) Plugin version\n"; + print " -h (--help) usage help\n"; +} + +sub print_help () { + print "######################################################\n"; + print "# Copyright (c) 2004-2006 Oreon-project #\n"; + print "# Bugs to http://www.oreon-project.org/ #\n"; + print "######################################################\n"; + print_usage(); + print "\n"; +} diff --git a/src/check_oreon_snmp_loadaverage b/src/check_oreon_snmp_loadaverage index 34de2acd2..8ee892856 100644 --- a/src/check_oreon_snmp_loadaverage +++ b/src/check_oreon_snmp_loadaverage @@ -28,7 +28,7 @@ use strict; use Net::SNMP qw(:snmp); use FindBin; use lib "$FindBin::Bin"; -use lib "@NAGIOS_PLUGINS@"; +use lib "/srv/nagios/libexec"; use utils qw($TIMEOUT %ERRORS &print_revision &support); if (eval "require oreon" ) { use oreon qw(get_parameters); @@ -46,7 +46,7 @@ use vars qw($opt_V $opt_h $opt_v $opt_C $opt_H $opt_c $opt_w $opt_D $snmp $opt_k my($return_code); -$PROGNAME = "check_graph_load_average"; +$PROGNAME = "$0"; sub print_help (); sub print_usage (); diff --git a/src/check_oreon_snmp_process b/src/check_oreon_snmp_process index 0e9c28721..e0eaa8083 100644 --- a/src/check_oreon_snmp_process +++ b/src/check_oreon_snmp_process @@ -28,7 +28,7 @@ use strict; use Net::SNMP qw(:snmp oid_lex_sort); use FindBin; use lib "$FindBin::Bin"; -use lib "@NAGIOS_PLUGINS@"; +use lib "/srv/nagios/libexec"; use utils qw($TIMEOUT %ERRORS &print_revision &support); if (eval "require oreon" ) { use oreon qw(get_parameters); @@ -47,7 +47,7 @@ use vars qw($opt_V $opt_h $opt_v $opt_C $opt_p $opt_H $opt_n $opt_k $opt_u $opt_ my($proc, $proc_run); -$PROGNAME = "check_graph_process"; +$PROGNAME = $0; sub print_help (); sub print_usage (); diff --git a/src/check_oreon_snmp_process.pl b/src/check_oreon_snmp_process.pl deleted file mode 100644 index 9ce8c071f..000000000 --- a/src/check_oreon_snmp_process.pl +++ /dev/null @@ -1,255 +0,0 @@ -#! /usr/bin/perl -w -################################################################### -# Oreon is developped with GPL Licence 2.0 -# -# GPL License: http://www.gnu.org/licenses/gpl.txt -# -# Developped by : Julien Mathis - Romain Le Merlus -# Christophe Coraboeuf -# -################################################################### -# 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. -# -# For information : contact@merethis.com -#################################################################### -# -# Script init -# - -use strict; -use Net::SNMP qw(:snmp oid_lex_sort); -use FindBin; -use lib "$FindBin::Bin"; -use lib "/usr/local/nagios/libexec/"; -use utils qw($TIMEOUT %ERRORS &print_revision &support); -if (eval "require oreon" ) { - use oreon qw(get_parameters); - use vars qw($VERSION %oreon); - %oreon=get_parameters(); -} else { - print "Unable to load oreon perl module\n"; - exit $ERRORS{'UNKNOWN'}; -} - -use vars qw($PROGNAME); -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_a $opt_v $opt_C $opt_p $opt_H $opt_n $opt_k $opt_u $opt_x $result @result $opt_c $opt_w $opt_f %process_list %STATUS); - -# Plugin var init - -my($proc, $proc_run); - -$PROGNAME = "check_graph_process"; -sub print_help (); -sub print_usage (); -%STATUS=(1=>'running',2=>'runnable',3=>'notRunnable',4=>'invalid'); - -Getopt::Long::Configure('bundling'); -GetOptions - ("h" => \$opt_h, "help" => \$opt_h, - "u=s" => \$opt_u, "username=s" => \$opt_u, - "x=s" => \$opt_x, "password=s" => \$opt_x, - "k=s" => \$opt_k, "key=s" => \$opt_k, - "V" => \$opt_V, "version" => \$opt_V, - "n" => \$opt_n, "number" => \$opt_n, - "v=s" => \$opt_v, "snmp=s" => \$opt_v, - "f" => \$opt_f, "full_pathname" => \$opt_f, - "a=s" => \$opt_a, "arguments=s" => \$opt_a, - "C=s" => \$opt_C, "community=s" => \$opt_C, - "p=s" => \$opt_p, "process=s" => \$opt_p, - "H=s" => \$opt_H, "hostname=s" => \$opt_H); - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1.2 $'); - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -if (!$opt_H) { -print_usage(); -exit $ERRORS{'OK'}; -} -my $snmp = "1"; -if ($opt_v && $opt_v =~ /^[0-9]$/) { -$snmp = $opt_v; -} - -if ($snmp eq "3") { -if (!$opt_u) { -print "Option -u (--username) is required for snmpV3\n"; -exit $ERRORS{'OK'}; -} -if (!$opt_x && !$opt_k) { -print "Option -k (--key) or -x (--password) is required for snmpV3\n"; -exit $ERRORS{'OK'}; -}elsif ($opt_x && $opt_k) { -print "Only option -k (--key) or -x (--password) is needed for snmpV3\n"; -exit $ERRORS{'OK'}; -} -} - -if (!$opt_C) { -$opt_C = "public"; -} - -my $process; -if(!$opt_p) { -print_usage(); -exit $ERRORS{'OK'}; -}elsif ($opt_p !~ /([-.A-Za-z0-9]+)/){ -print_usage(); -exit $ERRORS{'OK'}; -} -$process = $opt_p; - -my $name = $0; -$name =~ s/\.pl.*//g; - -# Plugin snmp requests -my $OID_SW_RunName = $oreon{MIB2}{SW_RUNNAME}; -if ($opt_f) { - $OID_SW_RunName = $oreon{MIB2}{SW_RUNFULLPATHNAME}; -} -my $OID_SW_Runargs = $oreon{MIB2}{SW_RUNARGS}; -my $OID_SW_RunIndex =$oreon{MIB2}{SW_RUNINDEX}; -my $OID_SW_RunStatus =$oreon{MIB2}{SW_RUNSTATUS}; - -my ($session, $error); -if ($snmp eq "1" || $snmp eq "2") { -($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); -if (!defined($session)) { - print("UNKNOWN: SNMP Session : $error\n"); - exit $ERRORS{'UNKNOWN'}; -} -}elsif ($opt_k) { - ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k); -if (!defined($session)) { - print("UNKNOWN: SNMP Session : $error\n"); - exit $ERRORS{'UNKNOWN'}; -} -}elsif ($opt_x) { - ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_x); -if (!defined($session)) { - print("UNKNOWN: SNMP Session : $error\n"); - exit $ERRORS{'UNKNOWN'}; -} -} - -$result = $session->get_table(Baseoid => $OID_SW_RunName); -if (!defined($result)) { - printf("UNKNOWN: %s.\n", $session->error); - $session->close; - exit $ERRORS{'UNKNOWN'}; -} - -$proc = 0; -foreach my $key (oid_lex_sort(keys %$result)) { - my @oid_list = split (/\./,$key); - my $args_index = $oid_list[scalar(@oid_list) - 1]; - if (defined($opt_p) && $opt_p ne ""){ - if ($$result{$key} eq $opt_p){ - my $result2 = $session->get_request(-varbindlist => [$OID_SW_Runargs . "." . $args_index]); - if (!defined($result2)) { - printf("UNKNOWN: %s.\n", $session->error); - $session->close; - exit $ERRORS{'UNKNOWN'}; - } - if ($opt_a && $result2->{$OID_SW_Runargs . "." . $args_index} =~ /$opt_a/) { - $proc++ ; - $process_list{$result->{$key}} = pop (@oid_list) ; - }elsif (!$opt_a) { - $process_list{$result->{$key}} = pop (@oid_list) ; - $proc++; - } - } - } else { - $proc++; - } -} - -if (!($opt_n)) -{ - if ($process_list{$process}) { - $result = $session->get_request(-varbindlist => [$OID_SW_RunStatus . "." . $process_list{$process}]); - if (!defined($result)) { - printf("UNKNOWN: %s.\n", $session->error); - $session->close; - exit $ERRORS{'UNKNOWN'}; - } - $proc_run = $result->{$OID_SW_RunStatus . "." . $process_list{$process} }; - } -} -if ($opt_n){ - if ($proc > 0) { - print "Processes OK - Number of current processes: $proc|nbproc=$proc\n"; - exit $ERRORS{'OK'}; - }else { - print "Process CRITICAL - $process not in 'running' state\n"; - exit $ERRORS{'CRITICAL'}; - } -} else { - if ($proc_run){ - print "Process OK - $process: $STATUS{$proc_run}|procstatus=$proc_run\n"; - exit $ERRORS{'OK'}; - } else { - print "Process CRITICAL - $process not in 'running' state\n"; - exit $ERRORS{'CRITICAL'}; - } -} -# Plugin return code -if ( $opt_n) { - if ($proc) { - print "Processes OK - Number of current processes: $proc|nbproc=$proc\n"; - exit $ERRORS{'OK'}; - - }else { - print "Process CRITICAL - $process not in 'running' state\n"; - exit $ERRORS{'CRITICAL'}; - } -}else { - if ($proc_run){ - print "Process OK - $process: $STATUS{$proc_run}|procstatus=$proc_run\n"; - exit $ERRORS{'OK'}; - } else { - print "Process CRITICAL - $process not in 'running' state\n"; - exit $ERRORS{'CRITICAL'}; - } -} - -sub print_usage () { - print "Usage:\n"; - print "$PROGNAME\n"; - print " -H (--hostname) Hostname to query - (required)\n"; - print " -C (--community) SNMP read community (defaults to public,\n"; - print " used with SNMP v1 and v2c\n"; - print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; - print " 2 for SNMP v2c\n"; - print " -a (--arguments) arguments of process you want to check\n"; - print " -f (--full_pathname) process with its full path\n"; - print " -n (--number) Return the number of current running processes. \n"; - print " -p (--process) Set the process name ex: by default smbd\n"; - print " -V (--version) Plugin version\n"; - print " -h (--help) usage help\n"; -} - -sub print_help () { - print "######################################################\n"; - print "# Copyright (c) 2004-2007 Oreon-project #\n"; - print "# Bugs to http://www.oreon-project.org/ #\n"; - print "######################################################\n"; - print_usage(); - print "\n"; -} - diff --git a/src/check_oreon_snmp_process_detailed.pl b/src/check_oreon_snmp_process_detailed similarity index 96% rename from src/check_oreon_snmp_process_detailed.pl rename to src/check_oreon_snmp_process_detailed index b801d0c00..fee93db43 100644 --- a/src/check_oreon_snmp_process_detailed.pl +++ b/src/check_oreon_snmp_process_detailed @@ -8,8 +8,6 @@ # TODO : put $o_delta as an option ############################################################### # -# help : ./check_snmp_process -h - ############### BASE DIRECTORY FOR TEMP FILE ######## my $o_base_dir="/tmp/tmp_Nagios_proc."; my $file_history=200; # number of data to keep in files. diff --git a/src/check_oreon_snmp_remote_storage b/src/check_oreon_snmp_remote_storage index c9d59422f..4ebde14ff 100644 --- a/src/check_oreon_snmp_remote_storage +++ b/src/check_oreon_snmp_remote_storage @@ -28,7 +28,7 @@ use strict; use Net::SNMP qw(:snmp); use FindBin; use lib "$FindBin::Bin"; -use lib "@NAGIOS_PLUGINS@"; +use lib "/srv/nagios/libexec"; use utils qw($TIMEOUT %ERRORS &print_revision &support); if (eval "require oreon" ) { use oreon qw(get_parameters); @@ -48,7 +48,7 @@ my ($hrStorageDescr, $hrStorageAllocationUnits, $hrStorageSize, $hrStorageUsed); my ($AllocationUnits, $Size, $Used); my ($tot, $used, $pourcent, $return_code); -$PROGNAME = "check_snmp_remote_storage"; +$PROGNAME = "$0"; sub print_help (); sub print_usage (); diff --git a/src/check_oreon_snmp_traffic b/src/check_oreon_snmp_traffic index d8466c513..691b2c95b 100644 --- a/src/check_oreon_snmp_traffic +++ b/src/check_oreon_snmp_traffic @@ -28,7 +28,7 @@ use strict; use Net::SNMP qw(:snmp oid_lex_sort); use FindBin; use lib "$FindBin::Bin"; -use lib "@NAGIOS_PLUGINS@"; +use lib "/srv/nagios/libexec"; use utils qw($TIMEOUT %ERRORS &print_revision &support); if (eval "require oreon" ) { use oreon qw(get_parameters); @@ -46,7 +46,7 @@ use vars qw($opt_V $opt_h $opt_v $opt_C $opt_b $opt_k $opt_u $opt_p $opt_H $opt_ my($proc, $proc_run, @test, $row, @laste_values, $last_check_time, $last_in_bits, $last_out_bits, @last_values, $update_time, $db_file, $in_traffic, $out_traffic, $in_usage, $out_usage); -$PROGNAME = "check_graph_traffic"; +$PROGNAME = "$0"; sub print_help (); sub print_usage (); diff --git a/src/check_oreon_snmp_uptime b/src/check_oreon_snmp_uptime new file mode 100644 index 000000000..0387bf70d --- /dev/null +++ b/src/check_oreon_snmp_uptime @@ -0,0 +1,181 @@ +#! /usr/bin/perl -w +# +# $Id: check_graph_uptime.pl,v 1.2 2005/07/27 22:21:49 wistof Exp $ +# +# This plugin is developped under GPL Licence: +# http://www.fsf.org/licenses/gpl.txt + +# Developped by Linagora SA: http://www.linagora.com + +# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf +# Modified For Oreon compatibility by Julien Mathis For Merethis +# +# The Software is provided to you AS IS and WITH ALL FAULTS. +# LINAGORA makes no representation and gives no warranty whatsoever, +# whether express or implied, and without limitation, with regard to the quality, +# safety, contents, performance, merchantability, non-infringement or suitability for +# any particular or intended purpose of the Software found on the LINAGORA web site. +# In no event will LINAGORA be liable for any direct, indirect, punitive, special, +# incidental or consequential damages however they may arise and even if LINAGORA has +# been previously advised of the possibility of such damages. + +# based on "graph plugins" developped by Oreon Team. See http://www.oreon.org. +## +## Plugin init +## +use strict; +use Net::SNMP qw(:snmp); +use FindBin; +use lib "$FindBin::Bin"; +use lib "/srv/nagios/libexec"; +use utils qw($TIMEOUT %ERRORS &print_revision &support); + +if (eval "require oreon" ) { + use oreon qw(get_parameters); + use vars qw($VERSION %oreon); + %oreon=get_parameters(); +} else { + print "Unable to load oreon perl module\n"; + exit $ERRORS{'UNKNOWN'}; +} + +use vars qw($PROGNAME); +use Getopt::Long; +use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_d $day); + +$PROGNAME = $0; +sub print_help (); +sub print_usage (); + +Getopt::Long::Configure('bundling'); +GetOptions + ("h" => \$opt_h, "help" => \$opt_h, + "V" => \$opt_V, "version" => \$opt_V, + "v=s" => \$opt_v, "snmp=s" => \$opt_v, + "C=s" => \$opt_C, "community=s" => \$opt_C, + "d" => \$opt_d, "day" => \$opt_d, + "H=s" => \$opt_H, "hostname=s" => \$opt_H); + +if ($opt_V) { + print_revision($PROGNAME,'$Revision: 1.2 $'); + exit $ERRORS{'OK'}; +} + +if ($opt_h) { + print_help(); + exit $ERRORS{'OK'}; +} + +$opt_H = shift unless ($opt_H); +(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); + + +($opt_v) || ($opt_v = shift) || ($opt_v = "1"); +my $snmp = $1 if ($opt_v =~ /(\d)/); + +($opt_C) || ($opt_C = shift) || ($opt_C = "public"); + +my $start=time; +my $name = $0; +$name =~ s/\.pl.*//g; +my $day = 0; + +## +## Plugin snmp requests +## + +my $OID_OBJECTID =$oreon{MIB2}{OBJECTID}; +my $OID_UPTIME_WINDOWS =$oreon{MIB2}{UPTIME_WINDOWS}; +my $OID_UPTIME_OTHER =$oreon{MIB2}{UPTIME_OTHER}; + +# create a SNMP session +my ( $session, $error ) = Net::SNMP->session(-hostname => $opt_H,-community => $opt_C, -version => $snmp); +if ( !defined($session) ) { + print("CRITICAL: $error"); + exit $ERRORS{'CRITICAL'}; +} + +my $result = $session->get_request( + -varbindlist => [$OID_OBJECTID] + ); +if (!defined($result)) { + printf("UNKNOWN: %s.\n", $session->error); + $session->close; + exit $ERRORS{'UNKNOWN'}; +} + +my $return_result = $result->{$OID_OBJECTID}; +my $OID = ""; +if ($return_result =~ /.*Windows.*/i ) { + $OID = $OID_UPTIME_WINDOWS; +} else { + $OID = $OID_UPTIME_OTHER; +} + +$result = $session->get_request( + -varbindlist => [$OID] + ); +if (!defined($result)) { + printf("UNKNOWN: %s.\n", $session->error); + $session->close; + exit $ERRORS{'UNKNOWN'}; +} + +my $un = 0; + +$return_result = $result->{$OID}; +if ( $return_result =~ m/(\d*) day[s]?,\s*(\d*):(\d*):(\d*).(\d*)/ ) { + $un = $5 + $4 * 100 + $3 * 100 * 60 + $2 * 100 * 60 * 60 + $1 * 100 * 60 * 60 * 24; + $day = $1; +} + +if ( $return_result =~ m/(\d*) hour.*(\d*):(\d*).(\d*)/ ) { + $un = $4 + $3 * 100 + $3 * 100 * 60 + $1 * 100 * 60 * 60 ; +} + +if ($opt_d) { + $un = $day; +} + +#print "un : $un\n"; + +## +## Plugin return code +## + +if ($un || ( $un == 0) ){ + if ($opt_d) { + print "OK - Uptime (in day): $un|uptime=".$un."hs\n"; + } else { + print "OK - Uptime (in hundredths of a second): $un|uptime=".$un."hs\n"; + } + exit $ERRORS{'OK'}; +} +else{ + print "CRITICAL Host unavailable\n"; + exit $ERRORS{'CRITICAL'}; +} + + +sub print_usage () { + print "\nUsage:\n"; + print "$PROGNAME\n"; + print " -H (--hostname) Hostname to query - (required)\n"; + print " -C (--community) SNMP read community (defaults to public,\n"; + print " used with SNMP v1 and v2c\n"; + print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; + print " 2 for SNMP v2c\n"; + print " -d (--day) Uptime in day\n"; + print " -V (--version) Plugin version\n"; + print " -h (--help) usage help\n"; + +} + +sub print_help () { + print "Copyright (c) 2005 Linagora\n"; + print "Modified by Merethis \n"; + print "Bugs to http://www.linagora.com/\n"; + print "\n"; + print_usage(); + print "\n"; +} diff --git a/src/check_oreon_tcp b/src/check_oreon_tcp new file mode 100644 index 000000000..71f945a86 --- /dev/null +++ b/src/check_oreon_tcp @@ -0,0 +1,115 @@ +#! /usr/bin/perl -w +# $Id: check_graph_tcp.pl,v 1.2 2005/08/01 17:50:50 gollum123 Exp $ +# +# Oreon's plugins are developped with GPL Licence : +# http://www.fsf.org/licenses/gpl.txt +# Developped by : Julien Mathis - Romain Le Merlus +# +# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf +# Modified By Julien Mathis - Sugumaran Mathavarajan For Merethis Company +# +# The Software is provided to you AS IS and WITH ALL FAULTS. +# OREON makes no representation and gives no warranty whatsoever, +# whether express or implied, and without limitation, with regard to the quality, +# safety, contents, performance, merchantability, non-infringement or suitability for +# any particular or intended purpose of the Software found on the OREON web site. +# In no event will OREON be liable for any direct, indirect, punitive, special, +# incidental or consequential damages however they may arise and even if OREON has +# been previously advised of the possibility of such damages. + +use strict; +use FindBin; +use lib "$FindBin::Bin"; +#use lib "/srv/nagios/libexec"; +use lib "/usr/lib/nagios/plugins"; +use utils qw($TIMEOUT %ERRORS &print_revision &support); + +if (eval "require oreon" ) { + use oreon qw(get_parameters); + use vars qw($VERSION %oreon); + %oreon=get_parameters(); +} else { + print "Unable to load oreon perl module\n"; + exit $ERRORS{'UNKNOWN'}; +} + +use Getopt::Long; +use vars qw($opt_V $opt_h $opt_p $opt_c $opt_w $opt_H); +use vars qw($PROGNAME); + +my $pathtolibexectcp = $oreon{GLOBAL}{NAGIOS_LIBEXEC}."check_tcp"; + +sub print_help (); +sub print_usage (); +$PROGNAME = "$0"; + +# +# get options +# + +Getopt::Long::Configure('bundling'); +GetOptions + ("h|help" => \$opt_h, + "V|version" => \$opt_V, + "H|hostname=s" => \$opt_H, + "p|port=s" => \$opt_p, + "w|warning=s" => \$opt_w, + "c|critical=s" => \$opt_c); + +if (defined($opt_h)) { + print_help(); + exit $ERRORS{'OK'}; +} + +$opt_H = shift unless ($opt_H); +(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H); + +$opt_p = shift unless ($opt_p); +(print_usage() && exit $ERRORS{'OK'}) unless ($opt_p); + + +################################################## +#### Create Command line +# + +my $args_check_tcp = "-H $opt_H -p $opt_p"; +$args_check_tcp .= " -w $opt_w -c $opt_c" if ($opt_w && $opt_c); + +my $start=time; + + +my $result = `$pathtolibexectcp $args_check_tcp`; +my $return_code = $? / 256; +$_ = $result; +m/(\d*\.\d*) second/; +my $time = $1; + +print "$result"; +exit $return_code; + +sub print_usage () { + print "\nUsage:\n"; + print $0."\n"; + print "\t-H (--hostname)\t\tHostname to query (required)\n"; + print "\t-p, --port\t\tPort number (required)\n"; + print "\t-w, --warning\t\tResponse time to result in warning status (seconds) - optional\n"; + print "\t-c, --critical\t\tResponse time to result in critical status (seconds) - optional\n"; + print "\t-V (--version)\t\tVieuw plugin version\n"; + print "\t-h (--help)\t\tusage help\n"; + +} + +sub print_help () { + print "################################################\n"; + print "# Bugs to http://bugs.oreon-project.org/ #\n"; + print "################################################\n"; + print "\n"; + print_usage(); + print "\n"; +} + + + + + + diff --git a/src/traps/snmptrapd.conf b/src/traps/snmptrapd.conf new file mode 100644 index 000000000..351a86b1c --- /dev/null +++ b/src/traps/snmptrapd.conf @@ -0,0 +1,76 @@ +########################################################################### +# +# snmptrapd.conf +# +# - created by the snmpconf configuration program +# +########################################################################### +# SECTION: Trap Handlers +# +# Here we define what programs are run when a trap is +# received by the trap receiver. + +# traphandle: When traps are received, a program can be run. +# When traps are received, the list of configured trap +# handles is consulted and any configured program is run. +# If no handler is found, any handler with "default" as the +# traphandle type is run instead. The information contained +# in trap is passed to the program via standard input (see +# the snmptrapd.conf manual page for details). +# +# arguments: oid|"default" program args + +traphandle default /usr/sbin/snmptt --ini=/etc/snmp/oreon_traps/snmptt.ini + + + +########################################################################### +# SECTION: Runtime options +# +# Runtime options + +# donotfork: Do not fork from the shell +# arguments: (1|yes|true|0|no|false) + +donotfork 1 + +# pidfile: Store Process ID in file +# arguments: PID file + +pidfile /var/run/snmptrapd.pid + + + +########################################################################### +# SECTION: Logging options +# +# Logging options + +# donotlogtraps: Prevent traps from being logged +# Useful when you only want to use traphandles +# arguments: (1|yes|true|0|no|false) + +donotlogtraps 0 + + + + + + +########################################################################### +# SECTION: Authentication options +# +# Authentication options + +# ignoreauthfailure: Ignore authentication failure traps +# arguments: (1|yes|true|0|no|false) + +ignoreauthfailure 0 +ignoreauthfailure no + + + +# +# Unknown directives read in from other files by snmpconf +# +disableAuthorization yes diff --git a/src/traps/snmptt.ini b/src/traps/snmptt.ini new file mode 100644 index 000000000..313ab4ed5 --- /dev/null +++ b/src/traps/snmptt.ini @@ -0,0 +1,489 @@ +# +# SNMPTT v1.0 Configuration File +# +# Linux / Unix +# + +[General] +# Set to either 'standalone' or 'daemon' +# standalone: snmptt called from snmptrapd.conf +# daemon: snmptrapd.conf calls snmptthandler +# Ignored by Windows. See documentation +mode = standalone + +# Set to 1 to allow multiple trap definitions to be executed for the same trap. +# Set to 0 to have it stop after the first match. +# Note: Wildcard matches are only matched if there are NO exact matches. This takes +# into consideration the NODES list. Therefore, if there is a matching trap, but +# the NODES list prevents it from being considered a match, the wildcard entry will +# only be used if there are no other exact matches. +multiple_event = 1 + +# SNMPTRAPD passes the IP address of device sending the trap, and the IP address of the +# actual SNMP agent. These addresses could differ if the trap was sent on behalf of another +# device (relay, proxy etc). +# If DNS is enabled, the agent IP address is converted to a host name using a DNS lookup +# (which includes the local hosts file, depending on how the OS is configured). This name +# will be used for: NODES entry matches, hostname field in logged traps (file / database), +# and the $A variable. Host names on the NODES line will be resolved and the IP address +# will then be used for comparing. +# Set to 0 to disable DNS resolution +# Set to 1 to enable DNS resolution +dns_enable = 0 + +# Set to 0 to enable the use of FQDN (Fully Qualified Domain Names). If a host name is +# passed to SNMPTT that contains a domain name, it will not be altered in any way by +# SNMPTT. This also affects resolve_value_ip_addresses. +# Set to 1 to have SNMPTT strip the domain name from the host name passed to it. For +# example, server01.domain.com would be changed to server01 +# Set to 2 to have SNMPTT strip the domain name from the host name passed to it +# based on the list of domains in strip_domain_list +strip_domain = 0 + +# List of domain names that should be stripped when strip_domain is set to 2. +# List can contain one or more domains. For example, if the FQDN of a host is +# server01.city.domain.com and the list contains domain.com, the 'host' will be +# set as server01.city. +strip_domain_list = <