Module: check_mk
Branch: master
Commit: 6c3c210261c5660be6706d99b9394c4d639d1dde
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6c3c210261c566…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Thu Feb 22 16:00:48 2018 +0100
5742 windows_tasks: show the hexadecimal representation of the status code
schtasks.exe used by the check plugin windows_tasks.ps1 returns a signed
integer value as the last result of a task. However, the status codes
(e.g. on MSDN) are usually represented as a hexadecimal value. To make
it easier to lookup a status code the hexadecimal value is now shown by
the check plugin.
Change-Id: I591eb397c172446e7312cf43ed077227ae47cd47
---
.werks/5742 | 14 ++++++++++++++
checks/windows_tasks | 12 ++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/.werks/5742 b/.werks/5742
new file mode 100644
index 0000000..11ee6cd
--- /dev/null
+++ b/.werks/5742
@@ -0,0 +1,14 @@
+Title: windows_tasks: show the hexadecimal representation of the status code
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i4
+Date: 1519374443
+Class: feature
+
+schtasks.exe used by the check plugin windows_tasks.ps1 returns a signed
+integer value as the last result of a task. However, the status codes
+(e.g. on MSDN) are usually represented as a hexadecimal value. To make
+it easier to lookup a status code the hexadecimal value is now shown by
+the check plugin.
diff --git a/checks/windows_tasks b/checks/windows_tasks
index 20fb62f..29f5137 100644
--- a/checks/windows_tasks
+++ b/checks/windows_tasks
@@ -82,6 +82,8 @@ def check_windows_tasks(item, _no_params, parsed):
return
map_codes = {
+ "0": "operation completed successfully",
+ "1": "task containing a popup action",
"267009": "currently running",
"267014": "terminated by user",
"267045": "queued",
@@ -91,10 +93,16 @@ def check_windows_tasks(item, _no_params, parsed):
data = parsed[item]
last_result = data['Last Result']
+ # schtasks.exe (used by the check plugin) returns a signed integer
+ # e.g. -2147024629. However, error codes are unsigned integers.
+ # To make it easier for the user to lookup the error code (e.g. on
+ # MSDN) we convert the negative numbers to the hexadecimal
+ # representation.
+ last_result_hex = hex(int(last_result) & 0xffffffff)
if last_result in map_codes:
- infotext = "Service Status: %s (%s)" % (map_codes[last_result],
last_result)
+ infotext = "Service Status: %s (%s)" % (map_codes[last_result],
last_result_hex)
else:
- infotext = "Service status: %s" % last_result
+ infotext = "Service status: Got exit code %s" % last_result_hex
state = 0
if last_result not in [