Module: check_mk
Branch: master
Commit: c6b94e02bd2d3cc6b0306e8a68b9567355b8c425
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c6b94e02bd2d3c…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Tue Jul 23 11:48:41 2013 +0200
win_netstat: new checkgroup params min_states/max_states. add english language for basic
states
---
checkman/win_netstat | 9 +++++++--
checks/win_netstat | 37 +++++++++++++++++++++++++++++-----
web/plugins/wato/check_parameters.py | 19 +++++++++++++++++
3 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/checkman/win_netstat b/checkman/win_netstat
index 3c1f0ab..f49a580 100644
--- a/checkman/win_netstat
+++ b/checkman/win_netstat
@@ -66,7 +66,12 @@ parameters (dict): A dictionary with the following keys, all of which
are
{"proto"} {TCP} or {UDP} are possible values:
The protocol used for the connection or the listener.
- {"state"} {"ESTABLISHED"}, {"LISTEN"},
{"TIME_WAIT"}, {"SYN_SENT"}, {"SYN_RECV"},
+ {"state"} {"ESTABLISHED"}, {"LISTENING"},
{"TIME_WAIT"}, {"SYN_SENT"}, {"SYN_RECV"},
{"LAST_ACK"}, {"CLOSE_WAIT"}, {"TIME_WAIT"},
{"CLOSED"}, {"CLOSING"}, {"FIN_WAIT1"},
{"FIN_WAIT2"},
or {"BOUND"}: The expected state of the TCP/UDP socket. You most probably
will use either
- {"ESTABLISHED"} or {"LISTEN"}.
+ {"ESTABLISHED"} or {"LISTENING"}.
+
+ {"min_states"} Tuple(warn, crit) The minimum allowed entries of the required
state
+
+ {"min_states"} Tuple(warn, crit) The maximum allowed entries of the required
state
+
diff --git a/checks/win_netstat b/checks/win_netstat
index 5cdba4a..4b221f6 100644
--- a/checks/win_netstat
+++ b/checks/win_netstat
@@ -53,11 +53,17 @@
# UDP 127.0.0.1:1900 *:*
win_netstat_states = {
- "ABH\x99REN" : "LISTEN",
+ # German
+ "ABH\x99REN" : "LISTENING",
"HERGESTELLT" : "ESTABLISHED",
"WARTEND" : "TIME_WAIT",
# Add further states in any required language here. Sorry, Windows
# has no "unset LANG" ;-)
+
+ # English
+ "LISTENING" : "LISTENING",
+ "ESTABLISHED" : "ESTABLISHED",
+ "TIME_WAIT" : "TIME_WAIT",
}
@@ -105,11 +111,32 @@ def check_win_netstat(item, params, info):
if match:
found += 1
- if found:
- state = 0
- else:
+ # Check if found connections are within limits
+ state = 0
+ extra_info = ""
+
+ if params["min_states"]:
+ min_warn, min_crit = params["min_states"]
+ if found <= min_crit:
+ state = max(state, 2)
+ extra_info += '(!!) Minimum at %d ' % min_crit
+ elif found <= min_warn:
+ state = max(state, 1)
+ extra_info += '(!) Minimum at %d ' % min_warn
+
+ if params["max_states"]:
+ max_warn, max_crit = params["max_states"]
+ if found >= max_crit:
+ state = max(state, 2)
+ extra_info += '(!!) Maximum at %d ' % max_crit
+ elif found >= max_warn:
+ state = max(state, 1)
+ extra_info += '(!) Maximum at %d ' % max_warn
+
+ if not found:
state = 2
- return state, "Found %d matching entries" % found
+
+ return state, "Found %d matching entries %s" % (found, extra_info)
check_info["win_netstat"] = {
'check_function' : check_win_netstat,
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 1381579..93084e8 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -1184,6 +1184,7 @@ register_check_parameters(
title = _("State"),
choices = [
( "ESTABLISHED", "ESTABLISHED" ),
+ ( "LISTENING", "LISTENING" ),
( "SYN_SENT", "SYN_SENT" ),
( "SYN_RECV", "SYN_RECV" ),
( "LAST_ACK", "LAST_ACK" ),
@@ -1201,6 +1202,24 @@ register_check_parameters(
( "local_port", Integer(title = _("Local port number"),
minvalue = 1, maxvalue = 65535, )),
( "remote_ip", IPv4Address(title = _("Remote IP
address"))),
( "remote_port", Integer(title = _("Remote port number"),
minvalue = 1, maxvalue = 65535, )),
+ ( "min_states",
+ Tuple(
+ title = _("Number of minimum connections or listeners"),
+ elements = [
+ Integer(title = _("Warning at")),
+ Integer(title = _("Critical at")),
+ ],
+ ),
+ ),
+ ( "max_states",
+ Tuple(
+ title = _("Number of maximum connections or listeners"),
+ elements = [
+ Integer(title = _("Warning at")),
+ Integer(title = _("Critical at")),
+ ],
+ ),
+ ),
]
),
TextAscii(title = _("Connection name"), help = _("Specify an arbitrary
name of this connection here"), allow_empty = False),