From 528dcba4649fb1573e3e5e1793df24eb8f79c7f0 Mon Sep 17 00:00:00 2001 From: Mat Sugumaran Date: Thu, 26 Jul 2007 09:40:58 +0000 Subject: [PATCH] new plugins + 1 deleted git-svn-id: http://svn.centreon.com/Plugins/Dev@2785 6bcd3966-0018-0410-8128-fd23d134de7e --- src/check_centreon_dell_temperature | 180 ------- src/check_centreon_dummy | 90 ++++ src/check_centreon_snmp_process_detailed | 626 +++++++++++++++++++++++ 3 files changed, 716 insertions(+), 180 deletions(-) delete mode 100644 src/check_centreon_dell_temperature create mode 100644 src/check_centreon_dummy create mode 100644 src/check_centreon_snmp_process_detailed diff --git a/src/check_centreon_dell_temperature b/src/check_centreon_dell_temperature deleted file mode 100644 index a98d92c4c..000000000 --- a/src/check_centreon_dell_temperature +++ /dev/null @@ -1,180 +0,0 @@ -#! /usr/bin/perl -w -# -# $Id: check_graph_dell_temperature,v 1.4 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 - Sugumaran Mathavarajan -# -# 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 Net::SNMP qw(:snmp oid_lex_sort); -use FindBin; -use lib "$FindBin::Bin"; -use 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 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_centreon_dummy b/src/check_centreon_dummy new file mode 100644 index 000000000..b0d97d346 --- /dev/null +++ b/src/check_centreon_dummy @@ -0,0 +1,90 @@ +#! /usr/bin/perl -w +# +# $Id: check_packetsErrors.pl,v 1.2 2005/07/27 22:21:49 Julio $ +# +# Oreon's plugins are developped with GPL Licence : +# http://www.fsf.org/licenses/gpl.txt +# Developped by : Julien Mathis - Romain Le Merlus - Sugumaran Mat +# +# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf +# Modified By Julien Mathis 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 vars qw($PROGNAME); +use Getopt::Long; +use vars qw($opt_h $opt_s $opt_o); + +################################################# +### Plugin var init +## +$PROGNAME = "$0"; + +sub print_help (); +sub print_usage (); + +Getopt::Long::Configure('bundling'); +GetOptions + ("h" => \$opt_h, "help" => \$opt_h, + "s=s" => \$opt_s, "status=s" => \$opt_s, + "o=s" => \$opt_o, "output=s" => \$opt_o); + + +################################################## +#### Verify Options +## + +if ($opt_h) { + print_help(); + exit 0; +} + +if (!defined($opt_s)) { + print_usage && exit 0; +} +if ($opt_s ne "0" && $opt_s ne "0" && $opt_s ne "0" && $opt_s ne "0") { + print_usage; + exit 0; +} +if (!$opt_o) { + $opt_o = "OK"; +} + +################################################# +## result +# + +$opt_o .= "\n"; +print $opt_o; +exit $opt_s; + +sub print_usage () { + print "Usage:"; + print "$PROGNAME\n"; + print " -s (--status) status that must be returned [0-3]\n"; + print " -o (--output) output that must be returned\n"; + print " -h (--help) usage help\n"; +} + +sub print_help () { + print "##########################################\n"; + print "# Copyright (c) 2004-2006 Oreon #\n"; + print "# Bugs to http://www.oreon-project.org/ #\n"; + print "##########################################\n"; + print_usage(); + print "\n"; +} diff --git a/src/check_centreon_snmp_process_detailed b/src/check_centreon_snmp_process_detailed new file mode 100644 index 000000000..ea88f53b9 --- /dev/null +++ b/src/check_centreon_snmp_process_detailed @@ -0,0 +1,626 @@ +#!/usr/bin/perl -w +############################## check_snmp_process ############## +# Version : 1.2.1 +# Date : Dec 12 2004 +# Author : Patrick Proy (patrick at proy.org) +# Help : http://www.manubulon.com/nagios/ +# Licence : GPL - http://www.fsf.org/licenses/gpl.txt +# TODO : put $o_delta as an option +############################################################### +# +# help : ./check_snmp_process -h + +############################## check_oreon_snmp_process_detailed ############## +# Version : 1.2.2 +# Date : Jun 20 2007 +# Author : Sugumaran Mathavarajan - msugumaran@merethis.com +# Company : Merethis +# Licence : GPL - http://www.fsf.org/licenses/gpl.txt +# 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. +my $delta_of_time_to_make_average=300; # 5minutes by default + +use strict; +use Net::SNMP; +use Getopt::Long; + +# Nagios specific + +use lib "/srv/nagios/libexec"; +use utils qw(%ERRORS $TIMEOUT); + +# Oreon specific + +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'}; +} + +# SNMP Datas +my $process_table= '1.3.6.1.2.1.25.4.2.1'; +my $index_table = '1.3.6.1.2.1.25.4.2.1.1'; +my $run_name_table = '1.3.6.1.2.1.25.4.2.1.2'; +my $run_path_table = '1.3.6.1.2.1.25.4.2.1.4'; +my $proc_mem_table = '1.3.6.1.2.1.25.5.1.1.2'; # Kbytes +my $proc_cpu_table = '1.3.6.1.2.1.25.5.1.1.1'; # Centi sec of CPU +my $proc_run_state = '1.3.6.1.2.1.25.4.2.1.7'; + +# Globals + +my $Version='1.2.1'; + +my $o_host = undef; # hostname +my $o_community =undef; # community +my $o_port = 161; # port +my $o_descr = undef; # description filter +my $o_warn = 0; # warning limit +my @o_warnL= undef; # warning limits (min,max) +my $o_crit= 0; # critical limit +my @o_critL= undef; # critical limits (min,max) +my $o_help= undef; # wan't some help ? +my $o_verb= undef; # verbose mode +my $o_version= undef; # print version +my $o_noreg= undef; # Do not use Regexp for name +my $o_path= undef; # check path instead of name +my $o_inverse= undef; # checks max instead of min number of process +my $o_timeout= 5; # Default 5s Timeout +# SNMP V3 specific +my $o_login= undef; # snmp v3 login +my $o_passwd= undef; # snmp v3 passwd +# Memory & CPU +my $o_mem= undef; # checks memory (max) +my @o_memL= undef; # warn and crit level for mem +my $o_mem_avg= undef; # cheks memory average +my $o_cpu= undef; # checks CPU usage +my @o_cpuL= undef; # warn and crit level for cpu +my $o_delta= $delta_of_time_to_make_average; # delta time for CPU check +# Oreon specific +my $o_step= undef; +my $o_g= undef; +my $o_S= undef; +my $step= undef; +my $rrd= undef; +my $start= undef; +my $ServiceId= undef; +my @rrd_data= undef; + +# functions + +sub p_version { print "check_snmp_process version : $Version\n"; } + +sub print_usage { + print "Usage: $0 [-v] -H -C | (-l login -x passwd) [-p ] -n [-w [,] -c [,max_proc] ] [-m, -a -u, ] [-t ] [-f ] [-r] [-V]\n"; +} + +sub isnotnum { # Return true if arg is not a number + my $num = shift; + if ( $num =~ /^(\d+\.?\d*)|(^\.\d+)$/ ) { return 0 ;} + return 1; +} + +# Get the alarm signal (just in case snmp timout screws up) +$SIG{'ALRM'} = sub { + print ("ERROR: Alarm signal (Nagios time-out)\n"); + exit $ERRORS{"UNKNOWN"}; +}; + +sub read_file { + # Input : File, items_number + # Returns : array of value : [line][item] + my ($traffic_file,$items_number)=@_; + my ($ligne,$n_rows)=(undef,0); + my (@last_values,@file_values,$i); + open(FILE,"<".$traffic_file) || return (1,0,0); + + while($ligne = ) + { + chomp($ligne); + @file_values = split(":",$ligne); + #verb("@file_values"); + if ($#file_values >= ($items_number-1)) { + # check if there is enough data, else ignore line + for ( $i=0 ; $i< $items_number ; $i++ ) {$last_values[$n_rows][$i]=$file_values[$i]; } + $n_rows++; + } + } + close FILE; + if ($n_rows != 0) { + return (0,$n_rows,@last_values); + } else { + return (1,0,0); + } +} + +sub write_file { + # Input : file , rows, items, array of value : [line][item] + # Returns : 0 / OK, 1 / error + my ($file_out,$rows,$item,@file_values)=@_; + my $start_line= ($rows > $file_history) ? $rows - $file_history : 0; + if ( open(FILE2,">".$file_out) ) { + for (my $i=$start_line;$i<$rows;$i++) { + for (my $j=0;$j<$item;$j++) { + print FILE2 $file_values[$i][$j]; + if ($j != ($item -1)) { print FILE2 ":" }; + } + print FILE2 "\n"; + } + close FILE2; + return 0; + } else { + return 1; + } +} + +sub help { + print "\nSNMP Process Monitor for Nagios version ",$Version,"\n"; + print "(c)2004 to my cat Ratoune - Author: Patrick Proy\n\n"; + print_usage(); + print < 100% : 100%=1 CPU +-t, --timeout=INTEGER + timeout for SNMP in seconds (Default: 5) +-V, --version + prints version number +-g (--rrdgraph) Create a rrd base if necessary and add datas into this one +--rrd_step Specifies the base interval in seconds with which data will be fed into the RRD (300 by default) +-S (--ServiceId) Oreon Service Id + +Note : + CPU usage is in % of one cpu, so maximum can be 100% * number of CPU + example : + Browse process list :