diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | ubnt_unifi.php | 34 |
2 files changed, 30 insertions, 8 deletions
@@ -3,6 +3,10 @@ * Requires: * Enabled SNMP on AP's. * Network access from munin-server to AP's network. + * PHP 7.0 or above + * PHP SNMP module + * PHP JSON module + * Debian(9+): `sudo apt-get install php php-cgi php-snmp php-json` * It can use php child-processes to get responses faster. * If snmp oids are different on your product, you can use `snmpwalk -v2c -c public ap01.network.lan 'iso.3.6.1.4.1.41112'` command to clarify them. diff --git a/ubnt_unifi.php b/ubnt_unifi.php index 097b15c..00edda5 100644 --- a/ubnt_unifi.php +++ b/ubnt_unifi.php @@ -577,12 +577,13 @@ $hosts = $hostsr; //$test = collect_response_time($raw, "ap12.wireless.lan"); //print_r($test); -if(!is_array($raw)){ - die(); -} + if (isset($argv[1]) and $argv[1] == "config"){ // munin config + if(!is_array($raw) || empty($raw) ){ + die(); + } print_header(collect_radio_summary($raw,null)); foreach($hosts as $key => $val){ print_header(collect_radio_summary($raw,$val)); @@ -604,20 +605,37 @@ if (isset($argv[1]) and $argv[1] == "config"){ // munin config echo "\tRetry: ".$retry."\n"; echo "\tMaxproc: ".$maxproc."\n"; echo "\tDevices_network: ".$devnetw."\n"; - echo "\tDevice_hosts: \n"; - print_r($hosts); + echo "\tDevice_hosts: \n"; + foreach($hosts as $dgk => $dgv){ + echo "\t\tIP: ".gethostbyname($dgv)."\tHost: ".$dgv."\n"; + } echo "\nInternal: \n"; - echo "\tShared_mem_key: ".$shm_key."\n"; + echo "\tShared_key: ".$shm_key."\n"; + echo "\tShared_mem_key".$shm."\n"; + echo "\tSemaphore_key".$sf."\n"; + echo "\tFunction_exist(ftok): ".function_exists("ftok"); + echo "\tFunction_exist(shmop_open): ".function_exists("shmop_open"); + echo "\tFunction_exist(sem_get): ".function_exists("sem_get"); + echo "\tFunction_exist(pcntl_fork): ".function_exists("pcntl_fork"); + echo "\tFunction_exist(pcntl_waitpid): ".function_exists("pcntl_waitpid"); + echo "\tFunction_exist(json_encode): ".function_exists("json_encode"); echo "\nRAW\n"; print_r($raw); - echo "\nController:\n"; + echo "\nCollected infos on Controller:\n"; print_r(collect_radio_summary($raw,null)); print_r(collect_netw_summary($raw,null)); - print_r(collect_response_time($raw,null)); + print_r(collect_response_time($raw,null)); + + echo "\n Print test on Controller: \n"; + print_header(collect_radio_summary($raw,null)); + print_data(collect_radio_summary($raw,null)); } else { // munin data + if(!is_array($raw) || empty($raw) ){ + die(); + } print_data(collect_radio_summary($raw,null)); foreach($hosts as $key => $val){ print_data(collect_radio_summary($raw,$val)); |