tuto:monitoring:zabbix_hp_smart_array

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

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'outil hpacucli permet de contrôler les cartes RAID depuis une machine Linux, en ligne de commande. Il faut récupérer le rpm sur le site d'HP [[http://downloads.linux.hp.com/SDR/downloads/PSP/RHEL/6/packages/x86_64/|ici]] L'outil hpacucli permet de contrôler les cartes RAID depuis une machine Linux, en ligne de commande. Il faut récupérer le rpm sur le site d'HP [[http://downloads.linux.hp.com/SDR/downloads/PSP/RHEL/6/packages/x86_64/|ici]]
 +
 +Voilà un petit script en perl qui permet de s'assurer de l'état des différent volumes logiques configurés:
 +
 +<file perl check_raid_hp.pl>
 +#!/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);
 +
 +</file>
 +
 +Ce script affichera simplement "OK" sur la sortie standard si tout va bien, et sinon, il affichera CRITICAL suivie de la première ligne d'erreur rencontrée
  • tuto/monitoring/zabbix_hp_smart_array.1380285135.txt.gz
  • Dernière modification: 27/09/2013 14:32
  • de dani