--- check_hr_storage.orig 2009-03-05 11:31:24.000000000 +0000 +++ check_hr_storage 2009-08-14 12:28:56.000000000 +0100 @@ -65,6 +65,7 @@ my $volumeName; my $exact; my $warning; +my $percentmode; my $critical; my $currentOID = ''; my @snmpoids; @@ -73,6 +74,7 @@ my $size; my $used; my $free; +my $freepct; my $hrStorageDescr = '1.3.6.1.2.1.25.2.3.1.3'; my $hrStorageAllocationUnits = '1.3.6.1.2.1.25.2.3.1.4'; @@ -125,15 +127,25 @@ printf("Usage of %s is %.2f MB.\n", $volumeName, $size) if $DEBUG; $free = $size - $used; + $freepct = ( ( $free / $size ) * 100); - if ( $free < $critical ) { - $state = 'CRITICAL'; - } elsif ( $free < $warning ) { - $state = 'WARNING'; + if (defined $percentmode) { + if ( $freepct < $critical ) { + $state = 'CRITICAL'; + } elsif ( $freepct < $warning ) { + $state = 'WARNING'; + } else { + $state = 'OK'; + } } else { - $state = 'OK'; + if ( $free < $critical ) { + $state = 'CRITICAL'; + } elsif ( $free < $warning ) { + $state = 'WARNING'; + } else { + $state = 'OK'; + } } - printf("%s: %.2f MB free|size=%.2f used=%.2f free=%.2f\n", $state, $free, $size, $used, $free); } @@ -220,6 +232,7 @@ printf " -U (--secname) username for SNMPv3 context\n"; printf " -w (--warning) amount of memory (in MB)\n"; printf " -c (--critical) amount of memory (in MB)\n"; + printf " -P (--percentmode) thresholds above given as a percentage of total\n"; printf " -A (--authpass) authentication password (cleartext ascii or localized key\n"; printf " in hex with 0x prefix generated by using \"snmpkey\" utility\n"; printf " auth password and authEngineID\n"; @@ -246,6 +259,7 @@ "h" => \$opt_h, "help" => \$opt_h, "l" => \$list, "list" => \$list, "e" => \$exact, "exact" => \$exact, + "P" => \$percentmode, "percentmode" => \$percentmode, "v=i" => \$snmp_version, "snmp_version=i" => \$snmp_version, "C=s" => \$community, "community=s" => \$community, "L=s" => \$seclevel, "seclevel=s" => \$seclevel,