aboutsummaryrefslogtreecommitdiffstats
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
parent3eadef4bb31e4ff39ce0b54dd7f3197aee6f8f24 (diff)
downloadmunin-unifi-41526163a28cb5c9960020a7392b21871650e2da.tar.gz
munin-unifi-41526163a28cb5c9960020a7392b21871650e2da.zip
some error handling
-rw-r--r--README.md7
-rw-r--r--ubnt_unifi.php10
2 files changed, 10 insertions, 7 deletions
diff --git a/README.md b/README.md
index 1712338..2c8481c 100644
--- a/README.md
+++ b/README.md
@@ -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));