diff options
author | M.Gergő | 2020-05-25 20:58:03 +0200 |
---|---|---|
committer | M.Gergő | 2020-05-25 20:58:03 +0200 |
commit | 4caa9cd08547c7234b1153df7714e6bbfae8df25 (patch) | |
tree | b1773b6bc0337d287a85755a87e8e5d4171f473e /ubnt_unifi.php | |
parent | 1d7b680e6a21f1b524d54b08152801720827bce0 (diff) | |
download | munin-unifi-4caa9cd08547c7234b1153df7714e6bbfae8df25.tar.gz munin-unifi-4caa9cd08547c7234b1153df7714e6bbfae8df25.zip |
Added: Ping average option
Diffstat (limited to 'ubnt_unifi.php')
-rw-r--r-- | ubnt_unifi.php | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/ubnt_unifi.php b/ubnt_unifi.php index 08ad0fa..8ea4c38 100644 --- a/ubnt_unifi.php +++ b/ubnt_unifi.php @@ -373,8 +373,8 @@ return $ret; } -function collect_response_time($inp,$host){ //Calculates the response_time array from raw data - global $controller, $replace_chars, $hosts; +function collect_response_time($inp, $host){ //Calculates the Roundtrip time array from raw data + global $controller, $replace_chars; $ret = array(); if(isset($host) and $host !== null and $host != "" ){ @@ -397,30 +397,21 @@ function collect_response_time($inp,$host){ //Calculates the response_time arr $ret['g_vlabel'] = "Roundtrip time (seconds)"; $ret['g_category'] = "Wl_ping_all"; $ret['g_info'] = "ubnt_wireless"; - $ret['g_order'] = ''; - foreach($hosts as $key => $val){ //prints the host names on summary - $ret['g_order'] .= "unifi_ping_".str_replace( array(".", ":"), "_" ,$val)." "; + $ret['g_order'] = 'unifi_ping_average'; + foreach($inp as $key => $val){ //prints the host names on summary + $ret['g_order'] .= "unifi_ping_".str_replace( array(".", ":"), "_" ,$key)." "; } } - - if(isset($host) and $host !== null and $host != "" ){ // chunks the raw data to the current AP's data only $temp = $inp; unset($inp); $inp = array($host => $temp[$host]); unset($temp); } - - + $sum_time = 0; + $key = 0; foreach($inp as $key => $val){ - -// if( (isset($host) and $host !== null and $host != "") ){ //Replace label's text on AP's graph -// $key = "time"; -// $label= "Response Time"; -// } else { -// $label = $key; -// } $ret['head'][$key]['name'] = "ping_".str_replace( array(".", ":"), "_" ,$key); $ret['head'][$key]['label'] = $key; $ret['head'][$key]['draw'] = "LINE1.2"; @@ -429,8 +420,20 @@ function collect_response_time($inp,$host){ //Calculates the response_time arr $ret['head'][$key]['min'] = "0"; $ret['data'][$key]['name'] = "ping_".str_replace( array(".", ":"), "_" ,$key); - $ret['data'][$key]['value'] = round($val["response_time"], 7); - } + $ret['data'][$key]['value'] = round($val["response_time"], 7); + $sum_time += $ret['data'][$key]['value']; + } + $ret['head'][$key+1]['name'] = "ping_average"; + $ret['head'][$key+1]['label'] = "Average"; + $ret['head'][$key+1]['draw'] = "LINE1.2"; + $ret['head'][$key+1]['info'] = "Response Time"; + $ret['head'][$key+1]['type'] = "GAUGE"; + $ret['head'][$key+1]['min'] = "0"; + + if(count($inp) != 0){ + $ret['data'][$key+1]['value'] = $sum_time/count($inp); + $ret['data'][$key+1]['name'] = "ping_average"; + } return $ret; } |