I am using a WMI Service Monitoring script to monitor all the automatic services on our servers. It's working nicely, but right now if I hover over the the application list or the application nodes (which I've displayed on a network map), it simply returns the status of "Critical" or "Up".
However, if I dig into the APM Application Details page of that node, and hover over the "info" button it displays more information -- it actually shows which services are down. I'd like to display this message in the front instead of having to dig into Solarwinds and even display it in our email alerts since not everyone on our team has Solarwinds access.
Is the message (the "echo" part) passed to a variable I could use to output it in our email alerts? Or is there any other way to do this?
I attempted to use ${StatusOrErrorDescription} but that did not seem to return a value in the email.
Thanks
Below is the script:
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1
'
' NAME: ServiceMonitorAPM1.vbs
'
' AUTHOR: Bob McDermand, State of Wa , DIS
' DATE : 20091002
'
' COMMENT: For use with APM monitoring template, credit to Solarwinds for "borrowed"
' logic.
'
'
'==========================================================================
Option Explicit
Const SUCCESS = 0, FAIL = 1, wbemFlagReturnImmediately = &h10, wbemFlagForwardOnly = &h20
Dim strComputer, strUser, strPassword, sCount, strServiceList, objItem, colItems, objSWbemLocator, objSWbemServices
Dim objArgs
Set objArgs = WScript.Arguments
'Use the following syntax for Script Arguments field in APM Monitor script:
'${IP} ${USER} ${PASSWORD}
strComputer = objArgs(0)
strUser = objArgs(1)
strPassword = objArgs(2)
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer _
(strComputer, "root\cimv2", strUser, strPassword)
objSWbemServices.Security_.ImpersonationLevel = 3
Set colItems = objSWbemServices.ExecQuery("SELECT * FROM Win32_Service where StartMode = 'Auto' and State = 'Stopped'", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
sCount=0
For Each objItem In colItems
Select Case objItem.Name
'If a service name is listed in the following Case statement, it will be ignored.
'The service name is case sensitive and must be an exact match.
Case "SysmonLog"
Case "TBS"
Case Else
If sCount=0 Then
strServiceList = objItem.DisplayName & " (" & objItem.Name & ")"
Else
strServiceList = strServiceList & ", " & objItem.DisplayName & " (" & objItem.Name & ")"
End If
sCount = sCount + 1
End Select
Next
If sCount > 0 Then
WScript.Echo "Message: Auto Start Services Down: " & strServiceList
WScript.Echo "Statistic: " & CStr(sCount)
WScript.Quit(SUCCESS)
Else
WScript.Echo "Message: All Auto Start Services Are Up"
WScript.Echo "Statistic: 0"
WScript.Quit(SUCCESS)
End If