Alrighty then, I've been working on this problem for two days now.
Yesterday, when I came into the office, 16 of my nodes had interfaces in an "Unknown State". I've complained on Thwack about this issue before, though I have a feeling it's more related to my systems and the Dell SNMP agent rather than Solarwinds.
Needless to say, I quickyl discovered that this "unknown state" is quickly cleared with a simple restart of the Windows SNMP Service. Through some searching, I wrote a WMI script to restart the service remotely. I wanted to setup an alert that would automatically run this script for me, should an interface go into an unknown state.
Now, I've already gone through the trouble of writing the script so that it issues the right command based on the current state of the service, that it runs with the right credentials, etc. etc. That, I thought, was the hard part. It appears that although Orion says it has run the script successfully, nothing happens. However, if I run the script manually, everything is peachy keen.
Here's what I've got:
This is what is in the Solarwinds Alert Trigger:
Execute Program:
\Progra~1\Solarwinds\Orion\CustomAlerts\SNMPRS\runme.bat ${NodeName}
This is what "runme.bat" contains:
runas /u:DOMAIN\username "wscript.exe
\Progra~1\Solarwinds\Orion\CustomAlerts\SNMPRS\snmprestart.vbs %1 SNMP" |
\Progra~1\Solarwinds\Orion\CustomAlerts\SNMPRS\sanur password
By the way, sanur is a small program used to pass alternate credentials to the runas command. I've used it for years.
And for those of you who are still with me, this is what snmprestart.vbs contains:
'// ---------------------------------------------
'// Windows Service Remote Restart Script
'// Version 1.0, G. Sewell, grantsewell@gmail.com
'// ---------------------------------------------
'// Pull the computer name, service name from an argument
Dim ArgObj, strComputer, strServiceName
Set ArgObj = WScript.Arguments
'// Set the variables
strComputer = ArgObj(0)
strServiceName = ArgObj(1)
'// Stop Service
StartWin32Service strComputer, strServiceName, False
'// Pause to allow service to stop
Wscript.Sleep 10000
'// Start Service
StartWin32Service strComputer, strServiceName, True
Sub StartWin32Service(vComputer, vServiceName, bStart)
Dim strWQL
Dim objWMIService
Dim colWinServiceSet
Dim objWinService
Dim intRetVal
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" & vComputer & "\root\cimv2")
If Err <> 0 Then
Wscript.Echo "Connect to " & vComputer & " failed."
Err.Clear
Exit Sub
End If
strWQL = "SELECT * FROM Win32_Service"
strWQL = strWQL & " WHERE Name = '" & vServiceName & "'"
Set colWinServiceSet = objWMIService.ExecQuery(strWQL)
If colWinServiceSet.Count > 0 Then
For Each objWinService in colWinServiceSet
If bStart = True Then '// Start Service
If objWinService.Started = False Then '// If Service is in Stop status
intRetVal = objWinService.StartService
End If
Else '// Stop Service
If objWinService.Started = True Then '// If Service is in Start status
intRetVal = objWinService.StopService
End If
End If
Next
End If
Set objWMIService = Nothing
End Sub
I found another post in the legacy application monitor forum that suggests that this should work, however, I'm stuck to no avail, and my head hurts. Does anyone else have a similar solution, or possibly a working suggestion to my problem?