diff --git a/centreon-plugins/Dev/.project b/centreon-plugins/Dev/.project deleted file mode 100644 index bc15201e8..000000000 --- a/centreon-plugins/Dev/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - Plugins - - - - - - - - diff --git a/centreon-plugins/Dev/CHANGELOG b/centreon-plugins/Dev/CHANGELOG deleted file mode 100644 index 2ece92566..000000000 --- a/centreon-plugins/Dev/CHANGELOG +++ /dev/null @@ -1,22 +0,0 @@ -########################## -# Oreon Plugins Change Log -########################## - -1.2.3 - 02/11/2005 ----------------- -* Enhanced Oreon Perl Package oreon.pm (wistof) -* Integration of some Manubulon plugins (wistof) -* New install script for plugins (wistof) -* Minor bug fixes - -1.2.2 - xx/08/2005 ----------------- -* Add Oreon Perl Package oreon.pm (gollum123) -* Globalization of paths in oreon.conf (gollum123) -* Management of RRDTOOL errors (wistof) -* Use Net::SNMP instead of snmpwalk and snmpget (wistof) -* Disable regex for '-H' option (wistof) -* Minor bug fixes - - - diff --git a/centreon-plugins/Dev/INSTALL b/centreon-plugins/Dev/INSTALL deleted file mode 100644 index ebefe6175..000000000 --- a/centreon-plugins/Dev/INSTALL +++ /dev/null @@ -1,8 +0,0 @@ -############################ -# Oreon Plugins Installation -############################ - -- just run install.sh in src/ directory -- don't directly copy plugins in Nagios plugins directory - - diff --git a/centreon-plugins/Dev/REQUIREMENT b/centreon-plugins/Dev/REQUIREMENT deleted file mode 100644 index 1ba6eba1d..000000000 --- a/centreon-plugins/Dev/REQUIREMENT +++ /dev/null @@ -1,12 +0,0 @@ -########################### -# Oreon Plugins Requirement -########################### - -- Perl in /usr/bin/perl - or just run 'perl script' -- Net::SNMP -- Config::IniFiles -- RRDTool installed (RRDs.pm) -- Oreon perl module (oreon.pm) -- Oreon configuration file for Oreon perl module (oreon.conf) -- file 'utils.pm' in plugin diretory (/usr/local/nagios/libexec) -- sed program for installation script \ No newline at end of file diff --git a/centreon-plugins/Dev/install.sh b/centreon-plugins/Dev/install.sh deleted file mode 100644 index b952bc377..000000000 --- a/centreon-plugins/Dev/install.sh +++ /dev/null @@ -1,228 +0,0 @@ -#!/bin/sh -# -# Oreon is developped with Apache Licence 2.0 : -# http://www.apache.org/licenses/LICENSE-2.0.txt -# Developped by : Julien Mathis - Romain Le Merlus -# Christophe Coraboeuf - Mathieu Chateau - -# 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. - -#Load install script functions -. ../functions - -## -## VARIABLES -## -## Make sure you know what you do if you modify it !! - -PWD=`pwd` - -PLUGINS_DIR="" - -LOG_FILE="../log/install_oreon.log" - -date > $LOG_FILE - -echo -echo "##########################################################################" -echo "# OREON Project (www.oreon-project.org) #" -echo "# Thanks for using OREON #" -echo "# #" -echo "# v 1.2.3 #" -echo "# #" -echo "# infos@oreon-project.org #" -echo "# #" -echo "# Make sure you have installed and configured #" -echo "# perl - sed #" -echo "# #" -echo "# #" -echo "##########################################################################" -echo "# The Team OREON #" -echo "##########################################################################" -echo "" -echo "" -$SETCOLOR_WARNING -echo " Make sure you have root permissions !" -$SETCOLOR_NORMAL -echo "" - -echo "Are you sure to continue?" -echo -n "[y/n], default to [n]:" -read temp -if [ -z $temp ];then - temp=n -fi - -if [ $temp = "n" ];then - echo "Bye bye !" - exit -fi - -test_answer() -{ - #$1 variable to fill - #$2 text typed by user - if [ ! -z $2 ];then - if [ $2 != "" ];then - eval $1=$2 - fi - fi -} - -## -## CONFIGURATION -## -if test -a $OREON_CONF ; then - echo "" - echo_success "Finding Oreon configuration file '$OREON_CONF' :" "OK" - echo "You already seem to have to install Oreon." - echo "Do you want use last Oreon install parameters ?" - echo -n "[y/n], default to [y]:" - read temp - if [ -z $temp ];then - temp=y - fi - - if [ $temp = "y" ];then - echo "" - echo_passed "Using '$OREON_CONF' :" "PASSED" - . $OREON_CONF - echo "" - else - echo "" - echo "First, let's talk about you !" - echo "-----------------------------" - echo "" - fi -fi - if [ -z $INSTALL_DIR_NAGIOS ];then - INSTALL_DIR_NAGIOS="/usr/local/nagios" - echo "Where is installed Nagios ?" - echo -n "default to [$INSTALL_DIR_NAGIOS]:" - read temp - test_answer INSTALL_DIR_NAGIOS $temp - echo "" - fi - - if [ -z $NAGIOS_ETC ];then - #nagios etc directory for oreon - NAGIOS_ETC="$INSTALL_DIR_NAGIOS/etc" - echo "Where are your nagios etc directory ?" - echo -n "default to [$NAGIOS_ETC]:" - read temp - test_answer NAGIOS_ETC $temp - echo "" - fi - - if [ -z $NAGIOS_PLUGIN ];then - #nagios plugins directory for oreon - NAGIOS_PLUGIN="$INSTALL_DIR_NAGIOS/libexec" - echo "Where are your nagios plugin / libexec directory ?" - echo -n "default to [$NAGIOS_PLUGIN]:" - read temp - test_answer NAGIOS_PLUGIN $temp - echo "" - fi - - if [ -z $INSTALL_DIR_OREON ];then - #setup directory for oreon - INSTALL_DIR_OREON="/usr/local/oreon" - echo "Where do I install Oreon ?" - echo -n "default to [$INSTALL_DIR_OREON]:" - read temp - test_answer INSTALL_DIR_OREON $temp - echo "" - fi - - if [ -z $SUDO_FILE ];then - #Configuration file for sudo - SUDO_FILE="/etc/sudoers" - echo "Where is sudo ?" - echo -n "default to [$SUDO_FILE]:" - read temp - test_answer SUDO_FILE $temp - echo "" - fi - - if [ -z $RRD_PERL ];then - #RRDTOOL perl module directory - RRD_PERL="/usr/local/rrdtool/lib/perl" - echo "Where is RRD perl modules RRDs.pm ?" - echo -n "default to [$RRD_PERL]:" - read temp - test_answer RRD_PERL $temp - echo "" - fi - -## -## FUNCTION -## - -# When exit on error - -function error() -{ - echo "ERROR" - exit 2 -} - -# install OREON PLUGIN - -function confirm_oreon() -{ - install_oreon_plugins -} - -# installation script - -#check_group_nagios -#check_user_nagios -#check_group_nagiocmd -#confirm_oreon - -## -## INSTALL -## -echo "Users Management" -echo "----------------" -# check for httpd directory -check_httpd_directory -## group apache -check_group_apache -## user apache -check_user_apache -check_group_nagios -check_user_nagios -echo "" - -echo "Other Stuff" -echo "------------" -if test -d $NAGIOS_PLUGIN ; then - echo_success "Nagios libexec directory" "OK" -else - mkdir -p $NAGIOS_PLUGIN > /dev/null - echo_success "Nagios libexec directory created" "OK" -fi - -# installation script - -confirm_oreon -#oreon_post_install - -echo "" -echo "###############################################################################" -echo "# #" -echo "# Report bugs at bugs@oreon-project.org #" -echo "# #" -echo "# Thanks for using OREON. #" -echo "# ----------------------- #" -echo "# Contact : infos@oreon-project.org #" -echo "# http://www.oreon-project.org #" -echo "###############################################################################" diff --git a/centreon-plugins/Dev/src/check_centreon_TcpConn b/centreon-plugins/Dev/src/check_centreon_TcpConn deleted file mode 100644 index b21bcaebc..000000000 --- a/centreon-plugins/Dev/src/check_centreon_TcpConn +++ /dev/null @@ -1,147 +0,0 @@ -#! /usr/bin/perl -w -# -# $Id: check_TcpConn.pl,v 1.2 2005/11/17 10:21:49 Sugumaran Mat $ -# -# This plugin is developped under GPL Licence: -# http://www.fsf.org/licenses/gpl.txt -# -# Developped by Merethis SARL : http://www.merethis.com -# -# The Software is provided to you AS IS and WITH ALL FAULTS. -# MERETHIS 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 MERETHIS be liable for any direct, indirect, punitive, special, -# incidental or consequential damages however they may arise and even if MERETHIS has -# been previously advised of the possibility of such damages. - -## -## Plugin init -## - -use strict; -use Net::SNMP qw(:snmp); -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 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_V $opt_H $opt_C $opt_v $opt_p $opt_c $opt_w); -use vars qw($snmp); - -$PROGNAME = "ckeck_TcpConn"; -sub print_help (); -sub print_usage (); - -Getopt::Long::Configure('bundling'); -GetOptions - ("h" => \$opt_h, "help" => \$opt_h, - "v=s" => \$opt_v, "snmp_version" => \$opt_v, - "V" => \$opt_V, "version" => \$opt_V, - "H=s" => \$opt_H, "Hostname" => \$opt_H, - "p=i" => \$opt_p, "port" => \$opt_p, -<<<<<<< .mine - "C=s" => \$opt_c, "Community" => \$opt_c -======= - "C=s" => \$opt_C, "Community" => \$opt_C, - "c=s" => \$opt_c, "w=s" => \$opt_w ->>>>>>> .r479 -); - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 1.0'); - 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_p = shift unless ($opt_p); -(print_usage() && exit $ERRORS{'OK'}) unless ($opt_p); - -($opt_v) || ($opt_v = shift) || ($opt_v = "v1"); -my $snmp = $1 if ($opt_v =~ /(\d)/); - -($opt_C) || ($opt_C = shift) || ($opt_C = "public"); - -my $name = $0; -$name =~ s/\.pl.*//g; -my $day = 0; - -#=== create a SNMP session ==== -# 1.3.6.1.4.1.232.1.2.2.1.1.6 - -my ($session, $error) = Net::SNMP->session(-hostname => $opt_H,-community => $opt_C, -version => $snmp); -if (!defined($session)) { - print("CRITICAL: $error"); - exit $ERRORS{'CRITICAL'}; -} - -my $OID_TCP_PORT = ".1.3.6.1.2.1.6.13.1.3"; - -my $result = $session->get_table(Baseoid => $OID_TCP_PORT); -if (!defined($result)) { - printf("ERROR: Description Table : %s.\n", $session->error); - $session->close; - exit $ERRORS{'UNKNOWN'}; -} - -my $cpt = 0; -foreach my $key (oid_lex_sort(keys %$result)) { - if ($result->{$key} == $opt_p) { - $cpt++; - } -} - -if (!defined($opt_w)){$opt_w = 20;} -if (!defined($opt_c)){$opt_c = 30;} - -print "Number of connections on port $opt_p : $cpt |nb_conn=$cpt\n"; -if ($cpt >= $opt_w && $cpt < $opt_c){ - exit $ERRORS{'WARNING'}; -} elsif ($cpt >= $opt_c){ - exit $ERRORS{'CRITICAL'}; -} else { - exit $ERRORS{'OK'}; -} - - -sub print_usage () { - print "\nUsage:\n"; - print "$PROGNAME\n"; - print " -H (--hostname) Hostname to query - (required)\n"; - print " -p (--port) port you want to check - (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 " -V (--version) Plugin version\n"; - print " -h (--help) usage help\n"; -} - -sub print_help () { - print "#=========================================\n"; - print "# Copyright (c) 2005 Merethis SARL =\n"; - print "# Developped by Julien Mathis =\n"; - print "# Bugs to http://www.oreon-project.org/ =\n"; - print "#=========================================\n"; - print_usage(); - print "\n"; -} diff --git a/centreon-plugins/Dev/src/check_centreon_dell_temperature b/centreon-plugins/Dev/src/check_centreon_dell_temperature deleted file mode 100644 index a98d92c4c..000000000 --- a/centreon-plugins/Dev/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/centreon-plugins/Dev/src/check_centreon_http b/centreon-plugins/Dev/src/check_centreon_http deleted file mode 100644 index 8b15905af..000000000 --- a/centreon-plugins/Dev/src/check_centreon_http +++ /dev/null @@ -1,191 +0,0 @@ -#! /usr/bin/perl -w -# -# $Id: check_graph_http,v 1.4 2005/08/01 18:03:52 gollum123 Exp $ -# -# This plugin is developped under GPL Licence: -# http://www.fsf.org/licenses/gpl.txt -# -# Modified for Oreon Project by : Sugumaran Mathavarajan - 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. - -## -## Plugin init -## -use strict; -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 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/centreon-plugins/Dev/src/check_centreon_nt b/centreon-plugins/Dev/src/check_centreon_nt deleted file mode 100644 index 830a81a58..000000000 --- a/centreon-plugins/Dev/src/check_centreon_nt +++ /dev/null @@ -1,336 +0,0 @@ -#! /usr/bin/perl -w -# -# $Id: check_graph_nt.pl,v 1.4 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 -# -# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf -# Modified for Oreon Project by : Sugumaran Mathavarajan - msugumaran@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 "@NAGIOS_PLUGINS@"; -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/centreon-plugins/Dev/src/check_centreon_packetErrors b/centreon-plugins/Dev/src/check_centreon_packetErrors deleted file mode 100644 index 572c0f686..000000000 --- a/centreon-plugins/Dev/src/check_centreon_packetErrors +++ /dev/null @@ -1,243 +0,0 @@ -#! /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 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($VERSION %oreon); -use vars qw(%oreon); -$VERSION = '$Revision: 1.2 $'; -$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/; - -use vars qw($PROGNAME); -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_v $opt_C $opt_H $opt_w $opt_c); - -# -# Plugin var init -# -$PROGNAME = "$0"; - -my ($row, @flg_created, @last_check_time, @last_in_errors, @last_out_errors, $result_in, $result_out, @nb_out_errors, @nb_in_errors, $update_time, $db_file); -my $pathtolibexecnt = $oreon{NAGIOS_LIBEXEC}; - -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, - "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: 1.2 $'); - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -################################################## -##### Verify Options -## - -$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"); -($opt_c) || ($opt_c = shift) || ($opt_c = 100); -my $critical = $1 if ($opt_c =~ /([0-9]+)/); - -($opt_w) || ($opt_w = shift) || ($opt_w = 80); -my $warning = $1 if ($opt_w =~ /([0-9]+)/); - -if ($critical <= $warning){ - print "(--crit) must be superior to (--warn)"; - print_usage(); - exit $ERRORS{'OK'}; -} - -my $start=time; - - -################################################# -##### Plugin snmp requests -## - -my $OID_IN_ERRORS = ".1.3.6.1.2.1.2.2.1.14"; -my $OID_OUT_ERRORS = ".1.3.6.1.2.1.2.2.1.20"; - - -# create a SNMP session - -my ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp); -if (!defined($session)) { - print("UNKNOWN: SNMP Session : $error"); - exit $ERRORS{'UNKNOWN'}; -} - -####### Get IN ERRORS - -$result_in = $session->get_table(Baseoid => $OID_IN_ERRORS); -if (!defined($result_in)) { - printf("ERROR: IN_ERRORS : %s.\n", $session->error); - $session->close; - exit $ERRORS{'UNKNOWN'}; -} - -# loop for each interface -foreach my $err (oid_lex_sort(keys %$result_in)) { - $nb_in_errors[scalar(@nb_in_errors)] = $result_in->{$err}; -} -# ####### Get OUT ERRORS - -$result_out = $session->get_table(Baseoid => $OID_OUT_ERRORS); -if (!defined($result_out)) { - printf("ERROR: OUT_ERRORS : %s.\n", $session->error); - $session->close; - exit $ERRORS{'UNKNOWN'}; -} -foreach my $err (oid_lex_sort(keys %$result_out)) { - $nb_out_errors[scalar(@nb_out_errors)] = $result_out->{$err}; -} - -# ############################################# -# ##### read and write in buffer file -# ## - -for (my $i = 0; $i < scalar(@nb_in_errors); $i++) { - if (-e "/tmp/packet_errors_if".$i."_".$opt_H.".tmp") { - open(FILE,"<"."/tmp/packet_errors_if".$i."_".$opt_H.".tmp"); - while($row = ){ - my @last_values = split(":",$row); - $last_check_time[$i] = $last_values[0]; - $last_in_errors[$i] = $last_values[1]; - $last_out_errors[$i] = $last_values[2]; - $flg_created[$i] = 1; - } - close(FILE); - } else { - $flg_created[$i] = 0; - } - - $update_time = time; - - unless (open(FILE,">"."/tmp/packet_errors_if".$i."_".$opt_H.".tmp")){ - print "Unknown - /tmp/tmp/packet_errors_if".$i."_".$opt_H.".tmp!\n"; - exit $ERRORS{"UNKNOWN"}; - } - print FILE "$update_time:$nb_in_errors[$i]:$nb_out_errors[$i]"; - close(FILE); - if ($flg_created[$i] eq 0){ - print "First execution : Buffer in creation.... \n"; - } -} - -# ############################################# -# ##### return result -# ## -my $status = "OK"; -my @msg; -my $diff_test = 0; -for (my $i = 0; $i < scalar(@nb_in_errors); $i++) { - my $interface = $i+1; - if ($flg_created[$i]) { - if (($nb_in_errors[$i] - $last_in_errors[$i] >= $critical) or ($nb_out_errors[$i] - $last_out_errors[$i] >= $critical)){ - $msg[$i] = "$interface:critical "; - $status = "CRITICAL"; - } - if(($nb_in_errors[$i] - $last_in_errors[$i] >= $warning) or ($nb_out_errors[$i] - $last_out_errors[$i] >= $warning)){ - if (!defined($msg[$i])) { - $msg[$i] = "$interface:warning "; - } - if ($status ne "CRITICAL") { - $status = "WARNING"; - } - } - $diff_test = 1; - } -} - -if (!$diff_test) { - exit($ERRORS{'UNKNOWN'}); -} -my $output = ""; -for (my $i = 0; $i < scalar (@msg); $i++) { - if (defined($msg[$i])) { - $output .= $msg[$i]; - } -} -if ($output ne ""){ - print $output."\n"; -}else { - print "Status OK on all interfaces\n"; -} -exit($ERRORS{$status}); - sub print_usage () { - print "\nUsage:\n"; - print "$PROGNAME\n"; - print " -H (--hostname) Hostname to query - (required)\n"; - print " -C (--community) SNMP read community (default 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 " -w (--warn) Signal strength at which a warning message will be generated\n"; - print " (default 80)\n"; - print " -c (--crit) Signal strength at which a critical message will be generated\n"; - print " (default 100)\n"; - print " -V (--version) Plugin version\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/centreon-plugins/Dev/src/check_centreon_ping b/centreon-plugins/Dev/src/check_centreon_ping deleted file mode 100644 index 29da08658..000000000 --- a/centreon-plugins/Dev/src/check_centreon_ping +++ /dev/null @@ -1,201 +0,0 @@ -#! /usr/bin/perl -w -# -# $Id: check_oreon_ping,v 1.3 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 "@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); -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/centreon-plugins/Dev/src/check_centreon_snmp_loadaverage b/centreon-plugins/Dev/src/check_centreon_snmp_loadaverage deleted file mode 100644 index 36373524e..000000000 --- a/centreon-plugins/Dev/src/check_centreon_snmp_loadaverage +++ /dev/null @@ -1,203 +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 -# Mathavarajan Sugumaran -# -################################################################### -# 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); -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); -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_v $opt_C $opt_H $opt_c $opt_w $opt_D $snmp $opt_k $opt_u $opt_p @critical @warning); - -# Plugin var init - -my($return_code); - -$PROGNAME = "$0"; -sub print_help (); -sub print_usage (); - -Getopt::Long::Configure('bundling'); -GetOptions - ("h" => \$opt_h, "help" => \$opt_h, - "u=s" => \$opt_u, "username=s" => \$opt_u, - "p=s" => \$opt_p, "password=s" => \$opt_p, - "k=s" => \$opt_k, "key=s" => \$opt_k, - "V" => \$opt_V, "version" => \$opt_V, - "v=s" => \$opt_v, "snmp=s" => \$opt_v, - "C=s" => \$opt_C, "community=s" => \$opt_C, - "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: 1.2 $'); - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -if (!$opt_H) { - print_usage(); - exit $ERRORS{'OK'}; -} - -my $snmp = "1"; -$snmp = $opt_v if ($opt_v && $opt_v =~ /^[0-9]$/); - -@critical = ('2', '4', '6'); -if ($opt_c && $opt_c =~ /^([0-9]+),([0-9]+),([0-9]+)$/) { - @critical = ($1,$2,$3); -} else { - print "Specify three critical treshold separated with a coma\n"; - exit $ERRORS{'OK'}; -} - -@warning = ('1', '3', '5'); -if ($opt_w && $opt_w =~ /^([0-9]+),([0-9]+),([0-9]+)$/) { - @warning = ($1,$2,$3); -} else { - print "Specify three warning treshold separated with a coma\n"; - exit $ERRORS{'OK'}; -} - -for (my $i = 0; $i < scalar(@warning); $i++) { - if ($warning[$i] >= $critical[$i]) { - print "Critical tresholds must be superior to warning tresholds.\n"; - exit $ERRORS{'OK'}; - } -} - -if ($snmp eq "3") { - if (!$opt_u) { - print "Option -u (--username) is required for snmpV3\n"; - exit $ERRORS{'OK'}; - } - if (!$opt_p && !$opt_k) { - print "Option -k (--key) or -p (--password) is required for snmpV3\n"; - exit $ERRORS{'OK'}; - } elsif ($opt_p && $opt_k) { - print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; - exit $ERRORS{'OK'}; - } -} - -$opt_C = "public" if (!$opt_C); - -my $name = $0; -$name =~ s/\.pl.*//g; - -# Plugin snmp requests - -my $OID_CPULOAD_1 =$oreon{UNIX}{CPU_LOAD_1M}; -my $OID_CPULOAD_5 =$oreon{UNIX}{CPU_LOAD_5M}; -my $OID_CPULOAD_15 =$oreon{UNIX}{CPU_LOAD_15M}; - -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_p) { - ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); - if (!defined($session)) { - print("UNKNOWN: SNMP Session : $error\n"); - exit $ERRORS{'UNKNOWN'}; - } -} - -my $result = $session->get_request( - -varbindlist => [$OID_CPULOAD_1, $OID_CPULOAD_5, $OID_CPULOAD_15 ] - ); -if (!defined($result)) { - printf("UNKNOWN: %s.\n", $session->error); - $session->close; - exit $ERRORS{'UNKNOWN'}; -} - -my $un = $result->{$OID_CPULOAD_1}; -my $cinq = $result->{$OID_CPULOAD_5}; -my $quinze = $result->{$OID_CPULOAD_15}; - -# Plugin return code -my $status = "OK"; -if ($warning[0] <= $un || $warning[1] <= $cinq || $warning[2] <= $quinze) { - $status = "WARNING"; -} -if ($critical[0] <= $un || $critical[1] <= $cinq || $critical[2] <= $quinze) { - $status = "CRITICAL"; -} - -print "load average: ".$un.", ".$cinq.", ".$quinze.".|load1=".$un." load5=".$cinq." load15=".$quinze."\n"; -exit $ERRORS{$status}; - -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 " -C (--community) SNMP read community (defaults to public,\n"; - print " -c (--critical) Three critical tresholds (defaults : 2,4,6)\n"; - print " -w (--warning) Three warning tresholds (defaults : 1,3,5)\n"; - print " -v (--snmp_version) 1 for SNMP v1 (default)\n"; - print " 2 for SNMP v2c\n"; - print " -k (--key) snmp V3 key\n"; - print " -p (--password) snmp V3 password\n"; - print " -u (--username) snmp v3 username \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/centreon-plugins/Dev/src/check_centreon_snmp_process b/centreon-plugins/Dev/src/check_centreon_snmp_process deleted file mode 100644 index 50f0b267e..000000000 --- a/centreon-plugins/Dev/src/check_centreon_snmp_process +++ /dev/null @@ -1,210 +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 - Sugumaran Mathavarajan -# -################################################################### -# 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 "@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); -use Getopt::Long; -use vars qw($opt_V $opt_h $opt_v $opt_C $opt_p $opt_H $opt_n $opt_k $opt_u $opt_x $result @result %process_list %STATUS); - -# Plugin var init - -my($proc, $proc_run); - -$PROGNAME = $0; -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, - "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"; -$snmp = $opt_v if ($opt_v && $opt_v =~ /^[0-9]$/); - -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'}; - } -} - -$opt_C = "public" if (!$opt_C); - -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}; -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); - $process_list{$$result{$key}} = pop (@oid_list) ; - if (defined($opt_p) && $opt_p ne ""){ - $proc++ if ($$result{$key} eq $opt_p); - } 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} }; - } -} - -# Plugin return code - -if ($opt_n){ - print "Processes OK - Number of current processes: $proc|nbproc=$proc\n"; - exit $ERRORS{'OK'}; -} 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 "\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 " -n (--number) Return the number of current running processes. \n"; - print " -p (--process) Set the process name ex: by default smbd\n"; - print " -k (--key) snmp V3 key\n"; - print " -x (--password) snmp V3 password\n"; - print " -u (--username) snmp v3 username \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/centreon-plugins/Dev/src/check_centreon_snmp_remote_storage b/centreon-plugins/Dev/src/check_centreon_snmp_remote_storage deleted file mode 100644 index 58b0c3f29..000000000 --- a/centreon-plugins/Dev/src/check_centreon_snmp_remote_storage +++ /dev/null @@ -1,329 +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 - Sugumaran Mathavarajan -# -################################################################### -# 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); -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(%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_v $opt_f $opt_C $opt_d $opt_k $opt_u $opt_p $opt_n $opt_w $opt_c $opt_H $opt_s @test); - -# Plugin var init - -my ($hrStorageDescr, $hrStorageAllocationUnits, $hrStorageSize, $hrStorageUsed); -my ($AllocationUnits, $Size, $Used); -my ($tot, $used, $pourcent, $return_code); - -$PROGNAME = "$0"; -sub print_help (); -sub print_usage (); - -Getopt::Long::Configure('bundling'); -GetOptions - ("h" => \$opt_h, "help" => \$opt_h, - "u=s" => \$opt_u, "username=s" => \$opt_u, - "p=s" => \$opt_p, "password=s" => \$opt_p, - "k=s" => \$opt_k, "key=s" => \$opt_k, - "V" => \$opt_V, "version" => \$opt_V, - "s" => \$opt_s, "show" => \$opt_s, - "v=s" => \$opt_v, "snmp=s" => \$opt_v, - "C=s" => \$opt_C, "community=s" => \$opt_C, - "d=s" => \$opt_d, "disk=s" => \$opt_d, - "f" => \$opt_f, "perfparse" => \$opt_f, - "n" => \$opt_n, "name" => \$opt_n, - "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: 1.2 $'); - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} -if (!$opt_H) { - print_usage(); - exit $ERRORS{'OK'}; -} - -if ($opt_n && !$opt_d) { - print "Option -n (--name) need option -d (--disk)\n"; - exit $ERRORS{'UNKNOWN'}; -} -my $snmp = "1"; -$snmp = $opt_v if ($opt_v && $opt_v =~ /^[0-9]$/); - -if ($snmp eq "3") { - if (!$opt_u) { - print "Option -u (--username) is required for snmpV3\n"; - exit $ERRORS{'OK'}; - } - if (!$opt_p && !$opt_k) { - print "Option -k (--key) or -p (--password) is required for snmpV3\n"; - exit $ERRORS{'OK'}; - } elsif ($opt_p && $opt_k) { - print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; - exit $ERRORS{'OK'}; - } -} - -$opt_C = "public" if (!$opt_C); -$opt_d = 2 if (!$opt_d); - -($opt_d) || ($opt_d = shift) || ($opt_d = 2); - -my $partition = 0; -if ($opt_d =~ /([0-9]+)/ && !$opt_n){ - $partition = $1; -} elsif (!$opt_n){ - print "Unknown -d number expected... or it doesn't exist, try another disk - number\n"; - exit $ERRORS{'UNKNOWN'}; -} - -my $critical = 95; -if ($opt_c && $opt_c =~ /^[0-9]+$/) { - $critical = $opt_c; -} -my $warning = 90; -if ($opt_w && $opt_w =~ /^[0-9]+$/) { - $warning = $opt_w; -} - -if ($critical <= $warning){ - print "(--crit) must be superior to (--warn)"; - print_usage(); - exit $ERRORS{'OK'}; -} - - -my $name = $0; -$name =~ s/\.pl.*//g; - -# Plugin snmp requests - -my $OID_hrStorageDescr =$oreon{MIB2}{HR_STORAGE_DESCR}; -my $OID_hrStorageAllocationUnits =$oreon{MIB2}{HR_STORAGE_ALLOCATION_UNITS}; -my $OID_hrStorageSize =$oreon{MIB2}{HR_STORAGE_SIZE}; -my $OID_hrStorageUsed =$oreon{MIB2}{HR_STORAGE_USED}; - -# create a SNMP session -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_p) { - ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); -if (!defined($session)) { - print("UNKNOWN: SNMP Session : $error\n"); - exit $ERRORS{'UNKNOWN'}; -} -} - -#getting partition using its name instead of its oid index -if ($opt_n) { - my $result = $session->get_table(Baseoid => $OID_hrStorageDescr); - if (!defined($result)) { - printf("ERROR: hrStorageDescr Table : %s.\n", $session->error); - $session->close; - exit $ERRORS{'UNKNOWN'}; - } - my $expr = ""; - if ($opt_d =~ m/^[A-Za-z]:/) { - $opt_d =~ s/\\/\\\\/g; - $expr = "^$opt_d"; - }elsif ($opt_d =~ m/^\//) { - $expr = "$opt_d\$"; - }else { - $expr = "$opt_d"; - } - foreach my $key ( oid_lex_sort(keys %$result)) { - if ($result->{$key} =~ m/$expr/) { - my @oid_list = split (/\./,$key); - $partition = pop (@oid_list) ; - } - } -} -if ($opt_s) { - # Get description table - my $result = $session->get_table( - Baseoid => $OID_hrStorageDescr - ); - - if (!defined($result)) { - printf("ERROR: hrStorageDescr 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 "hrStorage $index :: $$result{$key}\n"; - } - exit $ERRORS{'OK'}; -} - -my $result = $session->get_request( - -varbindlist => [$OID_hrStorageDescr.".".$partition , - $OID_hrStorageAllocationUnits.".".$partition , - $OID_hrStorageSize.".".$partition, - $OID_hrStorageUsed.".".$partition - ] - ); -if (!defined($result)) { - printf("ERROR: %s", $session->error); - if ($opt_n) { print(" - You must specify the disk name when option -n is used");} - print ".\n"; - $session->close; - exit $ERRORS{'UNKNOWN'}; -} -$hrStorageDescr = $result->{$OID_hrStorageDescr.".".$partition }; -$AllocationUnits = $result->{$OID_hrStorageAllocationUnits.".".$partition }; -$Size = $result->{$OID_hrStorageSize.".".$partition }; -$Used = $result->{$OID_hrStorageUsed.".".$partition }; - - -# Plugins var treatment - -if (!$Size){ - print "Disk CRITICAL - no output (-p number expected... it doesn't exist, try another disk - number\n"; - exit $ERRORS{'CRITICAL'}; -} - -if (($Size =~ /([0-9]+)/) && ($AllocationUnits =~ /([0-9]+)/)){ - if (!$Size){ - print "The number of the option -p is not a hard drive\n"; - exit $ERRORS{'CRITICAL'}; - } - $tot = 1; - $tot = $Size * $AllocationUnits; - if (!$tot){$tot = 1;} - $used = $Used * $AllocationUnits; - $pourcent = ($used * 100) / $tot; - - if (length($pourcent) > 2){ - @test = split (/\./, $pourcent); - $pourcent = $test[0]; - } - my $lastTot = $tot; - $tot = $tot / 1073741824; - $Used = ($Used * $AllocationUnits) / 1073741824; - - # Plugin return code - - if ($pourcent >= $critical){ - print "Disk CRITICAL - "; - $return_code = 2; - } elsif ($pourcent >= $warning){ - print "Disk WARNING - "; - $return_code = 1; - } else { - print "Disk OK - "; - $return_code = 0; - } - - if ($hrStorageDescr){ - print $hrStorageDescr . " TOTAL: "; - printf("%.3f", $tot); - print " Go USED: " . $pourcent . "% : "; - printf("%.3f", $Used); - print " Go"; - if ($opt_f){ - my $size_o = $Used * 1073741824; - my $warn = $opt_w * $size_o; - my $crit = $opt_c * $size_o; - print "|size=".$lastTot."o used=".$size_o.";".$warn.";".$crit; - } - print "\n"; - exit $return_code; - } else { - print "TOTAL: "; - printf("%.3f", $tot); - print " Go USED: " . $pourcent . "% : "; - printf("%.3f", $Used); - print " Go\n"; - exit $return_code; - } -} else { - print "Disk CRITICAL - no output (-d number expected... it doesn't exist, try another disk - number\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 (--disk) Set the disk (number expected) ex: 1, 2,... (defaults to 2 )\n"; - print " -n (--name) Allows to use disk name with option -d instead of disk oid index\n"; - print " (ex: -d \"C:\" -n, -d \"E:\" -n, -d \"Swap Memory\" -n, -d \"Real Memory\" -n\n"; - print " (choose an unique expression for each disk)\n"; - print " -s (--show) Describes all disk (debug mode)\n"; - print " -w (--warn) Signal strength at which a warning message will be generated\n"; - print " (default 80)\n"; - print " -c (--crit) Signal strength at which a critical message will be generated\n"; - print " (default 95)\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/centreon-plugins/Dev/src/check_centreon_snmp_traffic b/centreon-plugins/Dev/src/check_centreon_snmp_traffic deleted file mode 100644 index 0b815cdc0..000000000 --- a/centreon-plugins/Dev/src/check_centreon_snmp_traffic +++ /dev/null @@ -1,453 +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 - Sugumaran Mathavarajan -# -################################################################### -# 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 "@NAGIOS_PLUGINS@"; -use utils qw($TIMEOUT %ERRORS &print_revision &support); -if (eval "require oreon" ) { - use oreon qw(get_parameters); - use vars qw(%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_v $opt_C $opt_b $opt_k $opt_u $opt_p $opt_H $opt_D $opt_i $opt_n $opt_w $opt_c $opt_s $opt_T); - -# Plugin var init - -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 = "$0"; -sub print_help (); -sub print_usage (); - -Getopt::Long::Configure('bundling'); -GetOptions - ("h" => \$opt_h, "help" => \$opt_h, - "u=s" => \$opt_u, "username=s" => \$opt_u, - "p=s" => \$opt_p, "password=s" => \$opt_p, - "k=s" => \$opt_k, "key=s" => \$opt_k, - "s" => \$opt_s, "show" => \$opt_s, - "V" => \$opt_V, "version" => \$opt_V, - "i=s" => \$opt_i, "interface=s" => \$opt_i, - "n" => \$opt_n, "name" => \$opt_n, - "v=s" => \$opt_v, "snmp=s" => \$opt_v, - "C=s" => \$opt_C, "community=s" => \$opt_C, - "b=s" => \$opt_b, "bps=s" => \$opt_b, - "w=s" => \$opt_w, "warning=s" => \$opt_w, - "c=s" => \$opt_c, "critical=s" => \$opt_c, - "T=s" => \$opt_T, - "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'}; - -Getopt::Long::Configure('bundling'); -} - -################################################## -##### Verify Options -## - -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_p && !$opt_k) { -print "Option -k (--key) or -p (--password) is required for snmpV3\n"; -exit $ERRORS{'OK'}; -}elsif ($opt_p && $opt_k) { -print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; -exit $ERRORS{'OK'}; -} -} - -if ($opt_n && !$opt_i) { - print "Option -n (--name) need option -i (--interface)\n"; - exit $ERRORS{'UNKNOWN'}; -} - -if (!$opt_C) { -$opt_C = "public"; -} - -if (!$opt_i) { -$opt_i = 2; -} - -if (!$opt_b) { -$opt_b = 95; -} - -if ($opt_b =~ /([0-9]+)/) { -my $bps = $1; -} -my $critical = 95; -if ($opt_c && $opt_c =~ /[0-9]+/) { -$critical = $opt_c; -} -my $warning = 80; -if ($opt_w && $opt_w =~ /[0-9]+/) { -$warning = $opt_w; -} -my $interface = 0; -if ($opt_i =~ /([0-9]+)/ && !$opt_n){ - $interface = $1; -} elsif (!$opt_n) { - print "Unknown -i number expected... or it doesn't exist, try another interface - number\n"; - exit $ERRORS{'UNKNOWN'}; -} - -if ($critical <= $warning){ - print "(--crit) must be superior to (--warn)"; - print_usage(); - exit $ERRORS{'OK'}; -} - -################################################# -##### Plugin snmp requests -## - -my $OID_DESC =$oreon{MIB2}{IF_DESC}; - -# create a SNMP session -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_p) { - ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); -if (!defined($session)) { - print("UNKNOWN: SNMP Session : $error\n"); - exit $ERRORS{'UNKNOWN'}; -} -} - -#getting interface using its name instead of its oid index - -if ($opt_n) { - 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)) { - if ($result->{$key} =~ m/$opt_i/) { - my @oid_list = split (/\./,$key); - $interface = pop (@oid_list) ; - } - } -} - -my $OID_IN =$oreon{MIB2}{IF_IN_OCTET}.".".$interface; -my $OID_OUT = $oreon{MIB2}{IF_OUT_OCTET}.".".$interface; -my $OID_SPEED = $oreon{MIB2}{IF_SPEED}.".".$interface; - -# Get desctiption table - -if ($opt_s) { - 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 "Interface $index :: $$result{$key}\n"; - } - exit $ERRORS{'OK'}; -} - - -####### Get IN bytes - -my $in_bits; -my $result = $session->get_request(-varbindlist => [$OID_IN]); -if (!defined($result)) { - printf("ERROR: IN Bits : %s", $session->error); - if ($opt_n) { print " - You must specify interface name when option -n is used";} - print ".\n"; - $session->close; - exit $ERRORS{'UNKNOWN'}; -} -$in_bits = $result->{$OID_IN} * 8; - - -####### Get OUT bytes - -my $out_bits; -$result = $session->get_request(-varbindlist => [$OID_OUT]); -if (!defined($result)) { - printf("ERROR: Out Bits : %s", $session->error); - if ($opt_n) { print " - You must specify interface name when option -n is used";} - print ".\n"; - $session->close; - exit $ERRORS{'UNKNOWN'}; -} -$out_bits = $result->{$OID_OUT} * 8; - - -####### Get SPEED of interface - -my $speed_card; -$result = $session->get_request(-varbindlist => [$OID_SPEED]); -if (!defined($result)) { - printf("ERROR: Interface Speed : %s", $session->error); - if ($opt_n) { print " - You must specify interface name when option -n is used";} - print ".\n"; - $session->close; - exit $ERRORS{'UNKNOWN'}; -} - -if (defined($opt_T)){ - $speed_card = $opt_T * 1000000; -} else { - $speed_card = $result->{$OID_SPEED}; -} - -############################################# -##### Plugin return code -## - -$last_in_bits = 0; -$last_out_bits = 0; - -my $flg_created = 0; - -if (-e "/tmp/oreon_traffic_if".$interface."_".$opt_H) { - open(FILE,"<"."/tmp/oreon_traffic_if".$interface."_".$opt_H); - while($row = ){ - @last_values = split(":",$row); - $last_check_time = $last_values[0]; - $last_in_bits = $last_values[1]; - $last_out_bits = $last_values[2]; - $flg_created = 1; - } - close(FILE); -} else { - $flg_created = 0; -} - -$update_time = time(); - -unless (open(FILE,">"."/tmp/oreon_traffic_if".$interface."_".$opt_H)){ - print "Unknown - /tmp/oreon_traffic_if".$interface."_".$opt_H. " !\n"; - exit $ERRORS{"UNKNOWN"}; -} -print FILE "$update_time:$in_bits:$out_bits"; -close(FILE); - -if ($flg_created == 0){ - print "First execution : Buffer in creation.... \n"; - exit($ERRORS{"UNKNOWN"}); -} - - -## Bandwith = IN + OUT / Delta(T) = 6 Mb/s -## (100 * Bandwith) / (2(si full duplex) * Ispeed) -## Count must round at 4294967296 -## - -if (($in_bits - $last_in_bits > 0) && defined($last_in_bits)) { - my $total = 0; - if ($in_bits - $last_in_bits < 0){ - $total = 4294967296 - $last_in_bits + $in_bits; - } else { - $total = $in_bits - $last_in_bits; - } - my $diff = time() - $last_check_time; - if ($diff == 0){$diff = 1;} - my $pct_in_traffic = $in_traffic = abs($total / $diff); -} else { - $in_traffic = 0; -} - -if ($out_bits - $last_out_bits > 0 && defined($last_out_bits)) { - my $total = 0; - if ($out_bits - $last_out_bits < 0){ - $total = 4294967296 - $last_out_bits + $out_bits; - } else { - $total = $out_bits - $last_out_bits; - } - my $diff = time() - $last_check_time; - if ($diff == 0){$diff = 1;} - my $pct_out_traffic = $out_traffic = abs($total / $diff); -} else { - $out_traffic = 0; -} - -if ( $speed_card != 0 ) { - $in_usage = sprintf("%.1f",($in_traffic*100) / $speed_card); - $out_usage = sprintf("%.1f",($out_traffic*100) / $speed_card); -} - -my $in_prefix = ""; -my $out_prefix = ""; - -my $in_perfparse_traffic = $in_traffic; -my $out_perfparse_traffic = $out_traffic; - -if ($in_traffic > 1000) { - $in_traffic = $in_traffic / 1000; - $in_prefix = "k"; - if($in_traffic > 1000){ - $in_traffic = $in_traffic / 1000; - $in_prefix = "M"; - } - if($in_traffic > 1000){ - $in_traffic = $in_traffic / 1000; - $in_prefix = "G"; - } -} - -if ($out_traffic > 1000){ - $out_traffic = $out_traffic / 1000; - $out_prefix = "k"; - if ($out_traffic > 1000){ - $out_traffic = $out_traffic / 1000; - $out_prefix = "M"; - } - if ($out_traffic > 1000){ - $out_traffic = $out_traffic / 1000; - $out_prefix = "G"; - } -} - -my $in_bits_unit = ""; -$in_bits = $in_bits/1048576; -if ($in_bits > 1000){ - $in_bits = $in_bits / 1000; - $in_bits_unit = "G"; -} else { - $in_bits_unit = "M"; -} - -my $out_bits_unit = ""; -$out_bits = $out_bits/1048576; -if ($out_bits > 1000){ - $out_bits = $out_bits / 1000; - $out_bits_unit = "G"; -} else { - $out_bits_unit = "M"; -} - - -if ( $speed_card == 0 ) { - print "CRITICAL: Interface speed equal 0! Interface must be down.|traffic_in=0B/s traffic_out=0B/s\n"; - exit($ERRORS{"CRITICAL"}); -} - -##################################### -##### Display result -## - - -my $in_perfparse_traffic_str = sprintf("%.1f",abs($in_perfparse_traffic)); -my $out_perfparse_traffic_str = sprintf("%.1f",abs($out_perfparse_traffic)); - -$in_perfparse_traffic_str =~ s/\./,/g; -$out_perfparse_traffic_str =~ s/\./,/g; - -my $status = "OK"; - -if(($in_usage > $warning) or ($out_usage > $warning)){ - $status = "WARNING"; -} - -if (($in_usage > $critical) or ($out_usage > $critical)){ - $status = "CRITICAL"; -} - - -printf("Traffic In : %.2f ".$in_prefix."b/s (".$in_usage." %%), Out : %.2f ".$out_prefix."b/s (".$out_usage." %%) - ", $in_traffic, $out_traffic); -printf("Total RX Bits In : %.2f ".$in_bits_unit."B, Out : %.2f ".$out_bits_unit."b", $in_bits, $out_bits); -printf("|traffic_in=".$in_perfparse_traffic_str."Bits/s traffic_out=".$out_perfparse_traffic_str."Bits/s\n"); -exit($ERRORS{$status}); - -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 " -s (--show) Describes all interfaces number (debug mode)\n"; - print " -i (--interface) Set the interface number (2 by default)\n"; - print " -n (--name) Allows to use interface name with option -d instead of interface oid index\n"; - print " (ex: -i \"eth0\" -n, -i \"VMware Virtual Ethernet Adapter for VMnet8\" -n\n"; - print " (choose an unique expression for each interface)\n"; - print " -w (--warn) Signal strength at which a warning message will be generated\n"; - print " (default 80)\n"; - print " -c (--crit) Signal strength at which a critical message will be generated\n"; - print " -T Max Banwidth\n"; - print " (default 95)\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/centreon-plugins/Dev/src/check_centreon_snmp_uptime b/centreon-plugins/Dev/src/check_centreon_snmp_uptime deleted file mode 100644 index 2adffd9f4..000000000 --- a/centreon-plugins/Dev/src/check_centreon_snmp_uptime +++ /dev/null @@ -1,181 +0,0 @@ -#! /usr/bin/perl -w -# -# $Id: check_graph_uptime.pl,v 1.3 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 - Sugumaran mathavarajan 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 "@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); -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/centreon-plugins/Dev/src/check_centreon_snmp_value b/centreon-plugins/Dev/src/check_centreon_snmp_value deleted file mode 100644 index 4739d34b3..000000000 --- a/centreon-plugins/Dev/src/check_centreon_snmp_value +++ /dev/null @@ -1,204 +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 - Sugumaran Mathavarajan -# -################################################################### -# 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); -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_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u); - -$PROGNAME = $0; -sub print_help (); -sub print_usage (); - -Getopt::Long::Configure('bundling'); -GetOptions - ("h" => \$opt_h, "help" => \$opt_h, - "u=s" => \$opt_u, "username=s" => \$opt_u, - "p=s" => \$opt_p, "password=s" => \$opt_p, - "k=s" => \$opt_k, "key=s" => \$opt_k, - "V" => \$opt_V, "version" => \$opt_V, - "v=s" => \$opt_v, "snmp=s" => \$opt_v, - "C=s" => \$opt_C, "community=s" => \$opt_C, - "o=s" => \$opt_o, "oid=s" => \$opt_o, - "t=s" => \$opt_t, "type=s" => \$opt_t, - "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: 1.0'); - 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); - -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_p && !$opt_k) { -print "Option -k (--key) or -p (--password) is required for snmpV3\n"; -exit $ERRORS{'OK'}; -}elsif ($opt_p && $opt_k) { -print "Only option -k (--key) or -p (--password) is needed for snmpV3\n"; -exit $ERRORS{'OK'}; -} -} - -($opt_C) || ($opt_C = shift) || ($opt_C = "public"); - -my $DS_type = "GAUGE"; -($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE"); -$DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/); - -if (!$opt_c || !$opt_w) { - print "You must specify -c and -w options\n"; - exit $ERRORS{'OK'}; -} - -($opt_c) || ($opt_c = shift); -my $critical = $1 if ($opt_c =~ /([0-9]+)/); - -($opt_w) || ($opt_w = shift); -my $warning = $1 if ($opt_w =~ /([0-9]+)/); -if ($critical <= $warning){ - print "(--critical) must be superior to (--warning)"; - print_usage(); - exit $ERRORS{'OK'}; -} - -if (!$opt_o) { - print "Option -o needed.\n"; - exit $ERRORS{'OK'}; -}elsif (!($opt_o =~ /^[0-9\.]+$/)) { - print "Wrong OID format\n"; - exit $ERRORS{'OK'}; -} - -my $name = $0; -$name =~ s/\.pl.*//g; -my $day = 0; - -#=== create a SNMP session ==== - -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_p) { - ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p); -if (!defined($session)) { - print("UNKNOWN: SNMP Session : $error\n"); - exit $ERRORS{'UNKNOWN'}; -} -} - -my $result = $session->get_request(-varbindlist => [$opt_o]); -if (!defined($result)) { - printf("UNKNOWN: %s.\n", $session->error); - $session->close; - exit $ERRORS{'UNKNOWN'}; -} - -my $return_result = $result->{$opt_o}; - -#=== Plugin return code ==== - -if (defined($return_result)){ - if ($return_result !~ /^[0-9]$/) { - print "Snmp return value isn't numeric.\n"; - exit $ERRORS{'OK'}; - } - if ($opt_w && $opt_c && $return_result < $opt_w){ - print "Ok value : " . $return_result . "|value=".$return_result.";".$opt_w.";".$opt_c.";;\n"; - exit $ERRORS{'OK'}; - } elsif ($opt_w && $opt_c && $return_result >= $opt_w && $return_result < $opt_c){ - print "Warning value : " . $return_result . "|value=$return_result;".$opt_w.";".$opt_c.";;\n"; - exit $ERRORS{'WARNING'}; - } elsif ($opt_w && $opt_c && $return_result >= $opt_c){ - print "Critical value : " . $return_result."|value=".$return_result.";".$opt_w.";".$opt_c.";;\n"; - exit $ERRORS{'CRITICAL'}; - } -} 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 (--type) Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n"; - print " -o (--oid) OID to check\n"; - print " -k (--key) snmp V3 key\n"; - print " -p (--password) snmp V3 password\n"; - print " -u (--username) snmp v3 username \n"; - print " -w (--warning) Warning level\n"; - print " -c (--critical) Critical level\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/centreon-plugins/Dev/src/check_meta_service b/centreon-plugins/Dev/src/check_meta_service deleted file mode 100644 index 368314630..000000000 --- a/centreon-plugins/Dev/src/check_meta_service +++ /dev/null @@ -1,406 +0,0 @@ -#! /usr/bin/perl -w -# -# $Id: check_meta_service.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 -# -# Developped by Julien Mathis for Merethis SARL -# -# 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 DBI; -use vars qw($PROGNAME); -use Getopt::Long; -use vars qw($opt_V $opt_H $opt_h $opt_i); -use lib "@NAGIOS_PLUGINS@"; -use utils qw($TIMEOUT %ERRORS &print_revision &support); - -## For Debug mode = 1 -my $debug = 0; - -sub print_help (); -sub print_usage (); - -Getopt::Long::Configure('bundling'); -GetOptions - ("h" => \$opt_h, - "help" => \$opt_h, - "V" => \$opt_V, - "i=s" => \$opt_i); - -########################### -## Set Database information -########################### -use vars qw($mysql_database_oreon $mysql_database_ods $mysql_host $mysql_user $mysql_passwd); -require "@CENTREON_PATH@/ODS/etc/conf.pm"; - -my $dbh = DBI->connect("DBI:mysql:database=$mysql_database_oreon;host=$mysql_host", - "$mysql_user", "$mysql_passwd", - {'RaiseError' => 1}); - -my $dbh2 = DBI->connect("DBI:mysql:database=$mysql_database_ods;host=$mysql_host", - "$mysql_user", "$mysql_passwd", - {'RaiseError' => 1}); - -if ($opt_V) { - print_revision($PROGNAME,'$Revision: 0.1 $'); - exit $ERRORS{'OK'}; -} - -if ($opt_h) { - print_help(); - exit $ERRORS{'OK'}; -} - -my $result; -my $warning; -my $critical; -my $metric_id; - -sub return_value($$$){ - - my $sth_output = $dbh->prepare("SELECT meta_display FROM `meta_service`"); - if (!$sth_output->execute) {die "Error:" . $sth_output->errstr . "\n";} - my $sth_output_data = $sth_output->fetchrow_hashref(); - my $output = $sth_output_data->{'meta_display'}; - if ($output) { - $output =~ s/\%d/$result/g; - } - if ($warning ne $critical){ - if ($warning < $critical){ # Bon sens - if ($result < $warning){ - if ($output) { - print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n"; - }else { - print "OK result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n"; - } - exit $ERRORS{'OK'}; - } elsif (($result >= $warning) && ($result < $critical)){ - if ($output) { - print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n"; - }else { - print "WARNING result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n"; - } - exit $ERRORS{'WARNING'}; - } elsif ($result >= $critical){ - if ($output) { - print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n"; - }else { - print "CRITICAL result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n"; - } - exit $ERRORS{'CRITICAL'}; - } - } else { # sens inverse - if ($result < $critical){ - if ($output) { - print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n"; - }else { - print "CRITICAL result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n"; - } - exit $ERRORS{'CRITICAL'}; - } elsif ($result >= $critical && $result < $warning){ - if ($output) { - print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n"; - }else { - print "WARNING result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n"; - } - exit $ERRORS{'WARNING'}; - } elsif ($result >= $warning){ - if ($output) { - print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n"; - }else { - print "OK result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n"; - } - exit $ERRORS{'OK'}; - } else{ - if ($output) { - print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n"; - }else { - print "OK result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n"; - } - exit $ERRORS{'OK'}; - } - } - } else { - print "ERROR : warnig level = critical level"; - exit $ERRORS{'CRITICAL'}; - } -} - -my $ref; -my $svc_id; -my $metric; -my $host_id; - -## Get Value by metric Option - -sub get_value_in_database_metric_id($$$$){ - ## Get last entry in perfparse database for this service - my $str = "SELECT value FROM data_bin WHERE id_metric = '".$metric_id."'"; - if ($debug) {print $str . "\n";} - my $sth_deb2 = $dbh2->prepare($str); - if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";} - my $sth_deb2_data = $sth_deb2->fetchrow_hashref(); - return $sth_deb2_data->{'value'}; -} - -## Get value For Regexp Options - -sub get_value_in_database($$$$$){ - - my $str; - ## Get hostname and service description for perfparse request - - $str = "SELECT host_name,service_description FROM host,host_service_relation,service WHERE host.host_id = host_service_relation.host_host_id AND -service.service_id = host_service_relation.service_service_id AND service.service_id = '".$svc_id."'"; - - if ($debug) {print $str . "\n";} - my $host_data = $dbh->prepare($str); - if (!$host_data->execute) {die "Error:" . $host_data->errstr . "\n";} - my $data = $host_data->fetchrow_hashref(); - - ## Get last entry in perfparse database for this service - my $sth_deb2 = $dbh2->prepare("SELECT value FROM metrics m, data_bin d, index_data i WHERE i.host_name = '".$data->{'host_name'}."' AND i.service_description = '".$data->{'service_description'}."' AND and m.index_id=i.id AND m.metric_id = d.id_metric AND m.metric_name = '".$metric."'"); - if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";} - my $sth_deb2_data = $sth_deb2->fetchrow_hashref(); - return $sth_deb2_data->{'value'}; -} - -sub get_value_in_database_by_host($$$$$){ - - my $str; - - ## Get hostname and service description for perfparse request - - $str = "SELECT host_name,service_description FROM host,host_service_relation,service WHERE host.host_id = host_service_relation.host_host_id AND service.service_id = host_service_relation.service_service_id AND service.service_id = '".$svc_id."'"; - if ($debug) {print $str . "\n";} - my $host_data = $dbh->prepare($str); - if (!$host_data->execute) {die "Error:" . $host_data->errstr . "\n";} - my $data = $host_data->fetchrow_hashref(); - - ## Get last entry in perfparse database for this service - - my $sth_deb2 = $dbh2->prepare("SELECT value FROM metrics m, data_bin d, index_data i WHERE i.host_name = '".$data->{'host_name'}."' AND i.service_description = '".$data->{'service_description'}."' AND m.index_id=i.id AND m.metric_id = d.id_metric AND m.metric_name = '".$metric."'"); - if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";} - my $sth_deb2_data = $sth_deb2->fetchrow_hashref(); - return $sth_deb2_data->{'value'}; -} - -sub get_value_in_database_by_hg($$$$$$){ - - my $str; - - ## Get hostname - - $str = "SELECT host_name FROM host WHERE host.host_id = '".$host_id."'"; - if ($debug) {print $str . "\n";} - my $hd = $dbh->prepare($str); - if (!$hd->execute) {die "Error:" . $hd->errstr . "\n";} - my $host_data = $hd->fetchrow_hashref(); - - ## Get service description - - $str = "SELECT service_description FROM service WHERE service.service_id = '".$svc_id."'"; - if ($debug) {print $str . "\n";} - my $sd = $dbh->prepare($str); - if (!$sd->execute) {die "Error:" . $sd->errstr . "\n";} - my $service_data = $sd->fetchrow_hashref(); - - ## Get last entry in perfparse database for this service - - my $sth_deb2 = $dbh2->prepare("SELECT value FROM metrics m, data_bin d, index_data i WHERE i.host_name = '".$host_data->{'host_name'}."' AND i.service_description = '".$service_data->{'service_description'}."' AND m.index_id=i.id AND m.metric_id = d.id_metric AND m.metric_name = '".$metric."'"); - if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";} - my $sth_deb2_data = $sth_deb2->fetchrow_hashref(); - return $sth_deb2_data->{'value'}; -} - -my $cpt = 0; -my $total = 0; -my $max = 0; -my $min = 999999999; -my $svc; -my $value = 0; -my $svc_relation2; - -if ($opt_i){ - my $str; - - # get osl info - my $sth = $dbh->prepare("SELECT calcul_type,regexp_str,warning,critical,metric, meta_select_mode FROM meta_service WHERE meta_id = '".$opt_i."'"); - if (!$sth->execute) {die "Error:" . $sth->errstr . "\n";} - $ref = $sth->fetchrow_hashref(); - if (!defined($ref->{'calcul_type'})){ - print "Unvalidate Meta Service\n"; - exit $ERRORS{'CRITICAL'}; - } - - $warning = $ref->{'warning'}; - $critical = $ref->{'critical'}; - - # Get Service List by regexp - if ($ref->{'meta_select_mode'} eq '2'){ - - ############################################### - - $str = "SELECT service_id FROM service WHERE `service_description` LIKE '".$ref->{'regexp_str'}."' AND service_activate = '1' AND service_register = '1'"; - if ($debug) {print $str . "\n";} - $sth = $dbh->prepare($str); - if (!$sth->execute) {die "Error:" . $sth->errstr . "\n";} - while ($svc = $sth->fetchrow_hashref()){ - my $sth2 = $dbh->prepare("SELECT * FROM host_service_relation WHERE service_service_id = '".$svc->{'service_id'}."'"); - if (!$sth2->execute) {die "Error:" . $sth2->errstr . "\n";} - my $svc_relation = $sth2->fetchrow_hashref(); - if (defined($svc_relation->{'host_host_id'}) && $svc_relation->{'host_host_id'}){ - #### Par Host - if (defined($svc->{'service_id'})){$svc_id = $svc->{'service_id'};} else {$svc_id = $svc->{'svc_id'};} - if (defined($ref->{'regexp_str'})){$metric = $ref->{'metric'};} else {$metric = $svc->{'metric'};} - $value = get_value_in_database_by_host($dbh,$dbh2,$svc_id,$metric,$debug); - if ($ref->{'calcul_type'} =~ "AVE"){ - if (defined($value) && $value){$total += $value;} - if ($debug) {print "total = " . $total . " value = ".$value."\n";} - $cpt++; - $result = $total / $cpt; - } elsif ($ref->{'calcul_type'} =~ "SOM"){ - if ($value){$total += $value;} - if ($debug){print "total = " . $total . " value = ".$value."\n";} - $result = $total; - } elsif ($ref->{'calcul_type'} =~ "MIN"){ - if ($debug){print " min : " . $min . " value = ".$value."\n";} - if ($value && $value <= $min){$min = $value;} - $result = $min; - } elsif ($ref->{'calcul_type'} =~ "MAX"){ - if ($debug){print "max = " . $max . " value = ".$value."\n";} - if ($value && $value >= $max){$max = $value;} - $result = $max; - } - } elsif (defined($svc_relation->{'hostgroup_hg_id'}) && $svc_relation->{'hostgroup_hg_id'}) { - ### Par Hostgroup - my $sth3 = $dbh->prepare("SELECT host_host_id FROM hostgroup_relation WHERE hostgroup_hg_id = '".$svc_relation->{'hostgroup_hg_id'}."'"); - if (!$sth3->execute) {die "Error:" . $sth3->errstr . "\n";} - while ($svc_relation2 = $sth3->fetchrow_hashref()){ - if (defined($svc->{'service_id'})){ - $svc_id = $svc->{'service_id'}; - } else { - $svc_id = $svc->{'svc_id'}; - } - if (defined($ref->{'regexp_str'})){ - $metric = $ref->{'metric'}; - } else { - $metric = $svc->{'metric'}; - } - $host_id = $svc_relation2->{'host_host_id'}; - $value = get_value_in_database_by_hg($dbh,$dbh2,$svc_id, $host_id, $metric, $debug); - if ($ref->{'calcul_type'} =~ "AVE"){ - if (defined($value) && $value){ - $total += $value; - } - if ($debug) {print "total = " . $total . " value = ".$value."\n";} - $cpt++; - } elsif ($ref->{'calcul_type'} =~ "SOM"){ - if ($value){ - $total += $value; - } - if ($debug){print "total = " . $total . " value = ".$value."\n";} - } elsif ($ref->{'calcul_type'} =~ "MIN"){ - if ($debug){print " min : " . $min . " value = ".$value."\n";} - if ($value && $value <= $min){ - $min = $value; - } - } elsif ($ref->{'calcul_type'} =~ "MAX"){ - if ($debug){print "max = " . $max . " value = ".$value."\n";} - if ($value && $value >= $max){ - $max = $value; - } - } - } - if ($ref->{'calcul_type'} =~ "AVE"){ - $result = $total / $cpt; - } elsif ($ref->{'calcul_type'} =~ "SOM"){ - $result = $total; - } elsif ($ref->{'calcul_type'} =~ "MIN"){ - $result = $min; - } elsif ($ref->{'calcul_type'} =~ "MAX"){ - $result = $max; - } - } - } - return_value($result, $warning, $critical); - ############################################### - } else { - $sth = $dbh->prepare("SELECT metric_id FROM `meta_service_relation` WHERE meta_id = '".$opt_i."'"); - if (!$sth->execute) {die "Error:" . $sth->errstr . "\n";} - if ($ref->{'calcul_type'} =~ "AVE"){ - if (!$sth->rows) { - print "no result in table meta_service_relation for id $opt_i\n"; - exit $ERRORS{'UNKNOWN'}; - } - while ($svc = $sth->fetchrow_hashref()){ - if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};} - $value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug); - if (defined($value) && $value){$total += $value;} - $cpt++; - } - $result = $total / $cpt; - } elsif ($ref->{'calcul_type'} =~ "SOM"){ - while ($svc = $sth->fetchrow_hashref()){ - if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};} - $value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug); - if ($value){$total += $value;} - if ($debug){print "total = " . $total . " value = ".$value."\n";} - } - $result = $total; - } elsif ($ref->{'calcul_type'} =~ "MIN"){ - while ($svc = $sth->fetchrow_hashref()){ - if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};} - $value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug); - if ($debug){print " min : " . $min . " value = ".$value."\n";} - if ($value && $value <= $min){$min = $value;} - } - $result = $min; - } elsif ($ref->{'calcul_type'} =~ "MAX"){ - while ($svc = $sth->fetchrow_hashref()){ - if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};} - $value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug); - if ($debug){print "max = " . $max . " value = ".$value."\n";} - if ($value && $value >= $max){$max = $value;} - } - $result = $max; - } - return_value($result, $warning, $critical); - } -} - - -sub print_usage () { - print "Usage:\n"; - print " check_meta_service.pl\n"; - print " -i Meta Service id\n"; - print " -V (--version) Plugin version\n"; - print " -h (--help) usage help\n"; -} - -sub print_help () -{ - print "###########################################\n"; - print "# #\n"; - print "# Copyright (c) 2004-2007 Merethis #\n"; - print "# Bugs to http://www.oreon-services.com #\n"; - print "# #\n"; - print "###########################################\n"; - print_usage(); - print "\n"; -} diff --git a/centreon-plugins/Dev/src/check_nt_centreon b/centreon-plugins/Dev/src/check_nt_centreon deleted file mode 100644 index 9c99e77cf..000000000 --- a/centreon-plugins/Dev/src/check_nt_centreon +++ /dev/null @@ -1,344 +0,0 @@ -#! /usr/bin/perl -# -# $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 -# -# 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 "@NAGIOS_PLUGINS@"; -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, - "S=s" => \$opt_S, "ServiceId=s" => \$opt_S, - "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_d) { - ($opt_d) || ($opt_d = shift); - $op_d = $1 if ($opt_d =~ /([-.,A-Za-z0-9]+)/); -} - -if ($opt_s) { - ($opt_s) || ($opt_s = shift); - $op_s = $1 if ($opt_s =~ /([\_\-\.\,A-Za-z0-9]+)/); -} - -if ($opt_v) { - ($opt_v) || ($opt_v = shift); - $op_v = $1 if ($opt_v =~ /([-.,A-Za-z0-9]+)/); -} - -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 `; - my $return = $_; - if (!defined($return) || $return eq "") { - print "Error in command, check your command options\n"; - exit (3); - } - $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; - my @return_data = split(/\|/,$return); - if (@values){ - if (defined($opt_c) && defined($opt_w)){ - print $return_data[0] . "|cpu=@values%;$opt_w;$opt_c\n"; - } else { - print $return_data[0] . "|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; - my @return_part = split(/\|/, $return); - #$return =~ s/%/ pct/g; - ## Put value in octets : Mo -> o - if (defined($test[3]) && defined($test[7]) && defined($test[12])){ - $test[3] =~ s/\,/\./g; - $test[3] = eval($test[3] * 1024 * 1024 * 1024); - $test[7] =~ s/\,/\./g; - $test[7] = eval ($test[7] * 1024 * 1024 * 1024); - print $return_part[0] . "|total=".$test[3]."o used=".$test[7]."o\n"; - } else { - print $return_part[0] . "\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 - my @return_data = split(/\|/,$return); - $return =~ s/\n/ /g; - #$return =~ s/%/ pct/g; - if ($test4[1] && $test[6] && $test[11]){ - ## Put value in octets : Mo -> o - $test4[1] =~ s/\,/\./g; - $test4[1] = eval($test4[1] * 1024 * 1024); - $test[6] =~ s/\,/\./g; - $test[6] = eval($test[6] * 1024 * 1024); - print $return_data[0] . "|total=".$test4[1]."o used=".$test[6]."o\n"; - } else { - print $return_data[0] . "\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 = "Unknown"; - } - 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 ."---\n"; - 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] [-D rrd directory] -g -S ServiceID\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/centreon-plugins/Dev/src/check_snmp_cpfw.pl b/centreon-plugins/Dev/src/check_snmp_cpfw.pl deleted file mode 100644 index 14b29fa5d..000000000 --- a/centreon-plugins/Dev/src/check_snmp_cpfw.pl +++ /dev/null @@ -1,534 +0,0 @@ -#!/usr/bin/perl -w -############################## check_snmp_cpfw ############## -# Version : 0.7 -# Date : Oct 02 2004 -# Author : Patrick Proy (patrick at proy.org) -# Help : http://www.manubulon.com/nagios/ -# Licence : GPL - http://www.fsf.org/licenses/gpl.txt -# TODO : -# - check sync method -################################################################# -# -# Help : ./check_snmp_cpfw.pl -h -# - -use strict; -use Net::SNMP; -use Getopt::Long; - -# Nagios specific - -use lib "@NAGIOS_PLUGINS@"; -use utils qw(%ERRORS $TIMEOUT); -#my $TIMEOUT = 15; -#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); - -# 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'}; -} - -my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL}; - - -########### SNMP Datas ########### - -###### FW data -my $policy_state = "1.3.6.1.4.1.2620.1.1.1.0"; # "Installed" -my $policy_name = "1.3.6.1.4.1.2620.1.1.2.0"; # Installed policy name -my $connections = "1.3.6.1.4.1.2620.1.1.25.3.0"; # number of connections -#my $connections_peak = "1.3.6.1.4.1.2620.1.1.25.4.0"; # peak number of connections -my @fw_checks = ($policy_state,$policy_name,$connections); - -###### SVN data -my $svn_status = "1.3.6.1.4.1.2620.1.6.102.0"; # "OK" svn status -my %svn_checks = ($svn_status,"OK"); -my %svn_checks_n = ($svn_status,"SVN status"); -my @svn_checks_oid = ($svn_status); - -###### HA data - -my $ha_active = "1.3.6.1.4.1.2620.1.5.5.0"; # "yes" -my $ha_state = "1.3.6.1.4.1.2620.1.5.6.0"; # "active" -my $ha_block_state = "1.3.6.1.4.1.2620.1.5.7.0"; #"OK" : ha blocking state -my $ha_status = "1.3.6.1.4.1.2620.1.5.102.0"; # "OK" : ha status - -my %ha_checks =( $ha_active,"yes",$ha_state,"active",$ha_block_state,"OK",$ha_status,"OK"); -my %ha_checks_n =( $ha_active,"HA active",$ha_state,"HA state",$ha_block_state,"HA block state",$ha_status,"ha_status"); -my @ha_checks_oid =( $ha_active,$ha_state,$ha_block_state,$ha_status); - -my $ha_mode = "1.3.6.1.4.1.2620.1.5.11.0"; # "Sync only" : ha Working mode - -my $ha_tables = "1.3.6.1.4.1.2620.1.5.13.1"; # ha status table -my $ha_tables_index = ".1"; -my $ha_tables_name = ".2"; -my $ha_tables_state = ".3"; # "OK" -my $ha_tables_prbdesc = ".6"; # Description if state is != "OK" - -#my @ha_table_check = ("Synchronization","Filter","cphad","fwd"); # process to check - -####### MGMT data - -my $mgmt_status = "1.3.6.1.4.1.2620.1.7.5.0"; # "active" : management status -my $mgmt_alive = "1.3.6.1.4.1.2620.1.7.6.0"; # 1 : management is alive if 1 -my $mgmt_stat_desc = "1.3.6.1.4.1.2620.1.7.102.0"; # Management status description -my $mgmt_stats_desc_l = "1.3.6.1.4.1.2620.1.7.103.0"; # Management status long description - -my %mgmt_checks = ($mgmt_status,"active",$mgmt_alive,"1"); -my %mgmt_checks_n = ($mgmt_status,"Mgmt status",$mgmt_alive,"Mgmt alive"); -my @mgmt_checks_oid = ($mgmt_status,$mgmt_alive); - -#################################### Globals ##############################"" - -my $Version='0.7'; - -my $o_host = undef; # hostname -my $o_community = undef; # community -my $o_port = 161; # port -my $o_help= undef; # wan't some help ? -my $o_verb= undef; # verbose mode -my $o_version= undef; # print version -my $o_warn= undef; # Warning for connections -my $o_crit= undef; # Crit for connections -my $o_svn= undef; # Check for SVN status -my $o_fw= undef; # Check for FW status -my $o_ha= undef; # Check for HA status -my $o_mgmt= undef; # Check for management status -my $o_policy= undef; # Check for policy name -my $o_conn= undef; # Check for connexions -my $o_perf= undef; # Performance data output - -# SNMPv3 specific -my $o_login= undef; # Login for snmpv3 -my $o_passwd= undef; # Pass for snmpv3 - -# 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_cpfw version : $Version\n"; } - -sub print_usage { - print "Usage: $0 [-v] -H -C | (-l login -x passwd) [-s] [-w [-p=pol_name] [-c=warn,crit]] [-m] [-a] [-f] [-p ] [-t ] [-V]\n"; -} - -sub isnnum { # Return true if arg is not a number - my $num = shift; - if ( $num =~ /^(\d+\.?\d*)|(^\.\d+)$/ ) { return 0 ;} - return 1; -} - -sub help { - print "\nSNMP Checkpoint FW-1 Monitor for Nagios version ",$Version,"\n"; - print "(c)2004 - to my cat Ratoune\n\n"; - print_usage(); - print < \$o_verb, 'verbose' => \$o_verb, - 'h' => \$o_help, 'help' => \$o_help, - 'H:s' => \$o_host, 'hostname:s' => \$o_host, - 'P:i' => \$o_port, 'port:i' => \$o_port, - 'C:s' => \$o_community, 'community:s' => \$o_community, - 'l:s' => \$o_login, 'login:s' => \$o_login, - 'x:s' => \$o_passwd, 'passwd:s' => \$o_passwd, - 't:i' => \$TIMEOUT, 'timeout:i' => \$TIMEOUT, - 'V' => \$o_version, 'version' => \$o_version, - 's' => \$o_svn, 'svn' => \$o_svn, - 'w' => \$o_fw, 'fw' => \$o_fw, - 'a' => \$o_ha, 'ha' => \$o_ha, - 'm' => \$o_mgmt, 'mgmt' => \$o_mgmt, - 'p:s' => \$o_policy, 'policy:s' => \$o_policy, - 'c:s' => \$o_conn, 'connexions:s' => \$o_conn, - 'f' => \$o_perf, 'perfparse' => \$o_perf, - # For Oreon rrdtool graph - "rrd_step:s" => \$o_step, - "g" => \$o_g, "rrdgraph" => \$o_g, - "S=s" => \$o_S, "ServiceId=s" => \$o_S - ); - if (defined ($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}}; - if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}}; - if ( ! defined($o_host) ) # check host and filter - { print_usage(); exit $ERRORS{"UNKNOWN"}} - # check snmp information - if ( !defined($o_community) && (!defined($o_login) || !defined($o_passwd)) ) - { print "Put snmp login info!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - # Check firewall options - if ( defined($o_conn)) { - if ( ! defined($o_fw)) - { print "Cannot check connexions without checking fw\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - my @warncrit=split(/,/ , $o_conn); - if ( $#warncrit != 1 ) - { print "Put warn,crit levels with -c option\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - ($o_warn,$o_crit)=@warncrit; - if ( isnnum($o_warn) || isnnum($o_crit) ) - { print "Numeric values for warning and critical in -c options\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - if ($o_warn >= $o_crit) - { print "warning <= critical ! \n";print_usage(); exit $ERRORS{"UNKNOWN"}} - } - if ( defined($o_policy)) { - if (! defined($o_fw)) - { print "Cannot check policy name without checking fw\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - if ($o_policy eq "") - { print "Put a policy name !\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - } - if (defined($o_perf) && ! defined ($o_conn)) - { print "Nothing selected for perfparse !\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - if (!defined($o_fw) && !defined($o_ha) && !defined($o_mgmt) && !defined($o_svn)) - { print "Must select a product to check !\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - - ###### Oreon ####### - - if (!defined($o_S)) { $o_S="1_1" } - $ServiceId = is_valid_serviceid($o_S); - - if (!defined($o_step)) { $o_step="300" } - $step = $1 if ($o_step =~ /(\d+)/); - -} - -########## MAIN ####### - -check_options(); - -$rrd = $pathtorrdbase.$ServiceId.".rrd"; -$start=time; - -# Check gobal timeout if snmp screws up -alarm($TIMEOUT+15); - -# Connect to host -my ($session,$error); -if ( defined($o_login) && defined($o_passwd)) { - # SNMPv3 login - verb("SNMPv3 login"); - ($session, $error) = Net::SNMP->session( - -hostname => $o_host, - -version => '3', - -username => $o_login, - -authpassword => $o_passwd, - -authprotocol => 'md5', - -privpassword => $o_passwd - ); -} else { - # SNMPV1 login - ($session, $error) = Net::SNMP->session( - -hostname => $o_host, - -community => $o_community, - -port => $o_port, - -timeout => $TIMEOUT - ); -} -if (!defined($session)) { - printf("ERROR opening session: %s.\n", $error); - exit $ERRORS{"UNKNOWN"}; -} - -########### Global checks ################# - -my $global_status=0; # global status : 0=OK, 1=Warn, 2=Crit -my ($resultat,$key)=(undef,undef); - -########## Check SVN status ############# -my $svn_print=""; -my $svn_state=0; - -if (defined ($o_svn)) { - -$resultat = $session->get_request( - Varbindlist => \@svn_checks_oid -); - - if (defined($resultat)) { - foreach $key ( keys %svn_checks) { - verb("$svn_checks_n{$key} : $svn_checks{$key} / $$resultat{$key}"); - if ( $$resultat{$key} ne $svn_checks{$key} ) { - $svn_print .= $svn_checks_n{$key} . ":" . $$resultat{$key} . " "; - $svn_state=2; - } - } - } else { - $svn_print .= "cannot find oids"; - #Critical state if not found because it means soft is not activated - $svn_state=2; - } - - if ($svn_state == 0) { - $svn_print="SVN : OK"; - } else { - $svn_print="SVN : " . $svn_print; - } - verb("$svn_print"); -} -########## Check mgmt status ############# -my $mgmt_state=0; -my $mgmt_print=""; - -if (defined ($o_mgmt)) { -# Check all states - $resultat=undef; - $resultat = $session->get_request( - Varbindlist => \@mgmt_checks_oid - ); - if (defined($resultat)) { - foreach $key ( keys %mgmt_checks) { - verb("$mgmt_checks_n{$key} : $mgmt_checks{$key} / $$resultat{$key}"); - if ( $$resultat{$key} ne $mgmt_checks{$key} ) { - $mgmt_print .= $mgmt_checks_n{$key} . ":" . $$resultat{$key} . " "; - $mgmt_state=2; - } - } - } else { - $mgmt_print .= "cannot find oids"; - #Critical state if not found because it means soft is not activated - $mgmt_state=2; - } - if ($mgmt_state == 0) { - $mgmt_print="MGMT : OK"; - } else { - $mgmt_print="MGMT : " . $mgmt_print; - } - verb("$svn_print"); -} - -########### Check fw status ############## - -my $fw_state=0; -my $fw_print=""; -my $perf_conn=undef; - -if (defined ($o_fw)) { - -# Check all states - - $resultat = $session->get_request( - Varbindlist => \@fw_checks - ); - if (defined($resultat)) { - verb("State : $$resultat{$policy_state}"); - verb("Name : $$resultat{$policy_name}"); - verb("connections : $$resultat{$connections}"); - - if ($$resultat{$policy_state} ne "Installed") { - $fw_state=2; - $fw_print .= "Policy:". $$resultat{$policy_state}." "; - verb("Policy state not installed"); - } - - if (defined($o_policy)) { - if ($$resultat{$policy_name} ne $o_policy) { - $fw_state=2; - $fw_print .= "Policy installed : $$resultat{$policy_name}"; - } - } - - if (defined($o_conn)) { - if ($$resultat{$connections} > $o_crit) { - $fw_state=2; - $fw_print .= "Connexions : ".$$resultat{$connections}." > ".$o_crit." "; - } else { - if ($$resultat{$connections} > $o_warn) { - $fw_state=1; - $fw_print .= "Connexions : ".$$resultat{$connections}." > ".$o_warn." "; - } - } - $perf_conn=$$resultat{$connections}; - - ## - ## RRD management - ## - - if ($o_g) { - $start=time; - if (! -e $rrd) { - create_rrd($rrd,1,$start,$step,0,"U","GAUGE"); - } - update_rrd($rrd,$start, $perf_conn); - } - } - } else { - $fw_print .= "cannot find oids"; - #Critical state if not found because it means soft is not activated - $fw_state=2; - } - - if ($fw_state==0) { - $fw_print="FW : OK"; - } else { - $fw_print="FW : " . $fw_print; - } - -} -########### Check ha status ############## - -my $ha_state_n=0; -my $ha_print=""; - -if (defined ($o_ha)) { - # Check all states - - $resultat = $session->get_request( - Varbindlist => \@ha_checks_oid - ); - - if (defined($resultat)) { - foreach $key ( keys %ha_checks) { - verb("$ha_checks_n{$key} : $ha_checks{$key} / $$resultat{$key}"); - if ( $$resultat{$key} ne $ha_checks{$key} ) { - $ha_print .= $ha_checks_n{$key} . ":" . $$resultat{$key} . " "; - $ha_state_n=2; - } - } - #my $ha_mode = "1.3.6.1.4.1.2620.1.5.11.0"; # "Sync only" : ha Working mode - } else { - $ha_print .= "cannot find oids"; - #Critical state if not found because it means soft is not activated - $ha_state_n=2; - } - - # get ha status table - $resultat = $session->get_table( - Baseoid => $ha_tables - ); - my %status; - my (@index,@oid) = (undef,undef); - my $nindex=0; - my $index_search= $ha_tables . $ha_tables_index; - - if (defined($resultat)) { - foreach $key ( keys %$resultat) { - if ( $key =~ /$index_search/) { - @oid=split (/\./,$key); - pop(@oid); - $index[$nindex]=pop(@oid); - $nindex++; - } - } - } else { - $ha_print .= "cannot find oids" if ($ha_state_n ==0); - #Critical state if not found because it means soft is not activated - $ha_state_n=2; - } - verb ("found $nindex ha softs"); - if ( $nindex == 0 ) - { - $ha_print .= " no ha soft found" if ($ha_state_n ==0); - $ha_state_n=2; - } else { - my $ha_soft_name=undef; - - for (my $i=0;$i<$nindex;$i++) { - - $key=$ha_tables . $ha_tables_name . "." . $index[$i] . ".0"; - $ha_soft_name= $$resultat{$key}; - - $key=$ha_tables . $ha_tables_state . "." . $index[$i] . ".0"; - if (($status{$ha_soft_name} = $$resultat{$key}) ne "OK") { - $key=$ha_tables . $ha_tables_prbdesc . "." . $index[$i] . ".0"; - $status{$ha_soft_name} = $$resultat{$key}; - $ha_print .= $ha_soft_name . ":" . $status{$ha_soft_name} . " "; - $ha_state_n=2 - } - verb ("$ha_soft_name : $status{$ha_soft_name}"); - } - } - - if ($ha_state_n == 0) { - $ha_print = "HA : OK"; - } else { - $ha_print = "HA : " . $ha_print; - } - -} - -$session->close; - -########## print results and exit - -my $f_print=undef; - -if (defined ($o_fw)) { $f_print = $fw_print } -if (defined ($o_svn)) { $f_print = (defined ($f_print)) ? $f_print . " / ". $svn_print : $svn_print } -if (defined ($o_ha)) { $f_print = (defined ($f_print)) ? $f_print . " / ". $ha_print : $ha_print } -if (defined ($o_mgmt)) { $f_print = (defined ($f_print)) ? $f_print . " / ". $mgmt_print : $mgmt_print } - -my $exit_status=undef; -$f_print .= " / CPFW Status : "; -if (($ha_state_n+$svn_state+$fw_state+$mgmt_state) == 0 ) { - $f_print .= "OK"; - $exit_status= $ERRORS{"OK"}; -} else { - if (($fw_state==1) || ($ha_state_n==1) || ($svn_state==1) || ($mgmt_state==1)) { - $f_print .= "WARNING"; - $exit_status= $ERRORS{"WARNING"}; - } else { - $f_print .= "CRITICAL"; - $exit_status=$ERRORS{"CRITICAL"}; - } -} - -if (defined($o_perf) && defined ($perf_conn)) { - $f_print .= " | fw_connexions=" . $perf_conn; -} - -print "$f_print\n"; -exit $exit_status; - diff --git a/centreon-plugins/Dev/src/check_snmp_load.pl b/centreon-plugins/Dev/src/check_snmp_load.pl deleted file mode 100644 index 714a51e6f..000000000 --- a/centreon-plugins/Dev/src/check_snmp_load.pl +++ /dev/null @@ -1,593 +0,0 @@ -#!/usr/bin/perl -w -############################## check_snmp_load ################# -# Version : 1.2 / BETA -# Date : Aug 27 2005 -# Author : Patrick Proy ( patrick at proy.org) -# Help : http://www.manubulon.com/nagios/ -# Licence : GPL - http://www.fsf.org/licenses/gpl.txt -# Changelog : HP Procurve -# TODO : -################################################################# -# -# Help : ./check_snmp_load.pl -h -# - -use strict; -use Net::SNMP; -use Getopt::Long; - -# Nagios specific - -use lib "@NAGIOS_PLUGINS@"; -use utils qw(%ERRORS $TIMEOUT); -#my $TIMEOUT = 15; -#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); - -# 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'}; -} - -my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL}; - -# SNMP Datas - -# Generic with host-ressource-mib -my $base_proc = "1.3.6.1.2.1.25.3.3.1"; # oid for all proc info -my $proc_id = "1.3.6.1.2.1.25.3.3.1.1"; # list of processors (product ID) -my $proc_load = "1.3.6.1.2.1.25.3.3.1.2"; # %time the proc was not idle over last minute - -# Linux load - -my $linload_table= "1.3.6.1.4.1.2021.10.1"; # net-snmp load table -my $linload_name = "1.3.6.1.4.1.2021.10.1.2"; # text 'Load-1','Load-5', 'Load-15' -my $linload_load = "1.3.6.1.4.1.2021.10.1.3"; # effective load table - -# Cisco cpu/load - -my $cisco_cpu_5m = "1.3.6.1.4.1.9.2.1.58.0"; # Cisco CPU load (5min %) -my $cisco_cpu_1m = "1.3.6.1.4.1.9.2.1.57.0"; # Cisco CPU load (1min %) -my $cisco_cpu_5s = "1.3.6.1.4.1.9.2.1.56.0"; # Cisco CPU load (5sec %) - -# AS/400 CPU - -my $as400_cpu = "1.3.6.1.4.1.2.6.4.5.1.0"; # AS400 CPU load (10000=100%); - -# Net-SNMP CPU - -my $ns_cpu_idle = "1.3.6.1.4.1.2021.11.11.0"; # Net-snmp cpu idle -my $ns_cpu_user = "1.3.6.1.4.1.2021.11.9.0"; # Net-snmp user cpu usage -my $ns_cpu_system = "1.3.6.1.4.1.2021.11.10.0"; # Net-snmp system cpu usage - -# Procurve CPU -my $procurve_cpu = "1.3.6.1.4.1.11.2.14.11.5.1.9.6.1.0"; # Procurve CPU Counter - -# Nokia CPU -my $nokia_cpu = "1.3.6.1.4.1.94.1.21.1.7.1.0"; # Nokia CPU % usage - -# Bluecoat Appliance -my $bluecoat_cpu = "1.3.6.1.4.1.3417.2.4.1.1.1.4.1"; # Bluecoat %cpu usage. - -# Linkproof Appliance -my $linkproof_cpu= "1.3.6.1.4.1.89.35.1.53.0"; # Ressource utilisation (%) Considers network utilization and internal CPU utilization -# 1.3.6.1.4.1.89.35.1.54 : CPU only (%) -# 1.3.6.1.4.1.89.35.1.55 : network only (%) - -# CPU OID array -my %cpu_oid = ("netsc",$ns_cpu_idle,"as400",$as400_cpu,"bc",$bluecoat_cpu,"nokia",$nokia_cpu,"hp",$procurve_cpu,"lp",$linkproof_cpu); - -# Globals - -my $Version='1.2'; - -my $o_host = undef; # hostname -my $o_community = undef; # community -my $o_port = 161; # port -my $o_help= undef; # wan't some help ? -my $o_verb= undef; # verbose mode -my $o_version= undef; # print version -my $o_check_type= "stand"; # check type : stand | netsc | netsl | as400 | cisco | bc | nokia | hp | lp -# For backward compatibility -my $o_linux= undef; # Check linux load instead of CPU -my $o_linuxC= undef; # Check Net-SNMP CPU -my $o_as400= undef; # Check for AS 400 load -my $o_cisco= undef; # Check for Cisco CPU -# End compatibility -my $o_warn= undef; # warning level -my @o_warnL= undef; # warning levels for Linux Load or Cisco CPU -my $o_crit= undef; # critical level -my @o_critL= undef; # critical level for Linux Load or Cisco CPU -my $o_timeout= 5; # Default 5s Timeout -my $o_perf= undef; # Output performance data -my $o_version2= undef; # use snmp v2c -# SNMPv3 specific -my $o_login= undef; # Login for snmpv3 -my $o_passwd= undef; # Pass for snmpv3 -# 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; - -# functions - -sub p_version { print "check_snmp_load version : $Version\n"; } - -sub print_usage { - print "Usage: $0 [-v] -H -C [-2] | (-l login -x passwd) [-p ] -w -c -T=[stand|netsl|netsc|as400|cisco|bc|nokia|hp|lp] [-f] [-t ] [-V]\n"; -} - -sub isnnum { # Return true if arg is not a number - my $num = shift; - if ( $num =~ /^(\d+\.?\d*)|(^\.\d+)$/ ) { return 0 ;} - return 1; -} - -sub help { - print "\nSNMP Load & CPU Monitor for Nagios version ",$Version,"\n"; - print "(c)2004 to my cat Ratoune - Author : Patrick Proy\n\n"; - print_usage(); - print < \$o_verb, 'verbose' => \$o_verb, - 'h' => \$o_help, 'help' => \$o_help, - 'H:s' => \$o_host, 'hostname:s' => \$o_host, - 'p:i' => \$o_port, 'port:i' => \$o_port, - 'C:s' => \$o_community, 'community:s' => \$o_community, - 'l:s' => \$o_login, 'login:s' => \$o_login, - 'x:s' => \$o_passwd, 'passwd:s' => \$o_passwd, - 't:i' => \$o_timeout, 'timeout:i' => \$o_timeout, - 'V' => \$o_version, 'version' => \$o_version, - - '2' => \$o_version2, 'v2c' => \$o_version2, - 'c:s' => \$o_crit, 'critical:s' => \$o_crit, - 'w:s' => \$o_warn, 'warn:s' => \$o_warn, - 'f' => \$o_perf, 'perfparse' => \$o_perf, - 'T:s' => \$o_check_type, 'type:s' => \$o_check_type, -# For backward compatibility - 'L' => \$o_linux, 'linux' => \$o_linux, - 'A' => \$o_as400, 'as400' => \$o_as400, - 'I' => \$o_cisco, 'cisco' => \$o_cisco, - 'N' => \$o_linuxC, 'netsnmp' => \$o_linuxC, -# For Oreon rrdtool graph - "rrd_step:s" => \$o_step, - "g" => \$o_g, "rrdgraph" => \$o_g, - "S=s" => \$o_S, "ServiceId=s" => \$o_S - ); - # For backward compat - if (defined($o_linux)) { $o_check_type="netsl" } - if (defined($o_linuxC)) { $o_check_type="netsc" } - if (defined($o_as400)) { $o_check_type="as400"} - if (defined($o_cisco)) { $o_check_type="cisco"} - # TODO : check the -T option - if (defined ($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}}; - if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}}; - if ( ! defined($o_host) ) # check host and filter - { print_usage(); exit $ERRORS{"UNKNOWN"}} - # check snmp information - if ( !defined($o_community) && (!defined($o_login) || !defined($o_passwd)) ) - { print "Put snmp login info!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - # Check warnings and critical - if (!defined($o_warn) || !defined($o_crit)) - { print "put warning and critical info!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - # Get rid of % sign - $o_warn =~ s/\%//g; - $o_crit =~ s/\%//g; - # Check for multiple warning and crit in case of -L - if (($o_warn =~ /,/) || ($o_crit =~ /,/)) { - if (($o_check_type ne "netsl") && ($o_check_type ne "cisco")) { print "Multiple warning without -L or -I switch\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - @o_warnL=split(/,/ , $o_warn); - @o_critL=split(/,/ , $o_crit); - if (($#o_warnL != 2) || ($#o_critL != 2)) - { print "3 warnings and critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - for (my $i=0;$i<3;$i++) { - if ( isnnum($o_warnL[$i]) || isnnum($o_critL[$i])) - { print "Numeric value for warning or critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - if ($o_warnL[$i] > $o_critL[$i]) - { print "warning <= critical ! \n";print_usage(); exit $ERRORS{"UNKNOWN"}} - } - } else { - if (($o_check_type eq "netsl") || ($o_check_type eq "cisco")) { print "Multiple warn and crit levels needed with -L or -I switch\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - if ( isnnum($o_warn) || isnnum($o_crit) ) - { print "Numeric value for warning or critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - if ($o_warn > $o_crit) - { print "warning <= critical ! \n";print_usage(); exit $ERRORS{"UNKNOWN"}} - } - - ###### Oreon ####### - - if (!defined($o_S)) { $o_S="1_1" } - $ServiceId = is_valid_serviceid($o_S); - - if (!defined($o_step)) { $o_step="300" } - $step = $1 if ($o_step =~ /(\d+)/); - - -} - - - - - -########## MAIN ####### - -check_options(); - -$rrd = $pathtorrdbase.$ServiceId.".rrd"; -$start=time; - -# Check gobal timeout if snmp screws up -if (defined($TIMEOUT)) { - verb("Alarm at $TIMEOUT + 5"); - alarm($TIMEOUT+5); -} else { - verb("no timeout defined : $o_timeout + 10"); - alarm ($o_timeout+10); -} - -# Connect to host -my ($session,$error); -if ( defined($o_login) && defined($o_passwd)) { - # SNMPv3 login - verb("SNMPv3 login"); - ($session, $error) = Net::SNMP->session( - -hostname => $o_host, - -version => '3', - -username => $o_login, - -authpassword => $o_passwd, - -authprotocol => 'md5', - -privpassword => $o_passwd, - -timeout => $o_timeout - ); -} else { - if (defined ($o_version2)) { - # SNMPv2 Login - ($session, $error) = Net::SNMP->session( - -hostname => $o_host, - -version => 2, - -community => $o_community, - -port => $o_port, - -timeout => $o_timeout - ); - } else { - # SNMPV1 login - ($session, $error) = Net::SNMP->session( - -hostname => $o_host, - -community => $o_community, - -port => $o_port, - -timeout => $o_timeout - ); - } -} -if (!defined($session)) { - printf("ERROR opening session: %s.\n", $error); - exit $ERRORS{"UNKNOWN"}; -} - -my $exit_val=undef; -########### Linux load check ############## - -if ($o_check_type eq "netsl") { - -verb("Checking linux load"); -# Get load table -my $resultat = (Net::SNMP->VERSION < 4) ? - $session->get_table($linload_table) - : $session->get_table(Baseoid => $linload_table); - -if (!defined($resultat)) { - printf("ERROR: Description table : %s.\n", $session->error); - $session->close; - exit $ERRORS{"UNKNOWN"}; -} -$session->close; - -my @load = undef; -my @iload = undef; -my @oid=undef; -foreach my $key ( keys %$resultat) { - verb("OID : $key, Desc : $$resultat{$key}"); - if ( $key =~ /$linload_name/ ) { - @oid=split (/\./,$key); - $iload[0]= pop(@oid) if ($$resultat{$key} eq "Load-1"); - $iload[1]= pop(@oid) if ($$resultat{$key} eq "Load-5"); - $iload[2]= pop(@oid) if ($$resultat{$key} eq "Load-15"); - } -} - -for (my $i=0;$i<3;$i++) { $load[$i] = $$resultat{$linload_load . "." . $iload[$i]}}; - -## -## RRD management -## - -if ($o_g) { - $start=time; - if (! -e $rrd) { - create_rrd($rrd,3,$start,$step,0,"U","GAUGE"); - } - update_rrd($rrd,$start, $load[0] ,$load[1], $load[2]); -} - - -print "Load : $load[0] $load[1] $load[2] :"; - -$exit_val=$ERRORS{"OK"}; -for (my $i=0;$i<3;$i++) { - if ( $load[$i] > $o_critL[$i] ) { - print " $load[$i] > $o_critL[$i] : CRITICAL"; - $exit_val=$ERRORS{"CRITICAL"}; - } - if ( $load[$i] > $o_warnL[$i] ) { - # output warn error only if no critical was found - if ($exit_val eq $ERRORS{"OK"}) { - print " $load[$i] > $o_warnL[$i] : WARNING"; - $exit_val=$ERRORS{"WARNING"}; - } - } -} -print " OK" if ($exit_val eq $ERRORS{"OK"}); -if (defined($o_perf)) { - print " | load_1_min=$load[0];$o_warnL[0];$o_critL[0],"; - print "load_5_min=$load[1];$o_warnL[1];$o_critL[1],"; - print "load_15_min=$load[2];$o_warnL[2];$o_critL[2]\n"; -} else { - print "\n"; -} -exit $exit_val; -} - -############## Cisco CPU check ################ - -if ($o_check_type eq "cisco") { -my @oidlists = ($cisco_cpu_5m, $cisco_cpu_1m, $cisco_cpu_5s); -my $resultat = (Net::SNMP->VERSION < 4) ? - $session->get_request(@oidlists) - : $session->get_request(-varbindlist => \@oidlists); - -if (!defined($resultat)) { - printf("ERROR: Description table : %s.\n", $session->error); - $session->close; - exit $ERRORS{"UNKNOWN"}; -} - -$session->close; - -if (!defined ($$resultat{$cisco_cpu_5s})) { - print "No CPU information : UNKNOWN\n"; - exit $ERRORS{"UNKNOWN"}; -} - -my @load = undef; - -$load[0]=$$resultat{$cisco_cpu_5s}; -$load[1]=$$resultat{$cisco_cpu_1m}; -$load[2]=$$resultat{$cisco_cpu_5m}; - -## -## RRD management -## - -if ($o_g) { - $start=time; - if (! -e $rrd) { - create_rrd($rrd,3,$start,$step,0,"U","GAUGE"); - } - update_rrd($rrd,$start,$load[0] ,$load[1], $load[2]); -} - -print "CPU : $load[0] $load[1] $load[2] :"; - -$exit_val=$ERRORS{"OK"}; -for (my $i=0;$i<3;$i++) { - if ( $load[$i] > $o_critL[$i] ) { - print " $load[$i] > $o_critL[$i] : CRITICAL"; - $exit_val=$ERRORS{"CRITICAL"}; - } - if ( $load[$i] > $o_warnL[$i] ) { - # output warn error only if no critical was found - if ($exit_val eq $ERRORS{"OK"}) { - print " $load[$i] > $o_warnL[$i] : WARNING"; - $exit_val=$ERRORS{"WARNING"}; - } - } -} -print " OK" if ($exit_val eq $ERRORS{"OK"}); -if (defined($o_perf)) { - print " | load_5_sec=$load[0]%;$o_warnL[0];$o_critL[0],"; - print "load_1_min=$load[1]%;$o_warnL[1];$o_critL[1],"; - print "load_5_min=$load[2]%;$o_warnL[2];$o_critL[2]\n"; -} else { - print "\n"; -} - -exit $exit_val; -} - -################## CPU for : AS/400 , Netsnmp, HP, Bluecoat, linkproof ########### -if ( $o_check_type =~ /netsc|as400|bc|nokia|hp|lp/ ) { - -# Get load table -my @oidlist = $cpu_oid{$o_check_type}; -verb("Checking OID : @oidlist"); -my $resultat = (Net::SNMP->VERSION < 4) ? - $session->get_request(@oidlist) - : $session->get_request(-varbindlist => \@oidlist); -if (!defined($resultat)) { - printf("ERROR: Description table : %s.\n", $session->error); - $session->close; - exit $ERRORS{"UNKNOWN"}; -} -$session->close; - -if (!defined ($$resultat{$cpu_oid{$o_check_type}})) { - print "No CPU information : UNKNOWN\n"; - exit $ERRORS{"UNKNOWN"}; -} - -my $load=$$resultat{$cpu_oid{$o_check_type}}; -verb("OID returned $load"); -# for AS400, divide by 100 -if ($o_check_type eq "as400") {$load /= 100; }; -# for Net-snmp : oid returned idle time so load = 100-idle. -if ($o_check_type eq "netsc") {$load = 100 - $load; }; - -## -## RRD management -## - -if ($o_g) { - $start=time; - if (! -e $rrd) { - create_rrd($rrd,1,$start,$step,0,"U","GAUGE"); - } - update_rrd($rrd,$start,$load); -} - - -printf("CPU used %.1f%% (",$load); - -$exit_val=$ERRORS{"OK"}; -if ($load > $o_crit) { - print ">$o_crit) : CRITICAL"; - $exit_val=$ERRORS{"CRITICAL"}; -} else { - if ($load > $o_warn) { - print ">$o_warn) : WARNING"; - $exit_val=$ERRORS{"WARNING"}; - } -} -print "<$o_warn) : OK" if ($exit_val eq $ERRORS{"OK"}); -(defined($o_perf)) ? - print " | cpu_prct_used=$load%;$o_warn;$o_crit\n" - : print "\n"; -exit $exit_val; - -} - -########## Standard cpu usage check ############ -# Get desctiption table -my $resultat = (Net::SNMP->VERSION < 4) ? - $session->get_table($base_proc) - : $session->get_table(Baseoid => $base_proc); - -if (!defined($resultat)) { - printf("ERROR: Description table : %s.\n", $session->error); - $session->close; - exit $ERRORS{"UNKNOWN"}; -} - -$session->close; - -my ($cpu_used,$ncpu)=(0,0); -foreach my $key ( keys %$resultat) { - verb("OID : $key, Desc : $$resultat{$key}"); - if ( $key =~ /$proc_load/) { - $cpu_used += $$resultat{$key}; - $ncpu++; - } -} - -if ($ncpu==0) { - print "Can't find CPU usage information : UNKNOWN\n"; - exit $ERRORS{"UNKNOWN"}; -} - -$cpu_used /= $ncpu; - -## -## RRD management -## - -if ($o_g) { - $start=time; - if (! -e $rrd) { - create_rrd($rrd,1,$start,$step,0,"U","GAUGE"); - } - update_rrd($rrd,$start,$cpu_used); -} - -print "$ncpu CPU, ", $ncpu==1 ? "load" : "average load"; -printf(" %.1f",$cpu_used); -$exit_val=$ERRORS{"OK"}; - -if ($cpu_used > $o_crit) { - print " > $o_crit : CRITICAL"; - $exit_val=$ERRORS{"CRITICAL"}; -} else { - if ($cpu_used > $o_warn) { - print " > $o_warn : WARNING"; - $exit_val=$ERRORS{"WARNING"}; - } -} -print " < $o_warn : OK" if ($exit_val eq $ERRORS{"OK"}); -(defined($o_perf)) ? - print " | cpu_prct_used=$cpu_used%;$o_warn;$o_crit\n" - : print "\n"; -exit $exit_val; - diff --git a/centreon-plugins/Dev/src/check_snmp_mem.pl b/centreon-plugins/Dev/src/check_snmp_mem.pl deleted file mode 100644 index 485e925d3..000000000 --- a/centreon-plugins/Dev/src/check_snmp_mem.pl +++ /dev/null @@ -1,542 +0,0 @@ -#!/usr/bin/perl -w -############################## check_snmp_mem ############## -# Version : 0.9 -# Date : Jul 20 2005 -# Author : Patrick Proy (patrick at proy.org) -# Help : http://www.manubulon.com/nagios/ -# Licence : GPL - http://www.fsf.org/licenses/gpl.txt -# TODO : snmpv3 -################################################################# -# -# Help : ./check_snmp_mem.pl -h -# - -use strict; -use Net::SNMP; -use Getopt::Long; - -# Nagios specific - -use lib "@NAGIOS_PLUGINS@"; -use utils qw(%ERRORS $TIMEOUT); -#my $TIMEOUT = 15; -#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); - -# 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'}; -} - -my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL}; - -# SNMP Datas - -# Net-snmp memory - -my $nets_ram_free = "1.3.6.1.4.1.2021.4.6.0"; # Real memory free -my $nets_ram_total = "1.3.6.1.4.1.2021.4.5.0"; # Real memory total -my $nets_swap_free = "1.3.6.1.4.1.2021.4.4.0"; # swap memory free -my $nets_swap_total = "1.3.6.1.4.1.2021.4.3.0"; # Swap memory total -my @nets_oids = ($nets_ram_free,$nets_ram_total,$nets_swap_free,$nets_swap_total); - -# Cisco - -my $cisco_mem_pool = "1.3.6.1.4.1.9.9.48.1.1.1"; # Cisco memory pool -my $cisco_index = "1.3.6.1.4.1.9.9.48.1.1.1.2"; # memory pool name and index -my $cisco_valid = "1.3.6.1.4.1.9.9.48.1.1.1.4"; # Valid memory if 1 -my $cisco_used = "1.3.6.1.4.1.9.9.48.1.1.1.5"; # Used memory -my $cisco_free = "1.3.6.1.4.1.9.9.48.1.1.1.6"; # Used memory -# .1 : type, .2 : name, .3 : alternate, .4 : valid, .5 : used, .6 : free, .7 : max free - -# HP Procurve - -my $hp_mem_pool = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1"; # HP memory pool -my $hp_mem_index = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.1"; # memory slot index -my $hp_mem_total = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.5"; # Total Bytes -my $hp_mem_free = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.6"; # Free Bytes -my $hp_mem_free_seg = "1.3.6.1.4.1.11.2.14.11.5.1.1.2.2.1.1.3"; # Free segments - -# AS/400 - -# Windows NT/2K/(XP?) - -# check_snmp_storage.pl -C -H -m "^Virtual Memory$" -w -c - - -# Globals - -my $Version='0.9'; - -my $o_host = undef; # hostname -my $o_community = undef; # community -my $o_port = 161; # port -my $o_help= undef; # wan't some help ? -my $o_verb= undef; # verbose mode -my $o_version= undef; # print version -my $o_netsnmp= 1; # Check with netsnmp (default) -my $o_cisco= undef; # Check cisco router mem -my $o_hp= undef; # Check hp procurve mem -my $o_warn= undef; # warning level option -my $o_warnR= undef; # warning level for Real memory -my $o_warnS= undef; # warning levels for swap -my $o_crit= undef; # Critical level option -my $o_critR= undef; # critical level for Real memory -my $o_critS= undef; # critical level for swap -my $o_perf= undef; # Performance data option -my $o_timeout= 5; # Default 5s Timeout -my $o_version2= undef; # use snmp v2c -# SNMPv3 specific -my $o_login= undef; # Login for snmpv3 -my $o_passwd= undef; # Pass for snmpv3 - -# 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; - - -# functions - -sub p_version { print "check_snmp_mem version : $Version\n"; } - -sub print_usage { - print "Usage: $0 [-v] -H -C [-2] | (-l login -x passwd) [-p ] -w -c [-I|-N|-E] [-f] [-t ] [-V]\n"; -} - -sub isnnum { # Return true if arg is not a number - my $num = shift; - if ( $num =~ /^(\d+\.?\d*)|(^\.\d+)$/ ) { return 0 ;} - return 1; -} - -sub round ($$) { - sprintf "%.$_[1]f", $_[0]; -} - -sub help { - print "\nSNMP Memory Monitor for Nagios version ",$Version,"\n"; - print "(c)2004 to my cat Ratoune - Author: Patrick Proy\n\n"; - print_usage(); - print < \$o_verb, 'verbose' => \$o_verb, - 'h' => \$o_help, 'help' => \$o_help, - 'H:s' => \$o_host, 'hostname:s' => \$o_host, - 'p:i' => \$o_port, 'port:i' => \$o_port, - 'C:s' => \$o_community, 'community:s' => \$o_community, - 'l:s' => \$o_login, 'login:s' => \$o_login, - 'x:s' => \$o_passwd, 'passwd:s' => \$o_passwd, - 't:i' => \$o_timeout, 'timeout:i' => \$o_timeout, - 'V' => \$o_version, 'version' => \$o_version, - 'I' => \$o_cisco, 'cisco' => \$o_cisco, - 'N' => \$o_netsnmp, 'netsnmp' => \$o_netsnmp, - 'E' => \$o_hp, 'hp' => \$o_hp, - '2' => \$o_version2, 'v2c' => \$o_version2, - 'c:s' => \$o_crit, 'critical:s' => \$o_crit, - 'w:s' => \$o_warn, 'warn:s' => \$o_warn, - 'f' => \$o_perf, 'perfdata' => \$o_perf, -# For Oreon rrdtool graph - "rrd_step:s" => \$o_step, - "g" => \$o_g, "rrdgraph" => \$o_g, - "S=s" => \$o_S, "ServiceId=s" => \$o_S - ); - if (defined ($o_help) ) { help(); exit $ERRORS{"UNKNOWN"}}; - if (defined($o_version)) { p_version(); exit $ERRORS{"UNKNOWN"}}; - if ( ! defined($o_host) ) # check host and filter - { print "No host defined!\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - # check snmp information - if ( !defined($o_community) && (!defined($o_login) || !defined($o_passwd)) ) - { print "Put snmp login info!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - #Check Warning and crit are present - if ( ! defined($o_warn) || ! defined($o_crit)) - { print "Put warning and critical values!\n"; print_usage(); exit $ERRORS{"UNKNOWN"}} - # Get rid of % sign - $o_warn =~ s/\%//g; - $o_crit =~ s/\%//g; - # if -N or -E switch , undef $o_netsnmp - if (defined($o_cisco) || defined($o_hp) ) { - $o_netsnmp=undef; - if ( isnnum($o_warn) || isnnum($o_crit)) - { print "Numeric value for warning or critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"} } - if ( ($o_crit != 0) && ($o_warn > $o_crit) ) - { print "warning <= critical ! \n";print_usage(); exit $ERRORS{"UNKNOWN"}} - } - if (defined($o_netsnmp)) { - my @o_warnL=split(/,/ , $o_warn); - my @o_critL=split(/,/ , $o_crit); - if (($#o_warnL != 1) || ($#o_critL != 1)) - { print "2 warnings and critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - for (my $i=0;$i<2;$i++) { - if ( isnnum($o_warnL[$i]) || isnnum($o_critL[$i])) - { print "Numeric value for warning or critical !\n";print_usage(); exit $ERRORS{"UNKNOWN"} } - if (($o_critL[$i]!= 0) && ($o_warnL[$i] > $o_critL[$i])) - { print "warning <= critical ! \n";print_usage(); exit $ERRORS{"UNKNOWN"}} - if ( $o_critL[$i] > 100) - { print "critical percent must be < 100 !\n";print_usage(); exit $ERRORS{"UNKNOWN"}} - } - $o_warnR=$o_warnL[0];$o_warnS=$o_warnL[1]; - $o_critR=$o_critL[0];$o_critS=$o_critL[1]; - } - - ###### Oreon ####### - - if (!defined($o_S)) { $o_S="1_1" } - $ServiceId = is_valid_serviceid($o_S); - - if (!defined($o_step)) { $o_step="300" } - $step = $1 if ($o_step =~ /(\d+)/); - -} - -########## MAIN ####### - -check_options(); - -$rrd = $pathtorrdbase.$ServiceId.".rrd"; -$start=time; - -# Check gobal timeout if snmp screws up -if (defined($TIMEOUT)) { - verb("Alarm at $TIMEOUT"); - alarm($TIMEOUT); -} else { - verb("no timeout defined : $o_timeout + 10"); - alarm ($o_timeout+10); -} - -# Connect to host -my ($session,$error); -if ( defined($o_login) && defined($o_passwd)) { - # SNMPv3 login - verb("SNMPv3 login"); - ($session, $error) = Net::SNMP->session( - -hostname => $o_host, - -version => '3', - -username => $o_login, - -authpassword => $o_passwd, - -authprotocol => 'md5', - -privpassword => $o_passwd, - -timeout => $o_timeout - ); -} else { - if (defined ($o_version2)) { - # SNMPv2 Login - ($session, $error) = Net::SNMP->session( - -hostname => $o_host, - -version => 2, - -community => $o_community, - -port => $o_port, - -timeout => $o_timeout - ); - } else { - - # SNMPV1 login - ($session, $error) = Net::SNMP->session( - -hostname => $o_host, - -community => $o_community, - -port => $o_port, - -timeout => $o_timeout - ); - } -} -if (!defined($session)) { - printf("ERROR opening session: %s.\n", $error); - exit $ERRORS{"UNKNOWN"}; -} - -# Global variable -my $resultat=undef; - -########### Cisco memory check ############ -if (defined ($o_cisco)) { - - # Get Cisco memory table - $resultat = (Net::SNMP->VERSION < 4) ? - $session->get_table($cisco_mem_pool) - :$session->get_table(Baseoid => $cisco_mem_pool); - - if (!defined($resultat)) { - printf("ERROR: Description table : %s.\n", $session->error); - $session->close; - exit $ERRORS{"UNKNOWN"}; - } - my (@oid,@index)=(undef,undef); - my $nindex=0; - foreach my $key ( keys %$resultat) { - verb("OID : $key, Desc : $$resultat{$key}"); - if ( $key =~ /$cisco_index/ ) { - @oid=split (/\./,$key); - $index[$nindex++] = pop(@oid); - } - } - - # Check if at least 1 memory pool exists - if ($nindex == 0) { - printf("ERROR: No memory pools found"); - $session->close; - exit $ERRORS{"UNKNOWN"}; - } - - # Consolidate the datas - my ($used,$free)=(0,0); - my ($c_output,$prct_free)=(undef,undef); - foreach (@index) { - if ( $$resultat{$cisco_valid . "." . $_} == 1 ) { - $c_output .="," if defined ($c_output); - $used += $$resultat{$cisco_used . "." . $_}; - $free += $$resultat{$cisco_free . "." . $_}; - $c_output .= $$resultat{$cisco_index . "." . $_} . ":" - .round($$resultat{$cisco_used . "." . $_}*100/($$resultat{$cisco_free . "." . $_}+$$resultat{$cisco_used . "." . $_}) ,0) - . "%"; - } - } - my $total=$used+$free; - $prct_free=round($used*100/($total),0); - verb("Used : $used, Free: $free, Output : $c_output"); - - ## - ## RRD management - ## - - if ($o_g) { - $start=time; - if (! -e $rrd) { - create_rrd($rrd,1,$start,$step,0,100,"GAUGE"); - } - update_rrd($rrd,$start,$prct_free); - } - - my $c_status="OK"; - $c_output .=" : " . $prct_free ."% : "; - if (($o_crit!=0)&&($o_crit <= $prct_free)) { - $c_output .= " > " . $o_crit ; - $c_status="CRITICAL"; - } else { - if (($o_warn!=0)&&($o_warn <= $prct_free)) { - $c_output.=" > " . $o_warn; - $c_status="WARNING"; - } - } - $c_output .= " ; ".$c_status; - if (defined ($o_perf)) { - $c_output .= " | ram_used=" . $used.";"; - $c_output .= ($o_warn ==0)? ";" : round($o_warn * $total/100,0).";"; - $c_output .= ($o_crit ==0)? ";" : round($o_crit * $total/100,0).";"; - $c_output .= "0;" . $total ; - } - $session->close; - print "$c_output \n"; - exit $ERRORS{$c_status}; -} - -########### HP Procurve memory check ############ -if (defined ($o_hp)) { - - # Get hp memory table - $resultat = (Net::SNMP->VERSION < 4) ? - $session->get_table($hp_mem_pool) - :$session->get_table(Baseoid => $hp_mem_pool); - - if (!defined($resultat)) { - printf("ERROR: Description table : %s.\n", $session->error); - $session->close; - exit $ERRORS{"UNKNOWN"}; - } - my (@oid,@index)=(undef,undef); - my $nindex=0; - foreach my $key ( keys %$resultat) { - verb("OID : $key, Desc : $$resultat{$key}"); - if ( $key =~ /$hp_mem_index/ ) { - @oid=split (/\./,$key); - $index[$nindex++] = pop(@oid); - } - } - - # Check if at least 1 memory slots exists - if ($nindex == 0) { - printf("ERROR: No memory slots found"); - $session->close; - exit $ERRORS{"UNKNOWN"}; - } - - # Consolidate the datas - my ($total,$free)=(0,0); - my ($c_output,$prct_free)=(undef,undef); - foreach (@index) { - $c_output .="," if defined ($c_output); - $total += $$resultat{$hp_mem_total . "." . $_}; - $free += $$resultat{$hp_mem_free . "." . $_}; - $c_output .= "Slot " . $$resultat{$hp_mem_index . "." . $_} . ":" - .round( - 100 - ($$resultat{$hp_mem_free . "." . $_} *100 / - $$resultat{$hp_mem_total . "." . $_}) ,0) - . "%"; - } - my $used = $total - $free; - $prct_free=round($used*100/($total),0); - verb("Used : $used, Free: $free, Output : $c_output"); - - ## - ## RRD management - ## - - if ($o_g) { - $start=time; - if (! -e $rrd) { - create_rrd($rrd,1,$start,$step,0,100,"GAUGE"); - } - update_rrd($rrd,$start,$prct_free); - } - - my $c_status="OK"; - $c_output .=" : " . $prct_free ."% : "; - if (($o_crit!=0)&&($o_crit <= $prct_free)) { - $c_output .= " > " . $o_crit ; - $c_status="CRITICAL"; - } else { - if (($o_warn!=0)&&($o_warn <= $prct_free)) { - $c_output.=" > " . $o_warn; - $c_status="WARNING"; - } - } - $c_output .= " ; ".$c_status; - if (defined ($o_perf)) { - $c_output .= " | ram_used=" . $used.";"; - $c_output .= ($o_warn ==0)? ";" : round($o_warn * $total/100,0).";"; - $c_output .= ($o_crit ==0)? ";" : round($o_crit * $total/100,0).";"; - $c_output .= "0;" . $total ; - } - $session->close; - print "$c_output \n"; - exit $ERRORS{$c_status}; -} - -########### Net snmp memory check ############ -if (defined ($o_netsnmp)) { - - # Get NetSNMP memory values - $resultat = (Net::SNMP->VERSION < 4) ? - $session->get_request(@nets_oids) - :$session->get_request(-varbindlist => \@nets_oids); - - if (!defined($resultat)) { - printf("ERROR: netsnmp : %s.\n", $session->error); - $session->close; - exit $ERRORS{"UNKNOWN"}; - } - - my ($realused,$swapused)=(undef,undef); - - $realused= ($$resultat{$nets_ram_total} == 0) ? 0 : - ($$resultat{$nets_ram_total}-$$resultat{$nets_ram_free})/$$resultat{$nets_ram_total}; - $swapused= ($$resultat{$nets_swap_total} == 0) ? 0 : - ($$resultat{$nets_swap_total}-$$resultat{$nets_swap_free})/$$resultat{$nets_swap_total}; - $realused=round($realused*100,0); - $swapused=round($swapused*100,0); - verb ("Ram : $$resultat{$nets_ram_free} / $$resultat{$nets_ram_total} : $realused"); - verb ("Swap : $$resultat{$nets_swap_free} / $$resultat{$nets_swap_total} : $swapused"); - - ## - ## RRD management - ## - - if ($o_g) { - $start=time; - if (! -e $rrd) { - create_rrd($rrd,2,$start,$step,0,100,"GAUGE"); - } - update_rrd($rrd,$start,$realused, $swapused ); - } - - - - my $n_status="OK"; - my $n_output="Ram : " . $realused . "%, Swap : " . $swapused . "% :"; - if ((($o_critR!=0)&&($o_critR <= $realused)) || (($o_critS!=0)&&($o_critS <= $swapused))) { - $n_output .= " > " . $o_critR . ", " . $o_critS; - $n_status="CRITICAL"; - } else { - if ((($o_warnR!=0)&&($o_warnR <= $realused)) || (($o_warnS!=0)&&($o_warnS <= $swapused))) { - $n_output.=" > " . $o_warnR . ", " . $o_warnS; - $n_status="WARNING"; - } - } - $n_output .= " ; ".$n_status; - if (defined ($o_perf)) { - $n_output .= " | ram_used=" . ($$resultat{$nets_ram_total}-$$resultat{$nets_ram_free}).";"; - $n_output .= ($o_warnR ==0)? ";" : round($o_warnR * $$resultat{$nets_ram_total}/100,0).";"; - $n_output .= ($o_critR ==0)? ";" : round($o_critR * $$resultat{$nets_ram_total}/100,0).";"; - $n_output .= "0;" . $$resultat{$nets_ram_total}. " "; - $n_output .= "swap_used=" . ($$resultat{$nets_swap_total}-$$resultat{$nets_swap_free}).";"; - $n_output .= ($o_warnS ==0)? ";" : round($o_warnS * $$resultat{$nets_swap_total}/100,0).";"; - $n_output .= ($o_critS ==0)? ";" : round($o_critS * $$resultat{$nets_swap_total}/100,0).";"; - $n_output .= "0;" . $$resultat{$nets_swap_total}; - } - $session->close; - print "$n_output \n"; - exit $ERRORS{$n_status}; - -} diff --git a/centreon-plugins/Dev/src/check_snmp_process.pl b/centreon-plugins/Dev/src/check_snmp_process.pl deleted file mode 100644 index 41d4bfde3..000000000 --- a/centreon-plugins/Dev/src/check_snmp_process.pl +++ /dev/null @@ -1,602 +0,0 @@ -#!/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 - -############### 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 "@NAGIOS_PLUGINS@"; -use utils qw(%ERRORS $TIMEOUT); -#my $TIMEOUT = 5; -#my %ERRORS=('OK'=>0,'WARNING'=>1,'CRITICAL'=>2,'UNKNOWN'=>3,'DEPENDENT'=>4); - -# Oreon specific - -#use lib "@NAGIOS_PLUGINS@"; -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'}; -} - -my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL}; - - -# 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 :