Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
tuto:monitoring:zabbix_hp_smart_array [27/09/2013 14:32] dani créée |
tuto:monitoring:zabbix_hp_smart_array [01/10/2013 12:52] (Version actuelle) dani |
||
---|---|---|---|
Ligne 4: | Ligne 4: | ||
L' | L' | ||
+ | |||
+ | Voilà un petit script en perl qui permet de s' | ||
+ | |||
+ | <file perl check_raid_hp.pl> | ||
+ | # | ||
+ | |||
+ | use strict; | ||
+ | use Getopt:: | ||
+ | |||
+ | my $slot = ''; | ||
+ | my $hpacucli = '/ | ||
+ | my @validchecks = qw/ | ||
+ | my $check = join ',', | ||
+ | |||
+ | GetOptions (' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | |||
+ | sub usage(){ | ||
+ | print <<" | ||
+ | $0 --slot=< | ||
+ | |||
+ | * 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 " | ||
+ | exit(0); | ||
+ | } | ||
+ | |||
+ | if ($slot !~ /^\d+$/){ | ||
+ | usage(); | ||
+ | } | ||
+ | |||
+ | unless (-x $hpacucli){ | ||
+ | die " | ||
+ | } | ||
+ | |||
+ | 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 ' | ||
+ | open HPACUCLI, " | ||
+ | die "An error occured while running $hpacucli: $!"; | ||
+ | foreach my $line (< | ||
+ | if ( $line =~ / | ||
+ | my $res = $1; | ||
+ | chomp($res); | ||
+ | if ($res ne ' | ||
+ | print " | ||
+ | exit(0); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | close HPACUCLI; | ||
+ | } | ||
+ | else{ | ||
+ | open HPACUCLI, " | ||
+ | die "An error occured while running $hpacucli: $!"; | ||
+ | foreach my $line (< | ||
+ | if ( $line =~ / | ||
+ | my $res = $1; | ||
+ | chomp($res); | ||
+ | if ($res ne ' | ||
+ | print " | ||
+ | exit(0); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | close HPACUCLI; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | print ' | ||
+ | exit(0); | ||
+ | |||
+ | </ | ||
+ | |||
+ | Ce script affichera simplement " |