From 54db99c38b065ef81c07b3fd3ebd8436bc1a8449 Mon Sep 17 00:00:00 2001 From: M.Gergő Date: Tue, 5 Feb 2019 22:18:03 +0100 Subject: better error handling --- ubnt_unifi.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ubnt_unifi.php') diff --git a/ubnt_unifi.php b/ubnt_unifi.php index e53d461..648a4c0 100644 --- a/ubnt_unifi.php +++ b/ubnt_unifi.php @@ -44,6 +44,10 @@ function print_header($inp){ // prints Munin-config data from processed data arr function print_data($inp) { + + if(!array_key_exists('data', $inp) or !array_key_exists('g_multi', $inp)){ + return; + } $pf = "multigraph unifi_".$inp['g_multi']."\n"; foreach($inp['data'] as $key => $val){ @@ -77,6 +81,10 @@ function count_wl_networks($inp){ //Count wireless networks from interfade data function collect_radio_summary($inp,$host){ global $controller, $replace_chars; $ret = array(); + if(!array_key_exists($host, $inp)){ + return $ret; + } + if(isset($host) and $host !== null and $host != "" ){ $ret['g_multi'] = "radio_".str_replace( array(".", ":"), "_" ,$controller).".".str_replace( array(".", ":"), "_" ,$host); $ret['g_controller'] = $controller; @@ -177,6 +185,9 @@ return $ret; function collect_netw_summary($inp,$host){ //network information global $controller, $replace_chars; $ret = array(); + if(!array_key_exists($host, $inp)){ + return $ret; + } if(isset($host) and $host !== null and $host != "" ){ // When showing the Ap's summary. $temp = $inp; -- cgit v1.2.3