Module: check_mk
Branch: master
Commit: cf716e7952010bd9f3a082e383d425b36a867bf1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cf716e7952010b…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Fri Jan 11 15:55:05 2019 +0100
cpu_queues: Fix missing consideration of PM in 12 hour timestamp format
FEED-3234
Change-Id: Ifc9efc97af805626f58905cc07aaf20c84e23efa
---
checks/cups_queues | 2 +-
.../checks/generictests/datasets/cups_queues.py | 9 ++---
.../checks/generictests/datasets/cups_queues_am.py | 38 ++++++++++++++++++++++
.../checks/generictests/datasets/cups_queues_pm.py | 38 ++++++++++++++++++++++
4 files changed, 82 insertions(+), 5 deletions(-)
diff --git a/checks/cups_queues b/checks/cups_queues
index 98c6af6..98f68f8 100644
--- a/checks/cups_queues
+++ b/checks/cups_queues
@@ -85,7 +85,7 @@ def parse_cups_queues(info):
'%a %b %d %H:%M:%S %Y'))
except: # Thu 29 Aug 2013 12:41:42 AM CEST
job_time = time.mktime(time.strptime(' '.join(line[-7:]), \
- '%a %d %b %Y %H:%M:%S %p %Z'))
+ '%a %d %b %Y %I:%M:%S %p %Z'))
parsed[item]['jobs'].append(job_time)
return parsed
diff --git a/tests/unit/checks/generictests/datasets/cups_queues.py
b/tests/unit/checks/generictests/datasets/cups_queues.py
index 7eb0bbf..18eedf0 100644
--- a/tests/unit/checks/generictests/datasets/cups_queues.py
+++ b/tests/unit/checks/generictests/datasets/cups_queues.py
@@ -10,8 +10,9 @@ info = [[
[
'Wiederherstellbar:', 'Der', 'Netzwerk-Host',
'lpr2', 'ist', 'beschaeftigt,',
'erneuter', 'Versuch', 'in', '30',
'Sekunden'
- ], ['---'], ['lpr2-2', 'root', '1024',
'Tue', 'Jun', '29', '09:02:35', '2010'],
- ['lpr2-3', 'root', '1024', 'Tue', 'Jun',
'29', '09:05:54', '2010']]
+ ], ['---'], ['lpr2-2', 'root', '1024',
'Tue', 'Jun', '28', '09:05:56', '2010'],
+ ['lpr2-3', 'root', '1024', 'Tue', '28',
'Jun', '2010', '01:02:35', 'PM', 'CET'],
+ ['lpr2-4', 'root', '1024', 'Tue', '29',
'Jun', '2010', '09:05:54', 'AM', 'CET']]
discovery = {'': [('lpr2', {}), ('spr1', {})]}
@@ -25,8 +26,8 @@ checks = {
}, [(
0,
'now printing lpr2-3. enabled since Tue Jun 29 09:22:04 2010
(Wiederherstellbar: Der Netzwerk-Host lpr2 ist beschaeftigt, erneuter Versuch in 30
Sekunden)',
- []), (0, 'Jobs: 2', [('jobs', 2, 5, 10, 0, None)]),
- (2, 'Oldest job is from Tue Jun 29 09:02:35 2010', [])]),
+ []), (0, 'Jobs: 3', [('jobs', 3, 5, 10, 0, None)]),
+ (2, 'Oldest job is from Mon Jun 28 09:05:56 2010', [])]),
('spr1', {
'disabled_since': 2,
'is_idle': 0,
diff --git a/tests/unit/checks/generictests/datasets/cups_queues_am.py
b/tests/unit/checks/generictests/datasets/cups_queues_am.py
new file mode 100644
index 0000000..9c779ad
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/cups_queues_am.py
@@ -0,0 +1,38 @@
+checkname = 'cups_queues'
+
+info = [[
+ 'printer', 'spr1', 'is', 'idle.', 'enabled',
'since', 'Thu', 'Mar', '11', '14:28:23',
'2010'
+],
+ [
+ 'printer', 'lpr2', 'now', 'printing',
'lpr2-3.', 'enabled', 'since', 'Tue', 'Jun',
'29',
+ '09:22:04', '2010'
+ ],
+ [
+ 'Wiederherstellbar:', 'Der', 'Netzwerk-Host',
'lpr2', 'ist', 'beschaeftigt,',
+ 'erneuter', 'Versuch', 'in', '30',
'Sekunden'
+ ], ['---'], ['lpr2-2', 'root', '1024',
'Tue', '28', 'Jun', '2010', '09:05:54',
'AM', 'CET'],
+ ['lpr2-3', 'root', '1024', 'Tue', '29',
'Jun', '2010', '01:02:35', 'PM', 'CET'],
+ ['lpr2-4', 'root', '1024', 'Tue', 'Jun',
'29', '09:05:56', '2010']]
+
+discovery = {'': [('lpr2', {}), ('spr1', {})]}
+
+checks = {
+ '': [('lpr2', {
+ 'disabled_since': 2,
+ 'is_idle': 0,
+ 'job_age': (360, 720),
+ 'job_count': (5, 10),
+ 'now_printing': 0
+ }, [(
+ 0,
+ 'now printing lpr2-3. enabled since Tue Jun 29 09:22:04 2010
(Wiederherstellbar: Der Netzwerk-Host lpr2 ist beschaeftigt, erneuter Versuch in 30
Sekunden)',
+ []), (0, 'Jobs: 3', [('jobs', 3, 5, 10, 0, None)]),
+ (2, 'Oldest job is from Mon Jun 28 10:05:54 2010', [])]),
+ ('spr1', {
+ 'disabled_since': 2,
+ 'is_idle': 0,
+ 'job_age': (360, 720),
+ 'job_count': (5, 10),
+ 'now_printing': 0
+ }, [(0, 'is idle. enabled since Thu Mar 11 14:28:23 2010', [])])]
+}
diff --git a/tests/unit/checks/generictests/datasets/cups_queues_pm.py
b/tests/unit/checks/generictests/datasets/cups_queues_pm.py
new file mode 100644
index 0000000..3989e32
--- /dev/null
+++ b/tests/unit/checks/generictests/datasets/cups_queues_pm.py
@@ -0,0 +1,38 @@
+checkname = 'cups_queues'
+
+info = [[
+ 'printer', 'spr1', 'is', 'idle.', 'enabled',
'since', 'Thu', 'Mar', '11', '14:28:23',
'2010'
+],
+ [
+ 'printer', 'lpr2', 'now', 'printing',
'lpr2-3.', 'enabled', 'since', 'Tue', 'Jun',
'29',
+ '09:22:04', '2010'
+ ],
+ [
+ 'Wiederherstellbar:', 'Der', 'Netzwerk-Host',
'lpr2', 'ist', 'beschaeftigt,',
+ 'erneuter', 'Versuch', 'in', '30',
'Sekunden'
+ ], ['---'], ['lpr2-2', 'root', '1024',
'Tue', '28', 'Jun', '2010', '01:02:35',
'PM', 'CET'],
+ ['lpr2-3', 'root', '1024', 'Tue', '29',
'Jun', '2010', '09:05:54', 'AM', 'CET'],
+ ['lpr2-4', 'root', '1024', 'Tue', 'Jun',
'29', '09:05:56', '2010']]
+
+discovery = {'': [('lpr2', {}), ('spr1', {})]}
+
+checks = {
+ '': [('lpr2', {
+ 'disabled_since': 2,
+ 'is_idle': 0,
+ 'job_age': (360, 720),
+ 'job_count': (5, 10),
+ 'now_printing': 0
+ }, [(
+ 0,
+ 'now printing lpr2-3. enabled since Tue Jun 29 09:22:04 2010
(Wiederherstellbar: Der Netzwerk-Host lpr2 ist beschaeftigt, erneuter Versuch in 30
Sekunden)',
+ []), (0, 'Jobs: 3', [('jobs', 3, 5, 10, 0, None)]),
+ (2, 'Oldest job is from Mon Jun 28 14:02:35 2010', [])]),
+ ('spr1', {
+ 'disabled_since': 2,
+ 'is_idle': 0,
+ 'job_age': (360, 720),
+ 'job_count': (5, 10),
+ 'now_printing': 0
+ }, [(0, 'is idle. enabled since Thu Mar 11 14:28:23 2010', [])])]
+}