Module: check_mk
Branch: master
Commit: 572a42810c77cb56d6ddbc8c62b7f9a41987a211
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=572a42810c77cb…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Thu Jan 17 16:06:09 2019 +0100
7053 FIX tcp_conn_stat: resolve latency problems introduced by ss
On some systems the ss command used for the tcp_conn_stat check
introduced latency problems. To resolve this issue by default
now "cat /proc/net/tcp /proc/net/tcp6" is used again. ss is only
used as a fallback if cat runs into a timeout.
Additionally, the maximum waiting time for cat is reduced from
10s to 5s and SIGTERM is sent by waitmax instead of SIGHUP.
CMK-1352
Change-Id: I3b1af6faa2566ff86e6a764b9c395b059f6677f6
---
.werks/7053 | 17 +++++++++++++++++
agents/check_mk_agent.linux | 10 +++++-----
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/.werks/7053 b/.werks/7053
new file mode 100644
index 0000000..311cfaa
--- /dev/null
+++ b/.werks/7053
@@ -0,0 +1,17 @@
+Title: tcp_conn_stat: resolve latency problems introduced by ss
+Level: 1
+Component: checks
+Class: fix
+Compatible: incomp
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1547736918
+
+On some systems the ss command used for the tcp_conn_stat check
+introduced latency problems. To resolve this issue by default
+now "cat /proc/net/tcp /proc/net/tcp6" is used again. ss is only
+used as a fallback if cat runs into a timeout.
+
+Additionally, the maximum waiting time for cat is reduced from
+10s to 5s and SIGTERM is sent by waitmax instead of SIGHUP.
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 2baf6fa..cb8ce67 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -484,13 +484,13 @@ fi
# Number of TCP connections in the various states
-echo '<<<tcp_conn_stats>>>'
-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 type waitmax >/dev/null ; then
+ echo '<<<tcp_conn_stats>>>'
+ THIS=$(waitmax 5 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"
+ elif 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;'
fi
fi