Module: check_mk
Branch: master
Commit: dacd77491a84c67bc2e46f577cd82bddacf66a0a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=dacd77491a84c6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 6 09:53:54 2012 +0200
mssql_backup: Fixed problems with datetime/timezone calculations
---
ChangeLog | 2 ++
agents/windows/plugins/mssql.vbs | 2 +-
checks/mssql_backup | 11 +++++------
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4bfcfa3..8cdad1d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
1.2.0p3:
+ Checks & Agents:
+ * mssql_backup: Fixed problems with datetime/timezone calculations
BI:
* Great speed up of rule compilation in large environments
diff --git a/agents/windows/plugins/mssql.vbs b/agents/windows/plugins/mssql.vbs
index c2dc35c..faceb6f 100644
--- a/agents/windows/plugins/mssql.vbs
+++ b/agents/windows/plugins/mssql.vbs
@@ -144,7 +144,7 @@ For Each instId In instIds.Keys
Dim lastBackupDate
wscript.echo "<<<mssql_backup>>>"
For Each dbName in dbNames.Keys
- RS.open "SELECT DATEDIFF(s, '19700101', MAX(backup_finish_date)) AS
last_backup_date " & _
+ RS.open "SELECT CONVERT(VARCHAR, DATEADD(s, DATEDIFF(s, '19700101',
MAX(backup_finish_date)), '19700101'), 120) AS last_backup_date " & _
"FROM msdb.dbo.backupset " & _
"WHERE database_name = '" & dbName &
"'", CONN
Do While Not RS.Eof
diff --git a/checks/mssql_backup b/checks/mssql_backup
index 75f5679..2f5f363 100644
--- a/checks/mssql_backup
+++ b/checks/mssql_backup
@@ -24,7 +24,8 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-import datetime
+import datetime, time
+import pytz
#<<<mssql_backup>>>
#MSSQL_SQLEXPRESS test123 1331207325
@@ -38,14 +39,12 @@ def inventory_mssql_backup(info):
def check_mssql_backup(item, params, info):
for line in info:
- inst, tablespace, last_backup_timestamp = line
+ inst, tablespace, last_backup_date, last_backup_time = line
if item == inst + ' ' + tablespace:
- last_backup_timestamp = int(last_backup_timestamp)
- dt = datetime.datetime.fromtimestamp(last_backup_timestamp)
+ dt = datetime.datetime(*time.strptime(last_backup_date + ' ' +
last_backup_time, '%Y-%m-%d %H:%M:%S')[0:5])
state = 0
- now = datetime.datetime.now()
- sec_ago = int(now.strftime('%s')) - last_backup_timestamp
+ sec_ago = (datetime.datetime.now() - dt).seconds
if params is not None:
if sec_ago >= params[1]: