diff --git a/check_phpapc b/check_phpapc index 20f1f0e..47477a3 100755 --- a/check_phpapc +++ b/check_phpapc @@ -10,7 +10,7 @@ $service_name = "PHP-APC"; $wget_or_curl_command = "wget -O - -q "; ## read arguments/set default thresholds -$options = getopt("U:f:m:"); +$options = getopt("U:f:m:H:"); if (isset($options["U"])) { $url = $options["U"]; } else { @@ -26,6 +26,11 @@ if (isset($options["f"])) { } else { $frag_pct_max = 5; } +if (isset($options["H"])) { + $hits_pct_min = $options["H"]; +} else { + $hits_pct_min = 80 ; +} ## fetch APC stats from apc.php $cmd = $wget_or_curl_command.$url; @@ -46,6 +51,10 @@ if (preg_match_all('/Host Status Diagrams.*Free:\s+(\S+\s\S+)\s+\((\S+)%\).*Hits $frag_pct = $matches[9][0]; ## check APC stats against thresholds + $output[] = $hits_pct."% hits"; + if ($hits_pct < $hits_pct_min) { + if ($status < 2) { $status=1; } + } $output[] = $used_pct."% used mem"; if ($used_pct >= $used_pct_max) { if ($status < 2) { $status=1; } @@ -75,7 +84,7 @@ exit($status); ######### function usage() { - echo "Usage: check_phpapc -U [-m ] [-f ]\n"; - echo "Usage example: check_phpapc -U http://admin.com/apc.php -m 90 -f 10\n"; + echo "Usage: check_phpapc -U [-m ] [-f ] [-H ]\n"; + echo "Usage example: check_phpapc -U http://admin.com/apc.php -m 90 -f 10 -H 90\n"; exit(1); }