Skip to content

Instantly share code, notes, and snippets.

@rluisr
Last active February 4, 2016 05:56
Show Gist options
  • Save rluisr/76bf3845a5daafdb40c7 to your computer and use it in GitHub Desktop.
Save rluisr/76bf3845a5daafdb40c7 to your computer and use it in GitHub Desktop.
Zabbixでsquidclient
<?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