aboutsummaryrefslogtreecommitdiffstats
path: root/ubnt_unifi.php
diff options
context:
space:
mode:
authorM.Gergő2019-02-05 00:38:32 +0100
committerM.Gergő2019-02-05 00:38:32 +0100
commit41526163a28cb5c9960020a7392b21871650e2da (patch)
treeeea765ab001f08f8711b2b421b77aa0dbfe0a1bb /ubnt_unifi.php
parent3eadef4bb31e4ff39ce0b54dd7f3197aee6f8f24 (diff)
downloadmunin-unifi-41526163a28cb5c9960020a7392b21871650e2da.tar.gz
munin-unifi-41526163a28cb5c9960020a7392b21871650e2da.zip
some error handling
Diffstat (limited to 'ubnt_unifi.php')
-rw-r--r--ubnt_unifi.php10
1 files changed, 7 insertions, 3 deletions
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));