From bd1302c3f2529be040af76547b241aa2bf96faf6 Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Sun, 12 Jul 2020 19:14:07 +0200 Subject: [PATCH] Plugin unifi_api: handle missing error fields in response It seems to be possible, that the response lacks the values for `rx_errors` and `tx_errors`. This should not result in warnings due to undefined values. Thanks, kboenke! Closes: #1095 --- plugins/ubiquiti/unifi_api | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/ubiquiti/unifi_api b/plugins/ubiquiti/unifi_api index d689a75d..003a8fc4 100755 --- a/plugins/ubiquiti/unifi_api +++ b/plugins/ubiquiti/unifi_api @@ -1033,7 +1033,7 @@ sub make_data { 'label' => $label . '-' . $thisDevice->{'name'}, 'pckt' => $_->{$name . '-rx_packets'} + $_->{$name . '-tx_packets'}, 'dret' => $_->{$name . '-rx_dropped'} + $_->{$name . '-tx_retries'} + $_->{$name . '-tx_dropped'}, - 'err' => $_->{$name . '-rx_errors'} + $_->{$name . '-tx_errors'}, + 'err' => ($_->{$name . '-rx_errors'} || 0) + ($_->{$name . '-tx_errors'} || 0), 'type' => $label }; } @@ -1209,4 +1209,4 @@ sub env_default_bool_true { } # Quick 2 digit zero pad -sub zPad { return sprintf("%02d", $_[0]); } \ No newline at end of file +sub zPad { return sprintf("%02d", $_[0]); }