Module: check_mk
Branch: master
Commit: af8e3259cd6a32b9951d6a298bf81d8a4faa773b
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=af8e3259cd6a32…
Author: Marcel Arentz <ma(a)mathias-kettner.de>
Date: Thu Jun 21 12:28:07 2018 +0200
Removed ooutdated and missleading description
Change-Id: I4cbdf22254d8574065a3fb951f87163928fa3e2f
---
web/plugins/sidebar/nagvis_maps.py | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/web/plugins/sidebar/nagvis_maps.py b/web/plugins/sidebar/nagvis_maps.py
index 020c91a..ef9f815 100644
--- a/web/plugins/sidebar/nagvis_maps.py
+++ b/web/plugins/sidebar/nagvis_maps.py
@@ -33,9 +33,7 @@ def render_nagvis_maps():
sidebar_snapins["nagvis_maps"] = {
"title": _("NagVis Maps"),
- "description": _("List of available NagVis maps. This only works with NagVis 1.5 and above. " \
- "At the moment it is neccessarry to authenticate with NagVis first by opening " \
- "a NagVis map in the browser. After this the maplist should be filled."),
+ "description": _("List of available NagVis maps. This only works with NagVis 1.5 and above. "),
"render": render_nagvis_maps,
"allowed": [ "user", "admin", "guest" ],
"refresh": True,
Module: check_mk
Branch: master
Commit: 889e4a4eea56e9b00f42ad8838367cfa753bd672
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=889e4a4eea56e9…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Jun 22 16:02:21 2018 +0200
6222 FIX Fix exception during event rewriting, causing events for missing expected messages failing to be created
This issue had been introduced with Werk #5254
Change-Id: I488b51f231596aa412ddec0a740a1f0a3adbf0dc
---
.werks/6222 | 11 +++++++++++
cmk/ec/main.py | 4 ++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/.werks/6222 b/.werks/6222
new file mode 100644
index 0000000..1ecc02d
--- /dev/null
+++ b/.werks/6222
@@ -0,0 +1,11 @@
+Title: Fix exception during event rewriting, causing events for missing expected messages failing to be created
+Level: 1
+Component: ec
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1529675772
+
+This issue had been introduced with Werk #5254
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index f6fd0e4..fcf02ea 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -1271,7 +1271,7 @@ class EventServer(ECServerThread):
merge_event["text"] = text
# Better rewrite (again). Rule might have changed. Also we have changed
# the text and the user might have his own text added via set_text.
- self.rewrite_event(rule, merge_event, ())
+ self.rewrite_event(rule, merge_event, {})
self._history.add(merge_event, "COUNTFAILED")
else:
# Create artifical event from scratch. Make sure that all important
@@ -1295,7 +1295,7 @@ class EventServer(ECServerThread):
"match_groups_syslog_application": (),
}
self._add_rule_contact_groups_to_event(rule, event)
- self.rewrite_event(rule, event, ())
+ self.rewrite_event(rule, event, {})
self._event_status.new_event(event)
self._history.add(event, "COUNTFAILED")
cmk.ec.actions.event_has_opened(self._history, self.settings, self._config, self._logger, self, self._event_columns, rule, event)
Module: check_mk
Branch: master
Commit: 1ba100ce0d13001d7c6198e127927739c840e305
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1ba100ce0d1300…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Jun 21 07:53:58 2018 +0200
use new checktestlib objects in 'test_statgrab_cpu_check.py'
Change-Id: I77350fdaaa95715c06e1ea51b8ff2a9b5900784a
---
tests/unit/checks/checktestlib.py | 4 +
tests/unit/checks/test_statgrab_cpu_check.py | 129 +++++++++++++++++++++------
2 files changed, 107 insertions(+), 26 deletions(-)
diff --git a/tests/unit/checks/checktestlib.py b/tests/unit/checks/checktestlib.py
index 35aeb20..85ad02c 100644
--- a/tests/unit/checks/checktestlib.py
+++ b/tests/unit/checks/checktestlib.py
@@ -300,6 +300,8 @@ class MockItemState(object):
In all of these cases, the sanity of the returned values is checked
(i.e. they have to be BasicItemState).
+
+ See for example 'test_statgrab_cpu_check.py'.
"""
TARGET = 'cmk_base.item_state._cached_item_states.get_item_state'
@@ -364,6 +366,8 @@ class assertMKCounterWrapped(object):
with assertMKCounterWrapped():
# do a check that raises such an exception
run_my_check()
+
+ See for example 'test_statgrab_cpu_check.py'.
"""
def __init__(self, msg=None):
self.msg = msg
diff --git a/tests/unit/checks/test_statgrab_cpu_check.py b/tests/unit/checks/test_statgrab_cpu_check.py
index 96e3d0d..a3a47e7 100644
--- a/tests/unit/checks/test_statgrab_cpu_check.py
+++ b/tests/unit/checks/test_statgrab_cpu_check.py
@@ -1,33 +1,110 @@
import pytest
-from cmk_base.check_api import MKCounterWrapped
-import checktestlib
+from checktestlib import BasicCheckResult, CheckResult, \
+ assertCheckResultsEqual, BasicItemState, \
+ MockItemState, assertMKCounterWrapped
pytestmark = pytest.mark.checks
-info_statgrab_cpu_hpux = lambda t: [[u'idle', u'%d' % int(t*5)],
- [u'iowait', u'%d' % int(t*5)],
- [u'kernel', u'%d' % int(t*5)],
- [u'nice', u'%d' % int(t*5)],
- [u'swap', u'0'],
- [u'systime', u'%d' % int(t*5)],
- [u'total', u'%d' % int(t*30)],
- [u'user', u'%d' % int(t*5)]]
-
-(a)pytest.mark.parametrize("time_to_info,params,predicate", [
-(info_statgrab_cpu_hpux, {}, lambda cr: ("user", 40.0) in cr.perfdata and # TODO: This only represents the status quo - check whether this even makes sense.
- ("system", 20.0) in cr.perfdata and # Note that systime and total are being ignored entirely by the check.
- ("wait", 20.0) in cr.perfdata
- ),
+info_statgrab_cpu_hpux = [
+ [u'idle', u'300'],
+ [u'iowait', u'300'],
+ [u'kernel', u'300'],
+ [u'nice', u'300'],
+ [u'swap', u'0'],
+ [u'systime', u'300'],
+ [u'total', u'1800'],
+ [u'user', u'300'],
+]
+
+
+# If mock_state is a tuple, it is returned upon
+# every call to `get_item_state`. Let's say
+# The check ran 23 seconds ago, and all values
+# were zero:
+mock_state_tuple = (23., 0)
+
+
+# If mock_state is a dictionary, the values will
+# be returned according to their key,
+# as you would expect.
+mock_state_dict = {
+ 'cpu.util.1' : (3, 200), # user
+ 'cpu.util.2' : (1, 320), # nice
+ 'cpu.util.3' : (4, 100),# system
+ 'cpu.util.4' : (1, -123),# idle
+ 'cpu.util.5' : (5, 1000),# iowait
+ 'cpu.util.6' : (9, 3),# irq
+ 'cpu.util.7' : (2, 33),# softirq
+ 'cpu.util.8' : (6, 122),# steal
+ 'cpu.util.9' : (5, 300),# guest
+ 'cpu.util.10': (3, 300),# guest_nice
+}
+
+
+# If mock_state is a function, it must accept two
+# arguments, just like dict.get:
+def mock_state_function(key, _default):
+ counter = int(key.split('.')[-1])
+ return (23, (counter < 6) * 300)
+
+
+# TODO: These only represent the status quo - check whether they even make sense.
+# Note that systime and total are being ignored entirely by the check.
+expected_result_1 = CheckResult([
+ BasicCheckResult(0, "user: 40.0%, system: 20.0%",
+ [('user', 40.0, None, None, None, None),
+ ('system', 20.0, None, None, None, None),
+ ('wait', 20.0, None, None, None, None)]),
+ BasicCheckResult(0, "wait: 20.0%", None),
+ BasicCheckResult(0, "steal: 0.0%",
+ [('steal', 0.0, None, None, None, None)]),
+ BasicCheckResult(0, "total: 80.0%", None)
+])
+
+
+expected_result_2 = CheckResult([
+ BasicCheckResult(0, "user: -51.6%, system: -105.8%",
+ [('user', -51.61290322580645, None, None, None, None),
+ ('system', -105.80645161290323, None, None, None, None),
+ ('wait', 451.61290322580646, None, None, None, None)]),
+ BasicCheckResult(0, "wait: 451.6%", None),
+ BasicCheckResult(0, "steal: 78.7%",
+ [('steal', 78.70967741935483, None, None, None, None)]),
+ BasicCheckResult(0, "total: 372.9%", None)
+])
+
+
+(a)pytest.mark.parametrize("info,mockstate,expected_result", [
+(info_statgrab_cpu_hpux, mock_state_tuple, expected_result_1),
+(info_statgrab_cpu_hpux, mock_state_dict, expected_result_2),
])
-def test_statgrab_cpu_check(check_manager, time_to_info, params, predicate):
+def test_statgrab_cpu_check(check_manager, info, mockstate, expected_result):
+
check = check_manager.get_check("statgrab_cpu")
- # NOTE: We do not mock the time module here, because the check does not depend on any
- # absolute rates. The mocking that was included in this test previously had no
- # effect, which went unnoticed because it doesn't matter in this case.
- try:
- list(check.run_check(None, params, time_to_info(0)))
- except MKCounterWrapped:
- pass
- result = checktestlib.CheckResult(check.run_check(None, params, time_to_info(60)))
- assert predicate(result)
+
+ # set up mocking of `get_item_state`
+ with MockItemState(mockstate):
+ result = CheckResult(check.run_check(None, {}, info))
+ assertCheckResultsEqual(result, expected_result)
+
+
+(a)pytest.mark.parametrize("info,mockstate", [
+(info_statgrab_cpu_hpux, mock_state_function),
+])
+def test_statgrab_cpu_check_error(check_manager, info, mockstate):
+
+ check = check_manager.get_check("statgrab_cpu")
+
+ with MockItemState(mockstate):
+ # the mock values are designed to raise an exception.
+ # to make sure it is raised, use this:
+ with assertMKCounterWrapped('Too short time difference since last check'):
+ CheckResult(check.run_check(None, {}, info))
+ # # You could omit the error message it you don't care about it:
+ # with assertMKCounterWrapped()
+ # CheckResult(check.run_check(None, {}, info))
+
+
+
+
Module: check_mk
Branch: master
Commit: 789d48ab9851cf64750ee1667b2b3ba7eb357af6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=789d48ab9851cf…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed May 23 11:36:29 2018 +0200
Remove '<<<check_mk>>>' section from agent output.
The section is renamed to '<<<esx_systeminfo>>>' and the
keys are changed to the more appropriate 'apiVersion' and 'name'.
These are also used in agent_vsphere.
Change-Id: Id8ae9d4f3a795bfcd2f51f318a9586e7a4d90e8b
---
agents/special/agent_vsphere.pysphere | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/agents/special/agent_vsphere.pysphere b/agents/special/agent_vsphere.pysphere
index 6389333..b3d8fa9 100755
--- a/agents/special/agent_vsphere.pysphere
+++ b/agents/special/agent_vsphere.pysphere
@@ -250,9 +250,11 @@ if error:
esx_version = host.get_api_version()
esx_version_num = float(esx_version)
-print "<<<check_mk>>>"
-print "Version: %s" % esx_version
-print "AgentOS: %s " % host.get_server_type()
+# use the same section and keys as in
+# agent_vsphere
+print "<<<esx_systeminfo>>>"
+print "apiVersion %s" % esx_version
+print "name %s" % host.get_server_type()
# Prepare list of all hosts systems
all_hosts = host.get_hosts()
Module: check_mk
Branch: master
Commit: 512377b92168c8b75a20998e550ed24b8da36429
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=512377b92168c8…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed Jun 20 13:30:03 2018 +0200
Add support for counter mockery
Change-Id: I30b0c7b373da385f95f6b90663fd0e3970f8011c
---
tests/unit/checks/checktestlib.py | 118 ++++++++++++++++++++++++++++++++++++++
1 file changed, 118 insertions(+)
diff --git a/tests/unit/checks/checktestlib.py b/tests/unit/checks/checktestlib.py
index 98bfafc..35aeb20 100644
--- a/tests/unit/checks/checktestlib.py
+++ b/tests/unit/checks/checktestlib.py
@@ -1,4 +1,6 @@
import types
+import mock
+from cmk_base.item_state import MKCounterWrapped
class Tuploid(object):
@@ -262,3 +264,119 @@ class BasicItemState(object):
# We want to ba able to test time anomalies.
+class MockItemState(object):
+ """Mock the calls to item_state API.
+
+ Due to our rather unorthodox import structure, we cannot mock
+ cmk_base.item_state.get_item_state directly (it's a global var
+ in running checks!)
+ Instead, this context manager mocks
+ cmk_base.item_state._cached_item_states.get_item_state.
+
+ This will affect get_rate and get_average as well as
+ get_item_state.
+
+ Usage:
+
+ with MockItemState(mock_state):
+ # run your check test here
+ mocked_time_diff, mocked_value = \
+ cmk_base.item_state.get_item_state('whatever_key', default="IGNORED")
+
+ There are three different types of arguments to pass to MockItemState:
+
+ 1) Tuple or a BasicItemState:
+ The argument is assumed to be (time_diff, value). All calls to the
+ item_state API behave as if the last state had been `value`, recorded
+ `time_diff` seeconds ago.
+
+ 2) Dictionary containing Tuples or BasicItemStates:
+ The dictionary will replace the item states.
+ Basically `get_item_state` gets replaced by the dictionarys GET method.
+
+ 3) Callable object:
+ The callable object will replace `get_item_state`. It must accept two
+ arguments (key/default), in same way a dictionary does.
+
+ In all of these cases, the sanity of the returned values is checked
+ (i.e. they have to be BasicItemState).
+ """
+ TARGET = 'cmk_base.item_state._cached_item_states.get_item_state'
+
+ def __init__(self, mock_state):
+ self.context = None
+ self.get_val_function = None
+
+ if hasattr(mock_state, '__call__'):
+ self.get_val_function = mock_state
+ return
+
+ type_mock_state = type(mock_state)
+ allowed_types = (tuple, BasicItemState, dict)
+ assert type_mock_state in allowed_types, \
+ "type must be in %r, or callable - not %r" % \
+ (allowed_types, type_mock_state)
+
+ # in dict case check values
+ if type_mock_state == dict:
+ msg = "dict values must be in %r - not %r"
+ allowed_types = (tuple, BasicItemState)
+ for v in mock_state.values():
+ tyv = type(v)
+ assert tyv in allowed_types, msg % (allowed_types, tyv)
+ self.get_val_function = mock_state.get
+ else:
+ self.get_val_function = lambda key, default: mock_state
+
+
+ def __call__(self, user_key, default=None):
+ # ensure the default value is sane
+ BasicItemState(default)
+ val = self.get_val_function(user_key, default)
+ if not isinstance(val, BasicItemState):
+ val = BasicItemState(val)
+ return val.time_diff, val.value
+
+ def __enter__(self):
+ '''The default context: just mock get_item_state'''
+ self.context = mock.patch(MockItemState.TARGET,
+ # I'm the MockObj myself!
+ new_callable=lambda: self)
+ return self.context.__enter__()
+
+ def __exit__(self, *exc_info):
+ return self.context.__exit__(*exc_info)
+
+
+class assertMKCounterWrapped(object):
+ """Contextmanager in which a MKCounterWrapped exception is expected
+
+ If you can choose to also assert a certain error message:
+
+ with MockItemState((1., -42)):
+ with assertMKCounterWrapped("value is negative"):
+ # do a check that raises such an exception
+ run_my_check()
+
+ Or you can ignore the exact error message:
+
+ with MockItemState((1., -42)):
+ with assertMKCounterWrapped():
+ # do a check that raises such an exception
+ run_my_check()
+ """
+ def __init__(self, msg=None):
+ self.msg = msg
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, ty, ex, tb):
+ if ty is AssertionError:
+ raise
+ assert ty is not None, "No exception has occurred!"
+ assert ty == MKCounterWrapped, "%r is not of type %r" % (ex, MKCounterWrapped)
+ if self.msg is not None:
+ assert self.msg == str(ex), "%r != %r" % (self.msg, str(ex))
+ return True
+
Module: check_mk
Branch: master
Commit: 227a930fa3bcdde1741ab059a9b8bfc15dfafc3e
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=227a930fa3bcdd…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Jun 22 10:41:38 2018 +0200
Unified winperf_tcp_conn and tcp_conn_stats check plugins
Change-Id: I775697992f6f65c89a71cd8438ecfa7a7c787cfa
---
checks/tcp_conn_stats | 30 +++++++++++++++---
checks/tcp_connections.include | 70 ++++++++++++------------------------------
checks/winperf_tcp_conn | 57 +++++++++++++---------------------
3 files changed, 66 insertions(+), 91 deletions(-)
diff --git a/checks/tcp_conn_stats b/checks/tcp_conn_stats
index aa99bca..f91d380 100644
--- a/checks/tcp_conn_stats
+++ b/checks/tcp_conn_stats
@@ -40,20 +40,40 @@
def parse_tcp_conn_stats(info):
+ map_counter_keys = {
+ 1 : "ESTABLISHED", # connection up and passing data
+ 2 : "SYN_SENT", # session has been requested by us; waiting for reply from remote endpoint
+ 3 : "SYN_RECV", # session has been requested by a remote endpoint for a socket on which we were listening
+ 4 : "FIN_WAIT1", # our socket has closed; we are in the process of tearing down the connection
+ 5 : "FIN_WAIT2", # the connection has been closed; our socket is waiting for the remote endpoint to shut down
+ 6 : "TIME_WAIT", # socket is waiting after closing for any packets left on the network
+ 7 : "CLOSED", # socket is not being used (FIXME. What does mean?)
+ 8 : "CLOSE_WAIT", # remote endpoint has shut down; the kernel is waiting for the application to close the socket
+ 9 : "LAST_ACK", # our socket is closed; remote endpoint has also shut down; we are waiting for a final acknowledgement
+ 10 : "LISTEN", # represents waiting for a connection request from any remote TCP and port
+ 11 : "CLOSING", # our socket is shut down; remote endpoint is shut down; not all data has been sent
+ }
+
parsed = {}
- for tcp_state, tcp_count in info:
+ for line in info:
+ tcp_state = line[0]
if len(tcp_state) == 2:
- tcp_state = int(tcp_state, 16) # Hex
- parsed[tcp_state] = int(tcp_count)
+ tcp_state = map_counter_keys.get(int(tcp_state, 16)) # Hex
+ if tcp_state is None:
+ continue
+ try:
+ parsed[tcp_state] = int(line[1])
+ except ValueError:
+ pass
return parsed
check_info["tcp_conn_stats"] = {
'parse_function' : parse_tcp_conn_stats,
- 'check_function' : check_tcp_connections,
'inventory_function' : inventory_tcp_connections,
+ 'check_function' : check_tcp_connections,
'service_description' : 'TCP Connections',
'has_perfdata' : True,
'group' : 'tcp_conn_stats',
- 'includes' : [ "tcp_connections.include" ],
+ 'includes' : ["tcp_connections.include"],
}
diff --git a/checks/tcp_connections.include b/checks/tcp_connections.include
index 3d7ed62..a2a342f 100644
--- a/checks/tcp_connections.include
+++ b/checks/tcp_connections.include
@@ -24,31 +24,7 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-tcp_conn_stats_default_levels = {}
-
-tcp_connections_state_map = [
- ("ESTABLISHED", 1), # connection up and passing data
- ("SYN_SENT", 2), # session has been requested by us; waiting for reply from remote endpoint
- ("SYN_RECV", 3), # session has been requested by a remote endpoint for a socket on which we were listening
- ("LAST_ACK", 9), # our socket is closed; remote endpoint has also shut down; we are waiting for a final acknowledgement
- ("CLOSE_WAIT", 8), # remote endpoint has shut down; the kernel is waiting for the application to close the socket
- ("TIME_WAIT", 6), # socket is waiting after closing for any packets left on the network
- ("CLOSED", 7), # socket is not being used (FIXME. What does mean?)
- ("CLOSING", 11), # our socket is shut down; remote endpoint is shut down; not all data has been sent
- ("FIN_WAIT1", 4), # our socket has closed; we are in the process of tearing down the connection
- ("FIN_WAIT2", 5), # the connection has been closed; our socket is waiting for the remote endpoint to shut down
- ("LISTEN", 10), # represents waiting for a connection request from any remote TCP and port
- ("BOUND", None), # Socket did a bound() but TCP stack not yet active (Solaris)
- ("IDLE", None), # TCP endpoints are in IDLE state when first created
-]
-# parsed can be:
-# parsed = {
-# 1 : 6,
-# 6 : 17,
-# 8 : 1,
-# 10 : 10,
-# }
# parsed = {
# "ESTABLISHED" : 6,
# "BOUND" : 17,
@@ -57,36 +33,30 @@ tcp_connections_state_map = [
# }
+tcp_conn_stats_default_levels = {}
+
+
def inventory_tcp_connections(parsed):
- if len(parsed) > 0:
+ if parsed:
return [ (None, 'tcp_conn_stats_default_levels') ]
def check_tcp_connections(item, params, parsed):
- hit = False
- for tcp_state_readable, tcp_state_int_str in tcp_connections_state_map:
- num = parsed.get(tcp_state_readable, \
- parsed.get(tcp_state_int_str, 0))
- state = 0
- perf = [tcp_state_readable, num]
- if num > 0: # Only check positive counts
- hit = True
- infotext = "%s: %d" % (tcp_state_readable, num)
- levels = params.get(tcp_state_readable)
- if levels:
- warn, crit = levels
- perf.append(warn)
- perf.append(crit)
- if num >= crit:
- state = 2
- elif num >= warn:
- state = 1
- if state > 0:
- infotext += " (warn/crit at %d/%d)" % (warn, crit)
- yield state, infotext, [ tuple(perf) ]
- else:
- yield 0, None, [ tuple(perf) ]
-
- if not hit:
+ if not parsed:
yield 0, "Currently no TCP connections"
+ return
+ for tcp_state, tcp_count in parsed.iteritems():
+ if tcp_count <= 0:
+ continue
+
+ infotext = "%s: %s" % (tcp_state, tcp_count)
+ state = 0
+ warn, crit = params.get(tcp_state, (None, None))
+ if crit is not None and tcp_count >= crit:
+ state = 2
+ elif warn is not None and tcp_count >= warn:
+ state = 1
+ if state:
+ infotext += " (warn/crit at %d/%d)" % (warn, crit)
+ yield state, infotext, [(tcp_state, tcp_count, warn, crit)]
diff --git a/checks/winperf_tcp_conn b/checks/winperf_tcp_conn
index 1d8e425..a4401a9 100644
--- a/checks/winperf_tcp_conn
+++ b/checks/winperf_tcp_conn
@@ -38,45 +38,30 @@
# 16 18437 counter
-def inventory_winperf_tcp_conn(info):
- if len(info) > 1:
- return [ (None, {}) ]
+def parse_winperf_tcp_conn(info):
+ map_counter_keys = {
+ "2": "ESTABLISHED",
+ }
-
-def check_winperf_tcp_conn(item, params, info):
- if len(info) == 1:
- raise MKCounterWrapped("Got no information from agent")
-
- fields = [
- ( 2, "Established", "ESTABLISHED" ),
- ]
- infotext = ""
- worst_state = 0
- perfdata = []
- for offset, name, param_key in fields:
- value = saveint(info[offset][1])
- infotext += "%s: %s" % (name, value)
- warn, crit = "", ""
- if params.get(param_key):
- warn, crit = params.get(param_key)
- if value >= crit:
- worst_state = 2
- infotext += "(!!) (critical at %d)" % crit
- elif value >= warn:
- worst_state = max(1, worst_state)
- infotext += "(!) (warning at %d)" % warn
- infotext += ", "
- perfdata.append( (name, value, warn, crit) )
-
- infotext = infotext[:-2]
- return worst_state, infotext, perfdata
+ parsed = {}
+ for line in info:
+ tcp_state = map_counter_keys.get(line[0])
+ if tcp_state is None:
+ continue
+ try:
+ parsed[tcp_state] = int(line[1])
+ except ValueError:
+ pass
+ return parsed
check_info["winperf_tcp_conn"] = {
- 'check_function': check_winperf_tcp_conn,
- 'inventory_function': inventory_winperf_tcp_conn,
- 'service_description': 'TCP connections',
- 'has_perfdata': True,
- 'group': 'tcp_conn_stats',
+ 'parse_function' : parse_winperf_tcp_conn,
+ 'inventory_function' : inventory_tcp_connections,
+ 'check_function' : check_tcp_connections,
+ 'service_description' : 'TCP connections',
+ 'has_perfdata' : True,
+ 'group' : 'tcp_conn_stats',
+ 'includes' : ["tcp_connections.include"],
}