Fix some unifi stats for uap/usw in recent unifi versions

This commit is contained in:
Daniel Berteaud 2019-10-20 18:16:04 +02:00
parent 331090fe0c
commit 05624ee2e1
1 changed files with 14 additions and 7 deletions

View File

@ -121,13 +121,6 @@ if ($unifi){
cfgversion adopted avg_client_signal/){
$json->{$_} = $obj->{$_} if (defined $obj->{$_});
}
foreach (qw/guest-rx_packets guest-tx_packets guest-rx_bytes
guest-tx_bytes user-rx_packets user-tx_packets
user-rx_bytes user-tx_bytes rx_packets tx_packets
rx_bytes tx_bytes rx_errors tx_errors
rx_dropped tx_dropped/){
$json->{net_stats}->{$_} = $obj->{stat}->{$_} if (defined $obj->{stat}->{$_});
}
# Convert last seen into a relative time
$json->{last_seen} = time - $obj->{last_seen};
# Add some more info in sys_stats
@ -136,6 +129,14 @@ if ($unifi){
# If this is an ap
if ($obj->{type} eq 'uap'){
foreach (qw/guest-rx_packets guest-tx_packets guest-rx_bytes
guest-tx_bytes user-rx_packets user-tx_packets
user-rx_bytes user-tx_bytes rx_packets tx_packets
rx_bytes tx_bytes rx_errors tx_errors
rx_dropped tx_dropped/){
$json->{net_stats}->{$_} = $obj->{stat}->{ap}->{$_} if (defined $obj->{stat}->{ap}->{$_});
}
# Count the number of SSID served
$json->{num_wlan} = scalar @{$obj->{radio_table}};
@ -167,6 +168,12 @@ if ($unifi){
undef : $json->{'avg_' . $_ . '_rate_' . $proto} / $json->{'num_sta_' . $proto}
foreach (qw/tx rx/);
}
} elsif ($obj->{type} eq 'usw'){
foreach (qw/rx_packets tx_packets
rx_bytes tx_bytes rx_errors tx_errors
rx_dropped tx_dropped/){
$json->{net_stats}->{$_} = $obj->{stat}->{sw}->{$_} if (defined $obj->{stat}->{sw}->{$_});
}
}
} elsif ($station) {
# Client is identified by MAC