Additional scripts for Zabbix agent on Linux to discover and monitor several services
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.0 KiB

#!/usr/bin/perl -w
use strict;
use Getopt::Long;
my $slot = '';
my $hpacucli = '/usr/sbin/hpacucli';
my @validchecks = qw/controller array logicaldrive physicaldrive/;
my $check = join ',', @validchecks;
GetOptions ('slot=s' => \$slot,
'check=s' => \$check,
'help' => sub { &usage() }
);
sub usage(){
print <<"EOF";
$0 --slot=<slot number> --check=<what to check>
* slot must be a number. You can find on which slot you have controllers with the command:
$hpacucli controller all show status
* check is a comma separated list of item to check. Default values (without --check option) will check everything
Valid values are:
EOF
print "$_\n" foreach (@validchecks);
exit(0);
}
if ($slot !~ /^\d+$/){
usage();
}
unless (-x $hpacucli){
die "Cannot run $hpacucli\n";
}
my @checks = split /\s?,\s?/, $check;
foreach my $check (@checks){
usage() unless (grep { $_ eq $check} @validchecks);
}
foreach my $param (@checks){
# Global controller checks
if ($param eq 'controller'){
open HPACUCLI, "$hpacucli controller slot=$slot show status|" ||
die "An error occured while running $hpacucli: $!";
foreach my $line (<HPACUCLI>){
if ( $line =~ /Status\:\s*([\w\s]+)$/ ) {
my $res = $1;
chomp($res);
if ($res ne 'OK'){
print "CRITICAL: $line\n";
exit(0);
}
}
}
close HPACUCLI;
}
else{
open HPACUCLI, "$hpacucli controller slot=$slot $param all show status|" ||
die "An error occured while running $hpacucli: $!";
foreach my $line (<HPACUCLI>){
if ( $line =~ /^\s*$param.*:\s*(\w+[\w\s]*)$/i ) {
my $res = $1;
chomp($res);
if ($res ne 'OK'){
print "CRITICAL: $line\n";
exit(0);
}
}
}
close HPACUCLI;
}
}
print 'OK';
exit(0);