From c9ec25539ef29ca331c4f2e3147810b3d05b4a7f Mon Sep 17 00:00:00 2001 From: Damian Gerow Date: Wed, 24 Sep 2014 19:03:10 +0000 Subject: [PATCH] bsd: Pass '-W' to netstat for full interface names on FreeBSD --- checks.d/network.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/checks.d/network.py b/checks.d/network.py index 26ef7242d1..e3c63df659 100644 --- a/checks.d/network.py +++ b/checks.d/network.py @@ -240,9 +240,17 @@ def _check_linux(self, instance): self.log.debug("Unable to read /proc/net/snmp.") def _check_bsd(self, instance): - netstat = subprocess.Popen(["netstat", "-i", "-b"], - stdout=subprocess.PIPE, - close_fds=True).communicate()[0] + platf = sys.platform + + # FreeBSD's netstat truncates device names unless you pass '-W' + if Platform.is_freebsd(platf): + netstat = subprocess.Popen(["netstat", "-i", "-b", "-W"], + stdout=subprocess.PIPE, + close_fds=True).communicate()[0] + else: + netstat = subprocess.Popen(["netstat", "-i", "-b"], + stdout=subprocess.PIPE, + close_fds=True).communicate()[0] # Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll # lo0 16384 318258 0 428252203 318258 0 428252203 0 # lo0 16384 localhost fe80:1::1 318258 - 428252203 318258 - 428252203 -