Module: check_mk
Branch: master
Commit: abcf3ea751e29e94f0a22d8cbe670ca139104764
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=abcf3ea751e29e…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Tue Jan 17 15:00:57 2017 +0100
4187 FIX check_mk_agent.linux: better performance for tcp connections query
The previously method to get information about tcp connections will slow
down if the host is under heavy load. The new option to get these information
will be more stable in this point. The legacy method (cat /proc/net/tcp) will
still be used for older linux distributions, where ss may not be available.
Change-Id: If3b8405b956ee33f0481ba4167e41d36d5d968d9
---
.werks/4187 | 12 ++++++++++++
agents/check_mk_agent.linux | 9 ++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/.werks/4187 b/.werks/4187
new file mode 100644
index 0000000..0d3344e
--- /dev/null
+++ b/.werks/4187
@@ -0,0 +1,12 @@
+Title: check_mk_agent.linux: better performance for tcp connections query
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.4.0i4
+Date: 1484661608
+Class: fix
+
+The previously method to get information about tcp connections will slow
+down if the host is under heavy load. The new option to get these information
+will be more stable in this point. The legacy method (cat /proc/net/tcp) will
+still be used for older linux distributions, where ss may not be available.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index cecb049..4e1ec35 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -386,7 +386,14 @@ fi
# Number of TCP connections in the various states
echo '<<<tcp_conn_stats>>>'
-cat /proc/net/tcp /proc/net/tcp6 2>/dev/null | awk ' /:/ { c[$4]++; } END { for (x
in c) { print x, c[x]; } }'
+if 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;'
+ fi
+fi
# Linux Multipathing
if type multipath >/dev/null ; then