{"id":130,"date":"2007-01-25T22:59:29","date_gmt":"2007-01-25T20:59:29","guid":{"rendered":"http:\/\/contoso.se\/blog\/?p=130"},"modified":"2007-01-26T11:55:20","modified_gmt":"2007-01-26T09:55:20","slug":"check-two-or-more-performance-counters","status":"publish","type":"post","link":"http:\/\/contoso.se\/blog\/?p=130","title":{"rendered":"Check two or more performance counters"},"content":{"rendered":"<p>I have done a script that will check two performance counters and generate an alert if both are over threshold values. It simple to add more performance counters and change the threshold values. I have test it on Windows Server 2003 and Window XP 32bit. Its fairly basic, but it will show you a way to generate an alert based on two or more performance counters.<\/p>\n<blockquote><p>strComputer = &#8220;.&#8221;<br \/>\nSet objWMIService = GetObject(&#8220;winmgmts:&#8221; _<br \/>\n&#038; &#8220;{impersonationLevel=impersonate}!\\\\&#8221; &#038; strComputer &#038; &#8220;\\root\\cimv2&#8221;)<br \/>\nset objRefresher = CreateObject(&#8220;WbemScripting.SWbemRefresher&#8221;)<br \/>\nSet colItems = objRefresher.AddEnum _<br \/>\n(objWMIService, &#8220;Win32_PerfFormattedData_PerfOS_System&#8221;).objectSet<br \/>\nobjRefresher.Refresh<br \/>\nFor i = 1 to 2<br \/>\nFor Each objItem in colItems<\/p>\n<p>strProc = objItem.Processes<br \/>\nstrCPUQL = objItem.ProcessorQueueLength<\/p>\n<p>If strProc > 40 AND strCPUQL > 0 Then<br \/>\nConst EVENT_WARNING = 2<br \/>\nSet objShell = CreateObject(&#8220;Wscript.Shell&#8221;)<br \/>\nobjShell.LogEvent 2, &#8220;Number of processer: &#8221; &#038; strProc &#038; &#8220;. Processor Queue Lenght: &#8221; &#038; strCPUQL<br \/>\nEnd If<br \/>\nobjRefresher.Refresh<br \/>\nNext<br \/>\nNext<\/p><\/blockquote>\n<p>1. Create a new script and paste the script source<br \/>\n2. Create a new event rule to run the script every X minute as respond<br \/>\n3. Create a new event rule to collect event ID 2 and event type of Warning<br \/>\n4. Commit configuration change<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have done a script that will check two performance counters and generate an alert if both are over threshold values. It simple to add more performance counters and change the threshold values. I have test it on Windows Server 2003 and Window XP 32bit. Its fairly basic, but it will show you a way &hellip; <a href=\"http:\/\/contoso.se\/blog\/?p=130\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[2,13],"tags":[],"_links":{"self":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/130"}],"collection":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130"}],"version-history":[{"count":0,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions"}],"wp:attachment":[{"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/contoso.se\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}