Plugins-2-x: Change SVN props. Unix format
git-svn-id: http://svn.centreon.com/trunk/plugins-2.x@5108 6bcd3966-0018-0410-8128-fd23d134de7e
This commit is contained in:
parent
d0fd58c164
commit
3a42ca659c
|
@ -1,47 +1,47 @@
|
|||
[GLOBAL]
|
||||
DIR_NAGIOS=@INSTALL_DIR_NAGIOS@/
|
||||
NAGIOS_PLUGINS=@NAGIOS_PLUGINS@/
|
||||
NAGIOS_ETC=@NAGIOS_ETC@/
|
||||
|
||||
[NT]
|
||||
CPU=.1.3.6.1.2.1.25.3.3.1.2
|
||||
HD_USED=.1.3.6.1.2.1.25.2.3.1.6
|
||||
HD_NAME=.1.3.6.1.2.1.25.2.3.1.3
|
||||
|
||||
[CISCO]
|
||||
NB_CONNECT=.1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40.6
|
||||
|
||||
[UNIX]
|
||||
CPU_USER=.1.3.6.1.4.1.2021.11.50.0
|
||||
CPU_SYSTEM=.1.3.6.1.4.1.2021.11.52.0
|
||||
CPU_LOAD_1M =.1.3.6.1.4.1.2021.10.1.3.1
|
||||
CPU_LOAD_5M =.1.3.6.1.4.1.2021.10.1.3.2
|
||||
CPU_LOAD_15M =.1.3.6.1.4.1.2021.10.1.3.3
|
||||
|
||||
[DELL]
|
||||
TEMP=.1.3.6.1.4.1.674.10892.1.700.20.1.6.1
|
||||
|
||||
[ALTEON]
|
||||
VIRT=1.3.6.1.4.1.1872.2.1.8.2.7.1.3.1
|
||||
FRONT=1.3.6.1.4.1.1872.2.1.8.2.5.1.3.1
|
||||
|
||||
[MIB2]
|
||||
SW_RUNNAME=.1.3.6.1.2.1.25.4.2.1.2
|
||||
SW_RUNINDEX=.1.3.6.1.2.1.25.4.2.1.1
|
||||
SW_RUNSTATUS=.1.3.6.1.2.1.25.4.2.1.7
|
||||
HR_STORAGE_DESCR=.1.3.6.1.2.1.25.2.3.1.3
|
||||
HR_STORAGE_ALLOCATION_UNITS=.1.3.6.1.2.1.25.2.3.1.4
|
||||
HR_STORAGE_SIZE=.1.3.6.1.2.1.25.2.3.1.5
|
||||
HR_STORAGE_USED=.1.3.6.1.2.1.25.2.3.1.6
|
||||
OBJECTID=.1.3.6.1.2.1.1.1.0
|
||||
UPTIME_WINDOWS=.1.3.6.1.2.1.1.3.0
|
||||
UPTIME_OTHER=.1.3.6.1.2.1.25.1.1.0
|
||||
IF_IN_OCTET=.1.3.6.1.2.1.2.2.1.10
|
||||
IF_OUT_OCTET=.1.3.6.1.2.1.2.2.1.16
|
||||
IF_SPEED=.1.3.6.1.2.1.2.2.1.5
|
||||
IF_DESC=.1.3.6.1.2.1.2.2.1.2
|
||||
IF_IN_ERROR=.1.3.6.1.2.1.2.2.1.14
|
||||
IF_OUT_ERROR=.1.3.6.1.2.1.2.2.1.20
|
||||
IF_OPERSTATUS=.1.3.6.1.2.1.2.2.1.8
|
||||
|
||||
|
||||
[GLOBAL]
|
||||
DIR_NAGIOS=@INSTALL_DIR_NAGIOS@/
|
||||
NAGIOS_PLUGINS=@NAGIOS_PLUGINS@/
|
||||
NAGIOS_ETC=@NAGIOS_ETC@/
|
||||
|
||||
[NT]
|
||||
CPU=.1.3.6.1.2.1.25.3.3.1.2
|
||||
HD_USED=.1.3.6.1.2.1.25.2.3.1.6
|
||||
HD_NAME=.1.3.6.1.2.1.25.2.3.1.3
|
||||
|
||||
[CISCO]
|
||||
NB_CONNECT=.1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40.6
|
||||
|
||||
[UNIX]
|
||||
CPU_USER=.1.3.6.1.4.1.2021.11.50.0
|
||||
CPU_SYSTEM=.1.3.6.1.4.1.2021.11.52.0
|
||||
CPU_LOAD_1M =.1.3.6.1.4.1.2021.10.1.3.1
|
||||
CPU_LOAD_5M =.1.3.6.1.4.1.2021.10.1.3.2
|
||||
CPU_LOAD_15M =.1.3.6.1.4.1.2021.10.1.3.3
|
||||
|
||||
[DELL]
|
||||
TEMP=.1.3.6.1.4.1.674.10892.1.700.20.1.6.1
|
||||
|
||||
[ALTEON]
|
||||
VIRT=1.3.6.1.4.1.1872.2.1.8.2.7.1.3.1
|
||||
FRONT=1.3.6.1.4.1.1872.2.1.8.2.5.1.3.1
|
||||
|
||||
[MIB2]
|
||||
SW_RUNNAME=.1.3.6.1.2.1.25.4.2.1.2
|
||||
SW_RUNINDEX=.1.3.6.1.2.1.25.4.2.1.1
|
||||
SW_RUNSTATUS=.1.3.6.1.2.1.25.4.2.1.7
|
||||
HR_STORAGE_DESCR=.1.3.6.1.2.1.25.2.3.1.3
|
||||
HR_STORAGE_ALLOCATION_UNITS=.1.3.6.1.2.1.25.2.3.1.4
|
||||
HR_STORAGE_SIZE=.1.3.6.1.2.1.25.2.3.1.5
|
||||
HR_STORAGE_USED=.1.3.6.1.2.1.25.2.3.1.6
|
||||
OBJECTID=.1.3.6.1.2.1.1.1.0
|
||||
UPTIME_WINDOWS=.1.3.6.1.2.1.1.3.0
|
||||
UPTIME_OTHER=.1.3.6.1.2.1.25.1.1.0
|
||||
IF_IN_OCTET=.1.3.6.1.2.1.2.2.1.10
|
||||
IF_OUT_OCTET=.1.3.6.1.2.1.2.2.1.16
|
||||
IF_SPEED=.1.3.6.1.2.1.2.2.1.5
|
||||
IF_DESC=.1.3.6.1.2.1.2.2.1.2
|
||||
IF_IN_ERROR=.1.3.6.1.2.1.2.2.1.14
|
||||
IF_OUT_ERROR=.1.3.6.1.2.1.2.2.1.20
|
||||
IF_OPERSTATUS=.1.3.6.1.2.1.2.2.1.8
|
||||
|
||||
|
||||
|
|
204
src/centreon.pm
204
src/centreon.pm
|
@ -1,102 +1,102 @@
|
|||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Plugin init
|
||||
#
|
||||
package centreon;
|
||||
|
||||
use Exporter ();
|
||||
use FindBin qw($Bin);
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
|
||||
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require Config::IniFiles" ) {
|
||||
use Config::IniFiles;
|
||||
} else {
|
||||
print "Unable to load Config::IniFiles\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
### RRDTOOL Module
|
||||
use lib qw(@RRDTOOL_PERL_LIB@ ../lib/perl);
|
||||
if (eval "require RRDs" ) {
|
||||
use RRDs;
|
||||
} else {
|
||||
print "Unable to load RRDs perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
# On défini une version pour les vérifications
|
||||
#$VERSION = do { my @r = (q$Revision: XXX $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(get_parameters);
|
||||
our @EXPORT = @EXPORT_OK;
|
||||
|
||||
my $params_file = "centreon.conf";
|
||||
my @ds = ("a","b","c","d","e","f","g","h","i","j","k","l");
|
||||
|
||||
###############################################################################
|
||||
# Get all parameters from the ini file
|
||||
###############################################################################
|
||||
sub get_parameters {
|
||||
$params_file = "@NAGIOS_PLUGINS@/$params_file";
|
||||
unless (-e $params_file) {
|
||||
print "Unknown - In centreon.pm :: $params_file :: $!\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
my %centreon;
|
||||
tie %centreon, 'Config::IniFiles', ( -file => $params_file );
|
||||
return %centreon;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
centreon - shared module for Oreon plugins
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use centreon;
|
||||
centreon::get_parameters()
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
=head2 Functions
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Mathieu Chateau E<lt>mathieu.chateau@lsafrance.comE<gt>
|
||||
Christophe Coraboeuf E<lt>ccoraboeuf@oreon-project.orgE<gt>
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
||||
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Plugin init
|
||||
#
|
||||
package centreon;
|
||||
|
||||
use Exporter ();
|
||||
use FindBin qw($Bin);
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
|
||||
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require Config::IniFiles" ) {
|
||||
use Config::IniFiles;
|
||||
} else {
|
||||
print "Unable to load Config::IniFiles\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
### RRDTOOL Module
|
||||
use lib qw(@RRDTOOL_PERL_LIB@ ../lib/perl);
|
||||
if (eval "require RRDs" ) {
|
||||
use RRDs;
|
||||
} else {
|
||||
print "Unable to load RRDs perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
# On défini une version pour les vérifications
|
||||
#$VERSION = do { my @r = (q$Revision: XXX $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT_OK = qw(get_parameters);
|
||||
our @EXPORT = @EXPORT_OK;
|
||||
|
||||
my $params_file = "centreon.conf";
|
||||
my @ds = ("a","b","c","d","e","f","g","h","i","j","k","l");
|
||||
|
||||
###############################################################################
|
||||
# Get all parameters from the ini file
|
||||
###############################################################################
|
||||
sub get_parameters {
|
||||
$params_file = "@NAGIOS_PLUGINS@/$params_file";
|
||||
unless (-e $params_file) {
|
||||
print "Unknown - In centreon.pm :: $params_file :: $!\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
my %centreon;
|
||||
tie %centreon, 'Config::IniFiles', ( -file => $params_file );
|
||||
return %centreon;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
__END__
|
||||
|
||||
=head1 NAME
|
||||
|
||||
centreon - shared module for Oreon plugins
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use centreon;
|
||||
centreon::get_parameters()
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
=head2 Functions
|
||||
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Mathieu Chateau E<lt>mathieu.chateau@lsafrance.comE<gt>
|
||||
Christophe Coraboeuf E<lt>ccoraboeuf@oreon-project.orgE<gt>
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,194 +1,194 @@
|
|||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_v $opt_C $opt_H $opt_c $opt_w $opt_D $snmp $opt_k $opt_u $opt_p @critical @warning);
|
||||
|
||||
# Plugin var init
|
||||
|
||||
my($return_code);
|
||||
|
||||
$PROGNAME = "$0";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"u=s" => \$opt_u, "username=s" => \$opt_u,
|
||||
"p=s" => \$opt_p, "password=s" => \$opt_p,
|
||||
"k=s" => \$opt_k, "key=s" => \$opt_k,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if (!$opt_H) {
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $snmp = "1";
|
||||
$snmp = $opt_v if ($opt_v && $opt_v =~ /^[0-9]$/);
|
||||
|
||||
$opt_c = 95 if (defined($opt_c) || !$opt_c);
|
||||
$opt_w = 95 if (defined($opt_w) || !$opt_w);
|
||||
|
||||
if ($snmp eq "3") {
|
||||
if (!$opt_u) {
|
||||
print "Option -u (--username) is required for snmpV3\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
if (!$opt_p && !$opt_k) {
|
||||
print "Option -k (--key) or -p (--password) is required for snmpV3\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
} elsif ($opt_p && $opt_k) {
|
||||
print "Only option -k (--key) or -p (--password) is needed for snmpV3\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
$opt_C = "public" if (!$opt_C);
|
||||
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
# Plugin snmp requests
|
||||
|
||||
my $OID_CPU = "1.3.6.1.2.1.25.3.3.1.2";
|
||||
|
||||
my ($session, $error);
|
||||
if ($snmp eq "1" || $snmp eq "2") {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP 1 or 2 Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_k) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_p) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
# Get all datas
|
||||
my $result = $session->get_table(Baseoid => $OID_CPU);
|
||||
if (!defined($result)) {
|
||||
printf("ERROR when getting CPU percentage use values : ProcessorLoad Table : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
# Get all values and computes average cpu.
|
||||
my $cpu = 0;
|
||||
my $i = 0;
|
||||
my @cpulist;
|
||||
foreach my $key ( oid_lex_sort(keys %$result)) {
|
||||
my @oid_list = split (/\./,$key);
|
||||
my $index = pop (@oid_list);
|
||||
$cpulist[$i] = $$result{$key};
|
||||
$cpu += $$result{$key};
|
||||
$i++;
|
||||
}
|
||||
undef($result);
|
||||
|
||||
$cpu /= $i;
|
||||
|
||||
# Plugin return code
|
||||
my $status = "OK";
|
||||
if ($opt_w <= $cpu) {
|
||||
$status = "WARNING";
|
||||
} elsif ($opt_c <= $cpu) {
|
||||
$status = "CRITICAL";
|
||||
}
|
||||
|
||||
my $str = "Utilisation moyenne du CPU : ".$cpu."%|avg=".$cpu."%";
|
||||
for ($i = 0; defined($cpulist[$i]); $i++){
|
||||
$str .= " cpu$i=".$cpulist[$i]."%";
|
||||
}
|
||||
print $str."\n";
|
||||
undef($str);
|
||||
exit $ERRORS{$status};
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public,\n";
|
||||
print " -c (--critical) Three critical tresholds (defaults : 2,4,6)\n";
|
||||
print " -w (--warning) Three warning tresholds (defaults : 1,3,5)\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -k (--key) snmp V3 key\n";
|
||||
print " -p (--password) snmp V3 password\n";
|
||||
print " -u (--username) snmp v3 username \n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Merethis #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_v $opt_C $opt_H $opt_c $opt_w $opt_D $snmp $opt_k $opt_u $opt_p @critical @warning);
|
||||
|
||||
# Plugin var init
|
||||
|
||||
my($return_code);
|
||||
|
||||
$PROGNAME = "$0";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"u=s" => \$opt_u, "username=s" => \$opt_u,
|
||||
"p=s" => \$opt_p, "password=s" => \$opt_p,
|
||||
"k=s" => \$opt_k, "key=s" => \$opt_k,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if (!$opt_H) {
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $snmp = "1";
|
||||
$snmp = $opt_v if ($opt_v && $opt_v =~ /^[0-9]$/);
|
||||
|
||||
$opt_c = 95 if (defined($opt_c) || !$opt_c);
|
||||
$opt_w = 95 if (defined($opt_w) || !$opt_w);
|
||||
|
||||
if ($snmp eq "3") {
|
||||
if (!$opt_u) {
|
||||
print "Option -u (--username) is required for snmpV3\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
if (!$opt_p && !$opt_k) {
|
||||
print "Option -k (--key) or -p (--password) is required for snmpV3\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
} elsif ($opt_p && $opt_k) {
|
||||
print "Only option -k (--key) or -p (--password) is needed for snmpV3\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
$opt_C = "public" if (!$opt_C);
|
||||
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
# Plugin snmp requests
|
||||
|
||||
my $OID_CPU = "1.3.6.1.2.1.25.3.3.1.2";
|
||||
|
||||
my ($session, $error);
|
||||
if ($snmp eq "1" || $snmp eq "2") {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP 1 or 2 Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_k) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_p) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
# Get all datas
|
||||
my $result = $session->get_table(Baseoid => $OID_CPU);
|
||||
if (!defined($result)) {
|
||||
printf("ERROR when getting CPU percentage use values : ProcessorLoad Table : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
# Get all values and computes average cpu.
|
||||
my $cpu = 0;
|
||||
my $i = 0;
|
||||
my @cpulist;
|
||||
foreach my $key ( oid_lex_sort(keys %$result)) {
|
||||
my @oid_list = split (/\./,$key);
|
||||
my $index = pop (@oid_list);
|
||||
$cpulist[$i] = $$result{$key};
|
||||
$cpu += $$result{$key};
|
||||
$i++;
|
||||
}
|
||||
undef($result);
|
||||
|
||||
$cpu /= $i;
|
||||
|
||||
# Plugin return code
|
||||
my $status = "OK";
|
||||
if ($opt_w <= $cpu) {
|
||||
$status = "WARNING";
|
||||
} elsif ($opt_c <= $cpu) {
|
||||
$status = "CRITICAL";
|
||||
}
|
||||
|
||||
my $str = "Utilisation moyenne du CPU : ".$cpu."%|avg=".$cpu."%";
|
||||
for ($i = 0; defined($cpulist[$i]); $i++){
|
||||
$str .= " cpu$i=".$cpulist[$i]."%";
|
||||
}
|
||||
print $str."\n";
|
||||
undef($str);
|
||||
exit $ERRORS{$status};
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public,\n";
|
||||
print " -c (--critical) Three critical tresholds (defaults : 2,4,6)\n";
|
||||
print " -w (--warning) Three warning tresholds (defaults : 1,3,5)\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -k (--key) snmp V3 key\n";
|
||||
print " -p (--password) snmp V3 password\n";
|
||||
print " -u (--username) snmp v3 username \n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Merethis #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
|
@ -1,203 +1,203 @@
|
|||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_v $opt_C $opt_H $opt_c $opt_w $opt_D $snmp $opt_k $opt_u $opt_p @critical @warning);
|
||||
|
||||
# Plugin var init
|
||||
|
||||
my($return_code);
|
||||
|
||||
$PROGNAME = "$0";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"u=s" => \$opt_u, "username=s" => \$opt_u,
|
||||
"p=s" => \$opt_p, "password=s" => \$opt_p,
|
||||
"k=s" => \$opt_k, "key=s" => \$opt_k,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if (!$opt_H) {
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $snmp = "1";
|
||||
$snmp = $opt_v if ($opt_v && $opt_v =~ /^[0-9]$/);
|
||||
|
||||
if ($opt_c && $opt_c =~ /^([0-9]+),([0-9]+),([0-9]+)$/) {
|
||||
@critical = ($1,$2,$3);
|
||||
} elsif (!defined($opt_c) && !$opt_c){
|
||||
@critical = ('2', '4', '6');
|
||||
} else {
|
||||
print "Specify three critical treshold separated with a coma\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_w && $opt_w =~ /^([0-9]+),([0-9]+),([0-9]+)$/) {
|
||||
@warning = ($1,$2,$3);
|
||||
} elsif (!defined($opt_w) && !$opt_w) {
|
||||
@warning = ('1', '3', '5');
|
||||
} else {
|
||||
print "Specify three warning treshold separated with a coma\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
for (my $i = 0; $i < scalar(@warning); $i++) {
|
||||
if ($warning[$i] >= $critical[$i]) {
|
||||
print "Critical tresholds must be superior to warning tresholds.\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
}
|
||||
|
||||
if ($snmp eq "3") {
|
||||
if (!$opt_u) {
|
||||
print "Option -u (--username) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
if (!$opt_p && !$opt_k) {
|
||||
print "Option -k (--key) or -p (--password) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif ($opt_p && $opt_k) {
|
||||
print "Only option -k (--key) or -p (--password) is needed for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
}
|
||||
|
||||
$opt_C = "public" if (!$opt_C);
|
||||
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
# Plugin snmp requests
|
||||
|
||||
my $OID_CPULOAD_1 = $centreon{UNIX}{CPU_LOAD_1M};
|
||||
my $OID_CPULOAD_5 = $centreon{UNIX}{CPU_LOAD_5M};
|
||||
my $OID_CPULOAD_15 =$centreon{UNIX}{CPU_LOAD_15M};
|
||||
|
||||
my ($session, $error);
|
||||
if ($snmp eq "1" || $snmp eq "2") {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_k) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_p) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
my $result = $session->get_request(
|
||||
-varbindlist => [$OID_CPULOAD_1, $OID_CPULOAD_5, $OID_CPULOAD_15 ]
|
||||
);
|
||||
if (!defined($result)) {
|
||||
printf("UNKNOWN: %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my $un = $result->{$OID_CPULOAD_1};
|
||||
my $cinq = $result->{$OID_CPULOAD_5};
|
||||
my $quinze = $result->{$OID_CPULOAD_15};
|
||||
|
||||
# Plugin return code
|
||||
my $status = "OK";
|
||||
|
||||
$status = "WARNING" if ($warning[0] <= $un || $warning[1] <= $cinq || $warning[2] <= $quinze);
|
||||
$status = "CRITICAL" if ($critical[0] <= $un || $critical[1] <= $cinq || $critical[2] <= $quinze);
|
||||
|
||||
# Print output
|
||||
print "load average: ".$un.", ".$cinq.", ".$quinze.".|load1=".$un." load5=".$cinq." load15=".$quinze."\n";
|
||||
exit $ERRORS{$status};
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public)\n";
|
||||
print " -c (--critical) Three critical tresholds (defaults : 2,4,6)\n";
|
||||
print " -w (--warning) Three warning tresholds (defaults : 1,3,5)\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -k (--key) snmp V3 key\n";
|
||||
print " -p (--password) snmp V3 password\n";
|
||||
print " -u (--username) snmp v3 username \n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_v $opt_C $opt_H $opt_c $opt_w $opt_D $snmp $opt_k $opt_u $opt_p @critical @warning);
|
||||
|
||||
# Plugin var init
|
||||
|
||||
my($return_code);
|
||||
|
||||
$PROGNAME = "$0";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"u=s" => \$opt_u, "username=s" => \$opt_u,
|
||||
"p=s" => \$opt_p, "password=s" => \$opt_p,
|
||||
"k=s" => \$opt_k, "key=s" => \$opt_k,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if (!$opt_H) {
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $snmp = "1";
|
||||
$snmp = $opt_v if ($opt_v && $opt_v =~ /^[0-9]$/);
|
||||
|
||||
if ($opt_c && $opt_c =~ /^([0-9]+),([0-9]+),([0-9]+)$/) {
|
||||
@critical = ($1,$2,$3);
|
||||
} elsif (!defined($opt_c) && !$opt_c){
|
||||
@critical = ('2', '4', '6');
|
||||
} else {
|
||||
print "Specify three critical treshold separated with a coma\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_w && $opt_w =~ /^([0-9]+),([0-9]+),([0-9]+)$/) {
|
||||
@warning = ($1,$2,$3);
|
||||
} elsif (!defined($opt_w) && !$opt_w) {
|
||||
@warning = ('1', '3', '5');
|
||||
} else {
|
||||
print "Specify three warning treshold separated with a coma\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
for (my $i = 0; $i < scalar(@warning); $i++) {
|
||||
if ($warning[$i] >= $critical[$i]) {
|
||||
print "Critical tresholds must be superior to warning tresholds.\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
}
|
||||
|
||||
if ($snmp eq "3") {
|
||||
if (!$opt_u) {
|
||||
print "Option -u (--username) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
if (!$opt_p && !$opt_k) {
|
||||
print "Option -k (--key) or -p (--password) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif ($opt_p && $opt_k) {
|
||||
print "Only option -k (--key) or -p (--password) is needed for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
}
|
||||
|
||||
$opt_C = "public" if (!$opt_C);
|
||||
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
# Plugin snmp requests
|
||||
|
||||
my $OID_CPULOAD_1 = $centreon{UNIX}{CPU_LOAD_1M};
|
||||
my $OID_CPULOAD_5 = $centreon{UNIX}{CPU_LOAD_5M};
|
||||
my $OID_CPULOAD_15 =$centreon{UNIX}{CPU_LOAD_15M};
|
||||
|
||||
my ($session, $error);
|
||||
if ($snmp eq "1" || $snmp eq "2") {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_k) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_p) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
my $result = $session->get_request(
|
||||
-varbindlist => [$OID_CPULOAD_1, $OID_CPULOAD_5, $OID_CPULOAD_15 ]
|
||||
);
|
||||
if (!defined($result)) {
|
||||
printf("UNKNOWN: %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my $un = $result->{$OID_CPULOAD_1};
|
||||
my $cinq = $result->{$OID_CPULOAD_5};
|
||||
my $quinze = $result->{$OID_CPULOAD_15};
|
||||
|
||||
# Plugin return code
|
||||
my $status = "OK";
|
||||
|
||||
$status = "WARNING" if ($warning[0] <= $un || $warning[1] <= $cinq || $warning[2] <= $quinze);
|
||||
$status = "CRITICAL" if ($critical[0] <= $un || $critical[1] <= $cinq || $critical[2] <= $quinze);
|
||||
|
||||
# Print output
|
||||
print "load average: ".$un.", ".$cinq.", ".$quinze.".|load1=".$un." load5=".$cinq." load15=".$quinze."\n";
|
||||
exit $ERRORS{$status};
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public)\n";
|
||||
print " -c (--critical) Three critical tresholds (defaults : 2,4,6)\n";
|
||||
print " -w (--warning) Three warning tresholds (defaults : 1,3,5)\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -k (--key) snmp V3 key\n";
|
||||
print " -p (--password) snmp V3 password\n";
|
||||
print " -u (--username) snmp v3 username \n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
|
@ -1,253 +1,253 @@
|
|||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon 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_w $opt_c $opt_s $opt_H @test);
|
||||
my $pathtorrdbase = $centreon{GLOBAL}{DIR_RRDTOOL};
|
||||
|
||||
##
|
||||
## Plugin var init
|
||||
##
|
||||
|
||||
my ($hrStorageDescr, $hrStorageAllocationUnits, $hrStorageSize, $hrStorageUsed);
|
||||
my ($AllocationUnits, $Size, $Used);
|
||||
my ($tot, $used, $pourcent, $return_code);
|
||||
|
||||
$PROGNAME = "$0";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"s=s" => \$opt_s, "swap=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 = "2");
|
||||
my $snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
($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'};
|
||||
}
|
||||
|
||||
my $swap_limit;
|
||||
if ($opt_s)
|
||||
{
|
||||
($opt_s) || ($opt_s = shift) || ($opt_s = 10);
|
||||
$swap_limit = $1 if ($opt_s =~ /([0-9]+)/);
|
||||
}
|
||||
|
||||
my $start=time;
|
||||
my $name = $0;
|
||||
|
||||
## Plugin snmp requests
|
||||
|
||||
# my $OID_hrStorageDescr = $centreon{MIB2}{HR_STORAGE_DESCR};
|
||||
# my $OID_hrStorageAllocationUnits =$centreon{MIB2}{HR_STORAGE_ALLOCATION_UNITS};
|
||||
# my $OID_hrStorageSize =$centreon{MIB2}{HR_STORAGE_SIZE};
|
||||
# my $OID_hrStorageUsed =$centreon{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'};
|
||||
}
|
||||
|
||||
####################
|
||||
#### snmp request
|
||||
##
|
||||
|
||||
my $OID_descr_storage = ".1.3.6.1.2.1.25.2.3.1.3"; #"1.3.6.1.2.1.25.2.3.1.1";
|
||||
my $result = $session->get_table(Baseoid => $OID_descr_storage);
|
||||
if (!defined($result)) {
|
||||
printf("ERROR: Description Table hrStorageType : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my ($virt_alloc, my $virt_used, my $virt_size);
|
||||
|
||||
my $indexV = 0;
|
||||
my $indexR = 0;
|
||||
foreach my $key (oid_lex_sort(keys %$result)) {
|
||||
if ($result->{$key} =~ m/Swap|Virtual/) {
|
||||
my @cpt = split /\./,$key;
|
||||
$indexV = $cpt[scalar(@cpt) - 1];;
|
||||
}
|
||||
if ($result->{$key} =~ m/Real|Physical/) {
|
||||
my @cpt = split /\./,$key;
|
||||
$indexR = $cpt[scalar(@cpt)-1];
|
||||
}
|
||||
}
|
||||
if ($indexV == 0 || $indexR == 0) {
|
||||
printf("ERROR: cannot find ram information");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
my $OID_hrStorage_used = ".1.3.6.1.2.1.25.2.3.1.6";
|
||||
my $OID_Swap_storage_used = ".1.3.6.1.2.1.25.2.3.1.6.".$indexV;
|
||||
my $OID_RealM_storage_used = ".1.3.6.1.2.1.25.2.3.1.6.".$indexR;
|
||||
|
||||
my $used_mem = $session->get_table(Baseoid => $OID_hrStorage_used);
|
||||
if (!defined($used_mem)) {
|
||||
printf("ERROR: Description Table hrStorageUsed : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my $OID_hrStorage_size = ".1.3.6.1.2.1.25.2.3.1.5";
|
||||
my $OID_Swap_storage_size = ".1.3.6.1.2.1.25.2.3.1.5.".$indexV;
|
||||
my $OID_RealM_storage_size = ".1.3.6.1.2.1.25.2.3.1.5.".$indexR;
|
||||
|
||||
my $total_mem = $session->get_table(Baseoid => $OID_hrStorage_size);
|
||||
if (!defined($total_mem)) {
|
||||
printf("ERROR: Description Table hrStorageSize : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my $OID_storage_allocationUnits = ".1.3.6.1.2.1.25.2.3.1.4";
|
||||
my $OID_Swap_storage_allocationUnits = ".1.3.6.1.2.1.25.2.3.1.4.".$indexV;
|
||||
my $OID_RealM_storage_allocationUnits = ".1.3.6.1.2.1.25.2.3.1.4.".$indexR;
|
||||
my $alloc_units = $session->get_table(Baseoid => $OID_storage_allocationUnits);
|
||||
if (!defined($alloc_units)) {
|
||||
printf("ERROR: Description Table hrStorageUsed : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
my $swap_used = $used_mem->{$OID_Swap_storage_used} * $alloc_units->{$OID_Swap_storage_allocationUnits};
|
||||
my $realM_used = $used_mem->{$OID_RealM_storage_used} * $alloc_units->{$OID_RealM_storage_allocationUnits};
|
||||
|
||||
my $swap_size = $total_mem->{$OID_Swap_storage_size} * $alloc_units->{$OID_Swap_storage_allocationUnits};
|
||||
my $realM_size = $total_mem->{$OID_RealM_storage_size} * $alloc_units->{$OID_RealM_storage_allocationUnits};
|
||||
my $total_memory_used = $swap_used + $realM_used;
|
||||
my $total_memory_size = $swap_size + $realM_size;
|
||||
|
||||
# percentage of total, physical and swap memory used
|
||||
|
||||
if ($swap_size eq "0"){
|
||||
$swap_size = 1;
|
||||
}
|
||||
|
||||
my $percent_used = ($total_memory_used/$total_memory_size)*100;
|
||||
my $percent_swap_used = ($swap_used/$swap_size) * 100;
|
||||
my $percent_realM_used = ($realM_used/$realM_size) * 100;
|
||||
$percent_swap_used =~ s/\.[0-9]+//;
|
||||
$percent_used =~ s/\.[0-9]+//;
|
||||
$percent_realM_used =~ s/\.[0-9]+//;
|
||||
|
||||
# return
|
||||
|
||||
if(($opt_s) && ($opt_s =~ /([0-9]+)/))
|
||||
{
|
||||
if(($percent_realM_used >= 99) && ($percent_swap_used > $swap_limit))
|
||||
{
|
||||
print "swap threshold (".$opt_s."%) excedeed : total memory used : ".$percent_used."%, ram used : ".$percent_realM_used."%, swap used : ".$percent_swap_used."% | used=".$total_memory_used."o size=".$total_memory_size."o\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
}
|
||||
|
||||
if ($percent_used >= $opt_c){
|
||||
print "threshold (".$opt_c."%) excedeed : total memory used : ".$percent_used."%, ram used : ".$percent_realM_used."%, swap used : ".$percent_swap_used."% | used=".$total_memory_used."o size=".$total_memory_size."o\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
} elsif ($percent_used >= $opt_w){
|
||||
print "threshold (".$opt_w."%) excedeed : total memory used : ".$percent_used."%, ram used : ".$percent_realM_used."%, swap used ".$percent_swap_used."% | used=".$total_memory_used."o size=".$total_memory_size."o\n";
|
||||
exit $ERRORS{'WARNING'};
|
||||
} else {
|
||||
print "total memory used : ".$percent_used."% ram used : ".$percent_realM_used."%, swap used ".$percent_swap_used."% | used=".$total_memory_used."o size=".$total_memory_size."o\n";
|
||||
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 " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
print " -c (--critical) percentage of memory used at which a critical message will be generated\n";
|
||||
print " -w (--warning) percentage of memory used at which a warning message will be generated\n";
|
||||
print " -s (--swap) limit of swap memory can reach before the service turns critical, while phyical memory is near 100%\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "#=========================================\n";
|
||||
print "# Copyright (c) 2007 Merethis SARL =\n";
|
||||
print "# Developped by Julien Mathis =\n";
|
||||
print "# Bugs to http://www.oreon-project.org/ =\n";
|
||||
print "#=========================================\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
||||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon 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_w $opt_c $opt_s $opt_H @test);
|
||||
my $pathtorrdbase = $centreon{GLOBAL}{DIR_RRDTOOL};
|
||||
|
||||
##
|
||||
## Plugin var init
|
||||
##
|
||||
|
||||
my ($hrStorageDescr, $hrStorageAllocationUnits, $hrStorageSize, $hrStorageUsed);
|
||||
my ($AllocationUnits, $Size, $Used);
|
||||
my ($tot, $used, $pourcent, $return_code);
|
||||
|
||||
$PROGNAME = "$0";
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"s=s" => \$opt_s, "swap=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 = "2");
|
||||
my $snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
($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'};
|
||||
}
|
||||
|
||||
my $swap_limit;
|
||||
if ($opt_s)
|
||||
{
|
||||
($opt_s) || ($opt_s = shift) || ($opt_s = 10);
|
||||
$swap_limit = $1 if ($opt_s =~ /([0-9]+)/);
|
||||
}
|
||||
|
||||
my $start=time;
|
||||
my $name = $0;
|
||||
|
||||
## Plugin snmp requests
|
||||
|
||||
# my $OID_hrStorageDescr = $centreon{MIB2}{HR_STORAGE_DESCR};
|
||||
# my $OID_hrStorageAllocationUnits =$centreon{MIB2}{HR_STORAGE_ALLOCATION_UNITS};
|
||||
# my $OID_hrStorageSize =$centreon{MIB2}{HR_STORAGE_SIZE};
|
||||
# my $OID_hrStorageUsed =$centreon{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'};
|
||||
}
|
||||
|
||||
####################
|
||||
#### snmp request
|
||||
##
|
||||
|
||||
my $OID_descr_storage = ".1.3.6.1.2.1.25.2.3.1.3"; #"1.3.6.1.2.1.25.2.3.1.1";
|
||||
my $result = $session->get_table(Baseoid => $OID_descr_storage);
|
||||
if (!defined($result)) {
|
||||
printf("ERROR: Description Table hrStorageType : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my ($virt_alloc, my $virt_used, my $virt_size);
|
||||
|
||||
my $indexV = 0;
|
||||
my $indexR = 0;
|
||||
foreach my $key (oid_lex_sort(keys %$result)) {
|
||||
if ($result->{$key} =~ m/Swap|Virtual/) {
|
||||
my @cpt = split /\./,$key;
|
||||
$indexV = $cpt[scalar(@cpt) - 1];;
|
||||
}
|
||||
if ($result->{$key} =~ m/Real|Physical/) {
|
||||
my @cpt = split /\./,$key;
|
||||
$indexR = $cpt[scalar(@cpt)-1];
|
||||
}
|
||||
}
|
||||
if ($indexV == 0 || $indexR == 0) {
|
||||
printf("ERROR: cannot find ram information");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
my $OID_hrStorage_used = ".1.3.6.1.2.1.25.2.3.1.6";
|
||||
my $OID_Swap_storage_used = ".1.3.6.1.2.1.25.2.3.1.6.".$indexV;
|
||||
my $OID_RealM_storage_used = ".1.3.6.1.2.1.25.2.3.1.6.".$indexR;
|
||||
|
||||
my $used_mem = $session->get_table(Baseoid => $OID_hrStorage_used);
|
||||
if (!defined($used_mem)) {
|
||||
printf("ERROR: Description Table hrStorageUsed : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my $OID_hrStorage_size = ".1.3.6.1.2.1.25.2.3.1.5";
|
||||
my $OID_Swap_storage_size = ".1.3.6.1.2.1.25.2.3.1.5.".$indexV;
|
||||
my $OID_RealM_storage_size = ".1.3.6.1.2.1.25.2.3.1.5.".$indexR;
|
||||
|
||||
my $total_mem = $session->get_table(Baseoid => $OID_hrStorage_size);
|
||||
if (!defined($total_mem)) {
|
||||
printf("ERROR: Description Table hrStorageSize : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my $OID_storage_allocationUnits = ".1.3.6.1.2.1.25.2.3.1.4";
|
||||
my $OID_Swap_storage_allocationUnits = ".1.3.6.1.2.1.25.2.3.1.4.".$indexV;
|
||||
my $OID_RealM_storage_allocationUnits = ".1.3.6.1.2.1.25.2.3.1.4.".$indexR;
|
||||
my $alloc_units = $session->get_table(Baseoid => $OID_storage_allocationUnits);
|
||||
if (!defined($alloc_units)) {
|
||||
printf("ERROR: Description Table hrStorageUsed : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
my $swap_used = $used_mem->{$OID_Swap_storage_used} * $alloc_units->{$OID_Swap_storage_allocationUnits};
|
||||
my $realM_used = $used_mem->{$OID_RealM_storage_used} * $alloc_units->{$OID_RealM_storage_allocationUnits};
|
||||
|
||||
my $swap_size = $total_mem->{$OID_Swap_storage_size} * $alloc_units->{$OID_Swap_storage_allocationUnits};
|
||||
my $realM_size = $total_mem->{$OID_RealM_storage_size} * $alloc_units->{$OID_RealM_storage_allocationUnits};
|
||||
my $total_memory_used = $swap_used + $realM_used;
|
||||
my $total_memory_size = $swap_size + $realM_size;
|
||||
|
||||
# percentage of total, physical and swap memory used
|
||||
|
||||
if ($swap_size eq "0"){
|
||||
$swap_size = 1;
|
||||
}
|
||||
|
||||
my $percent_used = ($total_memory_used/$total_memory_size)*100;
|
||||
my $percent_swap_used = ($swap_used/$swap_size) * 100;
|
||||
my $percent_realM_used = ($realM_used/$realM_size) * 100;
|
||||
$percent_swap_used =~ s/\.[0-9]+//;
|
||||
$percent_used =~ s/\.[0-9]+//;
|
||||
$percent_realM_used =~ s/\.[0-9]+//;
|
||||
|
||||
# return
|
||||
|
||||
if(($opt_s) && ($opt_s =~ /([0-9]+)/))
|
||||
{
|
||||
if(($percent_realM_used >= 99) && ($percent_swap_used > $swap_limit))
|
||||
{
|
||||
print "swap threshold (".$opt_s."%) excedeed : total memory used : ".$percent_used."%, ram used : ".$percent_realM_used."%, swap used : ".$percent_swap_used."% | used=".$total_memory_used."o size=".$total_memory_size."o\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
}
|
||||
|
||||
if ($percent_used >= $opt_c){
|
||||
print "threshold (".$opt_c."%) excedeed : total memory used : ".$percent_used."%, ram used : ".$percent_realM_used."%, swap used : ".$percent_swap_used."% | used=".$total_memory_used."o size=".$total_memory_size."o\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
} elsif ($percent_used >= $opt_w){
|
||||
print "threshold (".$opt_w."%) excedeed : total memory used : ".$percent_used."%, ram used : ".$percent_realM_used."%, swap used ".$percent_swap_used."% | used=".$total_memory_used."o size=".$total_memory_size."o\n";
|
||||
exit $ERRORS{'WARNING'};
|
||||
} else {
|
||||
print "total memory used : ".$percent_used."% ram used : ".$percent_realM_used."%, swap used ".$percent_swap_used."% | used=".$total_memory_used."o size=".$total_memory_size."o\n";
|
||||
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 " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
print " -c (--critical) percentage of memory used at which a critical message will be generated\n";
|
||||
print " -w (--warning) percentage of memory used at which a warning message will be generated\n";
|
||||
print " -s (--swap) limit of swap memory can reach before the service turns critical, while phyical memory is near 100%\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "#=========================================\n";
|
||||
print "# Copyright (c) 2007 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,244 +1,244 @@
|
|||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# 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 centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
use vars qw($VERSION %centreon);
|
||||
use vars qw(%centreon);
|
||||
$VERSION = '$Revision: 1.2 $';
|
||||
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_v $opt_C $opt_H $opt_w $opt_c);
|
||||
|
||||
#
|
||||
# Plugin var init
|
||||
#
|
||||
$PROGNAME = "$0";
|
||||
|
||||
my ($row, @flg_created, @last_check_time, @last_in_errors, @last_out_errors, $result_in, $result_out, @nb_out_errors, @nb_in_errors, $update_time, $db_file);
|
||||
my $pathtolibexecnt = $centreon{NAGIOS_PLUGINS};
|
||||
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
##################################################
|
||||
##### Verify Options
|
||||
##
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
($opt_v) || ($opt_v = shift) || ($opt_v = "1");
|
||||
my $snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
($opt_c) || ($opt_c = shift) || ($opt_c = 100);
|
||||
my $critical = $1 if ($opt_c =~ /([0-9]+)/);
|
||||
|
||||
($opt_w) || ($opt_w = shift) || ($opt_w = 80);
|
||||
my $warning = $1 if ($opt_w =~ /([0-9]+)/);
|
||||
|
||||
if ($critical <= $warning){
|
||||
print "(--crit) must be superior to (--warn)";
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $start=time;
|
||||
|
||||
|
||||
#################################################
|
||||
##### Plugin snmp requests
|
||||
##
|
||||
|
||||
my $OID_IN_ERRORS = ".1.3.6.1.2.1.2.2.1.14";
|
||||
my $OID_OUT_ERRORS = ".1.3.6.1.2.1.2.2.1.20";
|
||||
|
||||
|
||||
# create a SNMP session
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
####### Get IN ERRORS
|
||||
|
||||
$result_in = $session->get_table(Baseoid => $OID_IN_ERRORS);
|
||||
if (!defined($result_in)) {
|
||||
printf("ERROR: IN_ERRORS : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
# loop for each interface
|
||||
foreach my $err (oid_lex_sort(keys %$result_in)) {
|
||||
$nb_in_errors[scalar(@nb_in_errors)] = $result_in->{$err};
|
||||
}
|
||||
# ####### Get OUT ERRORS
|
||||
|
||||
$result_out = $session->get_table(Baseoid => $OID_OUT_ERRORS);
|
||||
if (!defined($result_out)) {
|
||||
printf("ERROR: OUT_ERRORS : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
foreach my $err (oid_lex_sort(keys %$result_out)) {
|
||||
$nb_out_errors[scalar(@nb_out_errors)] = $result_out->{$err};
|
||||
}
|
||||
|
||||
# #############################################
|
||||
# ##### read and write in buffer file
|
||||
# ##
|
||||
|
||||
for (my $i = 0; $i < scalar(@nb_in_errors); $i++) {
|
||||
if (-e "@CENTPLUGINS_TMP@/packet_errors_if".$i."_".$opt_H.".tmp") {
|
||||
open(FILE,"<"."@CENTPLUGINS_TMP@/packet_errors_if".$i."_".$opt_H.".tmp");
|
||||
while($row = <FILE>){
|
||||
my @last_values = split(":",$row);
|
||||
$last_check_time[$i] = $last_values[0];
|
||||
$last_in_errors[$i] = $last_values[1];
|
||||
$last_out_errors[$i] = $last_values[2];
|
||||
$flg_created[$i] = 1;
|
||||
}
|
||||
close(FILE);
|
||||
} else {
|
||||
$flg_created[$i] = 0;
|
||||
}
|
||||
|
||||
$update_time = time;
|
||||
unless (open(FILE,">"."@CENTPLUGINS_TMP@/packet_errors_if".$i."_".$opt_H.".tmp")){
|
||||
print "Unknown - @CENTPLUGINS_TMP@/packet_errors_if".$i."_".$opt_H.".tmp!\n";
|
||||
exit $ERRORS{"UNKNOWN"};
|
||||
}
|
||||
print FILE "$update_time:$nb_in_errors[$i]:$nb_out_errors[$i]";
|
||||
close(FILE);
|
||||
if ($flg_created[$i] eq 0){
|
||||
print "First execution : Buffer in creation.... \n";
|
||||
}
|
||||
}
|
||||
|
||||
# #############################################
|
||||
# ##### return result
|
||||
# ##
|
||||
my $status = "OK";
|
||||
my @msg;
|
||||
my $diff_test = 0;
|
||||
for (my $i = 0; $i < scalar(@nb_in_errors); $i++) {
|
||||
my $interface = $i+1;
|
||||
if ($flg_created[$i]) {
|
||||
if (($nb_in_errors[$i] - $last_in_errors[$i] >= $critical) or ($nb_out_errors[$i] - $last_out_errors[$i] >= $critical)){
|
||||
$msg[$i] = "$interface:critical ";
|
||||
$status = "CRITICAL";
|
||||
}
|
||||
if (($nb_in_errors[$i] - $last_in_errors[$i] >= $warning) or ($nb_out_errors[$i] - $last_out_errors[$i] >= $warning)){
|
||||
if (!defined($msg[$i])) {
|
||||
$msg[$i] = "$interface:warning ";
|
||||
}
|
||||
if ($status ne "CRITICAL") {
|
||||
$status = "WARNING";
|
||||
}
|
||||
}
|
||||
$diff_test = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$diff_test) {
|
||||
exit($ERRORS{'UNKNOWN'});
|
||||
}
|
||||
my $output = "";
|
||||
for (my $i = 0; $i < scalar (@msg); $i++) {
|
||||
if (defined($msg[$i])) {
|
||||
$output .= $msg[$i];
|
||||
}
|
||||
}
|
||||
if ($output ne ""){
|
||||
print $output."\n";
|
||||
} else {
|
||||
print "Status OK on all interfaces\n";
|
||||
}
|
||||
exit($ERRORS{$status});
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (default to public)\n";
|
||||
print " used with SNMP v1 and v2c\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -w (--warn) Signal strength at which a warning message will be generated\n";
|
||||
print " (default 80)\n";
|
||||
print " -c (--crit) Signal strength at which a critical message will be generated\n";
|
||||
print " (default 100)\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# 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 centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
use vars qw($VERSION %centreon);
|
||||
use vars qw(%centreon);
|
||||
$VERSION = '$Revision: 1.2 $';
|
||||
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_v $opt_C $opt_H $opt_w $opt_c);
|
||||
|
||||
#
|
||||
# Plugin var init
|
||||
#
|
||||
$PROGNAME = "$0";
|
||||
|
||||
my ($row, @flg_created, @last_check_time, @last_in_errors, @last_out_errors, $result_in, $result_out, @nb_out_errors, @nb_in_errors, $update_time, $db_file);
|
||||
my $pathtolibexecnt = $centreon{NAGIOS_PLUGINS};
|
||||
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
##################################################
|
||||
##### Verify Options
|
||||
##
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
($opt_v) || ($opt_v = shift) || ($opt_v = "1");
|
||||
my $snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
($opt_c) || ($opt_c = shift) || ($opt_c = 100);
|
||||
my $critical = $1 if ($opt_c =~ /([0-9]+)/);
|
||||
|
||||
($opt_w) || ($opt_w = shift) || ($opt_w = 80);
|
||||
my $warning = $1 if ($opt_w =~ /([0-9]+)/);
|
||||
|
||||
if ($critical <= $warning){
|
||||
print "(--crit) must be superior to (--warn)";
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $start=time;
|
||||
|
||||
|
||||
#################################################
|
||||
##### Plugin snmp requests
|
||||
##
|
||||
|
||||
my $OID_IN_ERRORS = ".1.3.6.1.2.1.2.2.1.14";
|
||||
my $OID_OUT_ERRORS = ".1.3.6.1.2.1.2.2.1.20";
|
||||
|
||||
|
||||
# create a SNMP session
|
||||
|
||||
my ($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
####### Get IN ERRORS
|
||||
|
||||
$result_in = $session->get_table(Baseoid => $OID_IN_ERRORS);
|
||||
if (!defined($result_in)) {
|
||||
printf("ERROR: IN_ERRORS : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
# loop for each interface
|
||||
foreach my $err (oid_lex_sort(keys %$result_in)) {
|
||||
$nb_in_errors[scalar(@nb_in_errors)] = $result_in->{$err};
|
||||
}
|
||||
# ####### Get OUT ERRORS
|
||||
|
||||
$result_out = $session->get_table(Baseoid => $OID_OUT_ERRORS);
|
||||
if (!defined($result_out)) {
|
||||
printf("ERROR: OUT_ERRORS : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
foreach my $err (oid_lex_sort(keys %$result_out)) {
|
||||
$nb_out_errors[scalar(@nb_out_errors)] = $result_out->{$err};
|
||||
}
|
||||
|
||||
# #############################################
|
||||
# ##### read and write in buffer file
|
||||
# ##
|
||||
|
||||
for (my $i = 0; $i < scalar(@nb_in_errors); $i++) {
|
||||
if (-e "@CENTPLUGINS_TMP@/packet_errors_if".$i."_".$opt_H.".tmp") {
|
||||
open(FILE,"<"."@CENTPLUGINS_TMP@/packet_errors_if".$i."_".$opt_H.".tmp");
|
||||
while($row = <FILE>){
|
||||
my @last_values = split(":",$row);
|
||||
$last_check_time[$i] = $last_values[0];
|
||||
$last_in_errors[$i] = $last_values[1];
|
||||
$last_out_errors[$i] = $last_values[2];
|
||||
$flg_created[$i] = 1;
|
||||
}
|
||||
close(FILE);
|
||||
} else {
|
||||
$flg_created[$i] = 0;
|
||||
}
|
||||
|
||||
$update_time = time;
|
||||
unless (open(FILE,">"."@CENTPLUGINS_TMP@/packet_errors_if".$i."_".$opt_H.".tmp")){
|
||||
print "Unknown - @CENTPLUGINS_TMP@/packet_errors_if".$i."_".$opt_H.".tmp!\n";
|
||||
exit $ERRORS{"UNKNOWN"};
|
||||
}
|
||||
print FILE "$update_time:$nb_in_errors[$i]:$nb_out_errors[$i]";
|
||||
close(FILE);
|
||||
if ($flg_created[$i] eq 0){
|
||||
print "First execution : Buffer in creation.... \n";
|
||||
}
|
||||
}
|
||||
|
||||
# #############################################
|
||||
# ##### return result
|
||||
# ##
|
||||
my $status = "OK";
|
||||
my @msg;
|
||||
my $diff_test = 0;
|
||||
for (my $i = 0; $i < scalar(@nb_in_errors); $i++) {
|
||||
my $interface = $i+1;
|
||||
if ($flg_created[$i]) {
|
||||
if (($nb_in_errors[$i] - $last_in_errors[$i] >= $critical) or ($nb_out_errors[$i] - $last_out_errors[$i] >= $critical)){
|
||||
$msg[$i] = "$interface:critical ";
|
||||
$status = "CRITICAL";
|
||||
}
|
||||
if (($nb_in_errors[$i] - $last_in_errors[$i] >= $warning) or ($nb_out_errors[$i] - $last_out_errors[$i] >= $warning)){
|
||||
if (!defined($msg[$i])) {
|
||||
$msg[$i] = "$interface:warning ";
|
||||
}
|
||||
if ($status ne "CRITICAL") {
|
||||
$status = "WARNING";
|
||||
}
|
||||
}
|
||||
$diff_test = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$diff_test) {
|
||||
exit($ERRORS{'UNKNOWN'});
|
||||
}
|
||||
my $output = "";
|
||||
for (my $i = 0; $i < scalar (@msg); $i++) {
|
||||
if (defined($msg[$i])) {
|
||||
$output .= $msg[$i];
|
||||
}
|
||||
}
|
||||
if ($output ne ""){
|
||||
print $output."\n";
|
||||
} else {
|
||||
print "Status OK on all interfaces\n";
|
||||
}
|
||||
exit($ERRORS{$status});
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (default to public)\n";
|
||||
print " used with SNMP v1 and v2c\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -w (--warn) Signal strength at which a warning message will be generated\n";
|
||||
print " (default 80)\n";
|
||||
print " -c (--crit) Signal strength at which a critical message will be generated\n";
|
||||
print " (default 100)\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
|
@ -1,216 +1,216 @@
|
|||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Christophe Coraboeuf - Sugumaran Mathavarajan
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp oid_lex_sort);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_v $opt_C $opt_p $opt_H $opt_n $opt_k $opt_u $opt_x $result @result %process_list %STATUS);
|
||||
|
||||
# Plugin var init
|
||||
|
||||
my($proc, $proc_run);
|
||||
|
||||
$PROGNAME = $0;
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
%STATUS=(1=>'running',2=>'runnable',3=>'notRunnable',4=>'invalid');
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"u=s" => \$opt_u, "username=s" => \$opt_u,
|
||||
"x=s" => \$opt_x, "password=s" => \$opt_x,
|
||||
"k=s" => \$opt_k, "key=s" => \$opt_k,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"n" => \$opt_n, "number" => \$opt_n,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"p=s" => \$opt_p, "process=s" => \$opt_p,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if (!$opt_H) {
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
my $snmp = "1";
|
||||
$snmp = $opt_v if ($opt_v && $opt_v =~ /^[0-9]$/);
|
||||
|
||||
if ($snmp eq "3") {
|
||||
if (!$opt_u) {
|
||||
print "Option -u (--username) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
if (!$opt_x && !$opt_k) {
|
||||
print "Option -k (--key) or -x (--password) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif ($opt_x && $opt_k) {
|
||||
print "Only option -k (--key) or -x (--password) is needed for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
}
|
||||
|
||||
$opt_C = "public" if (!$opt_C);
|
||||
|
||||
my $process;
|
||||
if(!$opt_p) {
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif ($opt_p !~ /([-.A-Za-z0-9]+)/){
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
$process = $opt_p;
|
||||
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
# Plugin snmp requests
|
||||
my $OID_SW_RunName = $centreon{MIB2}{SW_RUNNAME};
|
||||
my $OID_SW_RunIndex =$centreon{MIB2}{SW_RUNINDEX};
|
||||
my $OID_SW_RunStatus =$centreon{MIB2}{SW_RUNSTATUS};
|
||||
|
||||
my ($session, $error);
|
||||
if ($snmp eq "1" || $snmp eq "2") {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
} elsif ($opt_k) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
} elsif ($opt_x) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_x);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
$result = $session->get_table(Baseoid => $OID_SW_RunName);
|
||||
if (!defined($result)) {
|
||||
printf("UNKNOWN: %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
$proc = 0;
|
||||
foreach my $key (oid_lex_sort(keys %$result)) {
|
||||
my @oid_list = split (/\./,$key);
|
||||
$process_list{$$result{$key}} = pop (@oid_list) ;
|
||||
if (defined($opt_p) && $opt_p ne ""){
|
||||
$proc++ if ($$result{$key} eq $opt_p);
|
||||
} else {
|
||||
$proc++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!($opt_n)) {
|
||||
if ($process_list{$process}) {
|
||||
$result = $session->get_request(-varbindlist => [$OID_SW_RunStatus . "." . $process_list{$process}]);
|
||||
if (!defined($result)) {
|
||||
printf("UNKNOWN: %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
$proc_run = $result->{$OID_SW_RunStatus . "." . $process_list{$process} };
|
||||
}
|
||||
}
|
||||
|
||||
# Plugin return code
|
||||
my $status;
|
||||
if ($opt_n){
|
||||
$status = 'OK';
|
||||
if ($proc >= $opt_w){
|
||||
$status = 'WARNING';
|
||||
}
|
||||
if ($proc >= $opt_c){
|
||||
$status = 'CRITICAL';
|
||||
}
|
||||
print "Number of current processes: $proc|nbproc=$proc\n";
|
||||
exit $ERRORS{$status};
|
||||
} else {
|
||||
if ($proc_run){
|
||||
print "Process OK - $process: $STATUS{$proc_run}\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} else {
|
||||
print "Process CRITICAL - $process not in 'running' state\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
}
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public,\n";
|
||||
print " used with SNMP v1 and v2c\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -n (--number) Return the number of current running processes. \n";
|
||||
print " -p (--process) Set the process name ex: by default smbd\n";
|
||||
print " -k (--key) snmp V3 key\n";
|
||||
print " -x (--password) snmp V3 password\n";
|
||||
print " -u (--username) snmp v3 username \n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Christophe Coraboeuf - Sugumaran Mathavarajan
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp oid_lex_sort);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon = get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_h $opt_v $opt_C $opt_p $opt_H $opt_n $opt_k $opt_u $opt_x $result @result %process_list %STATUS);
|
||||
|
||||
# Plugin var init
|
||||
|
||||
my($proc, $proc_run);
|
||||
|
||||
$PROGNAME = $0;
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
%STATUS=(1=>'running',2=>'runnable',3=>'notRunnable',4=>'invalid');
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"u=s" => \$opt_u, "username=s" => \$opt_u,
|
||||
"x=s" => \$opt_x, "password=s" => \$opt_x,
|
||||
"k=s" => \$opt_k, "key=s" => \$opt_k,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"n" => \$opt_n, "number" => \$opt_n,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"p=s" => \$opt_p, "process=s" => \$opt_p,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if (!$opt_H) {
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
my $snmp = "1";
|
||||
$snmp = $opt_v if ($opt_v && $opt_v =~ /^[0-9]$/);
|
||||
|
||||
if ($snmp eq "3") {
|
||||
if (!$opt_u) {
|
||||
print "Option -u (--username) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
if (!$opt_x && !$opt_k) {
|
||||
print "Option -k (--key) or -x (--password) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif ($opt_x && $opt_k) {
|
||||
print "Only option -k (--key) or -x (--password) is needed for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
}
|
||||
|
||||
$opt_C = "public" if (!$opt_C);
|
||||
|
||||
my $process;
|
||||
if(!$opt_p) {
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif ($opt_p !~ /([-.A-Za-z0-9]+)/){
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
$process = $opt_p;
|
||||
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
|
||||
# Plugin snmp requests
|
||||
my $OID_SW_RunName = $centreon{MIB2}{SW_RUNNAME};
|
||||
my $OID_SW_RunIndex =$centreon{MIB2}{SW_RUNINDEX};
|
||||
my $OID_SW_RunStatus =$centreon{MIB2}{SW_RUNSTATUS};
|
||||
|
||||
my ($session, $error);
|
||||
if ($snmp eq "1" || $snmp eq "2") {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
} elsif ($opt_k) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
} elsif ($opt_x) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_x);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
$result = $session->get_table(Baseoid => $OID_SW_RunName);
|
||||
if (!defined($result)) {
|
||||
printf("UNKNOWN: %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
$proc = 0;
|
||||
foreach my $key (oid_lex_sort(keys %$result)) {
|
||||
my @oid_list = split (/\./,$key);
|
||||
$process_list{$$result{$key}} = pop (@oid_list) ;
|
||||
if (defined($opt_p) && $opt_p ne ""){
|
||||
$proc++ if ($$result{$key} eq $opt_p);
|
||||
} else {
|
||||
$proc++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!($opt_n)) {
|
||||
if ($process_list{$process}) {
|
||||
$result = $session->get_request(-varbindlist => [$OID_SW_RunStatus . "." . $process_list{$process}]);
|
||||
if (!defined($result)) {
|
||||
printf("UNKNOWN: %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
$proc_run = $result->{$OID_SW_RunStatus . "." . $process_list{$process} };
|
||||
}
|
||||
}
|
||||
|
||||
# Plugin return code
|
||||
my $status;
|
||||
if ($opt_n){
|
||||
$status = 'OK';
|
||||
if ($proc >= $opt_w){
|
||||
$status = 'WARNING';
|
||||
}
|
||||
if ($proc >= $opt_c){
|
||||
$status = 'CRITICAL';
|
||||
}
|
||||
print "Number of current processes: $proc|nbproc=$proc\n";
|
||||
exit $ERRORS{$status};
|
||||
} else {
|
||||
if ($proc_run){
|
||||
print "Process OK - $process: $STATUS{$proc_run}\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} else {
|
||||
print "Process CRITICAL - $process not in 'running' state\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
}
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public,\n";
|
||||
print " used with SNMP v1 and v2c\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -n (--number) Return the number of current running processes. \n";
|
||||
print " -p (--process) Set the process name ex: by default smbd\n";
|
||||
print " -k (--key) snmp V3 key\n";
|
||||
print " -x (--password) snmp V3 password\n";
|
||||
print " -u (--username) snmp v3 username \n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
|
@ -1,204 +1,204 @@
|
|||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Christophe Coraboeuf - Sugumaran Mathavarajan
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u);
|
||||
|
||||
$PROGNAME = $0;
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"u=s" => \$opt_u, "username=s" => \$opt_u,
|
||||
"p=s" => \$opt_p, "password=s" => \$opt_p,
|
||||
"k=s" => \$opt_k, "key=s" => \$opt_k,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"o=s" => \$opt_o, "oid=s" => \$opt_o,
|
||||
"t=s" => \$opt_t, "type=s" => \$opt_t,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.0');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
my $snmp = "1";
|
||||
if ($opt_v && $opt_v =~ /^[0-9]$/) {
|
||||
$snmp = $opt_v;
|
||||
}
|
||||
|
||||
if ($snmp eq "3") {
|
||||
if (!$opt_u) {
|
||||
print "Option -u (--username) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
if (!$opt_p && !$opt_k) {
|
||||
print "Option -k (--key) or -p (--password) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}elsif ($opt_p && $opt_k) {
|
||||
print "Only option -k (--key) or -p (--password) is needed for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
}
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
my $DS_type = "GAUGE";
|
||||
($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE");
|
||||
$DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/);
|
||||
|
||||
if (!$opt_c || !$opt_w) {
|
||||
print "You must specify -c and -w options\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
($opt_c) || ($opt_c = shift);
|
||||
my $critical = $1 if ($opt_c =~ /([0-9]+)/);
|
||||
|
||||
($opt_w) || ($opt_w = shift);
|
||||
my $warning = $1 if ($opt_w =~ /([0-9]+)/);
|
||||
if ($critical <= $warning){
|
||||
print "(--critical) must be superior to (--warning)";
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if (!$opt_o) {
|
||||
print "Option -o needed.\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}elsif (!($opt_o =~ /^[0-9\.]+$/)) {
|
||||
print "Wrong OID format\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
my $day = 0;
|
||||
|
||||
#=== create a SNMP session ====
|
||||
|
||||
my ($session, $error);
|
||||
if ($snmp eq "1" || $snmp eq "2") {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_k) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_p) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
my $result = $session->get_request(-varbindlist => [$opt_o]);
|
||||
if (!defined($result)) {
|
||||
printf("UNKNOWN: %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my $return_result = $result->{$opt_o};
|
||||
|
||||
#=== Plugin return code ====
|
||||
|
||||
if (defined($return_result)){
|
||||
if ($return_result !~ /^[0-9]+$/) {
|
||||
print "Snmp return value isn't numeric.\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
if ($opt_w && $opt_c && $return_result < $opt_w){
|
||||
print "Ok value : " . $return_result . "|value=".$return_result.";".$opt_w.";".$opt_c.";;\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif ($opt_w && $opt_c && $return_result >= $opt_w && $return_result < $opt_c){
|
||||
print "Warning value : " . $return_result . "|value=$return_result;".$opt_w.";".$opt_c.";;\n";
|
||||
exit $ERRORS{'WARNING'};
|
||||
} elsif ($opt_w && $opt_c && $return_result >= $opt_c){
|
||||
print "Critical value : " . $return_result."|value=".$return_result.";".$opt_w.";".$opt_c.";;\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
} else {
|
||||
print "CRITICAL Host unavailable\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
|
||||
|
||||
sub print_usage () {
|
||||
print "Usage:";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public,\n";
|
||||
print " used with SNMP v1 and v2c\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -t (--type) Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n";
|
||||
print " -o (--oid) OID to check\n";
|
||||
print " -k (--key) snmp V3 key\n";
|
||||
print " -p (--password) snmp V3 password\n";
|
||||
print " -u (--username) snmp v3 username \n";
|
||||
print " -w (--warning) Warning level\n";
|
||||
print " -c (--critical) Critical level\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
||||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Christophe Coraboeuf - Sugumaran Mathavarajan
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use Net::SNMP qw(:snmp);
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin";
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_h $opt_V $opt_H $opt_C $opt_v $opt_o $opt_c $opt_w $opt_t $opt_p $opt_k $opt_u);
|
||||
|
||||
$PROGNAME = $0;
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"u=s" => \$opt_u, "username=s" => \$opt_u,
|
||||
"p=s" => \$opt_p, "password=s" => \$opt_p,
|
||||
"k=s" => \$opt_k, "key=s" => \$opt_k,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v, "snmp=s" => \$opt_v,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"o=s" => \$opt_o, "oid=s" => \$opt_o,
|
||||
"t=s" => \$opt_t, "type=s" => \$opt_t,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.0');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
my $snmp = "1";
|
||||
if ($opt_v && $opt_v =~ /^[0-9]$/) {
|
||||
$snmp = $opt_v;
|
||||
}
|
||||
|
||||
if ($snmp eq "3") {
|
||||
if (!$opt_u) {
|
||||
print "Option -u (--username) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
if (!$opt_p && !$opt_k) {
|
||||
print "Option -k (--key) or -p (--password) is required for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}elsif ($opt_p && $opt_k) {
|
||||
print "Only option -k (--key) or -p (--password) is needed for snmpV3\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
}
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
my $DS_type = "GAUGE";
|
||||
($opt_t) || ($opt_t = shift) || ($opt_t = "GAUGE");
|
||||
$DS_type = $1 if ($opt_t =~ /(GAUGE)/ || $opt_t =~ /(COUNTER)/);
|
||||
|
||||
if (!$opt_c || !$opt_w) {
|
||||
print "You must specify -c and -w options\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
($opt_c) || ($opt_c = shift);
|
||||
my $critical = $1 if ($opt_c =~ /([0-9]+)/);
|
||||
|
||||
($opt_w) || ($opt_w = shift);
|
||||
my $warning = $1 if ($opt_w =~ /([0-9]+)/);
|
||||
if ($critical <= $warning){
|
||||
print "(--critical) must be superior to (--warning)";
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if (!$opt_o) {
|
||||
print "Option -o needed.\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}elsif (!($opt_o =~ /^[0-9\.]+$/)) {
|
||||
print "Wrong OID format\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
my $day = 0;
|
||||
|
||||
#=== create a SNMP session ====
|
||||
|
||||
my ($session, $error);
|
||||
if ($snmp eq "1" || $snmp eq "2") {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -community => $opt_C, -version => $snmp);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_k) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authkey => $opt_k);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}elsif ($opt_p) {
|
||||
($session, $error) = Net::SNMP->session(-hostname => $opt_H, -version => $snmp, -username => $opt_u, -authpassword => $opt_p);
|
||||
if (!defined($session)) {
|
||||
print("UNKNOWN: SNMP Session : $error\n");
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
my $result = $session->get_request(-varbindlist => [$opt_o]);
|
||||
if (!defined($result)) {
|
||||
printf("UNKNOWN: %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
my $return_result = $result->{$opt_o};
|
||||
|
||||
#=== Plugin return code ====
|
||||
|
||||
if (defined($return_result)){
|
||||
if ($return_result !~ /^[0-9]+$/) {
|
||||
print "Snmp return value isn't numeric.\n";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
if ($opt_w && $opt_c && $return_result < $opt_w){
|
||||
print "Ok value : " . $return_result . "|value=".$return_result.";".$opt_w.";".$opt_c.";;\n";
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif ($opt_w && $opt_c && $return_result >= $opt_w && $return_result < $opt_c){
|
||||
print "Warning value : " . $return_result . "|value=$return_result;".$opt_w.";".$opt_c.";;\n";
|
||||
exit $ERRORS{'WARNING'};
|
||||
} elsif ($opt_w && $opt_c && $return_result >= $opt_c){
|
||||
print "Critical value : " . $return_result."|value=".$return_result.";".$opt_w.";".$opt_c.";;\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
} else {
|
||||
print "CRITICAL Host unavailable\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
|
||||
|
||||
sub print_usage () {
|
||||
print "Usage:";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public,\n";
|
||||
print " used with SNMP v1 and v2c\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -t (--type) Data Source Type (GAUGE or COUNTER) (GAUGE by default)\n";
|
||||
print " -o (--oid) OID to check\n";
|
||||
print " -k (--key) snmp V3 key\n";
|
||||
print " -p (--password) snmp V3 password\n";
|
||||
print " -u (--username) snmp v3 username \n";
|
||||
print " -w (--warning) Warning level\n";
|
||||
print " -c (--critical) Critical level\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
||||
|
|
|
@ -1,398 +1,398 @@
|
|||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Plugin init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use DBI;
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_H $opt_h $opt_i);
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
## For Debug mode = 1
|
||||
my $debug = 0;
|
||||
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h,
|
||||
"help" => \$opt_h,
|
||||
"V" => \$opt_V,
|
||||
"i=s" => \$opt_i);
|
||||
|
||||
###########################
|
||||
## Set Database information
|
||||
###########################
|
||||
use vars qw($mysql_database_oreon $mysql_database_ods $mysql_host $mysql_user $mysql_passwd);
|
||||
require "/usr/local/centreon/etc/conf.pm";
|
||||
|
||||
my $dbh = DBI->connect("DBI:mysql:database=$mysql_database_oreon;host=$mysql_host","$mysql_user", "$mysql_passwd",{'RaiseError' => 1});
|
||||
my $dbh2 = DBI->connect("DBI:mysql:database=$mysql_database_ods;host=$mysql_host","$mysql_user", "$mysql_passwd",{'RaiseError' => 1});
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 0.1 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $result;
|
||||
my $warning;
|
||||
my $critical;
|
||||
my $metric_id;
|
||||
|
||||
sub return_value($$$$){
|
||||
|
||||
my $sth_output = $dbh->prepare("SELECT meta_display FROM `meta_service` WHERE `meta_id` = '".$_[3]."'");
|
||||
if (!$sth_output->execute) {die "Error:" . $sth_output->errstr . "\n";}
|
||||
my $sth_output_data = $sth_output->fetchrow_hashref();
|
||||
my $output = $sth_output_data->{'meta_display'};
|
||||
if ($output) {
|
||||
$output =~ s/\%d/$result/g;
|
||||
}
|
||||
if ($warning ne $critical){
|
||||
if ($warning < $critical){ # Bon sens
|
||||
if ($result < $warning){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "OK result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif (($result >= $warning) && ($result < $critical)){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "WARNING result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'WARNING'};
|
||||
} elsif ($result >= $critical){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "CRITICAL result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
} else { # sens inverse
|
||||
if ($result < $critical){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "CRITICAL result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
} elsif ($result >= $critical && $result < $warning){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "WARNING result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'WARNING'};
|
||||
} elsif ($result >= $warning){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "OK result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'OK'};
|
||||
} else{
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "OK result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print "ERROR : warnig level = critical level";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
}
|
||||
|
||||
my $ref;
|
||||
my $svc_id;
|
||||
my $metric;
|
||||
my $host_id;
|
||||
|
||||
## Get Value by metric Option
|
||||
|
||||
sub get_value_in_database_metric_id($$$$){
|
||||
## Get last entry in perfparse database for this service
|
||||
my $str = "SELECT value FROM data_bin WHERE id_metric = '".$metric_id."'";
|
||||
if ($debug) {print $str . "\n";}
|
||||
my $sth_deb2 = $dbh2->prepare($str);
|
||||
if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";}
|
||||
my $sth_deb2_data = $sth_deb2->fetchrow_hashref();
|
||||
return $sth_deb2_data->{'value'};
|
||||
}
|
||||
|
||||
## Get value For Regexp Options
|
||||
|
||||
sub get_value_in_database($$$$$){
|
||||
|
||||
my $str;
|
||||
## Get hostname and service description for perfparse request
|
||||
|
||||
$str = "SELECT host_name,service_description FROM host,host_service_relation,service WHERE host.host_id = host_service_relation.host_host_id AND
|
||||
service.service_id = host_service_relation.service_service_id AND service.service_id = '".$svc_id."'";
|
||||
|
||||
if ($debug) {print $str . "\n";}
|
||||
my $host_data = $dbh->prepare($str);
|
||||
if (!$host_data->execute) {die "Error:" . $host_data->errstr . "\n";}
|
||||
my $data = $host_data->fetchrow_hashref();
|
||||
|
||||
## Get last entry in perfparse database for this service
|
||||
my $sth_deb2 = $dbh2->prepare("SELECT value FROM metrics m, data_bin d, index_data i WHERE i.host_name = '".$data->{'host_name'}."' AND i.service_description = '".$data->{'service_description'}."' AND and m.index_id=i.id AND m.metric_id = d.id_metric AND m.metric_name = '".$metric."'");
|
||||
if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";}
|
||||
my $sth_deb2_data = $sth_deb2->fetchrow_hashref();
|
||||
return $sth_deb2_data->{'value'};
|
||||
}
|
||||
|
||||
sub get_value_in_database_by_host($$$$$){
|
||||
|
||||
my $str;
|
||||
|
||||
## Get hostname and service description for perfparse request
|
||||
|
||||
$str = "SELECT host_name,service_description FROM host,host_service_relation,service WHERE host.host_id = host_service_relation.host_host_id AND service.service_id = host_service_relation.service_service_id AND service.service_id = '".$svc_id."'";
|
||||
if ($debug) {print $str . "\n";}
|
||||
my $host_data = $dbh->prepare($str);
|
||||
if (!$host_data->execute) {die "Error:" . $host_data->errstr . "\n";}
|
||||
my $data = $host_data->fetchrow_hashref();
|
||||
|
||||
## Get last entry in perfparse database for this service
|
||||
|
||||
my $sth_deb2 = $dbh2->prepare("SELECT value FROM metrics m, data_bin d, index_data i WHERE i.host_name = '".$data->{'host_name'}."' AND i.service_description = '".$data->{'service_description'}."' AND m.index_id=i.id AND m.metric_id = d.id_metric AND m.metric_name = '".$metric."'");
|
||||
if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";}
|
||||
my $sth_deb2_data = $sth_deb2->fetchrow_hashref();
|
||||
return $sth_deb2_data->{'value'};
|
||||
}
|
||||
|
||||
sub get_value_in_database_by_hg($$$$$$){
|
||||
my $str;
|
||||
## Get hostname
|
||||
$str = "SELECT host_name FROM host WHERE host.host_id = '".$host_id."'";
|
||||
if ($debug) {print $str . "\n";}
|
||||
my $hd = $dbh->prepare($str);
|
||||
if (!$hd->execute) {die "Error:" . $hd->errstr . "\n";}
|
||||
my $host_data = $hd->fetchrow_hashref();
|
||||
|
||||
## Get service description
|
||||
|
||||
$str = "SELECT service_description FROM service WHERE service.service_id = '".$svc_id."'";
|
||||
if ($debug) {print $str . "\n";}
|
||||
my $sd = $dbh->prepare($str);
|
||||
if (!$sd->execute) {die "Error:" . $sd->errstr . "\n";}
|
||||
my $service_data = $sd->fetchrow_hashref();
|
||||
|
||||
## Get last entry in perfparse database for this service
|
||||
|
||||
my $sth_deb2 = $dbh2->prepare("SELECT value FROM metrics m, data_bin d, index_data i WHERE i.host_name = '".$host_data->{'host_name'}."' AND i.service_description = '".$service_data->{'service_description'}."' AND m.index_id=i.id AND m.metric_id = d.id_metric AND m.metric_name = '".$metric."'");
|
||||
if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";}
|
||||
my $sth_deb2_data = $sth_deb2->fetchrow_hashref();
|
||||
return $sth_deb2_data->{'value'};
|
||||
}
|
||||
|
||||
my $cpt = 0;
|
||||
my $total = 0;
|
||||
my $max = 0;
|
||||
my $min = 999999999;
|
||||
my $svc;
|
||||
my $value = 0;
|
||||
my $svc_relation2;
|
||||
|
||||
if ($opt_i){
|
||||
my $str;
|
||||
|
||||
# get osl info
|
||||
my $sth = $dbh->prepare("SELECT calcul_type,regexp_str,warning,critical,metric, meta_select_mode FROM meta_service WHERE meta_id = '".$opt_i."'");
|
||||
if (!$sth->execute) {die "Error:" . $sth->errstr . "\n";}
|
||||
$ref = $sth->fetchrow_hashref();
|
||||
if (!defined($ref->{'calcul_type'})){
|
||||
print "Unvalidate Meta Service\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
|
||||
$warning = $ref->{'warning'};
|
||||
$critical = $ref->{'critical'};
|
||||
|
||||
# Get Service List by regexp
|
||||
if ($ref->{'meta_select_mode'} eq '2'){
|
||||
|
||||
###############################################
|
||||
|
||||
$str = "SELECT service_id FROM service WHERE `service_description` LIKE '".$ref->{'regexp_str'}."' AND service_activate = '1' AND service_register = '1'";
|
||||
if ($debug) {print $str . "\n";}
|
||||
$sth = $dbh->prepare($str);
|
||||
if (!$sth->execute) {die "Error:" . $sth->errstr . "\n";}
|
||||
while ($svc = $sth->fetchrow_hashref()){
|
||||
my $sth2 = $dbh->prepare("SELECT * FROM host_service_relation WHERE service_service_id = '".$svc->{'service_id'}."'");
|
||||
if (!$sth2->execute) {die "Error:" . $sth2->errstr . "\n";}
|
||||
my $svc_relation = $sth2->fetchrow_hashref();
|
||||
if (defined($svc_relation->{'host_host_id'}) && $svc_relation->{'host_host_id'}){
|
||||
#### Par Host
|
||||
if (defined($svc->{'service_id'})){$svc_id = $svc->{'service_id'};} else {$svc_id = $svc->{'svc_id'};}
|
||||
if (defined($ref->{'regexp_str'})){$metric = $ref->{'metric'};} else {$metric = $svc->{'metric'};}
|
||||
$value = get_value_in_database_by_host($dbh,$dbh2,$svc_id,$metric,$debug);
|
||||
if ($ref->{'calcul_type'} =~ "AVE"){
|
||||
if (defined($value) && $value){$total += $value;}
|
||||
if ($debug) {print "total = " . $total . " value = ".$value."\n";}
|
||||
$cpt++;
|
||||
$result = $total / $cpt;
|
||||
} elsif ($ref->{'calcul_type'} =~ "SOM"){
|
||||
if ($value){$total += $value;}
|
||||
if ($debug){print "total = " . $total . " value = ".$value."\n";}
|
||||
$result = $total;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MIN"){
|
||||
if ($debug){print " min : " . $min . " value = ".$value."\n";}
|
||||
if ($value && $value <= $min){$min = $value;}
|
||||
$result = $min;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MAX"){
|
||||
if ($debug){print "max = " . $max . " value = ".$value."\n";}
|
||||
if ($value && $value >= $max){$max = $value;}
|
||||
$result = $max;
|
||||
}
|
||||
} elsif (defined($svc_relation->{'hostgroup_hg_id'}) && $svc_relation->{'hostgroup_hg_id'}) {
|
||||
### Par Hostgroup
|
||||
my $sth3 = $dbh->prepare("SELECT host_host_id FROM hostgroup_relation WHERE hostgroup_hg_id = '".$svc_relation->{'hostgroup_hg_id'}."'");
|
||||
if (!$sth3->execute) {die "Error:" . $sth3->errstr . "\n";}
|
||||
while ($svc_relation2 = $sth3->fetchrow_hashref()){
|
||||
if (defined($svc->{'service_id'})){
|
||||
$svc_id = $svc->{'service_id'};
|
||||
} else {
|
||||
$svc_id = $svc->{'svc_id'};
|
||||
}
|
||||
if (defined($ref->{'regexp_str'})){
|
||||
$metric = $ref->{'metric'};
|
||||
} else {
|
||||
$metric = $svc->{'metric'};
|
||||
}
|
||||
$host_id = $svc_relation2->{'host_host_id'};
|
||||
$value = get_value_in_database_by_hg($dbh,$dbh2,$svc_id, $host_id, $metric, $debug);
|
||||
if ($ref->{'calcul_type'} =~ "AVE"){
|
||||
if (defined($value) && $value){
|
||||
$total += $value;
|
||||
}
|
||||
if ($debug) {print "total = " . $total . " value = ".$value."\n";}
|
||||
$cpt++;
|
||||
} elsif ($ref->{'calcul_type'} =~ "SOM"){
|
||||
if ($value){
|
||||
$total += $value;
|
||||
}
|
||||
if ($debug){print "total = " . $total . " value = ".$value."\n";}
|
||||
} elsif ($ref->{'calcul_type'} =~ "MIN"){
|
||||
if ($debug){print " min : " . $min . " value = ".$value."\n";}
|
||||
if ($value && $value <= $min){
|
||||
$min = $value;
|
||||
}
|
||||
} elsif ($ref->{'calcul_type'} =~ "MAX"){
|
||||
if ($debug){print "max = " . $max . " value = ".$value."\n";}
|
||||
if ($value && $value >= $max){
|
||||
$max = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($ref->{'calcul_type'} =~ "AVE"){
|
||||
$result = $total / $cpt;
|
||||
} elsif ($ref->{'calcul_type'} =~ "SOM"){
|
||||
$result = $total;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MIN"){
|
||||
$result = $min;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MAX"){
|
||||
$result = $max;
|
||||
}
|
||||
}
|
||||
}
|
||||
return_value($result, $warning, $critical, $opt_i);
|
||||
###############################################
|
||||
} else {
|
||||
$sth = $dbh->prepare("SELECT metric_id FROM `meta_service_relation` WHERE meta_id = '".$opt_i."'");
|
||||
if (!$sth->execute) {die "Error:" . $sth->errstr . "\n";}
|
||||
if ($ref->{'calcul_type'} =~ "AVE"){
|
||||
if (!$sth->rows) {
|
||||
print "no result in table meta_service_relation for id $opt_i\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
while ($svc = $sth->fetchrow_hashref()){
|
||||
if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};}
|
||||
$value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug);
|
||||
if (defined($value) && $value){$total += $value;}
|
||||
$cpt++;
|
||||
}
|
||||
$result = $total / $cpt;
|
||||
} elsif ($ref->{'calcul_type'} =~ "SOM"){
|
||||
while ($svc = $sth->fetchrow_hashref()){
|
||||
if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};}
|
||||
$value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug);
|
||||
if ($value){$total += $value;}
|
||||
if ($debug){print "total = " . $total . " value = ".$value."\n";}
|
||||
}
|
||||
$result = $total;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MIN"){
|
||||
while ($svc = $sth->fetchrow_hashref()){
|
||||
if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};}
|
||||
$value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug);
|
||||
if ($debug){print " min : " . $min . " value = ".$value."\n";}
|
||||
if ($value && $value <= $min){$min = $value;}
|
||||
}
|
||||
$result = $min;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MAX"){
|
||||
while ($svc = $sth->fetchrow_hashref()){
|
||||
if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};}
|
||||
$value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug);
|
||||
if ($debug){print "max = " . $max . " value = ".$value."\n";}
|
||||
if ($value && $value >= $max){$max = $value;}
|
||||
}
|
||||
$result = $max;
|
||||
}
|
||||
return_value($result, $warning, $critical, $opt_i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub print_usage () {
|
||||
print "Usage:\n";
|
||||
print " check_meta_service\n";
|
||||
print " -i Meta Service id\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2008 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Plugin init
|
||||
#
|
||||
|
||||
use strict;
|
||||
use DBI;
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_V $opt_H $opt_h $opt_i);
|
||||
use lib "@NAGIOS_PLUGINS@";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
## For Debug mode = 1
|
||||
my $debug = 0;
|
||||
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h,
|
||||
"help" => \$opt_h,
|
||||
"V" => \$opt_V,
|
||||
"i=s" => \$opt_i);
|
||||
|
||||
###########################
|
||||
## Set Database information
|
||||
###########################
|
||||
use vars qw($mysql_database_oreon $mysql_database_ods $mysql_host $mysql_user $mysql_passwd);
|
||||
require "/usr/local/centreon/etc/conf.pm";
|
||||
|
||||
my $dbh = DBI->connect("DBI:mysql:database=$mysql_database_oreon;host=$mysql_host","$mysql_user", "$mysql_passwd",{'RaiseError' => 1});
|
||||
my $dbh2 = DBI->connect("DBI:mysql:database=$mysql_database_ods;host=$mysql_host","$mysql_user", "$mysql_passwd",{'RaiseError' => 1});
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 0.1 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
my $result;
|
||||
my $warning;
|
||||
my $critical;
|
||||
my $metric_id;
|
||||
|
||||
sub return_value($$$$){
|
||||
|
||||
my $sth_output = $dbh->prepare("SELECT meta_display FROM `meta_service` WHERE `meta_id` = '".$_[3]."'");
|
||||
if (!$sth_output->execute) {die "Error:" . $sth_output->errstr . "\n";}
|
||||
my $sth_output_data = $sth_output->fetchrow_hashref();
|
||||
my $output = $sth_output_data->{'meta_display'};
|
||||
if ($output) {
|
||||
$output =~ s/\%d/$result/g;
|
||||
}
|
||||
if ($warning ne $critical){
|
||||
if ($warning < $critical){ # Bon sens
|
||||
if ($result < $warning){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "OK result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'OK'};
|
||||
} elsif (($result >= $warning) && ($result < $critical)){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "WARNING result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'WARNING'};
|
||||
} elsif ($result >= $critical){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "CRITICAL result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
} else { # sens inverse
|
||||
if ($result < $critical){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "CRITICAL result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
} elsif ($result >= $critical && $result < $warning){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "WARNING result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'WARNING'};
|
||||
} elsif ($result >= $warning){
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "OK result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'OK'};
|
||||
} else{
|
||||
if ($output) {
|
||||
print $output. "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}else {
|
||||
print "OK result : " . $result . "|OMS=" . $result . ";".$warning.";".$critical."\n";
|
||||
}
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print "ERROR : warnig level = critical level";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
}
|
||||
|
||||
my $ref;
|
||||
my $svc_id;
|
||||
my $metric;
|
||||
my $host_id;
|
||||
|
||||
## Get Value by metric Option
|
||||
|
||||
sub get_value_in_database_metric_id($$$$){
|
||||
## Get last entry in perfparse database for this service
|
||||
my $str = "SELECT value FROM data_bin WHERE id_metric = '".$metric_id."'";
|
||||
if ($debug) {print $str . "\n";}
|
||||
my $sth_deb2 = $dbh2->prepare($str);
|
||||
if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";}
|
||||
my $sth_deb2_data = $sth_deb2->fetchrow_hashref();
|
||||
return $sth_deb2_data->{'value'};
|
||||
}
|
||||
|
||||
## Get value For Regexp Options
|
||||
|
||||
sub get_value_in_database($$$$$){
|
||||
|
||||
my $str;
|
||||
## Get hostname and service description for perfparse request
|
||||
|
||||
$str = "SELECT host_name,service_description FROM host,host_service_relation,service WHERE host.host_id = host_service_relation.host_host_id AND
|
||||
service.service_id = host_service_relation.service_service_id AND service.service_id = '".$svc_id."'";
|
||||
|
||||
if ($debug) {print $str . "\n";}
|
||||
my $host_data = $dbh->prepare($str);
|
||||
if (!$host_data->execute) {die "Error:" . $host_data->errstr . "\n";}
|
||||
my $data = $host_data->fetchrow_hashref();
|
||||
|
||||
## Get last entry in perfparse database for this service
|
||||
my $sth_deb2 = $dbh2->prepare("SELECT value FROM metrics m, data_bin d, index_data i WHERE i.host_name = '".$data->{'host_name'}."' AND i.service_description = '".$data->{'service_description'}."' AND and m.index_id=i.id AND m.metric_id = d.id_metric AND m.metric_name = '".$metric."'");
|
||||
if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";}
|
||||
my $sth_deb2_data = $sth_deb2->fetchrow_hashref();
|
||||
return $sth_deb2_data->{'value'};
|
||||
}
|
||||
|
||||
sub get_value_in_database_by_host($$$$$){
|
||||
|
||||
my $str;
|
||||
|
||||
## Get hostname and service description for perfparse request
|
||||
|
||||
$str = "SELECT host_name,service_description FROM host,host_service_relation,service WHERE host.host_id = host_service_relation.host_host_id AND service.service_id = host_service_relation.service_service_id AND service.service_id = '".$svc_id."'";
|
||||
if ($debug) {print $str . "\n";}
|
||||
my $host_data = $dbh->prepare($str);
|
||||
if (!$host_data->execute) {die "Error:" . $host_data->errstr . "\n";}
|
||||
my $data = $host_data->fetchrow_hashref();
|
||||
|
||||
## Get last entry in perfparse database for this service
|
||||
|
||||
my $sth_deb2 = $dbh2->prepare("SELECT value FROM metrics m, data_bin d, index_data i WHERE i.host_name = '".$data->{'host_name'}."' AND i.service_description = '".$data->{'service_description'}."' AND m.index_id=i.id AND m.metric_id = d.id_metric AND m.metric_name = '".$metric."'");
|
||||
if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";}
|
||||
my $sth_deb2_data = $sth_deb2->fetchrow_hashref();
|
||||
return $sth_deb2_data->{'value'};
|
||||
}
|
||||
|
||||
sub get_value_in_database_by_hg($$$$$$){
|
||||
my $str;
|
||||
## Get hostname
|
||||
$str = "SELECT host_name FROM host WHERE host.host_id = '".$host_id."'";
|
||||
if ($debug) {print $str . "\n";}
|
||||
my $hd = $dbh->prepare($str);
|
||||
if (!$hd->execute) {die "Error:" . $hd->errstr . "\n";}
|
||||
my $host_data = $hd->fetchrow_hashref();
|
||||
|
||||
## Get service description
|
||||
|
||||
$str = "SELECT service_description FROM service WHERE service.service_id = '".$svc_id."'";
|
||||
if ($debug) {print $str . "\n";}
|
||||
my $sd = $dbh->prepare($str);
|
||||
if (!$sd->execute) {die "Error:" . $sd->errstr . "\n";}
|
||||
my $service_data = $sd->fetchrow_hashref();
|
||||
|
||||
## Get last entry in perfparse database for this service
|
||||
|
||||
my $sth_deb2 = $dbh2->prepare("SELECT value FROM metrics m, data_bin d, index_data i WHERE i.host_name = '".$host_data->{'host_name'}."' AND i.service_description = '".$service_data->{'service_description'}."' AND m.index_id=i.id AND m.metric_id = d.id_metric AND m.metric_name = '".$metric."'");
|
||||
if (!$sth_deb2->execute) {die "Error:" . $sth_deb2->errstr . "\n";}
|
||||
my $sth_deb2_data = $sth_deb2->fetchrow_hashref();
|
||||
return $sth_deb2_data->{'value'};
|
||||
}
|
||||
|
||||
my $cpt = 0;
|
||||
my $total = 0;
|
||||
my $max = 0;
|
||||
my $min = 999999999;
|
||||
my $svc;
|
||||
my $value = 0;
|
||||
my $svc_relation2;
|
||||
|
||||
if ($opt_i){
|
||||
my $str;
|
||||
|
||||
# get osl info
|
||||
my $sth = $dbh->prepare("SELECT calcul_type,regexp_str,warning,critical,metric, meta_select_mode FROM meta_service WHERE meta_id = '".$opt_i."'");
|
||||
if (!$sth->execute) {die "Error:" . $sth->errstr . "\n";}
|
||||
$ref = $sth->fetchrow_hashref();
|
||||
if (!defined($ref->{'calcul_type'})){
|
||||
print "Unvalidate Meta Service\n";
|
||||
exit $ERRORS{'CRITICAL'};
|
||||
}
|
||||
|
||||
$warning = $ref->{'warning'};
|
||||
$critical = $ref->{'critical'};
|
||||
|
||||
# Get Service List by regexp
|
||||
if ($ref->{'meta_select_mode'} eq '2'){
|
||||
|
||||
###############################################
|
||||
|
||||
$str = "SELECT service_id FROM service WHERE `service_description` LIKE '".$ref->{'regexp_str'}."' AND service_activate = '1' AND service_register = '1'";
|
||||
if ($debug) {print $str . "\n";}
|
||||
$sth = $dbh->prepare($str);
|
||||
if (!$sth->execute) {die "Error:" . $sth->errstr . "\n";}
|
||||
while ($svc = $sth->fetchrow_hashref()){
|
||||
my $sth2 = $dbh->prepare("SELECT * FROM host_service_relation WHERE service_service_id = '".$svc->{'service_id'}."'");
|
||||
if (!$sth2->execute) {die "Error:" . $sth2->errstr . "\n";}
|
||||
my $svc_relation = $sth2->fetchrow_hashref();
|
||||
if (defined($svc_relation->{'host_host_id'}) && $svc_relation->{'host_host_id'}){
|
||||
#### Par Host
|
||||
if (defined($svc->{'service_id'})){$svc_id = $svc->{'service_id'};} else {$svc_id = $svc->{'svc_id'};}
|
||||
if (defined($ref->{'regexp_str'})){$metric = $ref->{'metric'};} else {$metric = $svc->{'metric'};}
|
||||
$value = get_value_in_database_by_host($dbh,$dbh2,$svc_id,$metric,$debug);
|
||||
if ($ref->{'calcul_type'} =~ "AVE"){
|
||||
if (defined($value) && $value){$total += $value;}
|
||||
if ($debug) {print "total = " . $total . " value = ".$value."\n";}
|
||||
$cpt++;
|
||||
$result = $total / $cpt;
|
||||
} elsif ($ref->{'calcul_type'} =~ "SOM"){
|
||||
if ($value){$total += $value;}
|
||||
if ($debug){print "total = " . $total . " value = ".$value."\n";}
|
||||
$result = $total;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MIN"){
|
||||
if ($debug){print " min : " . $min . " value = ".$value."\n";}
|
||||
if ($value && $value <= $min){$min = $value;}
|
||||
$result = $min;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MAX"){
|
||||
if ($debug){print "max = " . $max . " value = ".$value."\n";}
|
||||
if ($value && $value >= $max){$max = $value;}
|
||||
$result = $max;
|
||||
}
|
||||
} elsif (defined($svc_relation->{'hostgroup_hg_id'}) && $svc_relation->{'hostgroup_hg_id'}) {
|
||||
### Par Hostgroup
|
||||
my $sth3 = $dbh->prepare("SELECT host_host_id FROM hostgroup_relation WHERE hostgroup_hg_id = '".$svc_relation->{'hostgroup_hg_id'}."'");
|
||||
if (!$sth3->execute) {die "Error:" . $sth3->errstr . "\n";}
|
||||
while ($svc_relation2 = $sth3->fetchrow_hashref()){
|
||||
if (defined($svc->{'service_id'})){
|
||||
$svc_id = $svc->{'service_id'};
|
||||
} else {
|
||||
$svc_id = $svc->{'svc_id'};
|
||||
}
|
||||
if (defined($ref->{'regexp_str'})){
|
||||
$metric = $ref->{'metric'};
|
||||
} else {
|
||||
$metric = $svc->{'metric'};
|
||||
}
|
||||
$host_id = $svc_relation2->{'host_host_id'};
|
||||
$value = get_value_in_database_by_hg($dbh,$dbh2,$svc_id, $host_id, $metric, $debug);
|
||||
if ($ref->{'calcul_type'} =~ "AVE"){
|
||||
if (defined($value) && $value){
|
||||
$total += $value;
|
||||
}
|
||||
if ($debug) {print "total = " . $total . " value = ".$value."\n";}
|
||||
$cpt++;
|
||||
} elsif ($ref->{'calcul_type'} =~ "SOM"){
|
||||
if ($value){
|
||||
$total += $value;
|
||||
}
|
||||
if ($debug){print "total = " . $total . " value = ".$value."\n";}
|
||||
} elsif ($ref->{'calcul_type'} =~ "MIN"){
|
||||
if ($debug){print " min : " . $min . " value = ".$value."\n";}
|
||||
if ($value && $value <= $min){
|
||||
$min = $value;
|
||||
}
|
||||
} elsif ($ref->{'calcul_type'} =~ "MAX"){
|
||||
if ($debug){print "max = " . $max . " value = ".$value."\n";}
|
||||
if ($value && $value >= $max){
|
||||
$max = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($ref->{'calcul_type'} =~ "AVE"){
|
||||
$result = $total / $cpt;
|
||||
} elsif ($ref->{'calcul_type'} =~ "SOM"){
|
||||
$result = $total;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MIN"){
|
||||
$result = $min;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MAX"){
|
||||
$result = $max;
|
||||
}
|
||||
}
|
||||
}
|
||||
return_value($result, $warning, $critical, $opt_i);
|
||||
###############################################
|
||||
} else {
|
||||
$sth = $dbh->prepare("SELECT metric_id FROM `meta_service_relation` WHERE meta_id = '".$opt_i."'");
|
||||
if (!$sth->execute) {die "Error:" . $sth->errstr . "\n";}
|
||||
if ($ref->{'calcul_type'} =~ "AVE"){
|
||||
if (!$sth->rows) {
|
||||
print "no result in table meta_service_relation for id $opt_i\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
while ($svc = $sth->fetchrow_hashref()){
|
||||
if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};}
|
||||
$value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug);
|
||||
if (defined($value) && $value){$total += $value;}
|
||||
$cpt++;
|
||||
}
|
||||
$result = $total / $cpt;
|
||||
} elsif ($ref->{'calcul_type'} =~ "SOM"){
|
||||
while ($svc = $sth->fetchrow_hashref()){
|
||||
if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};}
|
||||
$value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug);
|
||||
if ($value){$total += $value;}
|
||||
if ($debug){print "total = " . $total . " value = ".$value."\n";}
|
||||
}
|
||||
$result = $total;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MIN"){
|
||||
while ($svc = $sth->fetchrow_hashref()){
|
||||
if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};}
|
||||
$value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug);
|
||||
if ($debug){print " min : " . $min . " value = ".$value."\n";}
|
||||
if ($value && $value <= $min){$min = $value;}
|
||||
}
|
||||
$result = $min;
|
||||
} elsif ($ref->{'calcul_type'} =~ "MAX"){
|
||||
while ($svc = $sth->fetchrow_hashref()){
|
||||
if (defined($svc->{'metric_id'})){$metric_id = $svc->{'metric_id'};}
|
||||
$value = get_value_in_database_metric_id($dbh,$dbh2,$metric_id,$debug);
|
||||
if ($debug){print "max = " . $max . " value = ".$value."\n";}
|
||||
if ($value && $value >= $max){$max = $value;}
|
||||
}
|
||||
$result = $max;
|
||||
}
|
||||
return_value($result, $warning, $critical, $opt_i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub print_usage () {
|
||||
print "Usage:\n";
|
||||
print " check_meta_service\n";
|
||||
print " -i Meta Service id\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2008 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
|
@ -1,348 +1,348 @@
|
|||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# 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 centreon" ) {
|
||||
use centreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_H $opt_p $opt_s $opt_v $opt_V $opt_h $opt_w $opt_c $opt_S $opt_g $opt_t $opt_l $opt_d $opt_D $opt_step $step $opt_f);
|
||||
|
||||
## Plugin var init
|
||||
|
||||
my $pathtolibexecnt = $centreon{GLOBAL}{NAGIOS_PLUGINS}."check_nt";
|
||||
my($op_v, $op_d, $op_s, $op_t, $op_l, $port, @values, @test, @test2, @test3, @test4, @test5, $warning, $critical, @w, @c, $uptime);
|
||||
my($warning2, $critical2, $warning3, $critical3, $warning4, $critical4, @output);
|
||||
$PROGNAME = $0;
|
||||
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"p=s" => \$opt_p, "port=s" => \$opt_p,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"s=s" => \$opt_s, "password=s" => \$opt_s,
|
||||
"d=s" => \$opt_d, "showall=s" => \$opt_d,
|
||||
"v=s" => \$opt_v, "variable=s" => \$opt_v,
|
||||
"D=s" => \$opt_D, "directory=s" => \$opt_D,
|
||||
"t=s" => \$opt_t, "timeout=s" => \$opt_t,
|
||||
"l:s" => \$opt_l, "parameter:s" => \$opt_l,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_V) {
|
||||
$_ = `$pathtolibexecnt -V`;
|
||||
print "$_";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_p) {
|
||||
if ($opt_p =~ /([0-9]+)/){
|
||||
$port = $1;
|
||||
} else {
|
||||
print "Unknown -p number expected... or it doesn't exist, try another port - number\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
|
||||
if ($opt_c) {
|
||||
($opt_c) || ($opt_c = shift);
|
||||
$critical = $1 if ($opt_c =~ /([0-9]+)/);
|
||||
}
|
||||
|
||||
if ($opt_w) {
|
||||
($opt_w) || ($opt_w = shift);
|
||||
$warning = $1 if ($opt_w =~ /([0-9]+)/);
|
||||
}
|
||||
|
||||
if (($critical && $warning) && ($critical <= $warning)) {
|
||||
print "(--crit) must be superior to (--warn)";
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_t) {
|
||||
($opt_t) || ($opt_t = shift);
|
||||
$op_t = $1 if ($opt_t =~ /([-\.,\w]+)/);
|
||||
}
|
||||
|
||||
if ($opt_l) {
|
||||
($opt_l) || ($opt_l = shift);
|
||||
$op_l = $1 if ($opt_l =~ /(.+)/);
|
||||
}
|
||||
|
||||
if ($opt_d) {
|
||||
($opt_d) || ($opt_d = shift);
|
||||
$op_d = $1 if ($opt_d =~ /([-.,A-Za-z0-9]+)/);
|
||||
}
|
||||
|
||||
if ($opt_s) {
|
||||
($opt_s) || ($opt_s = shift);
|
||||
$op_s = $1 if ($opt_s =~ /([\_\-\.\,A-Za-z0-9]+)/);
|
||||
}
|
||||
|
||||
if ($opt_v) {
|
||||
($opt_v) || ($opt_v = shift);
|
||||
$op_v = $1 if ($opt_v =~ /([-.,A-Za-z0-9]+)/);
|
||||
}
|
||||
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
my $return_code;
|
||||
|
||||
## Plugin requests
|
||||
my $start=time;
|
||||
if ($op_v) {
|
||||
if ($op_v) {$op_v = "-v ".$op_v;}
|
||||
if ($port) {$port = "-p ".$port;} else { $port = " ";}
|
||||
if ($warning) {$warning = "-w ".$warning;} else { $warning = " ";}
|
||||
if ($critical) {$critical = "-c ".$critical;} else { $critical = " ";}
|
||||
if ($op_l) {$op_l = "-l \"".$op_l ."\"";} else { $op_l = " ";}
|
||||
if ($op_t) {$op_t = "-t ".$op_t;} else { $op_t = " ";}
|
||||
if ($op_s) {$op_s = "-s ".$op_s;} else { $op_s = " ";}
|
||||
if ($op_d) {$op_d = "-d ".$op_d;} else { $op_d = " ";}
|
||||
# print "$pathtolibexecnt -H $opt_H $op_v $port $warning $critical $op_l $op_t $op_s $op_d\n";
|
||||
$_ = `$pathtolibexecnt -H $opt_H $op_v $port $warning $critical $op_l $op_t $op_s $op_d `;
|
||||
my $return = $_;
|
||||
if (!defined($return) || $return eq "") {
|
||||
print "Error in command, check your command options\n";
|
||||
exit (3);
|
||||
}
|
||||
$return =~ s/\\//g;
|
||||
$return_code = $? / 256;
|
||||
## CLIENTVERSION
|
||||
if ($op_v =~ /CLIENTVERSION/){
|
||||
print "CLIENTVERSION impossible to Graph!\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
if (($op_v =~ /CPULOAD/) && ($op_l =~ /([-\.,\w]+)/)){ ## CPULOAD
|
||||
@output = split(/\|/,$_);
|
||||
@values = $output[0] =~ /(\d*)\%/g ;
|
||||
$start = time;
|
||||
## Print Plugins Output
|
||||
$return =~ s/\n//g;
|
||||
my @return_data = split(/\|/,$return);
|
||||
if (@values){
|
||||
if (defined($opt_c) && defined($opt_w)){
|
||||
print $return_data[0] . "|cpu=@values%;$opt_w;$opt_c\n";
|
||||
} else {
|
||||
print $return_data[0] . "|cpu=@values%\n";
|
||||
}
|
||||
} else {
|
||||
print $return . "\n";
|
||||
}
|
||||
exit $return_code;
|
||||
} elsif ($op_v =~ /UPTIME/){ ## UPTIME
|
||||
if ($_ =~ /.*[-:]+\s(\d+)\s.*$/ ) {
|
||||
$uptime = $1;
|
||||
} else {
|
||||
print "unable to parse check_nt output: $_\n" ;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
$_ =~ s/\n/ /g;
|
||||
if (defined($uptime)){
|
||||
print $_ . "|uptime=".$uptime."d\n";
|
||||
} else {
|
||||
print $_ . "\n";
|
||||
}
|
||||
exit $return_code;
|
||||
} elsif (($op_v =~ /USEDDISKSPACE/) && ($op_l =~ /([-\.,\w]+)/)){ ## USEDDISKSPACE
|
||||
my @test = split(/ /,$_);
|
||||
if (defined($test[9]) && defined($test2[1])){
|
||||
@test2 = split(/\(/, $test[9]);
|
||||
@test3 = split(/\%/, $test2[1]);
|
||||
}
|
||||
@c = split(/ /, $critical);
|
||||
$critical = $c[1];
|
||||
@w = split(/ /, $warning);
|
||||
$warning = $w[1];
|
||||
## Print Plugins Output
|
||||
$return =~ s/\n/ /g;
|
||||
my @return_part = split(/\|/, $return);
|
||||
#$return =~ s/%/ pct/g;
|
||||
## Put value in octets : Mo -> o
|
||||
if (defined($test[3]) && defined($test[7]) && defined($test[12])){
|
||||
$test[3] =~ s/\,/\./g;
|
||||
$test[3] = eval($test[3] * 1024 * 1024 * 1024);
|
||||
$test[7] =~ s/\,/\./g;
|
||||
$test[7] = eval ($test[7] * 1024 * 1024 * 1024);
|
||||
print $return_part[0] . "|total=".$test[3]."o used=".$test[7]."o\n";
|
||||
} else {
|
||||
print $return_part[0] . "\n";
|
||||
}
|
||||
exit $return_code;
|
||||
} elsif ($op_v =~ /MEMUSE/){ ## MEMUSE
|
||||
$start = time;
|
||||
my @test = split(/ /,$_);
|
||||
if (defined($test[2])){
|
||||
@test4 = split(/:/, $test[2]);
|
||||
}
|
||||
@c = split(/ /, $critical);
|
||||
$critical = $c[1];
|
||||
@w = split(/ /, $warning);
|
||||
$warning = $w[1];
|
||||
## Print Plugins Output
|
||||
my @return_data = split(/\|/,$return);
|
||||
$return =~ s/\n/ /g;
|
||||
#$return =~ s/%/ pct/g;
|
||||
if ($test4[1] && $test[6] && $test[11]){
|
||||
## Put value in octets : Mo -> o
|
||||
$test4[1] =~ s/\,/\./g;
|
||||
$test4[1] = eval($test4[1] * 1024 * 1024);
|
||||
$test[6] =~ s/\,/\./g;
|
||||
$test[6] = eval($test[6] * 1024 * 1024);
|
||||
print $return_data[0] . "|total=".$test4[1]."o used=".$test[6]."o\n";
|
||||
} else {
|
||||
print $return_data[0] . "\n";
|
||||
}
|
||||
exit $return_code;
|
||||
} elsif ($op_v =~ /SERVICESTATE/){## SERVICESTATE
|
||||
my (@tab, $process, $nom, $etat);
|
||||
@tab = split (' - ',$_);
|
||||
foreach $process (@tab) {
|
||||
($nom,$etat) = split (': ', $process);
|
||||
if (defined($etat)) {
|
||||
$etat =~ s/\n//;
|
||||
} else {
|
||||
$etat = "Unknown";
|
||||
}
|
||||
if ($etat =~ /Started/)
|
||||
{$etat=1;}
|
||||
elsif ($etat =~ /Stopped/)
|
||||
{$etat=0;}
|
||||
elsif ($etat =~ /Unknown/)
|
||||
{$etat=-1;}
|
||||
else {
|
||||
print "Unable to get $nom status [$etat]: \n\t$_\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
$return =~ s/%/ pct/g;
|
||||
print $return;
|
||||
exit $return_code;
|
||||
} elsif ($op_v =~ /PROCSTATE/){## PROCSTATE
|
||||
print "PROCSTATE not graphed\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
} elsif (($op_v =~ /COUNTER/) && ($op_l =~ /(.+)/)) { ## COUNTER
|
||||
@output = split(/\|/,$_);
|
||||
@values = $output[0] =~ /([,\.\d]*)\s?\%/ ;
|
||||
if (!@values) {@values = $output[0] =~ /([\d]*)/;}
|
||||
$start=time;
|
||||
## Print Plugins Output
|
||||
$return =~ s/\n/ /g;
|
||||
$return =~ s/%/ pct/g;
|
||||
#print "---".$return ."---\n";
|
||||
print $return . "|counter=".@values."\n";
|
||||
exit $return_code;
|
||||
}
|
||||
} else {
|
||||
print "Could not parse arguments\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
##
|
||||
## Plugin return code
|
||||
##
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " Usage: check_graph_nt -H host -v variable [-p port] [-s password] [-w warning] [-c critical] [-l params] [-d SHOWALL] [-t timeout] [-D rrd directory] -g -S ServiceID\n";
|
||||
print " Options:\n";
|
||||
print " -H, --hostname=HOST\n";
|
||||
print " Name of the host to check\n";
|
||||
print " -p, --port=INTEGER\n";
|
||||
print " Optional port number (default: 1248)\n";
|
||||
print " -s <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";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
||||
#! /usr/bin/perl -w
|
||||
###################################################################
|
||||
# Oreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Mathavarajan Sugumaran
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# 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 centreon" ) {
|
||||
use centreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon perl module\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
use vars qw($PROGNAME);
|
||||
use Getopt::Long;
|
||||
use vars qw($opt_H $opt_p $opt_s $opt_v $opt_V $opt_h $opt_w $opt_c $opt_S $opt_g $opt_t $opt_l $opt_d $opt_D $opt_step $step $opt_f);
|
||||
|
||||
## Plugin var init
|
||||
|
||||
my $pathtolibexecnt = $centreon{GLOBAL}{NAGIOS_PLUGINS}."check_nt";
|
||||
my($op_v, $op_d, $op_s, $op_t, $op_l, $port, @values, @test, @test2, @test3, @test4, @test5, $warning, $critical, @w, @c, $uptime);
|
||||
my($warning2, $critical2, $warning3, $critical3, $warning4, $critical4, @output);
|
||||
$PROGNAME = $0;
|
||||
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"p=s" => \$opt_p, "port=s" => \$opt_p,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"s=s" => \$opt_s, "password=s" => \$opt_s,
|
||||
"d=s" => \$opt_d, "showall=s" => \$opt_d,
|
||||
"v=s" => \$opt_v, "variable=s" => \$opt_v,
|
||||
"D=s" => \$opt_D, "directory=s" => \$opt_D,
|
||||
"t=s" => \$opt_t, "timeout=s" => \$opt_t,
|
||||
"l:s" => \$opt_l, "parameter:s" => \$opt_l,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"S=s" => \$opt_S, "ServiceId=s" => \$opt_S,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_V) {
|
||||
$_ = `$pathtolibexecnt -V`;
|
||||
print "$_";
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_p) {
|
||||
if ($opt_p =~ /([0-9]+)/){
|
||||
$port = $1;
|
||||
} else {
|
||||
print "Unknown -p number expected... or it doesn't exist, try another port - number\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
|
||||
if ($opt_c) {
|
||||
($opt_c) || ($opt_c = shift);
|
||||
$critical = $1 if ($opt_c =~ /([0-9]+)/);
|
||||
}
|
||||
|
||||
if ($opt_w) {
|
||||
($opt_w) || ($opt_w = shift);
|
||||
$warning = $1 if ($opt_w =~ /([0-9]+)/);
|
||||
}
|
||||
|
||||
if (($critical && $warning) && ($critical <= $warning)) {
|
||||
print "(--crit) must be superior to (--warn)";
|
||||
print_usage();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_t) {
|
||||
($opt_t) || ($opt_t = shift);
|
||||
$op_t = $1 if ($opt_t =~ /([-\.,\w]+)/);
|
||||
}
|
||||
|
||||
if ($opt_l) {
|
||||
($opt_l) || ($opt_l = shift);
|
||||
$op_l = $1 if ($opt_l =~ /(.+)/);
|
||||
}
|
||||
|
||||
if ($opt_d) {
|
||||
($opt_d) || ($opt_d = shift);
|
||||
$op_d = $1 if ($opt_d =~ /([-.,A-Za-z0-9]+)/);
|
||||
}
|
||||
|
||||
if ($opt_s) {
|
||||
($opt_s) || ($opt_s = shift);
|
||||
$op_s = $1 if ($opt_s =~ /([\_\-\.\,A-Za-z0-9]+)/);
|
||||
}
|
||||
|
||||
if ($opt_v) {
|
||||
($opt_v) || ($opt_v = shift);
|
||||
$op_v = $1 if ($opt_v =~ /([-.,A-Za-z0-9]+)/);
|
||||
}
|
||||
|
||||
my $name = $0;
|
||||
$name =~ s/\.pl.*//g;
|
||||
my $return_code;
|
||||
|
||||
## Plugin requests
|
||||
my $start=time;
|
||||
if ($op_v) {
|
||||
if ($op_v) {$op_v = "-v ".$op_v;}
|
||||
if ($port) {$port = "-p ".$port;} else { $port = " ";}
|
||||
if ($warning) {$warning = "-w ".$warning;} else { $warning = " ";}
|
||||
if ($critical) {$critical = "-c ".$critical;} else { $critical = " ";}
|
||||
if ($op_l) {$op_l = "-l \"".$op_l ."\"";} else { $op_l = " ";}
|
||||
if ($op_t) {$op_t = "-t ".$op_t;} else { $op_t = " ";}
|
||||
if ($op_s) {$op_s = "-s ".$op_s;} else { $op_s = " ";}
|
||||
if ($op_d) {$op_d = "-d ".$op_d;} else { $op_d = " ";}
|
||||
# print "$pathtolibexecnt -H $opt_H $op_v $port $warning $critical $op_l $op_t $op_s $op_d\n";
|
||||
$_ = `$pathtolibexecnt -H $opt_H $op_v $port $warning $critical $op_l $op_t $op_s $op_d `;
|
||||
my $return = $_;
|
||||
if (!defined($return) || $return eq "") {
|
||||
print "Error in command, check your command options\n";
|
||||
exit (3);
|
||||
}
|
||||
$return =~ s/\\//g;
|
||||
$return_code = $? / 256;
|
||||
## CLIENTVERSION
|
||||
if ($op_v =~ /CLIENTVERSION/){
|
||||
print "CLIENTVERSION impossible to Graph!\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
if (($op_v =~ /CPULOAD/) && ($op_l =~ /([-\.,\w]+)/)){ ## CPULOAD
|
||||
@output = split(/\|/,$_);
|
||||
@values = $output[0] =~ /(\d*)\%/g ;
|
||||
$start = time;
|
||||
## Print Plugins Output
|
||||
$return =~ s/\n//g;
|
||||
my @return_data = split(/\|/,$return);
|
||||
if (@values){
|
||||
if (defined($opt_c) && defined($opt_w)){
|
||||
print $return_data[0] . "|cpu=@values%;$opt_w;$opt_c\n";
|
||||
} else {
|
||||
print $return_data[0] . "|cpu=@values%\n";
|
||||
}
|
||||
} else {
|
||||
print $return . "\n";
|
||||
}
|
||||
exit $return_code;
|
||||
} elsif ($op_v =~ /UPTIME/){ ## UPTIME
|
||||
if ($_ =~ /.*[-:]+\s(\d+)\s.*$/ ) {
|
||||
$uptime = $1;
|
||||
} else {
|
||||
print "unable to parse check_nt output: $_\n" ;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
$_ =~ s/\n/ /g;
|
||||
if (defined($uptime)){
|
||||
print $_ . "|uptime=".$uptime."d\n";
|
||||
} else {
|
||||
print $_ . "\n";
|
||||
}
|
||||
exit $return_code;
|
||||
} elsif (($op_v =~ /USEDDISKSPACE/) && ($op_l =~ /([-\.,\w]+)/)){ ## USEDDISKSPACE
|
||||
my @test = split(/ /,$_);
|
||||
if (defined($test[9]) && defined($test2[1])){
|
||||
@test2 = split(/\(/, $test[9]);
|
||||
@test3 = split(/\%/, $test2[1]);
|
||||
}
|
||||
@c = split(/ /, $critical);
|
||||
$critical = $c[1];
|
||||
@w = split(/ /, $warning);
|
||||
$warning = $w[1];
|
||||
## Print Plugins Output
|
||||
$return =~ s/\n/ /g;
|
||||
my @return_part = split(/\|/, $return);
|
||||
#$return =~ s/%/ pct/g;
|
||||
## Put value in octets : Mo -> o
|
||||
if (defined($test[3]) && defined($test[7]) && defined($test[12])){
|
||||
$test[3] =~ s/\,/\./g;
|
||||
$test[3] = eval($test[3] * 1024 * 1024 * 1024);
|
||||
$test[7] =~ s/\,/\./g;
|
||||
$test[7] = eval ($test[7] * 1024 * 1024 * 1024);
|
||||
print $return_part[0] . "|total=".$test[3]."o used=".$test[7]."o\n";
|
||||
} else {
|
||||
print $return_part[0] . "\n";
|
||||
}
|
||||
exit $return_code;
|
||||
} elsif ($op_v =~ /MEMUSE/){ ## MEMUSE
|
||||
$start = time;
|
||||
my @test = split(/ /,$_);
|
||||
if (defined($test[2])){
|
||||
@test4 = split(/:/, $test[2]);
|
||||
}
|
||||
@c = split(/ /, $critical);
|
||||
$critical = $c[1];
|
||||
@w = split(/ /, $warning);
|
||||
$warning = $w[1];
|
||||
## Print Plugins Output
|
||||
my @return_data = split(/\|/,$return);
|
||||
$return =~ s/\n/ /g;
|
||||
#$return =~ s/%/ pct/g;
|
||||
if ($test4[1] && $test[6] && $test[11]){
|
||||
## Put value in octets : Mo -> o
|
||||
$test4[1] =~ s/\,/\./g;
|
||||
$test4[1] = eval($test4[1] * 1024 * 1024);
|
||||
$test[6] =~ s/\,/\./g;
|
||||
$test[6] = eval($test[6] * 1024 * 1024);
|
||||
print $return_data[0] . "|total=".$test4[1]."o used=".$test[6]."o\n";
|
||||
} else {
|
||||
print $return_data[0] . "\n";
|
||||
}
|
||||
exit $return_code;
|
||||
} elsif ($op_v =~ /SERVICESTATE/){## SERVICESTATE
|
||||
my (@tab, $process, $nom, $etat);
|
||||
@tab = split (' - ',$_);
|
||||
foreach $process (@tab) {
|
||||
($nom,$etat) = split (': ', $process);
|
||||
if (defined($etat)) {
|
||||
$etat =~ s/\n//;
|
||||
} else {
|
||||
$etat = "Unknown";
|
||||
}
|
||||
if ($etat =~ /Started/)
|
||||
{$etat=1;}
|
||||
elsif ($etat =~ /Stopped/)
|
||||
{$etat=0;}
|
||||
elsif ($etat =~ /Unknown/)
|
||||
{$etat=-1;}
|
||||
else {
|
||||
print "Unable to get $nom status [$etat]: \n\t$_\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
}
|
||||
$return =~ s/%/ pct/g;
|
||||
print $return;
|
||||
exit $return_code;
|
||||
} elsif ($op_v =~ /PROCSTATE/){## PROCSTATE
|
||||
print "PROCSTATE not graphed\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
} elsif (($op_v =~ /COUNTER/) && ($op_l =~ /(.+)/)) { ## COUNTER
|
||||
@output = split(/\|/,$_);
|
||||
@values = $output[0] =~ /([,\.\d]*)\s?\%/ ;
|
||||
if (!@values) {@values = $output[0] =~ /([\d]*)/;}
|
||||
$start=time;
|
||||
## Print Plugins Output
|
||||
$return =~ s/\n/ /g;
|
||||
$return =~ s/%/ pct/g;
|
||||
#print "---".$return ."---\n";
|
||||
print $return . "|counter=".@values."\n";
|
||||
exit $return_code;
|
||||
}
|
||||
} else {
|
||||
print "Could not parse arguments\n";
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
|
||||
##
|
||||
## Plugin return code
|
||||
##
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " Usage: check_graph_nt -H host -v variable [-p port] [-s password] [-w warning] [-c critical] [-l params] [-d SHOWALL] [-t timeout] [-D rrd directory] -g -S ServiceID\n";
|
||||
print " Options:\n";
|
||||
print " -H, --hostname=HOST\n";
|
||||
print " Name of the host to check\n";
|
||||
print " -p, --port=INTEGER\n";
|
||||
print " Optional port number (default: 1248)\n";
|
||||
print " -s <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";
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##############################################\n";
|
||||
print "# Copyright (c) 2004-2007 Centreon #\n";
|
||||
print "# Bugs to http://bugs.oreon-project.org/ #\n";
|
||||
print "##############################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
||||
|
|
|
@ -1,177 +1,177 @@
|
|||
#! /usr/bin/perl
|
||||
|
||||
#
|
||||
# $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 "/usr/local/nagios/libexec";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon 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);
|
||||
|
||||
# Plugin var init
|
||||
|
||||
my ($hrStorageDescr, $hrStorageAllocationUnits, $hrStorageSize, $hrStorageUsed);
|
||||
my ($AllocationUnits, $Size, $Used);
|
||||
my ($tot, $used, $pourcent, $return_code);
|
||||
|
||||
$PROGNAME = $0;
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v,
|
||||
"s" => \$opt_s, "show" => \$opt_s,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"n=s" => \$opt_n, "name=s" => \$opt_n,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
($opt_v) || ($opt_v = shift) || ($opt_v = "2");
|
||||
my $snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
($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'};
|
||||
}
|
||||
|
||||
# Plugin snmp requests
|
||||
|
||||
my $OID_ExecResult = ".1.3.6.1.4.1.2021.8.1.100";
|
||||
my $OID_ExecDescr = ".1.3.6.1.4.1.2021.8.1.2";
|
||||
my $OID_ExecOutput = ".1.3.6.1.4.1.2021.8.1.101";
|
||||
|
||||
# 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'};
|
||||
}
|
||||
|
||||
my $scriptname = "";
|
||||
|
||||
# getting partition using its name instead of its oid index
|
||||
|
||||
if ($opt_n) {
|
||||
my $result = $session->get_table(Baseoid => $OID_ExecDescr);
|
||||
if (!defined($result)) {
|
||||
printf("ERROR: hr Exec Descr Table : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
foreach my $key ( oid_lex_sort(keys %$result)) {
|
||||
if ($result->{$key} =~ m/^$opt_n$/) {
|
||||
my @oid_list = split (/\./,$key);
|
||||
$scriptname = pop (@oid_list) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($scriptname eq "") {
|
||||
print "No such process, verify your snmpd configuration\n";
|
||||
exit(3);
|
||||
}
|
||||
|
||||
my $result = $session->get_request(-varbindlist => [$OID_ExecDescr.".".$scriptname, $OID_ExecOutput.".".$scriptname]);
|
||||
|
||||
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'};
|
||||
}
|
||||
|
||||
my $ExecResult = $result->{$OID_ExecResult.".".$scriptname };
|
||||
my $ExecDescr = $result->{$OID_ExecDescr.".".$scriptname };
|
||||
my $ExecOutput = $result->{$OID_ExecOutput.".".$scriptname };
|
||||
if ($ExecOutput =~ /cannot\ open/) {
|
||||
$ExecResult = 3;
|
||||
}
|
||||
print $ExecOutput . "\n";
|
||||
exit($ExecResult);
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public,\n";
|
||||
print " used with SNMP v1 and v2c\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -n (--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 " -w (--warn) Signal strength at which a warning message will be generated\n";
|
||||
print " (default 80)\n";
|
||||
print " -c (--crit) Signal strength at which a critical message will be generated\n";
|
||||
print " (default 95)\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##########################################\n";
|
||||
print "# Copyright (c) 2004-2006 centreon #\n";
|
||||
print "# Bugs to http://www.oreon-project.org/ #\n";
|
||||
print "##########################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
||||
#! /usr/bin/perl
|
||||
|
||||
#
|
||||
# $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 "/usr/local/nagios/libexec";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon 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);
|
||||
|
||||
# Plugin var init
|
||||
|
||||
my ($hrStorageDescr, $hrStorageAllocationUnits, $hrStorageSize, $hrStorageUsed);
|
||||
my ($AllocationUnits, $Size, $Used);
|
||||
my ($tot, $used, $pourcent, $return_code);
|
||||
|
||||
$PROGNAME = $0;
|
||||
sub print_help ();
|
||||
sub print_usage ();
|
||||
Getopt::Long::Configure('bundling');
|
||||
GetOptions
|
||||
("h" => \$opt_h, "help" => \$opt_h,
|
||||
"V" => \$opt_V, "version" => \$opt_V,
|
||||
"v=s" => \$opt_v,
|
||||
"s" => \$opt_s, "show" => \$opt_s,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"n=s" => \$opt_n, "name=s" => \$opt_n,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
($opt_v) || ($opt_v = shift) || ($opt_v = "2");
|
||||
my $snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
($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'};
|
||||
}
|
||||
|
||||
# Plugin snmp requests
|
||||
|
||||
my $OID_ExecResult = ".1.3.6.1.4.1.2021.8.1.100";
|
||||
my $OID_ExecDescr = ".1.3.6.1.4.1.2021.8.1.2";
|
||||
my $OID_ExecOutput = ".1.3.6.1.4.1.2021.8.1.101";
|
||||
|
||||
# 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'};
|
||||
}
|
||||
|
||||
my $scriptname = "";
|
||||
|
||||
# getting partition using its name instead of its oid index
|
||||
|
||||
if ($opt_n) {
|
||||
my $result = $session->get_table(Baseoid => $OID_ExecDescr);
|
||||
if (!defined($result)) {
|
||||
printf("ERROR: hr Exec Descr Table : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
foreach my $key ( oid_lex_sort(keys %$result)) {
|
||||
if ($result->{$key} =~ m/^$opt_n$/) {
|
||||
my @oid_list = split (/\./,$key);
|
||||
$scriptname = pop (@oid_list) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($scriptname eq "") {
|
||||
print "No such process, verify your snmpd configuration\n";
|
||||
exit(3);
|
||||
}
|
||||
|
||||
my $result = $session->get_request(-varbindlist => [$OID_ExecDescr.".".$scriptname, $OID_ExecOutput.".".$scriptname]);
|
||||
|
||||
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'};
|
||||
}
|
||||
|
||||
my $ExecResult = $result->{$OID_ExecResult.".".$scriptname };
|
||||
my $ExecDescr = $result->{$OID_ExecDescr.".".$scriptname };
|
||||
my $ExecOutput = $result->{$OID_ExecOutput.".".$scriptname };
|
||||
if ($ExecOutput =~ /cannot\ open/) {
|
||||
$ExecResult = 3;
|
||||
}
|
||||
print $ExecOutput . "\n";
|
||||
exit($ExecResult);
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public,\n";
|
||||
print " used with SNMP v1 and v2c\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -n (--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 " -w (--warn) Signal strength at which a warning message will be generated\n";
|
||||
print " (default 80)\n";
|
||||
print " -c (--crit) Signal strength at which a critical message will be generated\n";
|
||||
print " (default 95)\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##########################################\n";
|
||||
print "# Copyright (c) 2004-2006 centreon #\n";
|
||||
print "# Bugs to http://www.oreon-project.org/ #\n";
|
||||
print "##########################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
||||
|
|
|
@ -1,196 +1,196 @@
|
|||
#! /usr/bin/perl
|
||||
|
||||
#
|
||||
# $Id: check_graph_remote_storage.pl,v 1.2 2005/07/27 22:21:49 wistof Exp $
|
||||
#
|
||||
# centreon'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 centreon Project by : Mathieu Chateau - Christophe Coraboeuf
|
||||
#
|
||||
# The Software is provided to you AS IS and WITH ALL FAULTS.
|
||||
# centreon 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 centreon web site.
|
||||
# In no event will centreon be liable for any direct, indirect, punitive, special,
|
||||
# incidental or consequential damages however they may arise and even if centreon 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 "/usr/local/nagios/libexec";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon 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);
|
||||
|
||||
# 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,
|
||||
"v=s" => \$opt_v,
|
||||
"s" => \$opt_s, "show" => \$opt_s,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"n=s" => \$opt_n, "name=s" => \$opt_n,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
($opt_v) || ($opt_v = shift) || ($opt_v = "2");
|
||||
my $snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
($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'};
|
||||
}
|
||||
|
||||
# Plugin snmp requests
|
||||
|
||||
my $OID_ExecDescr = ".1.3.6.1.4.1.2021.8.1.2";
|
||||
my $OID_ExecOutput = ".1.3.6.1.4.1.2021.8.1.101";
|
||||
|
||||
# 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'};
|
||||
}
|
||||
|
||||
my $scriptname = "";
|
||||
|
||||
# getting partition using its name instead of its oid index
|
||||
|
||||
if ($opt_n) {
|
||||
my $result = $session->get_table(Baseoid => $OID_ExecDescr);
|
||||
if (!defined($result)) {
|
||||
printf("ERROR: hr Exec Descr Table : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
foreach my $key ( oid_lex_sort(keys %$result)) {
|
||||
if ($result->{$key} =~ m/$opt_n/) {
|
||||
my @oid_list = split (/\./,$key);
|
||||
$scriptname = pop (@oid_list) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my $result = $session->get_request(-varbindlist => [$OID_ExecDescr.".".$scriptname, $OID_ExecOutput.".".$scriptname]);
|
||||
|
||||
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'};
|
||||
}
|
||||
|
||||
my $ExecDescr = $result->{$OID_ExecDescr.".".$scriptname };
|
||||
my $ExecOutput = $result->{$OID_ExecOutput.".".$scriptname };
|
||||
|
||||
print "|" . $ExecOutput . "\n";
|
||||
|
||||
my $return = 5;
|
||||
|
||||
if (!defined($opt_w) && !defined($opt_c)){
|
||||
$ExecOutput =~ /([0-9]*)/;
|
||||
if ($1 eq 1){
|
||||
print "OK : Process runnable \n";
|
||||
$return = 0;
|
||||
} else {
|
||||
print "CRITICAL : Process runnable \n";
|
||||
$return = 2;
|
||||
}
|
||||
} else {
|
||||
if ($ExecOutput =~ /([0-9]*)/){
|
||||
if ($1 >= $opt_w && $1 < $opt_c){
|
||||
print "OK : $1 Process runnable \n";
|
||||
$return = 1;
|
||||
} elsif ($1 > $opt_c) {
|
||||
print "WARNING : $1 Process runnable \n";
|
||||
$return = 2;
|
||||
} elsif ($1 < $opt_w) {
|
||||
print "CRITICAL : Process runnable \n";
|
||||
$return = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
exit($return);
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public,\n";
|
||||
print " used with SNMP v1 and v2c\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -n (--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 " -w (--warn) Signal strength at which a warning message will be generated\n";
|
||||
print " (default 80)\n";
|
||||
print " -c (--crit) Signal strength at which a critical message will be generated\n";
|
||||
print " (default 95)\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##########################################\n";
|
||||
print "# Copyright (c) 2004-2006 centreon #\n";
|
||||
print "# Bugs to http://www.oreon-project.org/ #\n";
|
||||
print "##########################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
||||
#! /usr/bin/perl
|
||||
|
||||
#
|
||||
# $Id: check_graph_remote_storage.pl,v 1.2 2005/07/27 22:21:49 wistof Exp $
|
||||
#
|
||||
# centreon'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 centreon Project by : Mathieu Chateau - Christophe Coraboeuf
|
||||
#
|
||||
# The Software is provided to you AS IS and WITH ALL FAULTS.
|
||||
# centreon 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 centreon web site.
|
||||
# In no event will centreon be liable for any direct, indirect, punitive, special,
|
||||
# incidental or consequential damages however they may arise and even if centreon 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 "/usr/local/nagios/libexec";
|
||||
use utils qw($TIMEOUT %ERRORS &print_revision &support);
|
||||
|
||||
if (eval "require centreon" ) {
|
||||
use centreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
|
||||
use vars qw($VERSION %centreon);
|
||||
%centreon=get_parameters();
|
||||
} else {
|
||||
print "Unable to load centreon 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);
|
||||
|
||||
# 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,
|
||||
"v=s" => \$opt_v,
|
||||
"s" => \$opt_s, "show" => \$opt_s,
|
||||
"C=s" => \$opt_C, "community=s" => \$opt_C,
|
||||
"n=s" => \$opt_n, "name=s" => \$opt_n,
|
||||
"w=s" => \$opt_w, "warning=s" => \$opt_w,
|
||||
"c=s" => \$opt_c, "critical=s" => \$opt_c,
|
||||
"H=s" => \$opt_H, "hostname=s" => \$opt_H);
|
||||
|
||||
|
||||
if ($opt_V) {
|
||||
print_revision($PROGNAME,'$Revision: 1.2 $');
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
if ($opt_h) {
|
||||
print_help();
|
||||
exit $ERRORS{'OK'};
|
||||
}
|
||||
|
||||
$opt_H = shift unless ($opt_H);
|
||||
(print_usage() && exit $ERRORS{'OK'}) unless ($opt_H);
|
||||
|
||||
($opt_v) || ($opt_v = shift) || ($opt_v = "2");
|
||||
my $snmp = $1 if ($opt_v =~ /(\d)/);
|
||||
|
||||
($opt_C) || ($opt_C = shift) || ($opt_C = "public");
|
||||
|
||||
($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'};
|
||||
}
|
||||
|
||||
# Plugin snmp requests
|
||||
|
||||
my $OID_ExecDescr = ".1.3.6.1.4.1.2021.8.1.2";
|
||||
my $OID_ExecOutput = ".1.3.6.1.4.1.2021.8.1.101";
|
||||
|
||||
# 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'};
|
||||
}
|
||||
|
||||
my $scriptname = "";
|
||||
|
||||
# getting partition using its name instead of its oid index
|
||||
|
||||
if ($opt_n) {
|
||||
my $result = $session->get_table(Baseoid => $OID_ExecDescr);
|
||||
if (!defined($result)) {
|
||||
printf("ERROR: hr Exec Descr Table : %s.\n", $session->error);
|
||||
$session->close;
|
||||
exit $ERRORS{'UNKNOWN'};
|
||||
}
|
||||
foreach my $key ( oid_lex_sort(keys %$result)) {
|
||||
if ($result->{$key} =~ m/$opt_n/) {
|
||||
my @oid_list = split (/\./,$key);
|
||||
$scriptname = pop (@oid_list) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my $result = $session->get_request(-varbindlist => [$OID_ExecDescr.".".$scriptname, $OID_ExecOutput.".".$scriptname]);
|
||||
|
||||
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'};
|
||||
}
|
||||
|
||||
my $ExecDescr = $result->{$OID_ExecDescr.".".$scriptname };
|
||||
my $ExecOutput = $result->{$OID_ExecOutput.".".$scriptname };
|
||||
|
||||
print "|" . $ExecOutput . "\n";
|
||||
|
||||
my $return = 5;
|
||||
|
||||
if (!defined($opt_w) && !defined($opt_c)){
|
||||
$ExecOutput =~ /([0-9]*)/;
|
||||
if ($1 eq 1){
|
||||
print "OK : Process runnable \n";
|
||||
$return = 0;
|
||||
} else {
|
||||
print "CRITICAL : Process runnable \n";
|
||||
$return = 2;
|
||||
}
|
||||
} else {
|
||||
if ($ExecOutput =~ /([0-9]*)/){
|
||||
if ($1 >= $opt_w && $1 < $opt_c){
|
||||
print "OK : $1 Process runnable \n";
|
||||
$return = 1;
|
||||
} elsif ($1 > $opt_c) {
|
||||
print "WARNING : $1 Process runnable \n";
|
||||
$return = 2;
|
||||
} elsif ($1 < $opt_w) {
|
||||
print "CRITICAL : Process runnable \n";
|
||||
$return = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
exit($return);
|
||||
|
||||
sub print_usage () {
|
||||
print "\nUsage:\n";
|
||||
print "$PROGNAME\n";
|
||||
print " -H (--hostname) Hostname to query - (required)\n";
|
||||
print " -C (--community) SNMP read community (defaults to public,\n";
|
||||
print " used with SNMP v1 and v2c\n";
|
||||
print " -v (--snmp_version) 1 for SNMP v1 (default)\n";
|
||||
print " 2 for SNMP v2c\n";
|
||||
print " -n (--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 " -w (--warn) Signal strength at which a warning message will be generated\n";
|
||||
print " (default 80)\n";
|
||||
print " -c (--crit) Signal strength at which a critical message will be generated\n";
|
||||
print " (default 95)\n";
|
||||
print " -V (--version) Plugin version\n";
|
||||
print " -h (--help) usage help\n";
|
||||
|
||||
}
|
||||
|
||||
sub print_help () {
|
||||
print "##########################################\n";
|
||||
print "# Copyright (c) 2004-2006 centreon #\n";
|
||||
print "# Bugs to http://www.oreon-project.org/ #\n";
|
||||
print "##########################################\n";
|
||||
print_usage();
|
||||
print "\n";
|
||||
}
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
#! /bin/sh
|
||||
###################################################################
|
||||
# Centreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Christophe Coraboeuf - Sugumaran Mathavarajan
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
# some parameters passed on command line
|
||||
TIMET=$1
|
||||
HOSTNAME=$2
|
||||
SERVICEDESC=$3
|
||||
OUTPUT=$4
|
||||
SERVICESTATE=$5
|
||||
PERFDATA=$6
|
||||
PERFFILE="@NAGIOS_VAR@/service-perfdata"
|
||||
|
||||
/usr/bin/printf "%b" "$TIMET\t$HOSTNAME\t$SERVICEDESC\t$OUTPUT\t$SERVICESTATE\t$PERFDATA\n" >> $PERFFILE
|
||||
#! /bin/sh
|
||||
###################################################################
|
||||
# Centreon is developped with GPL Licence 2.0
|
||||
#
|
||||
# GPL License: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
#
|
||||
# Developped by : Julien Mathis - Romain Le Merlus
|
||||
# Christophe Coraboeuf - Sugumaran Mathavarajan
|
||||
#
|
||||
###################################################################
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# For information : contact@merethis.com
|
||||
####################################################################
|
||||
#
|
||||
# Script init
|
||||
#
|
||||
|
||||
# some parameters passed on command line
|
||||
TIMET=$1
|
||||
HOSTNAME=$2
|
||||
SERVICEDESC=$3
|
||||
OUTPUT=$4
|
||||
SERVICESTATE=$5
|
||||
PERFDATA=$6
|
||||
PERFFILE="@NAGIOS_VAR@/service-perfdata"
|
||||
|
||||
/usr/bin/printf "%b" "$TIMET\t$HOSTNAME\t$SERVICEDESC\t$OUTPUT\t$SERVICESTATE\t$PERFDATA\n" >> $PERFFILE
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
mibs ALL
|
||||
mibAllowUnderline 1
|
||||
mibs ALL
|
||||
mibAllowUnderline 1
|
||||
|
|
|
@ -1,488 +1,488 @@
|
|||
#
|
||||
# SNMPTT v1.0 Configuration File
|
||||
#
|
||||
# Linux / Unix
|
||||
#
|
||||
|
||||
[General]
|
||||
# Set to either 'standalone' or 'daemon'
|
||||
# standalone: snmptt called from snmptrapd.conf
|
||||
# daemon: snmptrapd.conf calls snmptthandler
|
||||
# Ignored by Windows. See documentation
|
||||
mode = standalone
|
||||
|
||||
# Set to 1 to allow multiple trap definitions to be executed for the same trap.
|
||||
# Set to 0 to have it stop after the first match.
|
||||
# Note: Wildcard matches are only matched if there are NO exact matches. This takes
|
||||
# into consideration the NODES list. Therefore, if there is a matching trap, but
|
||||
# the NODES list prevents it from being considered a match, the wildcard entry will
|
||||
# only be used if there are no other exact matches.
|
||||
multiple_event = 1
|
||||
|
||||
# SNMPTRAPD passes the IP address of device sending the trap, and the IP address of the
|
||||
# actual SNMP agent. These addresses could differ if the trap was sent on behalf of another
|
||||
# device (relay, proxy etc).
|
||||
# If DNS is enabled, the agent IP address is converted to a host name using a DNS lookup
|
||||
# (which includes the local hosts file, depending on how the OS is configured). This name
|
||||
# will be used for: NODES entry matches, hostname field in logged traps (file / database),
|
||||
# and the $A variable. Host names on the NODES line will be resolved and the IP address
|
||||
# will then be used for comparing.
|
||||
# Set to 0 to disable DNS resolution
|
||||
# Set to 1 to enable DNS resolution
|
||||
dns_enable = 0
|
||||
|
||||
# Set to 0 to enable the use of FQDN (Fully Qualified Domain Names). If a host name is
|
||||
# passed to SNMPTT that contains a domain name, it will not be altered in any way by
|
||||
# SNMPTT. This also affects resolve_value_ip_addresses.
|
||||
# Set to 1 to have SNMPTT strip the domain name from the host name passed to it. For
|
||||
# example, server01.domain.com would be changed to server01
|
||||
# Set to 2 to have SNMPTT strip the domain name from the host name passed to it
|
||||
# based on the list of domains in strip_domain_list
|
||||
strip_domain = 0
|
||||
|
||||
# List of domain names that should be stripped when strip_domain is set to 2.
|
||||
# List can contain one or more domains. For example, if the FQDN of a host is
|
||||
# server01.city.domain.com and the list contains domain.com, the 'host' will be
|
||||
# set as server01.city.
|
||||
strip_domain_list = <<END
|
||||
merethis.net
|
||||
END
|
||||
|
||||
# Configures how IP addresses contained in the VALUE of the variable bindings are handled.
|
||||
# This only applies to the values for $n, $+n, $-n, $vn, $+*, $-*.
|
||||
# Set to 0 to disable resolving ip address to host names
|
||||
# Set to 1 to enable resolving ip address to host names
|
||||
# Note: net_snmp_perl_enable *must* be enabled. The strip_domain settings influence the
|
||||
# format of the resolved host name. DNS must be enabled (dns_enable)
|
||||
resolve_value_ip_addresses = 0
|
||||
|
||||
# Set to 1 to enable the use of the Perl module from the UCD-SNMP / NET-SNMP package.
|
||||
# This is required for $v variable substitution to work, and also for some other options
|
||||
# that are enabled in this .ini file.
|
||||
# Set to 0 to disable the use of the Perl module from the UCD-SNMP / NET-SNMP package.
|
||||
# Note: Enabling this with stand-alone mode can cause SNMPTT to run very slowly due to
|
||||
# the loading of the MIBS at startup.
|
||||
net_snmp_perl_enable = 1
|
||||
|
||||
# This sets the best_guess parameter used by the UCD-SNMP / NET-SNMP Perl module for
|
||||
# translating symbolic nams to OIDs and vice versa.
|
||||
# For UCD-SNMP, and Net-SNMP 5.0.8 and previous versions, set this value to 0.
|
||||
# For Net-SNMP 5.0.9, or any Net-SNMP with patch 722075 applied, set this value to 2.
|
||||
# A value of 2 is equivalent to -IR on Net-SNMP command line utilities.
|
||||
# UCD-SNMP and Net-SNMP 5.0.8 and previous may not be able to translate certain formats of
|
||||
# symbolic names such as RFC1213-MIB::sysDescr. Net-SNMP 5.0.9 or patch 722075 will allow
|
||||
# all possibilities to be translated. See the FAQ section in the README for more info
|
||||
net_snmp_perl_best_guess = 0
|
||||
|
||||
# Configures how the OID of the received trap is handled when outputting to a log file /
|
||||
# database. It does NOT apply to the $O variable.
|
||||
# Set to 0 to use the default of numerical OID
|
||||
# Set to 1 to translate the trap OID to short text (symbolic form) (eg: linkUp)
|
||||
# Set to 2 to translate the trap OID to short text with module name (eg: IF-MIB::linkUp)
|
||||
# Set to 3 to translate the trap OID to long text (eg: iso...snmpTraps.linkUp)
|
||||
# Set to 4 to translate the trap OID to long text with module name (eg:
|
||||
# IF-MIB::iso...snmpTraps.linkUp)
|
||||
# Note: -The output of the long format will vary depending on the version of Net-SNMP you
|
||||
# are using.
|
||||
# -net_snmp_perl_enable *must* be enabled
|
||||
# -If using database logging, ensure the trapoid column is large enough to hold the
|
||||
# entire line
|
||||
translate_log_trap_oid = 0
|
||||
|
||||
# Configures how OIDs contained in the VALUE of the variable bindings are handled.
|
||||
# This only applies to the values for $n, $+n, $-n, $vn, $+*, $-*. For substitutions
|
||||
# that include variable NAMES ($+n etc), only the variable VALUE is affected.
|
||||
# Set to 0 to disable translating OID values to text (symbolic form)
|
||||
# Set to 1 to translate OID values to short text (symbolic form) (eg: BuildingAlarm)
|
||||
# Set to 2 to translate OID values to short text with module name (eg: UPS-MIB::BuildingAlarm)
|
||||
# Set to 3 to translate OID values to long text (eg: iso...upsAlarm.BuildingAlarm)
|
||||
# Set to 4 to translate OID values to long text with module name (eg:
|
||||
# UPS-MIB::iso...upsAlarm.BuildingAlarm)
|
||||
# For example, if the value contained: 'A UPS Alarm (.1.3.6.1.4.1.534.1.7.12) has cleared.',
|
||||
# it could be translated to: 'A UPS Alarm (UPS-MIB::BuildingAlarm) has cleared.'
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
translate_value_oids = 1
|
||||
|
||||
# Configures how the symbolic enterprise OID will be displayed for $E.
|
||||
# Set to 1, 2, 3 or 4. See translate_value_oids options 1,2,3 and 4.
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
translate_enterprise_oid_format = 1
|
||||
|
||||
# Configures how the symbolic trap OID will be displayed for $O.
|
||||
# Set to 1, 2, 3 or 4. See translate_value_oids options 1,2,3 and 4.
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
translate_trap_oid_format = 1
|
||||
|
||||
# Configures how the symbolic trap OID will be displayed for $v, $-n, $+n, $-* and $+*.
|
||||
# Set to 1, 2, 3 or 4. See translate_value_oids options 1,2,3 and 4.
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
translate_varname_oid_format = 1
|
||||
|
||||
# Set to 0 to disable converting INTEGER values to enumeration tags as defined in the
|
||||
# MIB files
|
||||
# Set to 1 to enable converting INTEGER values to enumeration tags as defined in the
|
||||
# MIB files
|
||||
# Example: moverDoorState:open instead of moverDoorState:2
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
translate_integers = 1
|
||||
|
||||
# Allows you to set the MIBS environment variable used by SNMPTT
|
||||
# Leave blank or comment out to have the systems enviroment settings used
|
||||
# To have all MIBS processed, set to ALL
|
||||
# See the snmp.conf manual page for more info
|
||||
#mibs_environment = ALL
|
||||
|
||||
# Set what is used to separate variables when wildcards are expanded on the FORMAT /
|
||||
# EXEC line. Defaults to a space. Value MUST be within quotes. Can contain 1 or
|
||||
# more characters
|
||||
wildcard_expansion_separator = " "
|
||||
|
||||
# Set to 1 to allow unsafe REGEX code to be executed.
|
||||
# Set to 0 to prevent unsafe REGEX code from being executed (default).
|
||||
# Enabling unsafe REGEX code will allow variable interopolation and the use of the e
|
||||
# modifier to allow statements such as substitution with captures such
|
||||
# as: (one (two) three)(five $1 six)
|
||||
# which outputs: five two six
|
||||
# or: (one (two) three)("five ".length($1)." six")e
|
||||
# which outputs: five 3 six
|
||||
#
|
||||
# This is considered unsafe because the contents of the regular expression
|
||||
# (right) is executed (eval) by Perl which *could contain unsafe code*.
|
||||
# BE SURE THAT THE SNMPTT CONFIGURATION FILES ARE SECURE!
|
||||
allow_unsafe_regex = 0
|
||||
|
||||
# Set to 1 to have the backslash (escape) removed from quotes passed from
|
||||
# snmptrapd. For example, \" would be changed to just "
|
||||
# Set to 0 to disable
|
||||
remove_backslash_from_quotes = 0
|
||||
|
||||
# Set to 1 to have NODES files loaded each time a trap is processed.
|
||||
# Set to 0 to have all NODES files loaded when the snmptt.conf files are loaded.
|
||||
# If NODES files are used (files that contain lists of NODES), then setting to 1
|
||||
# will cause the list to be loaded each time an EVENT is processed that uses
|
||||
# NODES files. This will allow the NODES file to be modified while SNMPTT is
|
||||
# running but can result in many file reads depending on the number of traps
|
||||
# received. Defaults to 0
|
||||
dynamic_nodes = 0
|
||||
|
||||
# This option allows you to use the $D substitution variable to include the
|
||||
# description text from the SNMPTT.CONF or MIB files.
|
||||
# Set to 0 to disable the $D substitution variable. If $D is used, nothing
|
||||
# will be outputted.
|
||||
# Set to 1 to enable the $D substitution variable and have it use the
|
||||
# descriptions stored in the SNMPTT .conf files. Enabling this option can
|
||||
# greatly increase the amount of memory used by SNMPTT.
|
||||
# Set to 2 to enable the $D substitution variable and have it use the
|
||||
# description from the MIB files. This enables the UCD-SNMP / NET-SNMP Perl
|
||||
# module save_descriptions variable. Enabling this option can greatly
|
||||
# increase the amount of memory used by the Net-SNMP SNMP Perl module, which
|
||||
# will result in an increase of memory usage by SNMPTT.
|
||||
description_mode = 0
|
||||
|
||||
# Set to 1 to remove any white space at the start of each line from the MIB
|
||||
# or SNMPTT.CONF description when description_mode is set to 1 or 2.
|
||||
description_clean = 1
|
||||
|
||||
[DaemonMode]
|
||||
# Set to 1 to have snmptt fork to the background when run in daemon mode
|
||||
# Ignored by Windows. See documentation
|
||||
daemon_fork = 1
|
||||
|
||||
# Set to the numerical user id (eg: 500) or textual user id (eg: snmptt)
|
||||
# that snmptt should change to when running in daemon mode. Leave blank
|
||||
# to disable. The user used should have read/write access to all log
|
||||
# files, the spool folder, and read access to the configuration files.
|
||||
daemon_uid = root
|
||||
|
||||
# Directory to read received traps from. Ex: /var/spool/snmptt/
|
||||
# Don't forget the trailing slash!
|
||||
spool_directory = /var/spool/snmptt/
|
||||
|
||||
# Amount of time in seconds to sleep between processing spool files
|
||||
sleep = 2
|
||||
|
||||
# Set to 1 to have SNMPTT use the time that the trap was processed by SNMPTTHANDLER
|
||||
# Set to 0 to have SNMPTT use the time the trap was processed. Note: Using 0 can
|
||||
# result in the time being off by the number of seconds used for 'sleep'
|
||||
use_trap_time = 1
|
||||
|
||||
# Set to 0 to have SNMPTT erase the spooled trap file after it attempts to process
|
||||
# the trap even if it did not successfully log the trap to any of the log systems.
|
||||
# Set to 1 to have SNMPTT erase the spooled trap file only after it successfully
|
||||
# logs to at least ONE log system.
|
||||
# Set to 2 to have SNMPTT erase the spooled trap file only after it successfully
|
||||
# logs to ALL of the enabled log systems. Warning: If multiple log systems are
|
||||
# enabled and only one fails, the other log system will continuously be logged to
|
||||
# until ALL of the log systems function.
|
||||
# The recommended setting is 1 with only one log system enabled.
|
||||
keep_unlogged_traps = 1
|
||||
|
||||
[Logging]
|
||||
# Set to 1 to enable messages to be sent to standard output, or 0 to disable.
|
||||
# Would normally be disabled unless you are piping this program to another
|
||||
stdout_enable = 0
|
||||
|
||||
# Set to 1 to enable text logging. Make sure you specify a logfile location
|
||||
log_enable = 1
|
||||
|
||||
# Log file location. The COMPLETE path and filename. Ex: '/var/log/snmptt.log'
|
||||
log_file = /var/log/snmptt.log
|
||||
|
||||
# Set to 1 to enable logging of unknown traps. This should normally be left off
|
||||
# as the file could grow large quickly. Used primarily for troubleshooting. If
|
||||
# you have defined a trap in snmptt.conf, but it is not executing, enable this to
|
||||
# see if it is being considered an unknown trap due to an incorrect entry or
|
||||
# simply missing from the snmptt.conf file.
|
||||
# Unknown traps can be logged either a text file, a SQL table or both.
|
||||
# See SQL section to define SQL table to log unknown traps to.
|
||||
unknown_trap_log_enable = 1
|
||||
|
||||
# Unknown trap log file location. The COMPLETE path and filename.
|
||||
# Ex: '/var/log/snmpttunknown.log'
|
||||
# Leave blank to disable logging to text file if logging to SQL is enabled
|
||||
# for unknown traps
|
||||
unknown_trap_log_file = /var/log/snmpttunknown.log
|
||||
|
||||
# How often in seconds statistics should be logged to syslog or the event log.
|
||||
# Set to 0 to disable
|
||||
# 1 hour = 216000
|
||||
# 12 hours = 2592000
|
||||
# 24 hours = 5184000
|
||||
statistics_interval = 0
|
||||
|
||||
# Set to 1 to enable logging of *TRAPS* to syslog. If you do not have the Sys::Syslog
|
||||
# module then disable this. Windows users should disable this.
|
||||
syslog_enable = 0
|
||||
|
||||
# Syslog facility to use for logging of *TRAPS*. For example: 'local0'
|
||||
syslog_facility = local0
|
||||
|
||||
# Set the syslog level for *TRAPS* based on the severity level of the trap
|
||||
# as defined in the snmptt.conf file. Values must be one per line between
|
||||
# the syslog_level_* and END lines, and are not case sensitive. For example:
|
||||
# Warning
|
||||
# Critical
|
||||
# Duplicate definitions will use the definition with the higher severity.
|
||||
syslog_level_debug = <<END
|
||||
END
|
||||
syslog_level_info = <<END
|
||||
END
|
||||
syslog_level_notice = <<END
|
||||
END
|
||||
syslog_level_warning = <<END
|
||||
END
|
||||
syslog_level_err = <<END
|
||||
END
|
||||
syslog_level_crit = <<END
|
||||
END
|
||||
syslog_level_alert = <<END
|
||||
END
|
||||
|
||||
# Syslog default level to use for logging of *TRAPS*. For example: warning
|
||||
# Valid values: emerg, alert, crit, err, warning, notice, info, debug
|
||||
syslog_level = info
|
||||
|
||||
# Set to 1 to enable logging of *SNMPTT system errors* to syslog. If you do not have the
|
||||
# Sys::Syslog module then disable this. Windows users should disable this.
|
||||
syslog_system_enable = 1
|
||||
|
||||
# Syslog facility to use for logging of *SNMPTT system errors*. For example: 'local0'
|
||||
syslog_system_facility = local0
|
||||
|
||||
# Syslog level to use for logging of *SNMPTT system errors*.. For example: 'warning'
|
||||
# Valid values: emerg, alert, crit, err, warning, notice, info, debug
|
||||
syslog_system_level = err
|
||||
|
||||
[SQL]
|
||||
# Determines if the enterprise column contains the numeric OID or symbolic OID
|
||||
# Set to 0 for numeric OID
|
||||
# Set to 1 for symbolic OID
|
||||
# Uses translate_enterprise_oid_format to determine format
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
db_translate_enterprise = 0
|
||||
|
||||
# FORMAT line to use for unknown traps. If not defined, defaults to $-*.
|
||||
db_unknown_trap_format = '$-*'
|
||||
|
||||
# MySQL: Set to 1 to enable logging to a MySQL database via DBI (Linux / Windows)
|
||||
# This requires DBI:: and DBD::mysql
|
||||
mysql_dbi_enable = 0
|
||||
|
||||
# MySQL: Hostname of database server (optional - default localhost)
|
||||
mysql_dbi_host = localhost
|
||||
|
||||
# MySQL: Port number of database server (optional - default 3306)
|
||||
mysql_dbi_port = 3306
|
||||
|
||||
# MySQL: Database to use
|
||||
mysql_dbi_database = snmptt
|
||||
|
||||
# MySQL: Table to use
|
||||
mysql_dbi_table = snmptt
|
||||
|
||||
# MySQL: Table to use for unknown traps
|
||||
# Leave blank to disable logging of unknown traps to MySQL
|
||||
# Note: unknown_trap_log_enable must be enabled.
|
||||
mysql_dbi_table_unknown = snmptt_unknown
|
||||
|
||||
# MySQL: Username to use
|
||||
mysql_dbi_username = snmpttuser
|
||||
|
||||
# MySQL: Password to use
|
||||
mysql_dbi_password = password
|
||||
|
||||
# MySQL: Whether or not to 'ping' the database before attempting an INSERT
|
||||
# to ensure the connection is still valid. If *any* error is generate by
|
||||
# the ping such as 'Unable to connect to database', it will attempt to
|
||||
# re-create the database connection.
|
||||
# Set to 0 to disable
|
||||
# Set to 1 to enable
|
||||
# Note: This has no effect on mysql_ping_interval.
|
||||
mysql_ping_on_insert = 1
|
||||
|
||||
# MySQL: How often in seconds the database should be 'pinged' to ensure the
|
||||
# connection is still valid. If *any* error is generate by the ping such as
|
||||
# 'Unable to connect to database', it will attempt to re-create the database
|
||||
# connection. Set to 0 to disable pinging.
|
||||
# Note: This has no effect on mysql_ping_on_insert.
|
||||
# disabled = 0
|
||||
# 5 minutes = 300
|
||||
# 15 minutes = 900
|
||||
# 30 minutes = 1800
|
||||
mysql_ping_interval = 300
|
||||
|
||||
# PostgreSQL: Set to 1 to enable logging to a PostgreSQL database via DBI (Linux / Windows)
|
||||
# This requires DBI:: and DBD::PgPP
|
||||
postgresql_dbi_enable = 0
|
||||
|
||||
# Set to 0 to use the DBD::PgPP module
|
||||
# Set to 1 to use the DBD::Pg module
|
||||
postgresql_dbi_module = 0
|
||||
|
||||
# Set to 0 to disable host and port network support
|
||||
# Set to 1 to enable host and port network support
|
||||
# If set to 1, ensure PostgreSQL is configured to allow connections via TCPIP by setting
|
||||
# tcpip_socket = true in the $PGDATA/postgresql.conf file, and adding the ip address of
|
||||
# the SNMPTT server to $PGDATApg_hba.conf. The common location for the config files for
|
||||
# RPM installations of PostgreSQL is /var/lib/pgsql/data.
|
||||
postgresql_dbi_hostport_enable = 0
|
||||
|
||||
# PostgreSQL: Hostname of database server (optional - default localhost)
|
||||
postgresql_dbi_host = localhost
|
||||
|
||||
# PostgreSQL: Port number of database server (optional - default 5432)
|
||||
postgresql_dbi_port = 5432
|
||||
|
||||
# PostgreSQL: Database to use
|
||||
postgresql_dbi_database = snmptt
|
||||
|
||||
# PostgreSQL: Table to use for unknown traps
|
||||
# Leave blank to disable logging of unknown traps to PostgreSQL
|
||||
# Note: unknown_trap_log_enable must be enabled.
|
||||
postgresql_dbi_table_unknown = snmptt_unknown
|
||||
|
||||
# PostgreSQL: Table to use
|
||||
postgresql_dbi_table = snmptt
|
||||
|
||||
# PostgreSQL: Username to use
|
||||
postgresql_dbi_username = snmpttuser
|
||||
|
||||
# PostgreSQL: Password to use
|
||||
postgresql_dbi_password = password
|
||||
|
||||
# PostgreSQL: Whether or not to 'ping' the database before attempting an INSERT
|
||||
# to ensure the connection is still valid. If *any* error is generate by
|
||||
# the ping such as 'Unable to connect to database', it will attempt to
|
||||
# re-create the database connection.
|
||||
# Set to 0 to disable
|
||||
# Set to 1 to enable
|
||||
# Note: This has no effect on postgresqll_ping_interval.
|
||||
postgresql_ping_on_insert = 1
|
||||
|
||||
# PostgreSQL: How often in seconds the database should be 'pinged' to ensure the
|
||||
# connection is still valid. If *any* error is generate by the ping such as
|
||||
# 'Unable to connect to database', it will attempt to re-create the database
|
||||
# connection. Set to 0 to disable pinging.
|
||||
# Note: This has no effect on postgresql_ping_on_insert.
|
||||
# disabled = 0
|
||||
# 5 minutes = 300
|
||||
# 15 minutes = 900
|
||||
# 30 minutes = 1800
|
||||
postgresql_ping_interval = 300
|
||||
|
||||
# ODBC: Set to 1 to enable logging to a database via ODBC using DBD::ODBC.
|
||||
# This requires both DBI:: and DBD::ODBC
|
||||
dbd_odbc_enable = 0
|
||||
|
||||
# DBD:ODBC: Database to use
|
||||
dbd_odbc_dsn = snmptt
|
||||
|
||||
# DBD:ODBC: Table to use
|
||||
dbd_odbc_table = snmptt
|
||||
|
||||
# DBD:ODBC: Table to use for unknown traps
|
||||
# Leave blank to disable logging of unknown traps to DBD:ODBC
|
||||
# Note: unknown_trap_log_enable must be enabled.
|
||||
dbd_odbc_table_unknown = snmptt_unknown
|
||||
|
||||
# DBD:ODBC: Username to use
|
||||
dbd_odbc_username = snmptt
|
||||
|
||||
# DBD:DBC:: Password to use
|
||||
dbd_odbc_password = password
|
||||
|
||||
|
||||
# DBD:ODBC: Whether or not to 'ping' the database before attempting an INSERT
|
||||
# to ensure the connection is still valid. If *any* error is generate by
|
||||
# the ping such as 'Unable to connect to database', it will attempt to
|
||||
# re-create the database connection.
|
||||
# Set to 0 to disable
|
||||
# Set to 1 to enable
|
||||
# Note: This has no effect on dbd_odbc_ping_interval.
|
||||
dbd_odbc_ping_on_insert = 1
|
||||
|
||||
# DBD:ODBC:: How often in seconds the database should be 'pinged' to ensure the
|
||||
# connection is still valid. If *any* error is generate by the ping such as
|
||||
# 'Unable to connect to database', it will attempt to re-create the database
|
||||
# connection. Set to 0 to disable pinging.
|
||||
# Note: This has no effect on dbd_odbc_ping_on_insert.
|
||||
# disabled = 0
|
||||
# 5 minutes = 300
|
||||
# 15 minutes = 900
|
||||
# 30 minutes = 1800
|
||||
dbd_odbc_ping_interval = 300
|
||||
|
||||
[Exec]
|
||||
|
||||
# Set to 1 to allow EXEC statements to execute. Should normally be left on unless you
|
||||
# want to temporarily disable all EXEC commands
|
||||
exec_enable = 1
|
||||
|
||||
[Debugging]
|
||||
# 0 - do not output messages
|
||||
# 1 - output some basic messages
|
||||
# 2 - out all messages
|
||||
DEBUGGING = 0
|
||||
|
||||
# Debugging file - SNMPTT
|
||||
# Location of debugging output file. Leave blank to default to STDOUT (good for
|
||||
# standalone mode, or daemon mode without forking)
|
||||
#DEBUGGING_FILE =
|
||||
DEBUGGING_FILE = /var/log/debug.snmptt
|
||||
|
||||
# Debugging file - SNMPTTHANDLER
|
||||
# Location of debugging output file. Leave blank to default to STDOUT
|
||||
#DEBUGGING_FILE_HANDLER =
|
||||
DEBUGGING_FILE_HANDLER = /var/log/snmptthandler.debug
|
||||
|
||||
[TrapFiles]
|
||||
# A list of snmptt.conf files (this is NOT the snmptrapd.conf file). The COMPLETE path
|
||||
# and filename. Ex: '/etc/snmp/snmptt.conf'
|
||||
snmptt_conf_files = <<END
|
||||
/etc/snmp/centreon_traps/snmptt-cisco.conf
|
||||
/etc/snmp/centreon_traps/snmptt-hp.conf
|
||||
/etc/snmp/centreon_traps/snmptt-3com.conf
|
||||
/etc/snmp/centreon_traps/snmptt-ciscolinksys.conf
|
||||
/etc/snmp/centreon_traps/snmptt-dell.conf
|
||||
/etc/snmp/centreon_traps/snmptt-Generic.conf
|
||||
END
|
||||
#
|
||||
# SNMPTT v1.0 Configuration File
|
||||
#
|
||||
# Linux / Unix
|
||||
#
|
||||
|
||||
[General]
|
||||
# Set to either 'standalone' or 'daemon'
|
||||
# standalone: snmptt called from snmptrapd.conf
|
||||
# daemon: snmptrapd.conf calls snmptthandler
|
||||
# Ignored by Windows. See documentation
|
||||
mode = standalone
|
||||
|
||||
# Set to 1 to allow multiple trap definitions to be executed for the same trap.
|
||||
# Set to 0 to have it stop after the first match.
|
||||
# Note: Wildcard matches are only matched if there are NO exact matches. This takes
|
||||
# into consideration the NODES list. Therefore, if there is a matching trap, but
|
||||
# the NODES list prevents it from being considered a match, the wildcard entry will
|
||||
# only be used if there are no other exact matches.
|
||||
multiple_event = 1
|
||||
|
||||
# SNMPTRAPD passes the IP address of device sending the trap, and the IP address of the
|
||||
# actual SNMP agent. These addresses could differ if the trap was sent on behalf of another
|
||||
# device (relay, proxy etc).
|
||||
# If DNS is enabled, the agent IP address is converted to a host name using a DNS lookup
|
||||
# (which includes the local hosts file, depending on how the OS is configured). This name
|
||||
# will be used for: NODES entry matches, hostname field in logged traps (file / database),
|
||||
# and the $A variable. Host names on the NODES line will be resolved and the IP address
|
||||
# will then be used for comparing.
|
||||
# Set to 0 to disable DNS resolution
|
||||
# Set to 1 to enable DNS resolution
|
||||
dns_enable = 0
|
||||
|
||||
# Set to 0 to enable the use of FQDN (Fully Qualified Domain Names). If a host name is
|
||||
# passed to SNMPTT that contains a domain name, it will not be altered in any way by
|
||||
# SNMPTT. This also affects resolve_value_ip_addresses.
|
||||
# Set to 1 to have SNMPTT strip the domain name from the host name passed to it. For
|
||||
# example, server01.domain.com would be changed to server01
|
||||
# Set to 2 to have SNMPTT strip the domain name from the host name passed to it
|
||||
# based on the list of domains in strip_domain_list
|
||||
strip_domain = 0
|
||||
|
||||
# List of domain names that should be stripped when strip_domain is set to 2.
|
||||
# List can contain one or more domains. For example, if the FQDN of a host is
|
||||
# server01.city.domain.com and the list contains domain.com, the 'host' will be
|
||||
# set as server01.city.
|
||||
strip_domain_list = <<END
|
||||
merethis.net
|
||||
END
|
||||
|
||||
# Configures how IP addresses contained in the VALUE of the variable bindings are handled.
|
||||
# This only applies to the values for $n, $+n, $-n, $vn, $+*, $-*.
|
||||
# Set to 0 to disable resolving ip address to host names
|
||||
# Set to 1 to enable resolving ip address to host names
|
||||
# Note: net_snmp_perl_enable *must* be enabled. The strip_domain settings influence the
|
||||
# format of the resolved host name. DNS must be enabled (dns_enable)
|
||||
resolve_value_ip_addresses = 0
|
||||
|
||||
# Set to 1 to enable the use of the Perl module from the UCD-SNMP / NET-SNMP package.
|
||||
# This is required for $v variable substitution to work, and also for some other options
|
||||
# that are enabled in this .ini file.
|
||||
# Set to 0 to disable the use of the Perl module from the UCD-SNMP / NET-SNMP package.
|
||||
# Note: Enabling this with stand-alone mode can cause SNMPTT to run very slowly due to
|
||||
# the loading of the MIBS at startup.
|
||||
net_snmp_perl_enable = 1
|
||||
|
||||
# This sets the best_guess parameter used by the UCD-SNMP / NET-SNMP Perl module for
|
||||
# translating symbolic nams to OIDs and vice versa.
|
||||
# For UCD-SNMP, and Net-SNMP 5.0.8 and previous versions, set this value to 0.
|
||||
# For Net-SNMP 5.0.9, or any Net-SNMP with patch 722075 applied, set this value to 2.
|
||||
# A value of 2 is equivalent to -IR on Net-SNMP command line utilities.
|
||||
# UCD-SNMP and Net-SNMP 5.0.8 and previous may not be able to translate certain formats of
|
||||
# symbolic names such as RFC1213-MIB::sysDescr. Net-SNMP 5.0.9 or patch 722075 will allow
|
||||
# all possibilities to be translated. See the FAQ section in the README for more info
|
||||
net_snmp_perl_best_guess = 0
|
||||
|
||||
# Configures how the OID of the received trap is handled when outputting to a log file /
|
||||
# database. It does NOT apply to the $O variable.
|
||||
# Set to 0 to use the default of numerical OID
|
||||
# Set to 1 to translate the trap OID to short text (symbolic form) (eg: linkUp)
|
||||
# Set to 2 to translate the trap OID to short text with module name (eg: IF-MIB::linkUp)
|
||||
# Set to 3 to translate the trap OID to long text (eg: iso...snmpTraps.linkUp)
|
||||
# Set to 4 to translate the trap OID to long text with module name (eg:
|
||||
# IF-MIB::iso...snmpTraps.linkUp)
|
||||
# Note: -The output of the long format will vary depending on the version of Net-SNMP you
|
||||
# are using.
|
||||
# -net_snmp_perl_enable *must* be enabled
|
||||
# -If using database logging, ensure the trapoid column is large enough to hold the
|
||||
# entire line
|
||||
translate_log_trap_oid = 0
|
||||
|
||||
# Configures how OIDs contained in the VALUE of the variable bindings are handled.
|
||||
# This only applies to the values for $n, $+n, $-n, $vn, $+*, $-*. For substitutions
|
||||
# that include variable NAMES ($+n etc), only the variable VALUE is affected.
|
||||
# Set to 0 to disable translating OID values to text (symbolic form)
|
||||
# Set to 1 to translate OID values to short text (symbolic form) (eg: BuildingAlarm)
|
||||
# Set to 2 to translate OID values to short text with module name (eg: UPS-MIB::BuildingAlarm)
|
||||
# Set to 3 to translate OID values to long text (eg: iso...upsAlarm.BuildingAlarm)
|
||||
# Set to 4 to translate OID values to long text with module name (eg:
|
||||
# UPS-MIB::iso...upsAlarm.BuildingAlarm)
|
||||
# For example, if the value contained: 'A UPS Alarm (.1.3.6.1.4.1.534.1.7.12) has cleared.',
|
||||
# it could be translated to: 'A UPS Alarm (UPS-MIB::BuildingAlarm) has cleared.'
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
translate_value_oids = 1
|
||||
|
||||
# Configures how the symbolic enterprise OID will be displayed for $E.
|
||||
# Set to 1, 2, 3 or 4. See translate_value_oids options 1,2,3 and 4.
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
translate_enterprise_oid_format = 1
|
||||
|
||||
# Configures how the symbolic trap OID will be displayed for $O.
|
||||
# Set to 1, 2, 3 or 4. See translate_value_oids options 1,2,3 and 4.
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
translate_trap_oid_format = 1
|
||||
|
||||
# Configures how the symbolic trap OID will be displayed for $v, $-n, $+n, $-* and $+*.
|
||||
# Set to 1, 2, 3 or 4. See translate_value_oids options 1,2,3 and 4.
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
translate_varname_oid_format = 1
|
||||
|
||||
# Set to 0 to disable converting INTEGER values to enumeration tags as defined in the
|
||||
# MIB files
|
||||
# Set to 1 to enable converting INTEGER values to enumeration tags as defined in the
|
||||
# MIB files
|
||||
# Example: moverDoorState:open instead of moverDoorState:2
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
translate_integers = 1
|
||||
|
||||
# Allows you to set the MIBS environment variable used by SNMPTT
|
||||
# Leave blank or comment out to have the systems enviroment settings used
|
||||
# To have all MIBS processed, set to ALL
|
||||
# See the snmp.conf manual page for more info
|
||||
#mibs_environment = ALL
|
||||
|
||||
# Set what is used to separate variables when wildcards are expanded on the FORMAT /
|
||||
# EXEC line. Defaults to a space. Value MUST be within quotes. Can contain 1 or
|
||||
# more characters
|
||||
wildcard_expansion_separator = " "
|
||||
|
||||
# Set to 1 to allow unsafe REGEX code to be executed.
|
||||
# Set to 0 to prevent unsafe REGEX code from being executed (default).
|
||||
# Enabling unsafe REGEX code will allow variable interopolation and the use of the e
|
||||
# modifier to allow statements such as substitution with captures such
|
||||
# as: (one (two) three)(five $1 six)
|
||||
# which outputs: five two six
|
||||
# or: (one (two) three)("five ".length($1)." six")e
|
||||
# which outputs: five 3 six
|
||||
#
|
||||
# This is considered unsafe because the contents of the regular expression
|
||||
# (right) is executed (eval) by Perl which *could contain unsafe code*.
|
||||
# BE SURE THAT THE SNMPTT CONFIGURATION FILES ARE SECURE!
|
||||
allow_unsafe_regex = 0
|
||||
|
||||
# Set to 1 to have the backslash (escape) removed from quotes passed from
|
||||
# snmptrapd. For example, \" would be changed to just "
|
||||
# Set to 0 to disable
|
||||
remove_backslash_from_quotes = 0
|
||||
|
||||
# Set to 1 to have NODES files loaded each time a trap is processed.
|
||||
# Set to 0 to have all NODES files loaded when the snmptt.conf files are loaded.
|
||||
# If NODES files are used (files that contain lists of NODES), then setting to 1
|
||||
# will cause the list to be loaded each time an EVENT is processed that uses
|
||||
# NODES files. This will allow the NODES file to be modified while SNMPTT is
|
||||
# running but can result in many file reads depending on the number of traps
|
||||
# received. Defaults to 0
|
||||
dynamic_nodes = 0
|
||||
|
||||
# This option allows you to use the $D substitution variable to include the
|
||||
# description text from the SNMPTT.CONF or MIB files.
|
||||
# Set to 0 to disable the $D substitution variable. If $D is used, nothing
|
||||
# will be outputted.
|
||||
# Set to 1 to enable the $D substitution variable and have it use the
|
||||
# descriptions stored in the SNMPTT .conf files. Enabling this option can
|
||||
# greatly increase the amount of memory used by SNMPTT.
|
||||
# Set to 2 to enable the $D substitution variable and have it use the
|
||||
# description from the MIB files. This enables the UCD-SNMP / NET-SNMP Perl
|
||||
# module save_descriptions variable. Enabling this option can greatly
|
||||
# increase the amount of memory used by the Net-SNMP SNMP Perl module, which
|
||||
# will result in an increase of memory usage by SNMPTT.
|
||||
description_mode = 0
|
||||
|
||||
# Set to 1 to remove any white space at the start of each line from the MIB
|
||||
# or SNMPTT.CONF description when description_mode is set to 1 or 2.
|
||||
description_clean = 1
|
||||
|
||||
[DaemonMode]
|
||||
# Set to 1 to have snmptt fork to the background when run in daemon mode
|
||||
# Ignored by Windows. See documentation
|
||||
daemon_fork = 1
|
||||
|
||||
# Set to the numerical user id (eg: 500) or textual user id (eg: snmptt)
|
||||
# that snmptt should change to when running in daemon mode. Leave blank
|
||||
# to disable. The user used should have read/write access to all log
|
||||
# files, the spool folder, and read access to the configuration files.
|
||||
daemon_uid = root
|
||||
|
||||
# Directory to read received traps from. Ex: /var/spool/snmptt/
|
||||
# Don't forget the trailing slash!
|
||||
spool_directory = /var/spool/snmptt/
|
||||
|
||||
# Amount of time in seconds to sleep between processing spool files
|
||||
sleep = 2
|
||||
|
||||
# Set to 1 to have SNMPTT use the time that the trap was processed by SNMPTTHANDLER
|
||||
# Set to 0 to have SNMPTT use the time the trap was processed. Note: Using 0 can
|
||||
# result in the time being off by the number of seconds used for 'sleep'
|
||||
use_trap_time = 1
|
||||
|
||||
# Set to 0 to have SNMPTT erase the spooled trap file after it attempts to process
|
||||
# the trap even if it did not successfully log the trap to any of the log systems.
|
||||
# Set to 1 to have SNMPTT erase the spooled trap file only after it successfully
|
||||
# logs to at least ONE log system.
|
||||
# Set to 2 to have SNMPTT erase the spooled trap file only after it successfully
|
||||
# logs to ALL of the enabled log systems. Warning: If multiple log systems are
|
||||
# enabled and only one fails, the other log system will continuously be logged to
|
||||
# until ALL of the log systems function.
|
||||
# The recommended setting is 1 with only one log system enabled.
|
||||
keep_unlogged_traps = 1
|
||||
|
||||
[Logging]
|
||||
# Set to 1 to enable messages to be sent to standard output, or 0 to disable.
|
||||
# Would normally be disabled unless you are piping this program to another
|
||||
stdout_enable = 0
|
||||
|
||||
# Set to 1 to enable text logging. Make sure you specify a logfile location
|
||||
log_enable = 1
|
||||
|
||||
# Log file location. The COMPLETE path and filename. Ex: '/var/log/snmptt.log'
|
||||
log_file = /var/log/snmptt.log
|
||||
|
||||
# Set to 1 to enable logging of unknown traps. This should normally be left off
|
||||
# as the file could grow large quickly. Used primarily for troubleshooting. If
|
||||
# you have defined a trap in snmptt.conf, but it is not executing, enable this to
|
||||
# see if it is being considered an unknown trap due to an incorrect entry or
|
||||
# simply missing from the snmptt.conf file.
|
||||
# Unknown traps can be logged either a text file, a SQL table or both.
|
||||
# See SQL section to define SQL table to log unknown traps to.
|
||||
unknown_trap_log_enable = 1
|
||||
|
||||
# Unknown trap log file location. The COMPLETE path and filename.
|
||||
# Ex: '/var/log/snmpttunknown.log'
|
||||
# Leave blank to disable logging to text file if logging to SQL is enabled
|
||||
# for unknown traps
|
||||
unknown_trap_log_file = /var/log/snmpttunknown.log
|
||||
|
||||
# How often in seconds statistics should be logged to syslog or the event log.
|
||||
# Set to 0 to disable
|
||||
# 1 hour = 216000
|
||||
# 12 hours = 2592000
|
||||
# 24 hours = 5184000
|
||||
statistics_interval = 0
|
||||
|
||||
# Set to 1 to enable logging of *TRAPS* to syslog. If you do not have the Sys::Syslog
|
||||
# module then disable this. Windows users should disable this.
|
||||
syslog_enable = 0
|
||||
|
||||
# Syslog facility to use for logging of *TRAPS*. For example: 'local0'
|
||||
syslog_facility = local0
|
||||
|
||||
# Set the syslog level for *TRAPS* based on the severity level of the trap
|
||||
# as defined in the snmptt.conf file. Values must be one per line between
|
||||
# the syslog_level_* and END lines, and are not case sensitive. For example:
|
||||
# Warning
|
||||
# Critical
|
||||
# Duplicate definitions will use the definition with the higher severity.
|
||||
syslog_level_debug = <<END
|
||||
END
|
||||
syslog_level_info = <<END
|
||||
END
|
||||
syslog_level_notice = <<END
|
||||
END
|
||||
syslog_level_warning = <<END
|
||||
END
|
||||
syslog_level_err = <<END
|
||||
END
|
||||
syslog_level_crit = <<END
|
||||
END
|
||||
syslog_level_alert = <<END
|
||||
END
|
||||
|
||||
# Syslog default level to use for logging of *TRAPS*. For example: warning
|
||||
# Valid values: emerg, alert, crit, err, warning, notice, info, debug
|
||||
syslog_level = info
|
||||
|
||||
# Set to 1 to enable logging of *SNMPTT system errors* to syslog. If you do not have the
|
||||
# Sys::Syslog module then disable this. Windows users should disable this.
|
||||
syslog_system_enable = 1
|
||||
|
||||
# Syslog facility to use for logging of *SNMPTT system errors*. For example: 'local0'
|
||||
syslog_system_facility = local0
|
||||
|
||||
# Syslog level to use for logging of *SNMPTT system errors*.. For example: 'warning'
|
||||
# Valid values: emerg, alert, crit, err, warning, notice, info, debug
|
||||
syslog_system_level = err
|
||||
|
||||
[SQL]
|
||||
# Determines if the enterprise column contains the numeric OID or symbolic OID
|
||||
# Set to 0 for numeric OID
|
||||
# Set to 1 for symbolic OID
|
||||
# Uses translate_enterprise_oid_format to determine format
|
||||
# Note: net_snmp_perl_enable *must* be enabled
|
||||
db_translate_enterprise = 0
|
||||
|
||||
# FORMAT line to use for unknown traps. If not defined, defaults to $-*.
|
||||
db_unknown_trap_format = '$-*'
|
||||
|
||||
# MySQL: Set to 1 to enable logging to a MySQL database via DBI (Linux / Windows)
|
||||
# This requires DBI:: and DBD::mysql
|
||||
mysql_dbi_enable = 0
|
||||
|
||||
# MySQL: Hostname of database server (optional - default localhost)
|
||||
mysql_dbi_host = localhost
|
||||
|
||||
# MySQL: Port number of database server (optional - default 3306)
|
||||
mysql_dbi_port = 3306
|
||||
|
||||
# MySQL: Database to use
|
||||
mysql_dbi_database = snmptt
|
||||
|
||||
# MySQL: Table to use
|
||||
mysql_dbi_table = snmptt
|
||||
|
||||
# MySQL: Table to use for unknown traps
|
||||
# Leave blank to disable logging of unknown traps to MySQL
|
||||
# Note: unknown_trap_log_enable must be enabled.
|
||||
mysql_dbi_table_unknown = snmptt_unknown
|
||||
|
||||
# MySQL: Username to use
|
||||
mysql_dbi_username = snmpttuser
|
||||
|
||||
# MySQL: Password to use
|
||||
mysql_dbi_password = password
|
||||
|
||||
# MySQL: Whether or not to 'ping' the database before attempting an INSERT
|
||||
# to ensure the connection is still valid. If *any* error is generate by
|
||||
# the ping such as 'Unable to connect to database', it will attempt to
|
||||
# re-create the database connection.
|
||||
# Set to 0 to disable
|
||||
# Set to 1 to enable
|
||||
# Note: This has no effect on mysql_ping_interval.
|
||||
mysql_ping_on_insert = 1
|
||||
|
||||
# MySQL: How often in seconds the database should be 'pinged' to ensure the
|
||||
# connection is still valid. If *any* error is generate by the ping such as
|
||||
# 'Unable to connect to database', it will attempt to re-create the database
|
||||
# connection. Set to 0 to disable pinging.
|
||||
# Note: This has no effect on mysql_ping_on_insert.
|
||||
# disabled = 0
|
||||
# 5 minutes = 300
|
||||
# 15 minutes = 900
|
||||
# 30 minutes = 1800
|
||||
mysql_ping_interval = 300
|
||||
|
||||
# PostgreSQL: Set to 1 to enable logging to a PostgreSQL database via DBI (Linux / Windows)
|
||||
# This requires DBI:: and DBD::PgPP
|
||||
postgresql_dbi_enable = 0
|
||||
|
||||
# Set to 0 to use the DBD::PgPP module
|
||||
# Set to 1 to use the DBD::Pg module
|
||||
postgresql_dbi_module = 0
|
||||
|
||||
# Set to 0 to disable host and port network support
|
||||
# Set to 1 to enable host and port network support
|
||||
# If set to 1, ensure PostgreSQL is configured to allow connections via TCPIP by setting
|
||||
# tcpip_socket = true in the $PGDATA/postgresql.conf file, and adding the ip address of
|
||||
# the SNMPTT server to $PGDATApg_hba.conf. The common location for the config files for
|
||||
# RPM installations of PostgreSQL is /var/lib/pgsql/data.
|
||||
postgresql_dbi_hostport_enable = 0
|
||||
|
||||
# PostgreSQL: Hostname of database server (optional - default localhost)
|
||||
postgresql_dbi_host = localhost
|
||||
|
||||
# PostgreSQL: Port number of database server (optional - default 5432)
|
||||
postgresql_dbi_port = 5432
|
||||
|
||||
# PostgreSQL: Database to use
|
||||
postgresql_dbi_database = snmptt
|
||||
|
||||
# PostgreSQL: Table to use for unknown traps
|
||||
# Leave blank to disable logging of unknown traps to PostgreSQL
|
||||
# Note: unknown_trap_log_enable must be enabled.
|
||||
postgresql_dbi_table_unknown = snmptt_unknown
|
||||
|
||||
# PostgreSQL: Table to use
|
||||
postgresql_dbi_table = snmptt
|
||||
|
||||
# PostgreSQL: Username to use
|
||||
postgresql_dbi_username = snmpttuser
|
||||
|
||||
# PostgreSQL: Password to use
|
||||
postgresql_dbi_password = password
|
||||
|
||||
# PostgreSQL: Whether or not to 'ping' the database before attempting an INSERT
|
||||
# to ensure the connection is still valid. If *any* error is generate by
|
||||
# the ping such as 'Unable to connect to database', it will attempt to
|
||||
# re-create the database connection.
|
||||
# Set to 0 to disable
|
||||
# Set to 1 to enable
|
||||
# Note: This has no effect on postgresqll_ping_interval.
|
||||
postgresql_ping_on_insert = 1
|
||||
|
||||
# PostgreSQL: How often in seconds the database should be 'pinged' to ensure the
|
||||
# connection is still valid. If *any* error is generate by the ping such as
|
||||
# 'Unable to connect to database', it will attempt to re-create the database
|
||||
# connection. Set to 0 to disable pinging.
|
||||
# Note: This has no effect on postgresql_ping_on_insert.
|
||||
# disabled = 0
|
||||
# 5 minutes = 300
|
||||
# 15 minutes = 900
|
||||
# 30 minutes = 1800
|
||||
postgresql_ping_interval = 300
|
||||
|
||||
# ODBC: Set to 1 to enable logging to a database via ODBC using DBD::ODBC.
|
||||
# This requires both DBI:: and DBD::ODBC
|
||||
dbd_odbc_enable = 0
|
||||
|
||||
# DBD:ODBC: Database to use
|
||||
dbd_odbc_dsn = snmptt
|
||||
|
||||
# DBD:ODBC: Table to use
|
||||
dbd_odbc_table = snmptt
|
||||
|
||||
# DBD:ODBC: Table to use for unknown traps
|
||||
# Leave blank to disable logging of unknown traps to DBD:ODBC
|
||||
# Note: unknown_trap_log_enable must be enabled.
|
||||
dbd_odbc_table_unknown = snmptt_unknown
|
||||
|
||||
# DBD:ODBC: Username to use
|
||||
dbd_odbc_username = snmptt
|
||||
|
||||
# DBD:DBC:: Password to use
|
||||
dbd_odbc_password = password
|
||||
|
||||
|
||||
# DBD:ODBC: Whether or not to 'ping' the database before attempting an INSERT
|
||||
# to ensure the connection is still valid. If *any* error is generate by
|
||||
# the ping such as 'Unable to connect to database', it will attempt to
|
||||
# re-create the database connection.
|
||||
# Set to 0 to disable
|
||||
# Set to 1 to enable
|
||||
# Note: This has no effect on dbd_odbc_ping_interval.
|
||||
dbd_odbc_ping_on_insert = 1
|
||||
|
||||
# DBD:ODBC:: How often in seconds the database should be 'pinged' to ensure the
|
||||
# connection is still valid. If *any* error is generate by the ping such as
|
||||
# 'Unable to connect to database', it will attempt to re-create the database
|
||||
# connection. Set to 0 to disable pinging.
|
||||
# Note: This has no effect on dbd_odbc_ping_on_insert.
|
||||
# disabled = 0
|
||||
# 5 minutes = 300
|
||||
# 15 minutes = 900
|
||||
# 30 minutes = 1800
|
||||
dbd_odbc_ping_interval = 300
|
||||
|
||||
[Exec]
|
||||
|
||||
# Set to 1 to allow EXEC statements to execute. Should normally be left on unless you
|
||||
# want to temporarily disable all EXEC commands
|
||||
exec_enable = 1
|
||||
|
||||
[Debugging]
|
||||
# 0 - do not output messages
|
||||
# 1 - output some basic messages
|
||||
# 2 - out all messages
|
||||
DEBUGGING = 0
|
||||
|
||||
# Debugging file - SNMPTT
|
||||
# Location of debugging output file. Leave blank to default to STDOUT (good for
|
||||
# standalone mode, or daemon mode without forking)
|
||||
#DEBUGGING_FILE =
|
||||
DEBUGGING_FILE = /var/log/debug.snmptt
|
||||
|
||||
# Debugging file - SNMPTTHANDLER
|
||||
# Location of debugging output file. Leave blank to default to STDOUT
|
||||
#DEBUGGING_FILE_HANDLER =
|
||||
DEBUGGING_FILE_HANDLER = /var/log/snmptthandler.debug
|
||||
|
||||
[TrapFiles]
|
||||
# A list of snmptt.conf files (this is NOT the snmptrapd.conf file). The COMPLETE path
|
||||
# and filename. Ex: '/etc/snmp/snmptt.conf'
|
||||
snmptt_conf_files = <<END
|
||||
/etc/snmp/centreon_traps/snmptt-cisco.conf
|
||||
/etc/snmp/centreon_traps/snmptt-hp.conf
|
||||
/etc/snmp/centreon_traps/snmptt-3com.conf
|
||||
/etc/snmp/centreon_traps/snmptt-ciscolinksys.conf
|
||||
/etc/snmp/centreon_traps/snmptt-dell.conf
|
||||
/etc/snmp/centreon_traps/snmptt-Generic.conf
|
||||
END
|
||||
|
|
Loading…
Reference in New Issue