Last active
February 4, 2016 05:56
-
-
Save rluisr/76bf3845a5daafdb40c7 to your computer and use it in GitHub Desktop.
Zabbixでsquidclient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Squid の File descriptor を引数で取得するもの | |
* Zabbix で 使ってください。 | |
*/ | |
/** | |
* @param string $host 第1引数 IPアドレス | |
* @param string $key 第2引数 maximum or largest or number or file or ..... | |
*/ | |
$host = $argv[1]; | |
$key = $argv[2]; | |
file_put_contents("result", shell_exec("squidclient -h ${host} mgr:info")); | |
$result = file("result"); | |
switch($key){ | |
case 'maximum': | |
$maximum = preg_replace("/\\D/", "", $result[72]); //Maximum number of file descriptors | |
echo $maximum; | |
break; | |
case 'largest': | |
$largest = preg_replace("/\\D/", "", $result[73]); //Largest file desc currently in use | |
echo $largest; | |
break; | |
case 'number': | |
$number = preg_replace("/\\D/", "", $result[74]); //Number of file desc currently in use | |
echo $number; | |
break; | |
case 'file': | |
$file = preg_replace("/\\D/", "", $result[75]); //Files queued for open | |
echo $file; | |
break; | |
case 'available': | |
$available = preg_replace("/\\D/", "", $result[76]); //Available number of file descriptors | |
echo $available; | |
break; | |
case 'reserved': | |
$reserved = preg_replace("/\\D/", "", $result[77]); //Reserved number of file descriptors | |
echo $reserved; | |
break; | |
case 'store': | |
$store = preg_replace("/\\D/", "", $result[78]); //Store Disk files open | |
echo $store; | |
break; | |
default: | |
die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment