Module: check_mk
Branch: master
Commit: 597f25384312e7a9550d46e05964adb520930265
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=597f25384312e7…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Dec 15 14:34:18 2010 +0100
cups_queues: fixed plugin error due to invalid import of datetime
---
ChangeLog | 2 ++
checks/ad_replication | 7 +++----
checks/cups_queues | 11 +++++------
checks/smbios_sel | 11 +++++------
4 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d2adf2c..b5c4d51 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,8 @@
Checks & Agents:
* Fixed problem with OnlyFrom: in Linux agent (df didn't work properly)
+ * cups_queues: fixed plugin error due to invalid import of datetime,
+ converted other checks from 'from datetime import...' to 'import
datetime'.
1.1.9i2:
Checks & Agents:
diff --git a/checks/ad_replication b/checks/ad_replication
index 0f0e542..90f45f5 100644
--- a/checks/ad_replication
+++ b/checks/ad_replication
@@ -32,8 +32,7 @@
#
showrepl_INFO,Standardname-des-ersten-Standorts,WIN2003,"CN=Configuration,DC=corp,DC=de",Standardname-des-ersten-Standorts,WIN2003-DC2,RPC,0,0,2010-07-02
12:54:08,0
#
showrepl_INFO,Standardname-des-ersten-Standorts,WIN2003,"CN=Schema,CN=Configuration,DC=corp,DC=de",Standardname-des-ersten-Standorts,WIN2003-DC2,RPC,0,0,2010-07-02
12:46:28,0
-from datetime import datetime, timedelta
-import time
+import datetime, time
ad_replication_default_params = (20,)
@@ -41,7 +40,7 @@ def parse_ad_replication_dates(s):
if s == '0' or s == '(never)':
return None
else:
- return datetime(*time.strptime(s, '%Y-%m-%d %H:%M:%S')[0:5])
+ return datetime.datetime(*time.strptime(s, '%Y-%m-%d %H:%M:%S')[0:5])
def parse_ad_replication_info(info):
lines = []
@@ -60,7 +59,7 @@ def inventory_ad_replication(checktype, info):
def check_ad_replication(item, params, info):
status = 0
output = ''
- now = datetime.now()
+ now = datetime.datetime.now()
foundLine = False
for l in parse_ad_replication_info(info):
diff --git a/checks/cups_queues b/checks/cups_queues
index 2a8fda7..733efe3 100644
--- a/checks/cups_queues
+++ b/checks/cups_queues
@@ -45,8 +45,7 @@
#lpr2-2 root 1024 Tue Jun 29 09:02:35 2010
#lpr2-3 root 1024 Tue Jun 29 09:05:54 2010
-from datetime import datetime, timedelta
-import time
+import time, datetime
# Default thresholds
# ("<Warning max entries>", "<Critical num entries>",
"<Warning entry age in seconds>", "<Critical entry age>")
@@ -60,7 +59,7 @@ def check_cups_queues(item, params, info):
state = 3
output = "UNKNOWN - Queue not found"
numJobs = 0
- now = datetime.now()
+ now = datetime.datetime.now()
oldest = now
for num, line in enumerate(info):
if line[0] == 'printer' and line[1] == item:
@@ -83,15 +82,15 @@ def check_cups_queues(item, params, info):
elif line[0].startswith(item+'-'):
# This is a queue item count the number of items and check the max age
numJobs += 1
- dt = datetime(*time.strptime(' '.join(line[3:]), '%a %b %d
%H:%M:%S %Y')[0:5])
+ dt = datetime.datetime(*time.strptime(' '.join(line[3:]), '%a %b
%d %H:%M:%S %Y')[0:5])
if dt < oldest:
oldest = dt
jobOutput = 'Jobs: %d' % numJobs
if numJobs > 0:
- if oldest < now - timedelta(seconds=critAge) or numJobs > critNum:
+ if oldest < now - datetime.timedelta(seconds=critAge) or numJobs >
critNum:
state = 2
- elif oldest < now - timedelta(seconds=warnAge) or numJobs > warnNum:
+ elif oldest < now - datetime.timedelta(seconds=warnAge) or numJobs >
warnNum:
state = 1
jobOutput += ', Oldest job is from %s' % oldest
diff --git a/checks/smbios_sel b/checks/smbios_sel
index 0623024..d05b489 100644
--- a/checks/smbios_sel
+++ b/checks/smbios_sel
@@ -66,8 +66,7 @@
# 0xFF End-of-Log
#};
-from datetime import datetime
-import time
+import datetime, time
smbios_sel_msg_types = {
#Type: (Number-of-Entries Threshold, Status-Code, Current Count, Last Entry, Alias)
@@ -118,14 +117,14 @@ def check_smbios_sel(_no_item, _no_params, info):
if type == "E":
sum_status = 2
num_errors += 1;
- smbios_sel_msg_types["E%d"%num_errors] = [1, 2, 1, datetime.now(),
msg]
+ smbios_sel_msg_types["E%d"%num_errors] = [1, 2, 1,
datetime.datetime.now(), msg]
continue
# Informational messages are explicit created by our binary when the
# sel is empty. This is needed to create the smbios_sel service in Nagios.
if type == "I":
sum_status = 0
- smbios_sel_msg_types["I%d"%num_errors] = [1, 0, 1, datetime.now(),
msg]
+ smbios_sel_msg_types["I%d"%num_errors] = [1, 0, 1,
datetime.datetime.now(), msg]
continue
type = int(type)
@@ -144,14 +143,14 @@ def check_smbios_sel(_no_item, _no_params, info):
sum_status = smbios_sel_msg_types[type][1]
# Save the date when the current entry is newer
- dt = datetime(*time.strptime(isodate, "%Y-%m-%d %H:%M:%S")[0:5])
+ dt = datetime.datetime(*time.strptime(isodate, "%Y-%m-%d
%H:%M:%S")[0:5])
if smbios_sel_msg_types[type][3] == None or smbios_sel_msg_types[type][3]
< dt:
smbios_sel_msg_types[type][3] = dt;
else:
# Unknown types will result in UNKNOWN state
sum_status = 3
smbios_sel_msg_types[type] = [1, 3, 1,
- datetime.now(),
+ datetime.datetime.now(),
"Unknown log type (%s)" % type]
sum_output = ""