From: Robin Roevens Date: Fri, 5 Jun 2026 21:28:30 +0000 (+0200) Subject: zabbix_agentd: Fix gateway ping errorhandling X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0dcda07fec48da5f969ccc5ee771e0cf376ab328;p=ipfire-2.x.git zabbix_agentd: Fix gateway ping errorhandling Fixed gateway ping items: * ipfire.net.gateway.pingtime: now always returns 0 when fping does not return the expected stats * ipfire.net.gateway.ping: prevent possible stderr messages from slipping in the output * ipfire.net.gateway.arpingtime: now always return 0 when arping does not return the expected stats. * ipfire.net.gateway.arping: now effectively returns 0 when arping fails. Previously this returned the arping error making Zabbix fail to detect gateway down events. Signed-off-by: Robin Roevens Signed-off-by: Michael Tremer --- diff --git a/config/zabbix_agentd/userparameter_gateway.conf b/config/zabbix_agentd/userparameter_gateway.conf index cfae001ae..6f8d84c7b 100644 --- a/config/zabbix_agentd/userparameter_gateway.conf +++ b/config/zabbix_agentd/userparameter_gateway.conf @@ -2,11 +2,11 @@ # # ICMP Ping # Internet Gateway ping timings, can be used to measure "Internet Line Quality" -UserParameter=ipfire.net.gateway.pingtime,sudo /usr/sbin/fping -c 3 gateway 2>&1 | tail -n 1 | awk '{print $NF}' | cut -d '/' -f2 +UserParameter=ipfire.net.gateway.pingtime,output=$(sudo /usr/sbin/fping -c 3 gateway 2>&1) && echo "$output" | tail -n 1 | grep -q "xmt/rcv/%loss" && echo "$output" | tail -n 1 | awk '{print $NF}' | cut -d '/' -f2 || echo "0" # Internet Gateway availability, can be used to check Internet connection -UserParameter=ipfire.net.gateway.ping,sudo /usr/sbin/fping -q -r 3 gateway; [ ! $? == 0 ]; echo $? +UserParameter=ipfire.net.gateway.ping,sudo /usr/sbin/fping -q -r 3 gateway 2>/dev/null; [ ! $? == 0 ]; echo $? # ARP Ping # Internet Gateway ping timings, can be used to measure "Internet Line Quality" when ICMP ping is not available -UserParameter=ipfire.net.gateway.arpingtime,sudo /usr/sbin/arping -i red0 -c 3 gateway | awk 'match($0, /time=([0-9\.]+) (\w+)$/, arr) { n++; if (arr[2] == "usec") { arr[1]/=1000; }; sum+=arr[1] } END { print sum / n }' +UserParameter=ipfire.net.gateway.arpingtime,sudo /usr/sbin/arping -i red0 -c 3 gateway 2>/dev/null | awk 'match($0, /time=([0-9\.]+) (\w+)$/, arr) { n++; if (arr[2] == "usec") { arr[1]/=1000; }; sum+=arr[1] } END { if (n > 0) print sum / n; else print "0" }' # Internet Gateway availability, can be used to check Internet connection when ICMP ping is not available -UserParameter=ipfire.net.gateway.arping,sudo /usr/sbin/arping -q -c 3 gateway; [ ! $? == 0 ]; echo $? +UserParameter=ipfire.net.gateway.arping,sudo /usr/sbin/arping -q -c 3 gateway 2>/dev/null; [ ! $? == 0 ]; echo $?