Here are instructions to set up a Windows Powershell data collector to monitoring the status of any windows service.

1. In your Dotcom-Monitor account, set up a MetricsView Custom Collector:
MVCol

2. Setup a custom collector task. You must fill out the host category instance and counter fields, but it doesn’t matter what they are, they are not used for this.  The Aggregation type for the Task must be set to MIN or MAX.  MVCCTask

The service status can be in 7 states. By default they are transformed into values:

  • Service is stopped – default 1000
  • Service is starting – default 2000
  • Service is stopping – default 3000
  • Service is running – default 4000
  • Service is resuming work after pause – default 5000
  • Service is pausing – default 6000
  • Service is paused – default 7000

We recommend using Min, so you can set your Min threshold to Anything less than 2000 to will detect “service is Stopped”.

3. Create a ticket to receive the script.

4. Open Powershell as administrator.

5. Navigate to the directory where ServiceMonitoring.ps1 is (for example, I created a folder in the c: drive) cd c:\ps\

6. Run the command

 set-executionpolicy unrestricted

7. Run the  command

 .\ServiceMonitoring.ps1 -collector <Collector ID>-task <Task UID> -service <Service name>  -log

The collector ID is found under Configure MetricsView Collectors.  MVCCID

The task ID is found when editing the task.MVCCTaskId

Service Name is spelled exactly as it shows up in the services window.

If you don’t put in a valid task ID you will get an error.

With the –log command you can verify the script was working correctly in the event viewer:WindowsLog

8. Set up the script to run periodically through Windows Task Scheduler or any other tool you use to run scripts.

Additional Information about the Script

To get built-in help, execute

.\ServiceMonitoring.ps1

The -log key enables logging to EventLog “Windows Logs/Application”. By default, the logging is done to the Console only.

The service status can be in 7 states. By default they are transformed into values:

  • Service is stopped – default 1000
  • Service is starting – default 2000
  • Service is stopping – default 3000
  • Service is running – default 4000
  • Service is resuming work after pause – default 5000
  • Service is pausing – default 6000
  • Service is paused – default 7000

These values can be set to any other values using command line keys:

-stopped <number>

-starting <number>

-stopping <number>

-running <number>

-continuing <number>

-pausing <number>

-paused <number>

  • Why to Monitor Windows Services