Module: check_mk
Branch: master
Commit: 63171b5d3f488d7d2b4ad0c34e3c07ae3a4d92fe
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=63171b5d3f488d…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Fri Mar 9 15:44:02 2018 +0100
5749 FIX tcp_conn_stats: use ss by default if present otherwise fall back to cat
/proc/net/tcp
Change-Id: I7c34ea6e80e69499c45e7de72d90e16fee8ad1a7
---
.werks/5749 | 10 ++++++++++
agents/check_mk_agent.linux | 8 ++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/.werks/5749 b/.werks/5749
new file mode 100644
index 0000000..3b4dd8f
--- /dev/null
+++ b/.werks/5749
@@ -0,0 +1,10 @@
+Title: tcp_conn_stats: use ss by default if present otherwise fall back to cat
/proc/net/tcp
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1520606516
+Class: fix
+
+
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 2d7a048..a0dbd70 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -420,12 +420,12 @@ fi
# Number of TCP connections in the various states
echo '<<<tcp_conn_stats>>>'
-if type waitmax >/dev/null ; then
+if type ss > /dev/null ; then
+ ss -ant |grep -v ^State | awk ' /:/ { c[$1]++; } END { for (x in c) { print x,
c[x]; } }' |sed -e
's/^ESTAB/01/g;s/^SYN-SENT/02/g;s/^SYN-RECV/03/g;s/^FIN-WAIT-1/04/g;s/^FIN-WAIT-2/05/g;s/^TIME-WAIT/06/g;s/^CLOSED/07/g;s/^CLOSE-WAIT/08/g;s/^LAST-ACK/09/g;s/^LISTEN/0A/g;s/^CLOSING/0B/g;'
+elif type waitmax >/dev/null ; then
THIS=$(waitmax -s 1 10 cat /proc/net/tcp /proc/net/tcp6 2>/dev/null | awk '
/:/ { c[$4]++; } END { for (x in c) { print x, c[x]; } }')
if [ $? == 0 ] ; then
- echo "$THIS"
- else
- ss -ant |grep -v ^State | awk ' /:/ { c[$1]++; } END { for (x in c) { print
x, c[x]; } }' |sed -e
's/^ESTAB/01/g;s/^SYN-SENT/02/g;s/^SYN-RECV/03/g;s/^FIN-WAIT-1/04/g;s/^FIN-WAIT-2/05/g;s/^TIME-WAIT/06/g;s/^CLOSED/07/g;s/^CLOSE-WAIT/08/g;s/^LAST-ACK/09/g;s/^LISTEN/0A/g;s/^CLOSING/0B/g;'
+ echo "$THIS"
fi
fi