git-svn-id: http://svn.centreon.com/Plugins/Dev@2608 6bcd3966-0018-0410-8128-fd23d134de7e
This commit is contained in:
parent
15ff38c281
commit
d6f7563cf9
|
@ -1,218 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_graph_dell_temperature.pl,v 1.1 2005/07/27 22:22:48 wistof Exp $
|
||||
#
|
||||
# Oreon's plugins are developped with GPL Licence :
|
||||
# http://www.fsf.org/licenses/gpl.txt
|
||||
# Developped by : Wistof
|
||||
#
|
||||
# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf
|
||||
#
|
||||
# The Software is provided to you AS IS and WITH ALL FAULTS.
|
||||
# OREON makes no representation and gives no warranty whatsoever,
|
||||
# whether express or implied, and without limitation, with regard to the quality,
|
||||
# safety, contents, performance, merchantability, non-infringement or suitability for
|
||||
# any particular or intended purpose of the Software found on the OREON web site.
|
||||
# In no event will OREON be liable for any direct, indirect, punitive, special,
|
||||
# incidental or consequential damages however they may arise and even if OREON has
|
||||
# been previously advised of the possibility of such damages.
|
||||
|
||||
# based on "graph plugins" developped by Oreon Team. See http://www.oreon.org.
|
||||
##
|
||||
## Plugin init
|
||||
##
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp oid_lex_sort);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@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 $VERSION);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_h $opt_V $opt_g $opt_D $opt_S $opt_H $opt_C $opt_v $opt_s $opt_t $opt_step $step $sensor $OID $OID_DESC);
|
||||
|
||||
##
|
||||
## Plugin var init
|
||||
##
|
||||
|
||||
|
||||
$VERSION = '$Revision: 1.1 $';
|
||||
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
|
||||
|
||||
my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
$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,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"rrd_step=s" => \$opt_step,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"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_S) || ($opt_S = shift) || ($opt_S = "1_1");
|
||||
my $ServiceId = is_valid_serviceid($opt_S);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
($opt_step) || ($opt_step = shift) || ($opt_step = "300");
|
||||
$step = $1 if ($opt_step =~ /(\d+)/);
|
||||
|
||||
|
||||
my $rrd = $pathtorrdbase.$ServiceId.".rrd";
|
||||
|
||||
my $start=time;
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
##
|
||||
## RRDTools create rrd
|
||||
##
|
||||
if ($opt_g) {
|
||||
if (! -e $rrd) {
|
||||
oreon::create_rrd ($rrd,1,$start,$step,"U","U","GAUGE");
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
## 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);
|
||||
|
||||
##
|
||||
## RRDtools update
|
||||
##
|
||||
if ($opt_g) {
|
||||
$start=time;
|
||||
oreon::update_rrd ($rrd,$start,$un);
|
||||
}
|
||||
|
||||
##
|
||||
## 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 " -g (--rrdgraph) create a rrd base 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 " -D (--directory) Path to rrdatabase (or create the .rrd in this directory)\n";
|
||||
print " by default: ".$pathtorrdbase."\n";
|
||||
print " (The path is valid with spaces '/my\ path/...')\n";
|
||||
print " -S (--ServiceId) Oreon Service Id\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";
|
||||
}
|
|
@ -1,202 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_graph_http.pl,v 1.3 2005/08/01 18:03:52 gollum123 Exp $
|
||||
#
|
||||
# This plugin is developped under GPL Licence:
|
||||
# http://www.fsf.org/licenses/gpl.txt
|
||||
|
||||
# Developped by Linagora SA: http://www.linagora.com
|
||||
|
||||
# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf
|
||||
|
||||
# The Software is provided to you AS IS and WITH ALL FAULTS.
|
||||
# LINAGORA makes no representation and gives no warranty whatsoever,
|
||||
# whether express or implied, and without limitation, with regard to the quality,
|
||||
# safety, contents, performance, merchantability, non-infringement or suitability for
|
||||
# any particular or intended purpose of the Software found on the LINAGORA web site.
|
||||
# In no event will LINAGORA be liable for any direct, indirect, punitive, special,
|
||||
# incidental or consequential damages however they may arise and even if LINAGORA has
|
||||
# been previously advised of the possibility of such damages.
|
||||
|
||||
# based on "graph plugins" developped by Oreon Team. See http://www.oreon.org.
|
||||
|
||||
##
|
||||
## Plugin init
|
||||
##
|
||||
use strict;
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@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 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 $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
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,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"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
|
||||
|
||||
my $result = `$pathtolibexechttp $args_check_http`;
|
||||
my $return_code = $? / 256;
|
||||
|
||||
$_ = $result;
|
||||
m/time=\s*(\d*\.\d*)/;
|
||||
my $time = $1;
|
||||
$result =~ s/\n//;
|
||||
my @output = split(/\|/,$result);
|
||||
print $output[0];
|
||||
if ($output[1]) {
|
||||
my @outputpp = split(/\ /,$output[1]);
|
||||
print "|".$outputpp[0];
|
||||
}
|
||||
print "\n";
|
||||
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";
|
||||
}
|
|
@ -1,182 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_graph_load_average.pl,v 1.2 2005/07/27 22:21:49 wistof Exp $
|
||||
#
|
||||
# Oreon's plugins are developped with GPL Licence :
|
||||
# http://www.fsf.org/licenses/gpl.txt
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
#
|
||||
# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf
|
||||
#
|
||||
# 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);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
#use lib "/srv/nagios/libexec";
|
||||
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_V $opt_h $opt_g $opt_v $opt_C $opt_H $opt_D $opt_S $opt_step $step $snmp $opt_f);
|
||||
|
||||
|
||||
##
|
||||
## Plugin var init
|
||||
##
|
||||
my($return_code);
|
||||
|
||||
my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
|
||||
$PROGNAME = "check_graph_load_average";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"rrd_step=s" => \$opt_step,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
|
||||
"f" => \$opt_f, "perfparse" => \$opt_f);
|
||||
|
||||
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_S) || ($opt_S = shift) || ($opt_S = "1_1");
|
||||
my $ServiceId = is_valid_serviceid($opt_S);
|
||||
|
||||
($opt_v) || ($opt_v = shift) || ($opt_v = "2");
|
||||
$snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
($opt_step) || ($opt_step = shift) || ($opt_step = "300");
|
||||
$step = $1 if ($opt_step =~ /(\d+)/);
|
||||
|
||||
my $rrd = $pathtorrdbase.$ServiceId.".rrd";
|
||||
|
||||
my $start=time;
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
##
|
||||
## RRDTools create rrd
|
||||
##
|
||||
if ($opt_g) {
|
||||
if (! -e $rrd) {
|
||||
create_rrd ($rrd,3,$start,$step,"U","U","GAUGE");
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
## Plugin snmp requests
|
||||
##
|
||||
$return_code = 0;
|
||||
|
||||
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 ) = Net::SNMP->session(-hostname => $opt_H,-community => $opt_C, -version => $snmp);
|
||||
if ( !defined($session) ) {
|
||||
print("UNKNOWN: $error");
|
||||
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};
|
||||
|
||||
##
|
||||
## RRDtools update
|
||||
##
|
||||
if ($opt_g && ( $return_code == 0) ) {
|
||||
$start=time;
|
||||
update_rrd ($rrd,$start,$un,$cinq,$quinze);
|
||||
}
|
||||
|
||||
##
|
||||
## Plugin return code
|
||||
##
|
||||
|
||||
my $PERFPARSE = "";
|
||||
|
||||
if ($return_code == 0){
|
||||
$PERFPARSE = "|load1=".$un."%;;;0;100 load5=".$cinq."%;;;0;100 load15=".$quinze."%;;;0;100";
|
||||
print "load average: $un, $cinq, $quinze".$PERFPARSE."\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} else {
|
||||
print "Load Average CRITICAL\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 " -g (--rrdgraph) create à rrd base 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 " -D (--directory) Path to rrdatabase (or create the .rrd in this directory)\n";
|
||||
print " by default: ".$pathtorrdbase."\n";
|
||||
print " (The path is valid with spaces '/my\ path/...')\n";
|
||||
print " -S (--ServiceId) Oreon Service Id\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "Copyright (c) 2004-2005 OREON\n";
|
||||
print "Bugs to http://bugs.oreon-project.org/\n";
|
||||
print "\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
|
@ -1,404 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_graph_nt.pl,v 1.3 2005/08/01 18:04:00 gollum123 Exp $
|
||||
#
|
||||
# Oreon's plugins are developped with GPL Licence :
|
||||
# http://www.fsf.org/licenses/gpl.txt
|
||||
# Developped by : Julien Mathis - Mathieu Mettre
|
||||
# Under control of Flavien Astraud, Jerome Landrieu for Epitech.
|
||||
# Oreon's plugins are developped in partnership with Linagora company.
|
||||
#
|
||||
# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf
|
||||
#
|
||||
# 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 $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
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 = "check_graph_nt";
|
||||
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,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"rrd_step=s" => \$opt_step,
|
||||
"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_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+)/);
|
||||
|
||||
($opt_S) || ($opt_S = shift) || ($opt_S = "1_1");
|
||||
my $ServiceId = is_valid_serviceid($opt_S);
|
||||
|
||||
##
|
||||
## RRDTool var init
|
||||
##
|
||||
|
||||
my $rrd = $pathtorrdbase.$ServiceId.".rrd";
|
||||
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;
|
||||
if ($opt_g) {
|
||||
unless (-e $rrd) {
|
||||
create_rrd ($rrd,$#values +1,$start,$step,"U","U","GAUGE");
|
||||
}
|
||||
update_rrd ($rrd,$start,@values);
|
||||
}
|
||||
## 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'};
|
||||
}
|
||||
if ($opt_g) {
|
||||
if (! -e $rrd) {
|
||||
create_rrd ($rrd,1,$start,$step,"U","U","GAUGE");
|
||||
} else {
|
||||
update_rrd ($rrd,$start,$uptime);
|
||||
}
|
||||
}
|
||||
$_ =~ 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];
|
||||
if ($opt_g) {
|
||||
unless (-e $rrd) {
|
||||
create_rrd ($rrd,3,$start,$step,"U","U","GAUGE");
|
||||
}
|
||||
if (defined($test[3]) && defined($test[7]) && defined($test[12])){
|
||||
$test[3] =~ s/,/\./ ;
|
||||
$test[7] =~ s/,/\./ ;
|
||||
$test[12] =~ s/,/\./ ;
|
||||
update_rrd ($rrd,$start,$test[3],$test[7],$test[12]);
|
||||
}
|
||||
}
|
||||
## 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];
|
||||
if ($opt_g) {
|
||||
unless (-e $rrd) {
|
||||
create_rrd ($rrd,3,$start,$step,"U","U","GAUGE");
|
||||
}
|
||||
if (defined($test4[1]) && defined($test[6]) && defined($test[11])){
|
||||
# Replace , by . to convert in real float number (for rrdtool)
|
||||
$test4[1] =~ s/,/\./ ;
|
||||
$test[6] =~ s/,/\./ ;
|
||||
$test[11] =~ s/,/\./ ;
|
||||
update_rrd ($rrd,$start,$test4[1],$test[6],$test[11]);
|
||||
}
|
||||
}
|
||||
## 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'};
|
||||
}
|
||||
}
|
||||
if ($opt_g) {
|
||||
if (! -e $rrd) {
|
||||
create_rrd ($rrd,1,$start,$step,"U","U","GAUGE");
|
||||
} else {
|
||||
update_rrd ($rrd,$start,$etat);
|
||||
}
|
||||
}
|
||||
$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;
|
||||
if ($opt_g) {
|
||||
unless (-e $rrd) {
|
||||
create_rrd ($rrd,$#values +1,$start,$step,"U","U","GAUGE");
|
||||
}
|
||||
update_rrd ($rrd,$start,@values);
|
||||
}
|
||||
## 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] [-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 <password>\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 <minutes range>,<warning threshold>,<critical threshold>. <minute range> 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 <service1>... 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 <service1>,<service2>,<service3>,... 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 \"<performance object>counter\",\"<description>\" The <description> 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";
|
||||
print " -g (--rrdgraph) create à rrd base 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 " -D (--directory) Path to rrdatabase (or create the .rrd in this directory)\n";
|
||||
print " by default: ".$pathtorrdbase."\n";
|
||||
print " (The path is valid with spaces '/my\ path/...')\n";
|
||||
print " -S (--ServiceId) Oreon Service Id\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "Copyright (c) 2004 OREON\n";
|
||||
print "Bugs to http://www.oreon.org/\n";
|
||||
print "\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
|
@ -1,215 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_graph_ping.pl,v 1.2 2006/04/28 10:21:49 Julien Mathis $
|
||||
#
|
||||
# Oreon's plugins are developped with GPL Licence :
|
||||
# http://www.fsf.org/licenses/gpl.txt
|
||||
# Developped by : Julien Mathis - Mathieu Mettre - Romain Le Merlus
|
||||
#
|
||||
# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf
|
||||
# Modified By Julien Mathis 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 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_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 $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
|
||||
my $ping = `whereis -b ping`;
|
||||
$ping =~ /^.*:\s(.*)$/;
|
||||
$ping = $1;
|
||||
|
||||
$PROGNAME = "check_graph_ping";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"rrd_step=s" => \$opt_step,"f" => \$opt_f,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"n=s" => \$opt_n, "number=s" => \$opt_n,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
($opt_c) || ($opt_c = shift) || ($opt_c = "500,40%");
|
||||
if ($opt_c =~ /([0-9]+),([0-9]+)%/) {
|
||||
$rta_critical = $1;
|
||||
$pl_critical = $2;
|
||||
}
|
||||
|
||||
($opt_w) || ($opt_w = shift) || ($opt_w = "200,20%");
|
||||
if ($opt_w =~ /([0-9]+),([0-9]+)%/) {
|
||||
$rta_warning = $1;
|
||||
$pl_warning = $2;
|
||||
}
|
||||
|
||||
if ( ($rta_critical <= $rta_warning) || ($pl_critical <= $pl_warning) ) {
|
||||
print "critical must be superior to warning\n";
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
($opt_n) || ($opt_n = shift) || ($opt_n = 1);
|
||||
my $NbPing;
|
||||
if ($opt_n =~ /([0-9]+)/){
|
||||
$NbPing = $1;
|
||||
} else{
|
||||
print "Unknown ping number\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
($opt_S) || ($opt_S = shift) || ($opt_S = 1);
|
||||
my $rrd = $pathtorrdbase.is_valid_serviceid($opt_S).".rrd";
|
||||
|
||||
|
||||
($opt_step) || ($opt_step = shift) || ($opt_step = "300");
|
||||
$step = $1 if ($opt_step =~ /(\d+)/);
|
||||
|
||||
|
||||
my $start=time;
|
||||
|
||||
#
|
||||
# RRDTools create rrd
|
||||
#
|
||||
|
||||
if ($opt_g) {
|
||||
create_rrd($rrd,1,$start,$step,0,"U","GAUGE") if (! -e $rrd);}
|
||||
|
||||
#
|
||||
# Plugin requests
|
||||
#
|
||||
|
||||
$_ = `$ping -n -c $NbPing $opt_H 2>/dev/null`;
|
||||
my $return = $? / 256;
|
||||
|
||||
#
|
||||
# Get Data From Ping Result
|
||||
#
|
||||
|
||||
my $ping_result = $_;
|
||||
my @ping_result_array = split(/\n/,$ping_result);
|
||||
my @ping_subresult1_array;
|
||||
my @ping_subresult2_array;
|
||||
my $rta = 0;
|
||||
my $pl;
|
||||
my $time_answer;
|
||||
|
||||
if( ( $return != 0 ) || $ping_result_array[@ping_result_array -2 ] =~ /100% packet loss/) {
|
||||
$rta = -1;
|
||||
$time_answer = 0;
|
||||
} else {
|
||||
@ping_subresult1_array = split(/=/,$ping_result_array[@ping_result_array -1 ]);
|
||||
@ping_subresult2_array = split(/,/,$ping_result_array[@ping_result_array -2 ]);
|
||||
@ping_subresult1_array = split(/\//,$ping_subresult1_array[1]);
|
||||
@ping_subresult2_array = split(/ /,$ping_subresult2_array[2]);
|
||||
$rta = $ping_subresult1_array[1];
|
||||
$pl = $ping_subresult2_array[1];
|
||||
$time_answer = $ping_subresult1_array[1];
|
||||
$pl =~ /([0-9]+)\%/;
|
||||
$pl = $1;
|
||||
}
|
||||
|
||||
#
|
||||
# Update RRDTool Database.
|
||||
#
|
||||
|
||||
update_rrd($rrd,$start,$rta) if ($opt_g);
|
||||
|
||||
#
|
||||
# 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";
|
||||
}
|
|
@ -1,232 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_graph_process.pl,v 1.2 2005/07/27 22:21:49 wistof Exp $
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# 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 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_V $opt_h $opt_g $opt_v $opt_C $opt_p $opt_H $opt_D $opt_n $opt_S $opt_step $step $result @result %process_list %STATUS $opt_f);
|
||||
my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
|
||||
##
|
||||
## Plugin var init
|
||||
##
|
||||
|
||||
my($proc, $proc_run);
|
||||
|
||||
$PROGNAME = "check_graph_process";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
|
||||
%STATUS=(1=>'running',2=>'runnable',3=>'notRunnable',4=>'invalid');
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"rrd_step=s" => \$opt_step, "f" => \$opt_f,
|
||||
"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,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"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_S) || ($opt_S = shift) || ($opt_S = 1);
|
||||
my $ServiceId = is_valid_serviceid($opt_S);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
my $process = "";
|
||||
if ($opt_p){
|
||||
$process = $1 if ($opt_p =~ /([-.A-Za-z0-9]+)/);
|
||||
}
|
||||
|
||||
($opt_step) || ($opt_step = shift) || ($opt_step = "300");
|
||||
$step = $1 if ($opt_step =~ /(\d+)/);
|
||||
|
||||
|
||||
my $rrd = $pathtorrdbase.$ServiceId.".rrd";
|
||||
my $start=time;
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
##
|
||||
## RRDTools create rrd
|
||||
##
|
||||
|
||||
if ( $opt_g && $opt_n && (! -e $rrd)) {
|
||||
create_rrd ($rrd,1,$start,$step,"U","U","GAUGE");
|
||||
}
|
||||
|
||||
##
|
||||
## 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 ) = Net::SNMP->session(-hostname => $opt_H,-community => $opt_C, -version => $snmp);
|
||||
if ( !defined($session) ) {
|
||||
print("UNKNOWN: $error");
|
||||
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 ""){
|
||||
if ($$result{$key} eq $opt_p){
|
||||
$proc++;
|
||||
}
|
||||
} else {
|
||||
$proc++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!($opt_n))
|
||||
{
|
||||
if ($process_list{$process}) {
|
||||
$result = $session->get_request(-varbindlist => [$OID_SW_RunStatus . "." . $process_list{$process}]);
|
||||
if (!defined($result)) {
|
||||
printf("UNKNOWN: %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
$proc_run = $result->{$OID_SW_RunStatus . "." . $process_list{$process} };
|
||||
print $proc_run;
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
## RRDtools update
|
||||
##
|
||||
|
||||
if ( $opt_g && $opt_n) {
|
||||
$start=time;
|
||||
my $totrrd;
|
||||
if ($opt_n){$totrrd = $proc;}
|
||||
else{
|
||||
if ( ($proc_run == "3") || ($proc_run == "4") ){$totrrd = 0;}
|
||||
else{$totrrd = 1;}
|
||||
}
|
||||
update_rrd ($rrd,$start,$totrrd);
|
||||
}
|
||||
|
||||
##
|
||||
## Plugin return code
|
||||
##
|
||||
|
||||
my $PERFPARSE = "";
|
||||
|
||||
if ($opt_n){
|
||||
if ($opt_f){
|
||||
$PERFPARSE = "|nbproc=$proc";
|
||||
}
|
||||
print "Processes OK - Number of current processes: $proc".$PERFPARSE."\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} else {
|
||||
if ($proc_run){
|
||||
if ($opt_f){
|
||||
$PERFPARSE = "|procstatus=$proc_run";
|
||||
}
|
||||
print "Process OK - $process: $STATUS{$proc_run}".$PERFPARSE."\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 " -g (--rrdgraph) create à rrd base 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 " -D (--directory) Path to rrdatabase (or create the .rrd in this directory)\n";
|
||||
print " by default: ".$pathtorrdbase."\n";
|
||||
print " (The path is valid with spaces '/my\ path/...')\n";
|
||||
print " -n (--number) Return the number of current running processes. \n";
|
||||
print " -p (--process) Set the process name ex: by default smbd\n";
|
||||
print " -S (--ServiceId) Oreon Service Id\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
print " -f Perfparse Compatible\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";
|
||||
}
|
||||
|
|
@ -1,333 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_graph_remote_storage.pl,v 1.2 2005/07/27 22:21:49 wistof Exp $
|
||||
#
|
||||
# Oreon's plugins are developped with GPL Licence :
|
||||
# http://www.fsf.org/licenses/gpl.txt
|
||||
# Developped by : Julien Mathis - Mathieu Mettre - Romain Le Merlus - Yohann Lecarpentier
|
||||
#
|
||||
# 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 Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
#use lib "/usr/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_V $opt_h $opt_g $opt_v $opt_C $opt_d $opt_n $opt_w $opt_c $opt_H $opt_S $opt_D $opt_s $opt_step $step @test $opt_f);
|
||||
my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
|
||||
##
|
||||
## Plugin var init
|
||||
##
|
||||
|
||||
my ($hrStorageDescr, $hrStorageAllocationUnits, $hrStorageSize, $hrStorageUsed);
|
||||
my ($AllocationUnits, $Size, $Used);
|
||||
my ($tot, $used, $pourcent, $return_code);
|
||||
|
||||
$PROGNAME = "check_snmp_remote_storage";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"s" => \$opt_s, "show" => \$opt_s,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"rrd_step=s" => \$opt_step, "f" => \$opt_f,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"d=s" => \$opt_d, "disk=s" => \$opt_d,
|
||||
"n" => \$opt_n, "name" => \$opt_n,
|
||||
"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_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);
|
||||
|
||||
if ($opt_n && !$opt_d) {
|
||||
print "Option -n (--name) need option -d (--disk)\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
($opt_v) || ($opt_v = shift) || ($opt_v = "2");
|
||||
my $snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
($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'};
|
||||
}
|
||||
|
||||
($opt_S) || ($opt_S = shift) || ($opt_S = "1_1");
|
||||
my $ServiceId = is_valid_serviceid($opt_S);
|
||||
|
||||
($opt_c) || ($opt_c = shift) || ($opt_c = 95);
|
||||
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'};
|
||||
}
|
||||
|
||||
($opt_step) || ($opt_step = shift) || ($opt_step = "300");
|
||||
$step = $1 if ($opt_step =~ /(\d+)/);
|
||||
|
||||
my $rrd = $pathtorrdbase.$ServiceId.".rrd";
|
||||
my $start=time;
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
##
|
||||
## RRDTools create rrd
|
||||
##
|
||||
if ($opt_g) {
|
||||
if (! -e $rrd) {
|
||||
create_rrd ($rrd,2,$start,$step,"U","U","GAUGE");
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
## 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 ) = Net::SNMP->session(-hostname => $opt_H,-community => $opt_C, -version => $snmp);
|
||||
if ( !defined($session) ) {
|
||||
print("CRITICAL: SNMP Session : $error");
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
|
||||
#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];
|
||||
}
|
||||
$tot = $tot / 1073741824;
|
||||
$Used = ($Used * $AllocationUnits) / 1073741824;
|
||||
|
||||
##
|
||||
## RRDtools update
|
||||
##
|
||||
|
||||
$start=time;
|
||||
my $totrrd = $tot * 1073741824;
|
||||
|
||||
if ($opt_g) {
|
||||
update_rrd ($rrd,$start,$totrrd,$used);
|
||||
}
|
||||
|
||||
##
|
||||
## 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=".$totrrd."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 " -g (--rrdgraph) create a rrd base 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 " -D (--directory) Path to rrdatabase (or create the .rrd in this directory)\n";
|
||||
print " by default: ".$pathtorrdbase."\n";
|
||||
print " (The path is valid with spaces '/my\ path/...')\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 " -f Perfparse Compatible\n";
|
||||
print " -S (--ServiceId) Oreon Service Id\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";
|
||||
}
|
|
@ -1,195 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_snmp_value.pl,v 1.2 2005/11/17 10:21:49 Julien Mathis $
|
||||
#
|
||||
# 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_g $opt_D $opt_S $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_f $opt_t);
|
||||
use vars qw($ServiceId $rrd $snmp $DS_type);
|
||||
my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
|
||||
$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,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"f" => \$opt_f,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"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);
|
||||
|
||||
($opt_v) || ($opt_v = shift) || ($opt_v = "1");
|
||||
my $snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_S) || ($opt_S = shift) || ($opt_S = "1_1");
|
||||
my $ServiceId = is_valid_serviceid($opt_S);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
my $rrd = $pathtorrdbase.$ServiceId.".rrd";
|
||||
|
||||
($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE");
|
||||
my $DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/);
|
||||
|
||||
($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'};
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $start=time;
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
my $day = 0;
|
||||
|
||||
|
||||
#=== RRDTools create rrd ====
|
||||
|
||||
|
||||
if ($opt_g) {
|
||||
if (! -e $rrd) {
|
||||
create_rrd($rrd,1,$start,300,"U","U",$DS_type);
|
||||
}
|
||||
}
|
||||
|
||||
#=== 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 => [$opt_o]);
|
||||
if (!defined($result)) {
|
||||
printf("UNKNOWN: %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my $return_result = $result->{$opt_o};
|
||||
|
||||
#=== RRDtools update ====
|
||||
|
||||
if ($opt_g) {
|
||||
$start=time;
|
||||
update_rrd($rrd,$start,$return_result);
|
||||
}
|
||||
|
||||
#=== Plugin return code ====
|
||||
if (defined($return_result)){
|
||||
if ($opt_w && $opt_c && $return_result < $opt_w){
|
||||
print "Ok value : " . $return_result;
|
||||
if ($opt_f){ print "|value=".$return_result.";".$opt_w.";".$opt_c.";;";}
|
||||
print "\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif ($opt_w && $opt_c && $return_result >= $opt_w && $return_result < $opt_c){
|
||||
print "Warning value : " . $return_result;
|
||||
if ($opt_f){ print "|value=$return_result;".$opt_w.";".$opt_c.";;";}
|
||||
print "\n";
|
||||
exit $ERRORS{'WARNING'};
|
||||
} elsif ($opt_w && $opt_c && $return_result >= $opt_c){
|
||||
print "Critical value : " . $return_result;
|
||||
if ($opt_f){ print "|value=".$return_result.";".$opt_w.";".$opt_c.";;";}
|
||||
print "\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 " -g (--rrdgraph) create a rrd base and add datas into this one\n";
|
||||
print " -D (--directory) Path to rrdatabase (or create the .rrd in this directory)\n";
|
||||
print " by default: ".$pathtorrdbase."\n";
|
||||
print " (The path is valid with spaces '/my\ path/...')\n";
|
||||
print " -S (--ServiceId) Oreon Service Id\n";
|
||||
print " -o (--oid) OID to check\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";
|
||||
print " -f Perfparse Compatible\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";
|
||||
}
|
|
@ -1,455 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_graph_traffic.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
|
||||
#
|
||||
# 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 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($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_g $opt_v $opt_C $opt_b $opt_H $opt_D $opt_i $opt_n $opt_w $opt_c $opt_s $opt_S $opt_T $opt_step $step);
|
||||
|
||||
my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
|
||||
#
|
||||
# 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);
|
||||
my $pathtolibexecnt = $oreon{NAGIOS_LIBEXEC};
|
||||
|
||||
$PROGNAME = "check_graph_traffic";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"s" => \$opt_s, "show" => \$opt_s,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"rrd_step=s" => \$opt_step,
|
||||
"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,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"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'};
|
||||
}
|
||||
|
||||
##################################################
|
||||
##### 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)/);
|
||||
|
||||
if ($opt_n && !$opt_i) {
|
||||
print "Option -n (--name) need option -i (--interface)\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
($opt_i) || ($opt_i = shift) || ($opt_i = 2);
|
||||
($opt_S) || ($opt_S = shift) || ($opt_S = 1);
|
||||
my $ServiceId = is_valid_serviceid($opt_S);
|
||||
|
||||
($opt_b) || ($opt_b = shift) || ($opt_b = 95);
|
||||
my $bps = $1 if ($opt_b =~ /([0-9]+)/);
|
||||
|
||||
($opt_c) || ($opt_c = shift) || ($opt_c = 95);
|
||||
my $critical = $1 if ($opt_c =~ /([0-9]+)/);
|
||||
|
||||
($opt_w) || ($opt_w = shift) || ($opt_w = 80);
|
||||
my $warning = $1 if ($opt_w =~ /([0-9]+)/);
|
||||
|
||||
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'};
|
||||
}
|
||||
|
||||
($opt_step) || ($opt_step = shift) || ($opt_step = "300");
|
||||
$step = $1 if ($opt_step =~ /(\d+)/);
|
||||
|
||||
##################################################
|
||||
##### RRDTool var init
|
||||
##
|
||||
|
||||
my $rrd = $pathtorrdbase.$ServiceId.".rrd";
|
||||
my $start=time;
|
||||
|
||||
##################################################
|
||||
##### RRDTool create rrd
|
||||
##
|
||||
|
||||
if ($opt_g) {
|
||||
if (! -e $rrd) {
|
||||
create_rrd ($rrd,2,$start,$step,"U","U","GAUGE");
|
||||
}
|
||||
}
|
||||
|
||||
#################################################
|
||||
##### Plugin snmp requests
|
||||
##
|
||||
|
||||
my $OID_DESC =$oreon{MIB2}{IF_DESC};
|
||||
|
||||
# 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'};
|
||||
}
|
||||
|
||||
#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/traffic_if".$interface."_".$opt_H) {
|
||||
open(FILE,"<"."/tmp/traffic_if".$interface."_".$opt_H);
|
||||
while($row = <FILE>){
|
||||
@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/traffic_if".$interface."_".$opt_H)){
|
||||
print "Unknown - /tmp/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);
|
||||
## RRDtools update
|
||||
if ($opt_g) {
|
||||
$start = time;
|
||||
update_rrd($rrd,$start, sprintf("%.1f",abs($in_traffic)), sprintf("%.1f",abs($out_traffic)));
|
||||
}
|
||||
}
|
||||
|
||||
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 " -g (--rrdgraph) create a rrd base 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 " -D (--directory) Path to rrdatabase (or create the .rrd in this directory)\n";
|
||||
print " by default: ".$pathtorrdbase."\n";
|
||||
print " (The path is valid with spaces '/my\ path/...')\n";
|
||||
print " (The path is valid with spaces '/my\ path/...')\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 " -S (--ServiceId) Oreon Service Id\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";
|
||||
}
|
|
@ -1,316 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_graph_traffic,v 1.1 2004/10/21 17:00:00 projectOREON $
|
||||
#
|
||||
# Oreon's plugins are developped with GPL Licence :
|
||||
# http://www.fsf.org/licenses/gpl.txt
|
||||
# Last Developpement by : Jean Baptiste Gouret - Julien Mathis - Mathieu Mettre - Romain Le Merlus - Yohann Lecarpentier
|
||||
#
|
||||
# REVISED BY CVF 6/05/05
|
||||
# Modified for Oreon Project by : Christophe Coraboeuf
|
||||
|
||||
##
|
||||
## 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 create_rrd update_rrd fetch_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($VERSION %oreon);
|
||||
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_g $opt_v $opt_C $opt_H $opt_D $opt_step $opt_i $opt_w $opt_c $opt_s $opt_S $opt_T $opt_Y);
|
||||
use Data::Dumper;
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions ("h" => \$opt_h, "help" => \$opt_h,
|
||||
"s" => \$opt_s, "show" => \$opt_s,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"D=s" => \$opt_D, "directory=s" => \$opt_D,
|
||||
"i=s" => \$opt_i, "interface=s" => \$opt_i,
|
||||
"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,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H,
|
||||
"T=s" => \$opt_T, "Speed=s" => \$opt_T,
|
||||
"rrd_step=s" => \$opt_step,
|
||||
);
|
||||
|
||||
my $PROGNAME = "check_graph_traffic_rrd";
|
||||
my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
|
||||
|
||||
sub print_help () {
|
||||
print "\n";
|
||||
print_revision($PROGNAME,'Revision: 1.1 ');
|
||||
print "\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
support();
|
||||
print "\n";
|
||||
}
|
||||
|
||||
sub main () {
|
||||
|
||||
##
|
||||
## Plugin var init
|
||||
##
|
||||
my ($in_usage, $out_usage, $in_prefix, $out_prefix, $in_traffic, $out_traffic);
|
||||
my ($host, $snmp, $community);
|
||||
my ($interface, $ServiceId, $critical, $warning, $rrd, $start, $name);
|
||||
my $ERROR;
|
||||
my $result;
|
||||
my ($in_bits, $out_bits, $speed, $ds_names, $step, $data);
|
||||
my @valeur;
|
||||
my $i = 0;
|
||||
my ($line, $update_time, $rrdstep, $rrdheartbeat, $bitcounter);
|
||||
my $not_traffic = 1;
|
||||
|
||||
my $OID_IN =$oreon{MIB2}{IF_IN_OCTET};
|
||||
my $OID_OUT = $oreon{MIB2}{IF_OUT_OCTET};
|
||||
my $OID_SPEED = $oreon{MIB2}{IF_SPEED};
|
||||
my $OID_DESC = $oreon{MIB2}{IF_DESC};
|
||||
|
||||
if ($opt_V) { print_revision ($PROGNAME, "Revision: 1.1 "); exit $ERRORS{'OK'}; }
|
||||
if ($opt_h) { print_help(); exit $ERRORS{'OK'}; }
|
||||
if (defined($opt_H) && $opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/) { $host = $1; } else { print_usage(); exit $ERRORS{'UNKNOWN'}; }
|
||||
if ($opt_v) { $snmp = $opt_v; } else { $snmp = "2c"; }
|
||||
if ($opt_C) { $community = $opt_C; } else { $community = "public"; }
|
||||
if ($opt_s || (defined($opt_i) && $opt_i =~ /([0-9]+)/)) { $interface = $1;} else { print "\nUnknown -i number expected... or it doesn't exist, try another interface - number\n"; }
|
||||
if ($opt_g) {
|
||||
($opt_S) || ($opt_S = shift) || ($opt_S = "1_1");
|
||||
$ServiceId = is_valid_serviceid($opt_S);
|
||||
}
|
||||
if (defined($opt_step) && $opt_step =~ /([0-9]+)/) { $rrdstep = $1; $rrdheartbeat = $rrdstep * 2; } else { $rrdstep = 300; $rrdheartbeat = $rrdstep * 2; }
|
||||
if (defined($opt_c) && $opt_c =~ /([0-9]+)/) { $critical = $1; } else { $critical = 95; }
|
||||
if (defined($opt_w) && $opt_w =~ /([0-9]+)/) { $warning = $1; } else { $warning = 80; }
|
||||
if (defined($opt_c) && defined($opt_w) && $critical <= $warning){ print "(--crit) must be superior to (--warn)"; print_usage(); exit $ERRORS{'OK'}; }
|
||||
if (defined($opt_D) && $opt_D =~ /([-.\/\_\ A-Za-z0-9]+)/) { $pathtorrdbase = $1; }
|
||||
|
||||
($opt_v) || ($opt_v = shift) || ($opt_v = "1");
|
||||
$snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
##
|
||||
## RRDTool var init
|
||||
##
|
||||
if ($opt_i) {
|
||||
$OID_IN .= ".".$interface;
|
||||
$OID_OUT .= ".".$interface;
|
||||
$OID_SPEED .= ".".$interface;
|
||||
}
|
||||
|
||||
if ($opt_g && $opt_S) {
|
||||
$rrd = $pathtorrdbase.$ServiceId.".rrd";
|
||||
$start = time;
|
||||
$name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
##
|
||||
## RRDTool create rrd
|
||||
##
|
||||
|
||||
if (!(-e $rrd)) {
|
||||
$_ = `/usr/bin/snmpwalk $host -c $community -v $snmp $OID_IN 2>/dev/null`;
|
||||
if ($_ =~ m/Counter(\d+)/) { $bitcounter = $1; } else { $bitcounter = 32; }
|
||||
$bitcounter = 2 ** $bitcounter;
|
||||
create_rrd ($rrd,2,$start,$rrdstep,0,$bitcounter,"COUNTER");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
## Plugin snmp requests
|
||||
##
|
||||
|
||||
# if ($opt_s) { $_ = `/usr/bin/snmpwalk $host -c $community -v $snmp $OID_DESC 2>/dev/null`; print $_; exit $ERRORS{'OK'}; }
|
||||
|
||||
|
||||
# create a SNMP session #
|
||||
my ( $session, $error ) = Net::SNMP->session(-hostname => $host,-community => $community, -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 "Interface $index :: $$result{$key}\n";
|
||||
}
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
# get IN bits #
|
||||
$result = $session->get_request( -varbindlist => [$OID_IN] );
|
||||
if (!defined($result)) { printf("ERROR : IN : %s.\n", $session->error); $session->close; exit($ERRORS{"CRITICAL"}); }
|
||||
$in_bits = $result->{$OID_IN} * 8;
|
||||
|
||||
|
||||
# get OUT bits #
|
||||
$result = $session->get_request( -varbindlist => [$OID_OUT] );
|
||||
if (!defined($result)) { printf("ERROR : OUT : %s.\n", $session->error); $session->close; exit($ERRORS{"CRITICAL"}); }
|
||||
$out_bits = $result->{$OID_OUT} * 8;
|
||||
|
||||
|
||||
# Get SPEED of interface #
|
||||
if (!defined($opt_T) || $opt_T == 0) {
|
||||
$result = $session->get_request( -varbindlist => [$OID_SPEED] );
|
||||
if (!defined($result)) { printf("ERROR: %s.\n", $session->error); $session->close; exit($ERRORS{"CRITICAL"}); }
|
||||
$speed = $result->{$OID_SPEED};
|
||||
}
|
||||
else {
|
||||
$speed = $opt_T * 1000000;
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
## RRDtools update
|
||||
##
|
||||
|
||||
if ($opt_g) {
|
||||
$start=time;
|
||||
update_rrd ($rrd,$start,$in_bits,$out_bits);
|
||||
|
||||
##
|
||||
## Get the real value in rrdfile
|
||||
##
|
||||
# ($update_time,$step,$ds_names,$data) = RRDs::fetch($rrd, "--resolution=300","--start=now-5min","--end=now","AVERAGE");
|
||||
# foreach $line (@$data) {
|
||||
# foreach $val (@$line) {
|
||||
# if ( defined $val ) { $valeur[$i]=$val; } else { $valeur[$i]="undef"; }
|
||||
# $i++;
|
||||
# }
|
||||
# }*/
|
||||
@valeur = fetch_rrd($rrd,"AVERAGE");
|
||||
$in_traffic = $valeur[0];
|
||||
$out_traffic = $valeur[1];
|
||||
}
|
||||
|
||||
if (!(defined($in_traffic)) && !(defined($out_traffic))) {
|
||||
$not_traffic = 0;
|
||||
} else {
|
||||
$in_prefix = " ";
|
||||
$out_prefix = " ";
|
||||
|
||||
if (!($in_traffic eq "undef")) {
|
||||
if ($in_traffic > 1000000) {
|
||||
$in_usage = sprintf("%.2f",($in_traffic/($speed))*100);
|
||||
$in_traffic = sprintf("%.2f",$in_traffic/1000000);
|
||||
$in_prefix = "M";
|
||||
}
|
||||
elsif ($in_traffic > 1000) {
|
||||
$in_usage = sprintf("%.2f",($in_traffic/($speed))*100);
|
||||
$in_traffic = sprintf("%.2f",$in_traffic/1000);
|
||||
$in_prefix = "K";
|
||||
}
|
||||
elsif ($in_traffic < 1000) {
|
||||
$in_usage = sprintf("%.2f",($in_traffic/($speed))*100);
|
||||
$in_traffic = sprintf("%.2f",$in_traffic);
|
||||
$in_prefix = " ";
|
||||
}
|
||||
else {
|
||||
print "ERROR\n"; exit 1;
|
||||
}
|
||||
|
||||
} else {
|
||||
$in_usage = 0 ;
|
||||
}
|
||||
|
||||
if (!($out_traffic eq "undef")) {
|
||||
if ($out_traffic > 1000000) {
|
||||
$out_usage = sprintf("%.2f",($out_traffic/($speed))*100);
|
||||
$out_traffic = sprintf("%.2f",$out_traffic/1000000);
|
||||
$out_prefix = "M";
|
||||
}
|
||||
elsif ($out_traffic > 1000) {
|
||||
$out_usage = sprintf("%.2f",($out_traffic/($speed))*100);
|
||||
$out_traffic = sprintf("%.2f",$out_traffic/1000);
|
||||
$out_prefix = "K";
|
||||
}
|
||||
elsif ($out_traffic < 1000) {
|
||||
$out_usage = sprintf("%.2f",($out_traffic/($speed))*100);
|
||||
$out_traffic = sprintf("%.2f",$out_traffic);
|
||||
$out_prefix = " ";
|
||||
}
|
||||
} else {
|
||||
$out_usage = 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
## Plugin return code && Status
|
||||
##
|
||||
|
||||
if ( $speed == 0 ) {
|
||||
print "CRITICAL: Interface speed equal 0! Interface must be down.\n";
|
||||
exit($ERRORS{"CRITICAL"});
|
||||
}
|
||||
else {
|
||||
$speed = sprintf("%.2f",($speed/1000000));
|
||||
}
|
||||
|
||||
if ($not_traffic != 1) {
|
||||
print "Counter: IN = $in_bits bits and OUT = $out_bits bits - Traffic cannot be calculated when the last value from the rrdfile is `undef' (check if the `-g' option is enabled)\n"; exit($ERRORS{"OK"});
|
||||
} else {
|
||||
if(($in_usage > $critical) || ($out_usage > $critical)) {
|
||||
print "CRITICAL: (".$critical."%) depassed threshold. Traffic: $in_traffic ".$in_prefix."b/s (".$in_usage."%) in, $out_traffic ".$out_prefix."b/s (".$out_usage."%) out - Speed Interface = ".$speed." Mb/s \n";
|
||||
exit($ERRORS{"CRITICAL"});
|
||||
}
|
||||
if(($in_usage > $warning) || ($out_usage > $warning)) {
|
||||
print "WARNING: (".$warning."%) depassed threshold. Traffic: $in_traffic ".$in_prefix."b/s (".$in_usage."%) in, $out_traffic ".$out_prefix."b/s (".$out_usage."%) out - Speed Interface = ".$speed." Mb/s\n";
|
||||
exit($ERRORS{"WARNING"});
|
||||
}
|
||||
print "OK: Traffic: $in_traffic ".$in_prefix."b/s (".$in_usage."%) in, $out_traffic ".$out_prefix."b/s (".$out_usage."%) out - Speed Interface = ".$speed." Mb/s\n $opt_g"; exit($ERRORS{"OK"});
|
||||
}
|
||||
}
|
||||
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 " -g (--rrdgraph) create à rrd base and add datas into this one\n";
|
||||
print " -D (--directory) Path to rrdatabase (or create the .rrd in this directory)\n";
|
||||
print " by default: ".$pathtorrdbase."\n";
|
||||
print " (The path is valid with spaces '/my\ path/...')\n";
|
||||
print " -s (--show) Describes all interfaces number (debug mode)\n";
|
||||
print " -i (--interface) Set the interface number (2 by default)\n";
|
||||
print " -T (--speed) Set the speed interface in Mbit/s (by default speed interface capacity)\n";
|
||||
print " --rrdstep Set the rrdstep in second (5 minuntes by default)\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 " -S (--ServiceId) Oreon Service Id\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n\n";
|
||||
}
|
||||
|
||||
main ();
|
|
@ -1,212 +0,0 @@
|
|||
#! /usr/bin/perl -w
|
||||
#
|
||||
# $Id: check_graph_uptime.pl,v 1.2 2005/07/27 22:21:49 wistof Exp $
|
||||
#
|
||||
# This plugin is developped under GPL Licence:
|
||||
# http://www.fsf.org/licenses/gpl.txt
|
||||
|
||||
# Developped by Linagora SA: http://www.linagora.com
|
||||
|
||||
# Modified for Oreon Project by : Mathieu Chateau - Christophe Coraboeuf
|
||||
# Modified For Oreon compatibility by Julien Mathis For Merethis
|
||||
#
|
||||
# The Software is provided to you AS IS and WITH ALL FAULTS.
|
||||
# LINAGORA makes no representation and gives no warranty whatsoever,
|
||||
# whether express or implied, and without limitation, with regard to the quality,
|
||||
# safety, contents, performance, merchantability, non-infringement or suitability for
|
||||
# any particular or intended purpose of the Software found on the LINAGORA web site.
|
||||
# In no event will LINAGORA be liable for any direct, indirect, punitive, special,
|
||||
# incidental or consequential damages however they may arise and even if LINAGORA has
|
||||
# been previously advised of the possibility of such damages.
|
||||
|
||||
# based on "graph plugins" developped by Oreon Team. See http://www.oreon.org.
|
||||
##
|
||||
## Plugin init
|
||||
##
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@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_g $opt_D $opt_S $opt_H $opt_C $opt_v $opt_d $day $opt_step);
|
||||
my $pathtorrdbase = $oreon{GLOBAL}{DIR_RRDTOOL};
|
||||
|
||||
$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,
|
||||
"g" => \$opt_g, "rrdgraph" => \$opt_g,
|
||||
"rrd_step=s" => \$opt_step,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"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_S) || ($opt_S = shift) || ($opt_S = "1_1");
|
||||
my $ServiceId = is_valid_serviceid($opt_S);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
my $rrd = $pathtorrdbase.$ServiceId.".rrd";
|
||||
|
||||
my $start=time;
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
my $day = 0;
|
||||
|
||||
##
|
||||
## RRDTools create rrd
|
||||
##
|
||||
if ($opt_g) {
|
||||
if (! -e $rrd) {
|
||||
create_rrd($rrd,1,$start,300,"U","U","GAUGE");
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
## 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";
|
||||
|
||||
##
|
||||
## RRDtools update
|
||||
##
|
||||
if ($opt_g) {
|
||||
$start=time;
|
||||
update_rrd($rrd,$start,$un);
|
||||
}
|
||||
|
||||
##
|
||||
## 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 " -g (--rrdgraph) create a rrd base and add datas into this one\n";
|
||||
print " -D (--directory) Path to rrdatabase (or create the .rrd in this directory)\n";
|
||||
print " by default: ".$pathtorrdbase."\n";
|
||||
print " (The path is valid with spaces '/my\ path/...')\n";
|
||||
print " -S (--ServiceId) Oreon Service Id\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";
|
||||
}
|
Loading…
Reference in New Issue