{"id":1301,"date":"2009-03-20T08:45:31","date_gmt":"2009-03-20T16:45:31","guid":{"rendered":"http:\/\/www.sapien.com\/blog\/2009\/03\/20\/status-indicators-with-powershell-and-polymonrt\/"},"modified":"2009-03-20T08:45:31","modified_gmt":"2009-03-20T16:45:31","slug":"status-indicators-with-powershell-and-polymonrt","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2009\/03\/20\/status-indicators-with-powershell-and-polymonrt\/","title":{"rendered":"Status Indicators with PowerShell and PolyMonRT"},"content":{"rendered":"<p>In my last <a href=\"http:\/\/redmondmag.com\/columns\/columnist.asp?ColumnistsID=38\" target=\"_blank\">Mr. Roboto<\/a> <a href=\"http:\/\/redmondmag.com\/columns\/article.asp?EditorialsID=3009\" target=\"_blank\">column<\/a>, I wrote about the open source project, <a href=\"http:\/\/www.codeplex.com\/polymon\" target=\"_blank\">PolyMonRT<\/a>. 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.<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2009\/03\/monitorproperties.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 5px 5px 5px 0px; border-right-width: 0px\" height=\"218\" alt=\"monitorproperties\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2009\/03\/monitorproperties-thumb.png\" width=\"244\" align=\"left\" border=\"0\"><\/a>First, 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.<\/p>\n<p>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: <\/p>\n<p><font face=\"Lucida Console\" color=\"#0000ff\" size=\"2\">$computer=&#8221;chaos&#8221;<br \/>$service=&#8221;spooler&#8221;<br \/>$svc=get-wmiobject win32_service -filter &#8220;name=&#8217;$service'&#8221; -computer $computer<br \/>if ($svc.state -eq &#8220;Running&#8221;) {<br \/>$polymonRT.counter=1<br \/>}<br \/>else {<br \/>$polymonRT.counter=0<br \/>}<\/font><\/p>\n<p>Click OK and start the monitor. You should get a result like this:<\/p>\n<p><a href=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2009\/03\/greenlight.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px\" height=\"124\" alt=\"greenlight\" src=\"http:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2009\/03\/greenlight-thumb.png\" width=\"122\" border=\"0\"><\/a><\/p>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2,25],"tags":[374,478,479,28,35],"class_list":["post-1301","post","type-post","status-publish","format-standard","hentry","category-general","category-windows-powershell","tag-performance","tag-polymon","tag-polymonrt","tag-powershell","tag-wmi"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/1301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=1301"}],"version-history":[{"count":0,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/1301\/revisions"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=1301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=1301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=1301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}