diff options
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | ubnt_unifi.php | 10 |
2 files changed, 10 insertions, 7 deletions
@@ -65,11 +65,10 @@ For example: timeout 240 env.controller unifi.company.com env.devices ap01.wl.company.lan ap02.wl.company.lan ap03.wl.company.lan 10.10.1.6 10.10.1.7 10.10.1.8 - env.maxproc 32 env.devnetw 10.10.1.10/24 - env.timeout 500 - env.retry 1 - + env.timeout 850 + env.retry 3 + env.maxproc 32 diff --git a/ubnt_unifi.php b/ubnt_unifi.php index 1158190..e53d461 100644 --- a/ubnt_unifi.php +++ b/ubnt_unifi.php @@ -441,14 +441,14 @@ for ($p=0; $p<$maxproc; $p++){ //Starts child processes to retrieve SNMP data. } $null=""; - for($f=0; $f<(32768 - strlen(json_encode($raw))); $f++) + for($f=0; $f<(32768 - strlen(@json_encode($raw))); $f++) { $null .= "\0"; //Because the json_decode() error. } sem_acquire($sf); while(ord(shmop_read($shm, 0, 0)) ) {continue;} //waiting for master to pull the data - shmop_write($shm, json_encode($raw).$null, 0); + shmop_write($shm, @json_encode($raw).$null, 0); sem_release($sf); } exit; @@ -480,7 +480,7 @@ while(numchild($child, $maxproc)){ //Receive the raw data segments and wait for $ret = shmop_read($shm, 0, 0); //Read from shared memory if(ord($ret)){ $ret = preg_replace('/[[:cntrl:]]/', '', $ret); // for json_decode - $raw = array_merge($raw, json_decode($ret, true)); + $raw = @array_merge($raw, @json_decode($ret, true)); shmop_write($shm,"\0\0\0\0\0", 0); } usleep(100); // @@ -495,6 +495,10 @@ $hosts = $hostsr; //$test = collect_netw_summary($raw,"ap12.wireless.lan"); //print_r($test); +if(!is_array($raw)){ + die(); +} + if (isset($argv[1]) and $argv[1] == "config"){ // munin config print_header(collect_radio_summary($raw,null)); |