From: Robin Roevens <robin.roevens@disroot.org>
To: development@lists.ipfire.org
Cc: Robin Roevens <robin.roevens@disroot.org>
Subject: [PATCH] zabbix_agentd: Fix gateway ping errorhandling
Date: Fri, 5 Jun 2026 23:28:30 +0200 [thread overview]
Message-ID: <20260605212830.1067298-1-robin.roevens@disroot.org> (raw)
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 <robin.roevens@disroot.org>
---
config/zabbix_agentd/userparameter_gateway.conf | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
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 $?
--
2.54.0
--
Dit bericht is gescanned op virussen en andere gevaarlijke
inhoud door MailScanner en lijkt schoon te zijn.
reply other threads:[~2026-06-05 21:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260605212830.1067298-1-robin.roevens@disroot.org \
--to=robin.roevens@disroot.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox