Module: check_mk
Branch: master
Commit: f41e62f82263bbc67f24bbd95638395cef1f1c01
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f41e62f82263bb…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Wed Mar 27 12:57:35 2013 +0100
resolved merge conflict
---
ChangeLog | 3 +-
agents/windows/plugins/mssql.vbs | 39 +++++++++++++++++++++++++++----------
checks/mssql_versions | 6 ++++-
3 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f9751c3..d8ea486 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -90,7 +90,8 @@
* ADD: wmic_processs: cpucores now being considered when calculating
user/kernel percentages. (thanks to William Baum)
* FIX: UPS checks support Eaton Evolution
-
+ * FIX: windows agent plugin: mssql now exits after 10 seconds
+
Notifications:
* FIX: fixed crash on host notification when contact had explicit services set
diff --git a/agents/windows/plugins/mssql.vbs b/agents/windows/plugins/mssql.vbs
index f515f14..80ffd7d 100644
--- a/agents/windows/plugins/mssql.vbs
+++ b/agents/windows/plugins/mssql.vbs
@@ -21,11 +21,24 @@
Option Explicit
-Dim WMI, prop, instId, instVersion, instIds, instName
+Dim WMI, prop, instId, instVersion, instIds, instName, output
+
+WScript.Timeout = 10
' Directory of all database instance names
Set instIds = CreateObject("Scripting.Dictionary")
+
+output = ""
+Sub addOutput(text)
+ output = output & text & vbLf
+End Sub
+
+
+' Dummy empty output.
+' Contains timeout error if this scripts runtime exceeds the timeout
+WScript.echo "<<<mssql_versions>>>"
+
' Loop all found local MSSQL server instances
' Try different trees to handle different versions of MSSQL
On Error Resume Next
@@ -43,7 +56,7 @@ If Err.Number <> 0 Then
' try MSSQL < 10
Set WMI =
GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement")
If Err.Number <> 0 Then
- wscript.echo "Error: " & Err.Number & " " &
Err.Description
+ addOutput( "Error: " & Err.Number & " " &
Err.Description )
Err.Clear()
wscript.quit()
End If
@@ -57,8 +70,8 @@ For Each prop In WMI.ExecQuery("SELECT * FROM
SqlServiceAdvancedProperty WHERE "
instId = Replace(prop.ServiceName, "$", "_")
instVersion = prop.PropertyStrValue
- WScript.echo "<<<mssql_versions>>>"
- WScript.echo instId & " " & instVersion
+ addOutput( "<<<mssql_versions>>>" )
+ addOutput( instId & " " & instVersion )
' Now query the server instance for the databases
' Use name as key and always empty value for the moment
@@ -103,7 +116,7 @@ For Each instId In instIds.Keys
RS.Open "SELECT counter_name, object_name, instance_name, cntr_value "
& _
"FROM sys.dm_os_performance_counters " & _
"WHERE object_name NOT LIKE '%Deprecated%'", CONN
- wscript.echo "<<<mssql_counters>>>"
+ addOutput( "<<<mssql_counters>>>" )
Dim objectName, counterName, instanceName, value
Do While NOT RS.Eof
objectName = Replace(Replace(Trim(RS("object_name")), " ",
"_"), "$", "_")
@@ -113,7 +126,7 @@ For Each instId In instIds.Keys
instanceName = "None"
End If
value = Trim(RS("cntr_value"))
- wscript.echo objectName & " " & counterName & " "
& instanceName & " " & value
+ addOutput( objectName & " " & counterName & " "
& instanceName & " " & value )
RS.MoveNext
Loop
RS.Close
@@ -130,7 +143,7 @@ For Each instId In instIds.Keys
RS.Close
' Now gather the db size and unallocated space
- wscript.echo "<<<mssql_tablespaces>>>"
+ addOutput( "<<<mssql_tablespaces>>>" )
Dim i, dbSize, unallocated, reserved, data, indexSize, unused
For Each dbName in dbNames.Keys
' Switch to other database and then ask for stats
@@ -164,15 +177,15 @@ For Each instId In instIds.Keys
Set RS = RS.NextRecordset
i = i + 1
Loop
- wscript.echo instId & " " & Replace(dbName, " ",
"_") & " " & dbSize & " " & unallocated
& " " & reserved & " " & _
- data & " " & indexSize & " " &
unused
+ addOutput( instId & " " & Replace(dbName, " ",
"_") & " " & dbSize & " " & unallocated
& " " & reserved & " " & _
+ data & " " & indexSize & " " &
unused )
Set RS = CreateObject("ADODB.Recordset")
Next
' Loop all databases to get the date of the last backup. Only show databases
' which have at least one backup
Dim lastBackupDate
- wscript.echo "<<<mssql_backup>>>"
+ addOutput( "<<<mssql_backup>>>" )
For Each dbName in dbNames.Keys
RS.open "SELECT CONVERT(VARCHAR, DATEADD(s, DATEDIFF(s, '19700101',
MAX(backup_finish_date)), '19700101'), 120) AS last_backup_date " & _
"FROM msdb.dbo.backupset " & _
@@ -180,7 +193,7 @@ For Each instId In instIds.Keys
Do While Not RS.Eof
lastBackupDate = Trim(RS("last_backup_date"))
If lastBackupDate <> "" Then
- wscript.echo instId & " " & Replace(dbName, "
", "_") & " " & lastBackupDate
+ addOutput( instId & " " & Replace(dbName, "
", "_") & " " & lastBackupDate )
End If
RS.MoveNext
Loop
@@ -192,3 +205,7 @@ Next
Set RS = nothing
Set CONN = nothing
+
+' finally output collected data
+WScript.echo output
+
diff --git a/checks/mssql_versions b/checks/mssql_versions
index c4c76be..a6116df 100644
--- a/checks/mssql_versions
+++ b/checks/mssql_versions
@@ -28,7 +28,11 @@
# MSSQL_SQLEXPRESS 10.50.1600.1
def inventory_mssql_versions(info):
- return [ (line[0], None) for line in info if len(line) >= 2 ]
+ inventory = []
+ for line in info:
+ if len(line) == 2 and line[0] != "Error:":
+ inventory.append((line[0], None))
+ return inventory
def check_mssql_versions(item, _unused, info):
for line in info: