Module: check_mk
Branch: master
Commit: fa513c2530c6bf6190f740e1bdadb7e9ef48746c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fa513c2530c6bf…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Apr 22 15:13:32 2016 +0200
3464 FIX netstat.linux: fix monitoring of UDP listeners
Thanks to Davice Delgrande.
---
.werks/3464 | 10 ++++++++++
ChangeLog | 1 +
agents/plugins/netstat.linux | 2 +-
checks/netstat | 16 ++++++++++++++--
4 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/.werks/3464 b/.werks/3464
new file mode 100644
index 0000000..f96f8ec
--- /dev/null
+++ b/.werks/3464
@@ -0,0 +1,10 @@
+Title: netstat.linux: fix monitoring of UDP listeners
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1461330784
+
+Thanks to Davice Delgrande.
diff --git a/ChangeLog b/ChangeLog
index 73e0baf..eb8226c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -180,6 +180,7 @@
* 3421 FIX: cisco_asa_failover: Do not discover interfaces where failover is not
enabled...
* 3422 FIX: printer_pages, canon_pages: Detect pages on Canon 8350 with generic
check...
* 3463 FIX: ups_modulys_alarms: avoid crash on some SOCOMEC UPS where some alarm OIDs
are empty
+ * 3464 FIX: netstat.linux: fix monitoring of UDP listeners...
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/agents/plugins/netstat.linux b/agents/plugins/netstat.linux
index f467d04..55a27ae 100755
--- a/agents/plugins/netstat.linux
+++ b/agents/plugins/netstat.linux
@@ -28,4 +28,4 @@
# have an execution time complexity of at least O(n^2) on Linux.
echo '<<<netstat>>>'
-netstat -ntu | egrep '^(tcp|udp)'
+netstat -ntua | egrep '^(tcp|udp)' | sed -e 's/LISTEN/LISTENING/g'
diff --git a/checks/netstat b/checks/netstat
index 48112b3..846bcf0 100644
--- a/checks/netstat
+++ b/checks/netstat
@@ -24,8 +24,11 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-# Example output from agent (Linux)
+# Example output from agent (Linux) - note missing LISTENING column for UDP
# <<netstat>>>
+# tcp 0 0 0.0.0.0:6556 0.0.0.0:* LISTENING
+# tcp 0 0 127.0.0.1:445 0.0.0.0:* LISTENING
+# tcp 0 0 10.1.1.50:445 0.0.0.0:* LISTENING
# tcp 0 0 127.0.0.1:57573 127.0.0.1:80 ESTABLISHED
# tcp 0 0 10.1.1.50:38692 178.248.246.154:993 ESTABLISHED
# tcp 0 0 127.0.0.1:34929 127.0.0.1:5000 TIME_WAIT
@@ -44,6 +47,9 @@
# tcp 0 0 127.0.0.1:34984 127.0.0.1:5000 TIME_WAIT
# tcp 0 0 127.0.0.1:80 127.0.0.1:57488 TIME_WAIT
# tcp 0 0 127.0.0.1:34967 127.0.0.1:5000 TIME_WAIT
+# udp 0 0 10.1.2.255:137 0.0.0.0:*
+# udp 0 0 10.1.2.160:137 0.0.0.0:*
+# udp 0 0 0.0.0.0:137 0.0.0.0:*
def parse_netstat(info):
connections = []
@@ -55,7 +61,13 @@ def parse_netstat(info):
elif proto.startswith("udp"):
proto = "UDP"
- connections.append( (proto, local.rsplit(":", 1),
remote.rsplit(":", 1),
+ if len(line) == 5: # handles UDP listeners
+ proto, recv_q, send_q, local, remote = line
+ if proto.startswith("udp"):
+ proto = "UDP"
+ connstate = "LISTENING"
+
+ connections.append( (proto, local.rsplit(":", 1),
remote.rsplit(":", 1),
connstate) )
return connections