1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| #!/usr/bin/perl
use strict;
use warnings;
use Nagios::Plugin;
print "1";
my $plugin = Nagios::Plugin->new(
usage => "Usage: %s [-H <host>] [-V <snmp version>] [-c <community>]"
);
$plugin->add_arg(
spec => 'host|H=s',
help => "--host NAME\n Ip address of the controller to check",
required => 1,
);
$plugin->add_arg(
spec => 'version|V=s@',
help => "--version NAME\n The version of the snmp community (1/2c/3)",
required => 1,
);
$plugin->add_arg(
spec => 'community|c=s@',
help => "--community NAME\n The name of the snmp community",
required => 1,
);
print "2";
$plugin->getopts();
print "3";
my $opts = $plugin->opts();
my $host = $opts->get('host');
my $version = $opts->get('version');
my $community = $opts->get('community');
print "4";
my $Backup = `snmpwalk -v $version -c $community $host 1.3.6.1.4.1.789.1.17.15.2 | grep *_Backup | wc -l`;
if ( $Backup != 0 ) {
print "Présence de backup de LUN";
exit 2;
}
else {
print "Pas de Backup de LUN présent";
exit 0;
} |