How to monitor a Windows process and restart it when it goes down?
A:
In IPHost Network Monitor each monitor should return integer, so you have to SELECT some
integer property of the process to be considered as a performance value for
monitor. You may choose any integer property of the Win32_Process class,
say ProcessId, HandleCount or VirtualSize form the list specified at:
http://msdn.microsoft.com/en-us/library/aa394372(VS.85).aspx
For example, you can use the following query:
SELECT ProcessId FROM Win32_Process WHERE Name = "startup.exe"
To restart the program you may use 2 options. Both use the alert configured to be executed once a monitor is switched to Down state:
- If you need to restart the program on the local host the IPHost is installed on, you may use the "Execute Program" alert in the "Run program" mode.
- If you need to restart the program on the remote server you would need to use the external VBS script. Put it somewhere on the server the IPHost is installed on and use the "Execute Program" alert in "Run Script" mode to run the program remotely.
The following simple VBS script which may be used for restart:
Restart.vbs file:
----------------------
Dim args
Set args = WScript.Arguments
strComputer = args(0)
strCommandLine = args(1)
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
Error = objWMIService.Create(strCommandLine, null, null, intProcessID)
WScript.quit Error
----------------------
The script accepts 2 parameters: host name of the server to run program on and the command line. It may be started from the command prompt as:
cscript restart.vbs server C:\\somedirectory\\startup.exe
To invoke script from IPHost Network Monitor you should create a custom alerting rule and alert for monitor and configure them as shown on the screenshots below:
For more details on how to configure alerts please refer to the appropriate Help topic.
Related Topics:
Software application monitoring
Monitoring Remote Servers Through Firewalls




