Status Indicators with PowerShell and PolyMonRT

In my last Mr. Roboto column, I wrote about the open source project, PolyMonRT. I recently suggested it to someone as a solution, especially because PolyMonRT supports PowerShell as a provider. My friend wanted to use the status light indicator to show when a particular service was running or not. Basically Green is good and Red is not. It tool a little fiddling on my part but I came up with the process.

monitorpropertiesFirst, add a new monitoring chart, selecting PowerShell and change the style to Status Light. Then select Properties. Give your monitor a name. Enable both Thresholds. Set the first threshhold to a value of 0 and change the color to Red. Set the second threshold to 1 and change its color to Green. Adjust the refresh intervals as needed.

Next, click the Monitoring tab. Select PowerShelll from the dropdown. PolymonRT can use any value that you can derive from PowerShell. All you have to do assign the value to $PolyMonRT.Counter. Insert code like this:

$computer=”chaos”
$service=”spooler”
$svc=get-wmiobject win32_service -filter “name=’$service'” -computer $computer
if ($svc.state -eq “Running”) {
$polymonRT.counter=1
}
else {
$polymonRT.counter=0
}

Click OK and start the monitor. You should get a result like this:

greenlight

If the service stops the light will turn red. Personally, I would use this counter as an on/off display so something like this works just fine for me.