Isso é um pouco feio, mas você provavelmente poderia modificá-lo para atender às suas necessidades. Basta configurar uma tarefa agendada para chamar o script de vez em quando.
Dim ServiceDown
Dim Message
Function sGetServiceStatus(ByVal strServiceName)
wbemImpersonationLevelImpersonate = 3
wbemAuthenticationLevelPktPrivacy = 6
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer("localhost")
objWMIService.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
objWMIService.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy
Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service Where DisplayName ='"& strServiceName & "'")
if(colListOfServices.Count=0) then
sGetServiceStatus = ""
Exit function
end if
For Each objItem in colListOfServices
If objItem.DisplayName = strServiceName and objItem.State = "Running" Then
sGetServiceStatus = objItem.State
Exit Function
else
sGetServiceStatus = objItem.State
ServiceDown = True
Message = Message & vbcrlf & strServiceName
Exit function
End If
Next
sGetServiceStatus = ""
End Function
sGetServiceStatus("ISC BIND")
sGetServiceStatus("Apache2.2")
sGetServiceStatus("MySQL")
If ServiceDown Then
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Check Services"
objMessage.From = "[email protected]"
objMessage.To = "[email protected]"
objMessage.TextBody = "The following service(s) is/are down: " & Message
objMessage.Send
End If