Module: check_mk
Branch: master
Commit: f31669d226ad35d39d416b1b0e0b6166e87f8472
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f31669d226ad35…
Author: Óscar Nájera <on(a)mathias-kettner.de>
Date: Tue Oct 2 11:02:30 2018 +0200
6642 Performance data for mknotify
The OMD Notification Spooler now includes performance data. Graphs about
the last instant the spool was refreshed and how many new files are in the
queue are shown. In case there are corrupted files in the spool or they
have been deferred corresponding graphs will be included.
CMK-906
Change-Id: I7182d730ac13b06fa1b2cf5c588d2e587245a677
---
.werks/6642 | 13 +++++++
checks/mknotifyd | 73 ++++++++++++++++++++++---------------
cmk/gui/plugins/metrics/check_mk.py | 46 +++++++++++++++++++++++
3 files changed, 103 insertions(+), 29 deletions(-)
diff --git a/.werks/6642 b/.werks/6642
new file mode 100644
index 0000000..c691e72
--- /dev/null
+++ b/.werks/6642
@@ -0,0 +1,13 @@
+Title: Performance data for mknotify
+Level: 1
+Component: nagvis
+Compatible: compat
+Edition: c1e
+Version: 1.6.0i1
+Date: 1538662417
+Class: feature
+
+The OMD Notification Spooler now includes performance data. Graphs about
+the last instant the spool was refreshed and how many new files are in the
+queue are shown. In case there are corrupted files in the spool or they
+have been deferred corresponding graphs will be included.
diff --git a/checks/mknotifyd b/checks/mknotifyd
index 825af50..9601903 100644
--- a/checks/mknotifyd
+++ b/checks/mknotifyd
@@ -55,15 +55,16 @@
# InputBuffer: 0 Bytes
# OutputBuffer: 0 Bytes
+
def parse_mknotifyd(info):
parsed = {}
for line in info:
if line[0].startswith('['):
site = line[0][1:-1]
site_entry = {
- "spools" : {},
- "connections" : {},
- "queues" : {}
+ "spools": {},
+ "connections": {},
+ "queues": {},
}
sub_entry = site_entry
parsed[site] = site_entry
@@ -87,8 +88,13 @@ def parse_mknotifyd(info):
if value == "None":
value = None
elif value and varname not in [
- "Type", "State", "Version",
"Status Message",
- "Pending Acknowledgements", "Connect Time" ]:
+ "Type",
+ "State",
+ "Version",
+ "Status Message",
+ "Pending Acknowledgements",
+ "Connect Time",
+ ]:
value = int(value.split()[0])
elif varname == "Connect Time":
value = float(value.split()[0])
@@ -111,12 +117,11 @@ def parse_mknotifyd(info):
stats["connections"][address] = connections[0]
else:
for nr, connection in enumerate(connections):
- stats["connections"][address + "/" + str(nr+1)] =
connection
+ stats["connections"][address + "/" + str(nr + 1)]
= connection
return parsed
-#.
# .--Spooler Status------------------------------------------------------.
# | ____ _ ____ _ _ |
# |/ ___| _ __ ___ ___ | | ___ _ __ / ___|| |_ __ _| |_ _ _ ___ |
@@ -128,8 +133,10 @@ def parse_mknotifyd(info):
# | |
# '----------------------------------------------------------------------'
+
def inventory_mknotifyd(parsed):
- return [ (p, {}) for p in parsed ]
+ return [(p, {}) for p in parsed]
+
def check_mknotifyd(item, _no_params, parsed):
if item not in parsed:
@@ -141,45 +148,53 @@ def check_mknotifyd(item, _no_params, parsed):
version = stat["Version"]
# Output Version
- yield 0, "Version: " + version
+ yield 0, "Version: " + version, []
# Check age of status file. It's updated every 20 seconds
status_age = now - stat["Updated"]
if status_age > 90:
- yield 2, "Status last updated %s ago, spooler seems crashed or busy" %
get_age_human_readable(status_age)
+ state = 2
+ infotext = "Status last updated %s ago, spooler seems crashed or busy"
% get_age_human_readable(
+ status_age)
else:
- yield 0, "Spooler running"
+ state = 0
+ infotext = "Spooler running"
+ yield state, infotext, [('last_updated', status_age), ('new_files',
stat['spools']['New']['Count'])]
# Are there any corrupted files
corrupted = stat["spools"]["Corrupted"]
if corrupted["Count"]:
- yield 1, "%d corrupted files: youngest %s ago" %
(corrupted["Count"], get_age_human_readable(now -
corrupted["Youngest"]))
+ age = now - corrupted["Youngest"]
+ perf_data = [('corrupted_files', corrupted["Count"])]
+ yield 1, "%d corrupted files: youngest %s ago" %
(corrupted["Count"],
+ get_age_human_readable(age)),
perf_data
# Are there deferred files that are too old?
deferred = stat["spools"]["Deferred"]
if deferred["Count"]:
age = now - deferred["Oldest"]
count = deferred["Count"]
+ perf_data = [('deferred_age', age), ('deferred_files',
deferred["Count"])]
if age > 5:
state = 1
elif age > 600:
state = 2
else:
state = 0
- yield state, "%d deferred files: oldest %s ago" % (count,
get_age_human_readable(age))
+ yield state, "%d deferred files: oldest %s ago" % (count,
+ get_age_human_readable(age)),
perf_data
return
+
check_info["mknotifyd"] = {
- "parse_function" : parse_mknotifyd,
- "inventory_function" : inventory_mknotifyd,
- "check_function" : check_mknotifyd,
- "service_description" : "OMD %s Notification Spooler",
+ "parse_function": parse_mknotifyd,
+ "inventory_function": inventory_mknotifyd,
+ "check_function": check_mknotifyd,
+ "has_perfdata": True,
+ "service_description": "OMD %s Notification Spooler",
}
-
-
-#.
# .--Connections---------------------------------------------------------.
# | ____ _ _ |
# | / ___|___ _ __ _ __ ___ ___| |_(_) ___ _ __ ___ |
@@ -189,6 +204,7 @@ check_info["mknotifyd"] = {
# | |
# '----------------------------------------------------------------------'
+
def inventory_mknotifyd_connection(parsed):
for site_name, stats in parsed.items():
for connection_name in stats["connections"]:
@@ -197,10 +213,10 @@ def inventory_mknotifyd_connection(parsed):
def check_mknotifyd_connection(item, _no_params, parsed):
states = {
- "established" : (0, "Alive"),
- "cooldown" : (2, "Connection failed or terminated"),
- "initial" : (1, "Initialized"),
- "connecting" : (2, "Trying to connect"),
+ "established": (0, "Alive"),
+ "cooldown": (2, "Connection failed or terminated"),
+ "initial": (1, "Initialized"),
+ "connecting": (2, "Trying to connect"),
}
site_name, connection_name = item.split('-', 1)
@@ -227,15 +243,14 @@ def check_mknotifyd_connection(item, _no_params, parsed):
yield 0, "Connect time: %.3f sec" % connection["Connect
Time"]
# Stats
- for what in ( "Sent", "Received" ):
+ for what in ("Sent", "Received"):
num = connection["Notifications " + what]
if num:
yield 0, "%d Notifications %s" % (num, what.lower())
-
check_info["mknotifyd.connection"] = {
- "inventory_function" : inventory_mknotifyd_connection,
- "check_function" : check_mknotifyd_connection,
- "service_description" : "OMD %s Notify Connection",
+ "inventory_function": inventory_mknotifyd_connection,
+ "check_function": check_mknotifyd_connection,
+ "service_description": "OMD %s Notify Connection",
}
diff --git a/cmk/gui/plugins/metrics/check_mk.py b/cmk/gui/plugins/metrics/check_mk.py
index 0cbb4d7..e9e41fd 100644
--- a/cmk/gui/plugins/metrics/check_mk.py
+++ b/cmk/gui/plugins/metrics/check_mk.py
@@ -438,6 +438,18 @@ metric_info["age"] = {
"color" : "#80f000",
}
+metric_info["last_updated"] = {
+ "title" : _("Last Updated"),
+ "unit" : "s",
+ "color" : "#80f000",
+}
+
+metric_info["deferred_age"] = {
+ "title" : _("Deferred Files Age"),
+ "unit" : "s",
+ "color" : "#80f000",
+}
+
metric_info["runtime"] = {
"title" : _("Process Runtime"),
"unit" : "s",
@@ -533,6 +545,23 @@ metric_info["file_count"] = {
"color" : "23/a",
}
+metric_info["new_files"] = {
+ "title" : _("New files in Spool"),
+ "unit" : "count",
+ "color" : "23/a",
+}
+
+metric_info["deferred_files"] = {
+ "title" : _("Deferred files in Spool"),
+ "unit" : "count",
+ "color" : "16/a",
+}
+
+metric_info["corrupted_files"] = {
+ "title" : _("Corrupted files in Spool"),
+ "unit" : "count",
+ "color" : "34/a",
+}
# database, tablespace
metric_info["data_files"] = {
@@ -5558,6 +5587,13 @@ perfometer_info.append({
perfometer_info.append({
"type" : "logarithmic",
+ "metric" : "last_updated",
+ "half_value" : 40.0,
+ "exponent" : 2,
+})
+
+perfometer_info.append({
+ "type" : "logarithmic",
"metric" : "job_duration",
"half_value" : 120.0,
"exponent" : 2,
@@ -8501,3 +8537,13 @@ graph_info['amount_of_mails_in_secondary_queues'] = {
( 'mail_queue_drop_length', 'stack'),
],
}
+
+graph_info['files_notification_spool'] = {
+ 'title': _('Amount of files in notification spool'),
+ 'metrics': [
+ ('new_files', 'area'),
+ ('deferred_files', 'area'),
+ ('corrupted_files', 'area'),
+ ],
+ "optional_metrics": ['deferred_files', 'corrupted_files'],
+}