add AIX and AS400 support

git-svn-id: http://svn.centreon.com/Plugins/Dev@2946 6bcd3966-0018-0410-8128-fd23d134de7e
This commit is contained in:
Julien Mathis 2007-08-07 19:41:40 +00:00
parent e5421414bc
commit 15c49f8b7a

View File

@ -40,7 +40,7 @@ if (eval "require oreon" ) {
} }
use vars qw($PROGNAME); use vars qw($PROGNAME);
use Getopt::Long; use Getopt::Long;
use vars qw($opt_V $opt_h $opt_v $opt_f $opt_C $opt_d $opt_k $opt_u $opt_p $opt_n $opt_w $opt_c $opt_H $opt_s @test); use vars qw($opt_V $opt_t $opt_h $opt_v $opt_f $opt_C $opt_d $opt_k $opt_u $opt_p $opt_n $opt_w $opt_c $opt_H $opt_s @test);
# Plugin var init # Plugin var init
@ -66,7 +66,8 @@ GetOptions
"n" => \$opt_n, "name" => \$opt_n, "n" => \$opt_n, "name" => \$opt_n,
"w=s" => \$opt_w, "warning=s" => \$opt_w, "w=s" => \$opt_w, "warning=s" => \$opt_w,
"c=s" => \$opt_c, "critical=s" => \$opt_c, "c=s" => \$opt_c, "critical=s" => \$opt_c,
"H=s" => \$opt_H, "hostname=s" => \$opt_H); "H=s" => \$opt_H, "hostname=s" => \$opt_H,
"t=s" => \$opt_t);
if ($opt_V) { if ($opt_V) {
@ -142,8 +143,12 @@ my $name = $0;
$name =~ s/\.pl.*//g; $name =~ s/\.pl.*//g;
# Plugin snmp requests # Plugin snmp requests
my $OID_hrStorageDescr = "";
my $OID_hrStorageDescr =$oreon{MIB2}{HR_STORAGE_DESCR}; if (defined($opt_t) && ($opt_t eq "AIX" || $opt_t eq "AS400")){
$OID_hrStorageDescr = ".1.3.6.1.2.1.25.3.8.1.2";
} else {
$OID_hrStorageDescr = $oreon{MIB2}{HR_STORAGE_DESCR};
}
my $OID_hrStorageAllocationUnits = $oreon{MIB2}{HR_STORAGE_ALLOCATION_UNITS}; my $OID_hrStorageAllocationUnits = $oreon{MIB2}{HR_STORAGE_ALLOCATION_UNITS};
my $OID_hrStorageSize = $oreon{MIB2}{HR_STORAGE_SIZE}; my $OID_hrStorageSize = $oreon{MIB2}{HR_STORAGE_SIZE};
my $OID_hrStorageUsed = $oreon{MIB2}{HR_STORAGE_USED}; my $OID_hrStorageUsed = $oreon{MIB2}{HR_STORAGE_USED};
@ -188,12 +193,16 @@ if ($opt_n) {
$expr = "$opt_d"; $expr = "$opt_d";
} }
foreach my $key ( oid_lex_sort(keys %$result)) { foreach my $key ( oid_lex_sort(keys %$result)) {
if (defined($opt_t) && $opt_t eq "AS400"){
$result->{$key} =~ s/\ //g;
}
if ($result->{$key} =~ m/$expr/) { if ($result->{$key} =~ m/$expr/) {
my @oid_list = split (/\./,$key); my @oid_list = split (/\./,$key);
$partition = pop (@oid_list) ; $partition = pop (@oid_list) ;
} }
} }
} }
if ($opt_s) { if ($opt_s) {
# Get description table # Get description table
my $result = $session->get_table( my $result = $session->get_table(
@ -214,6 +223,7 @@ if ($opt_s) {
exit $ERRORS{'OK'}; exit $ERRORS{'OK'};
} }
my $result = $session->get_request( my $result = $session->get_request(
-varbindlist => [$OID_hrStorageDescr.".".$partition , -varbindlist => [$OID_hrStorageDescr.".".$partition ,
$OID_hrStorageAllocationUnits.".".$partition , $OID_hrStorageAllocationUnits.".".$partition ,
@ -228,6 +238,7 @@ if (!defined($result)) {
$session->close; $session->close;
exit $ERRORS{'UNKNOWN'}; exit $ERRORS{'UNKNOWN'};
} }
$hrStorageDescr = $result->{$OID_hrStorageDescr.".".$partition }; $hrStorageDescr = $result->{$OID_hrStorageDescr.".".$partition };
$AllocationUnits = $result->{$OID_hrStorageAllocationUnits.".".$partition }; $AllocationUnits = $result->{$OID_hrStorageAllocationUnits.".".$partition };
$Size = $result->{$OID_hrStorageSize.".".$partition }; $Size = $result->{$OID_hrStorageSize.".".$partition };
@ -274,6 +285,7 @@ if (($Size =~ /([0-9]+)/) && ($AllocationUnits =~ /([0-9]+)/)){
} }
if ($hrStorageDescr){ if ($hrStorageDescr){
$hrStorageDescr =~ s/\ //g if (defined($opt_t) && $opt_t eq "AS400");
print $hrStorageDescr . " TOTAL: "; print $hrStorageDescr . " TOTAL: ";
printf("%.3f", $tot); printf("%.3f", $tot);
print " Go USED: " . $pourcent . "% : "; print " Go USED: " . $pourcent . "% : ";