VB Script to Monitor Windows Process and send alerts

By | September 11, 2012

VB Script to Monitor Windows Process

Monitoring a Windows process is different from service monitoring. I was using IPSentry to monitor few of my websites, but the IPSentry applications was crashing without my knowledge and thus leaving the websites with no monitoring. So I setup a Windows schedule task with the following VB script to monitor the IPsentry process on every 5 minutes.

The script identify IPSentry.exe process availability and sent email if incase the process was not running. So I can know at what time the process was crashed and even I can restart the application.

Set email = CreateObject(“CDO.Message”)

strComputer = “.”

Set objWMIService = GetObject(“winmgmts:” _

& “{impersonationLevel=impersonate}!\\” & strComputer & “\root\cimv2″)

Set colProcesses = objWMIService.ExecQuery _

(“Select * from Win32_Process Where Name = ‘IPSentry.exe'”)

If colProcesses.Count = 0 Then

email.Subject = “IPSentry DOWN”

email.From = “alerts @techiesweb.com”

email.To = “monitoring @techiesweb.com”

email.TextBody = “IPSentry process is NOT running. Immediately start the application to avoid any further problems.”

email.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/sendusing”)=2

email.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserver”)=”smtp1.techiesweb.com”

email.Configuration.Fields.Item(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”)=25

email.Configuration.Fields.Update

email.Send

End If

set email = Nothing

Copy the VB script in a notepad and save it as TechieswebPM.vbs. Add the process monitoring VB script to Windows schedule task to monitor the required process at a specific internal.

A monitoring script to monitor the monitoring tool :)

Cheers!!

Melbin Mathew

www.techiesweb.com

Melbin Mathew

I am Melbin Mathew, Systems Engineer from Kerala, India. I live with my parents, daughter and my wonderful wife. I graduated in 2004 with a bachelor’s degree in Electronics and Hardware from Mahatma Gandhi University, Kottayam and completed certification in MCITP, RHCE, CCNA, VCP ...Read More