Module: check_mk
Branch: master
Commit: 1c1943b7846816dfe8c7f7c31226795b59daec1f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1c1943b7846816…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jul 23 08:23:43 2012 +0200
mssql agent: Added WMI code to be able to monitor MSSQL version 9
---
agents/windows/plugins/mssql.vbs | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/agents/windows/plugins/mssql.vbs b/agents/windows/plugins/mssql.vbs
index faceb6f..7e12135 100644
--- a/agents/windows/plugins/mssql.vbs
+++ b/agents/windows/plugins/mssql.vbs
@@ -27,7 +27,23 @@ Dim WMI, prop, instId, instVersion, instIds, instName
Set instIds = CreateObject("Scripting.Dictionary")
' Loop all found local MSSQL server instances
+' Try different trees to handle different versions of MSSQL
+On Error Resume Next
+' MSSQL >= 10
Set WMI =
GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement10")
+If Err.Number <> 0 Then
+ Err.Clear()
+
+ ' MSSQL < 10
+ Set WMI =
GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement")
+ If Err.Number <> 0 Then
+ wscript.echo "Error: " & Err.Number & " " &
Err.Description
+ Err.Clear()
+ wscript.quit()
+ End If
+End If
+On Error Goto 0
+
For Each prop In WMI.ExecQuery("SELECT * FROM SqlServiceAdvancedProperty WHERE
" & _
"SQLServiceType = 1 AND PropertyName =
'VERSION'")