Module: check_mk
Branch: master
Commit: e99e75aebba6d31d4ed1bdc8372ae9c544119167
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e99e75aebba6d3…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed Jan 25 12:03:06 2017 +0100
4300 FIX job: fixed missing information handling
Change-Id: Icd646e5c5cc6bd8ff1b004fcf3267b8b4996f46a
---
.werks/4300 | 10 ++++++++++
ChangeLog | 1 +
checks/job | 32 +++++++++++++++++++++-----------
3 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/.werks/4300 b/.werks/4300
new file mode 100644
index 0000000..f2dc873
--- /dev/null
+++ b/.werks/4300
@@ -0,0 +1,10 @@
+Title: job: fixed missing information handling
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.4.0i4
+Date: 1485342137
+
+
diff --git a/ChangeLog b/ChangeLog
index ed537dd..514b0fc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -64,6 +64,7 @@
* 4297 FIX: oracle_instance: fixed discovery function...
* 4298 FIX: omd_apache: fixed missing data handling
* 4299 FIX: df: fixed missing filesystem type handling
+ * 4300 FIX: job: fixed missing information handling
Multisite:
* 4169 View action: Default values of sticky, notification and persistent options can
now be configured via global settings....
diff --git a/checks/job b/checks/job
index 091304c..5fbe10e 100644
--- a/checks/job
+++ b/checks/job
@@ -48,10 +48,12 @@
# max_res_kbytes 1984
# avg_mem_kbytes 0
+
factory_settings["job_default_levels"] = {
"age": (0, 0) # disabled as default
}
+
def inventory_job(info):
inventory = []
for line in info:
@@ -61,6 +63,7 @@ def inventory_job(info):
inventory.append( (item, {} ) )
return inventory
+
def job_parse_real_time(s):
parts = s.split(':')
min_sec, hour_sec = 0, 0
@@ -70,6 +73,7 @@ def job_parse_real_time(s):
min_sec = int(parts[-2]) * 60
return float(parts[-1]) + min_sec + hour_sec
+
def job_parse(item, info):
data = {}
prefix = None
@@ -107,6 +111,7 @@ def job_parse(item, info):
return data
+
def check_job(item, params, info):
warn, crit = params.get('age')
job = job_parse(item, info)
@@ -143,18 +148,22 @@ def check_job(item, params, info):
txt += ' (!!)'
output.append(txt)
- for key, title, value in [
- ('start_time', 'Started',
job['start_time']),
- ('real_time', 'Real-Time',
job['real_time']),
- ('user_time', 'User-Time',
job['user_time']),
- ('system_time', 'System-Time',
job['system_time']),
- ('reads', 'Filesystem Reads',
job['reads']),
- ('writes', 'Filesystem Writes',
job['writes']),
- ('max_res_bytes', 'Max. Memory',
job['max_res_bytes']),
- ('avg_mem_bytes', 'Avg. Memory',
job['avg_mem_bytes']),
- ('vol_context_switches', 'Vol. Context Switches',
job['vol_context_switches']),
- ('invol_context_switches', 'Invol. Context Switches',
job['invol_context_switches']),
+ for key, title in [
+ ('start_time', 'Started'),
+ ('real_time', 'Real-Time'),
+ ('user_time', 'User-Time'),
+ ('system_time', 'System-Time'),
+ ('reads', 'Filesystem Reads'),
+ ('writes', 'Filesystem Writes'),
+ ('max_res_bytes', 'Max. Memory'),
+ ('avg_mem_bytes', 'Avg. Memory'),
+ ('vol_context_switches', 'Vol. Context Switches'),
+ ('invol_context_switches', 'Invol. Context Switches'),
]:
+ value = job.get(key)
+ if value is None:
+ continue
+
if key in [ 'max_res_bytes', 'avg_mem_bytes' ]:
display_value = get_bytes_human_readable(value, 1000)
elif key in [ 'real_time', 'user_time', 'system_time' ]:
@@ -169,6 +178,7 @@ def check_job(item, params, info):
return state, ', '.join(output), perfdata
+
check_info["job"] = {
'check_function' : check_job,
'inventory_function' : inventory_job,