parent
a74483d3b8
commit
217d4a932a
3 changed files with 128 additions and 0 deletions
@ -0,0 +1,17 @@ |
||||
# Description: HP Smart Array status |
||||
# Type: Agent or Agent (active) |
||||
# Key: raid.hp.status |
||||
# Type of Information: Character |
||||
# Show Value: As is |
||||
|
||||
# The value reported is like: |
||||
# OK |
||||
# If an error is found, the output will be: |
||||
# CRITICAL: <line with the first error> |
||||
|
||||
# You can add a simple trigger on this check like: |
||||
# { hostname:raid.hp.status.str( OK ) }=0 |
||||
UserParameter=raid.hp.status[*],/usr/bin/sudo /var/lib/zabbix/bin/check_raid_hp_sudo --slot=$1 |
||||
|
||||
# This is a discovery rule to find which slot are used |
||||
UserParameter=raid.hp.discovery,/usr/bin/sudo /var/lib/zabbix/bin/disco_raid_hp_sudo |
@ -0,0 +1,81 @@ |
||||
#!/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); |
@ -0,0 +1,30 @@ |
||||
#!/usr/bin/perl -w |
||||
|
||||
use strict; |
||||
use JSON; |
||||
|
||||
my $json; |
||||
@{$json->{data}} = (); |
||||
|
||||
my $hpacucli = '/usr/sbin/hpacucli'; |
||||
|
||||
# the hpacucli utility is needed |
||||
unless (-x $hpacucli){ |
||||
print to_json($json); |
||||
exit(0); |
||||
} |
||||
|
||||
open( HPACUCLI, "$hpacucli controller all show status|" ) |
||||
or die "An error occured while running $hpacucli: $!"; |
||||
|
||||
foreach my $line (<HPACUCLI>){ |
||||
if ( $line =~ m/Another instance of hpacucli is running! Stop it first\./i ){ |
||||
die "Another instance of hpacucli is running\n"; |
||||
} |
||||
elsif ( $line =~ m/(.*) in Slot (\d+)/i ) { |
||||
push @{$json->{data}}, {"#MODEL" => $1, "#SLOT" => $2}; |
||||
} |
||||
} |
||||
close HPACUCLI; |
||||
print to_json($json); |
||||
exit(0); |
Loading…
Reference in new issue