With scripts you can monitor almost everything in SCOM. Out of the box SCOM uses mostly VBScript instead of PowerShell, because it works on all Windows versions. I prefer PowerShell above VBScript, so I created some PowerShell performance collection rules and PowerShell monitors.
Silect created an awesome tool called MP Author to build management packs wizard driven.
The steps:
– Create new management pack, give it a name, choose a folder, locate the references and select Empty Management pack.
– Create a custom application class. In MPAuthor this called Targets, create a new target. I used WMI to locate the custom application service (Select * From Win32_Service Where Name Like “%Service name%”). We are working with a Windows local application, with Windows Computer as target.
– Next, create a custom PowerShell performance rule or a PowerShell monitor (works the same). New “Script performance rule”. Give the script a name and paste the code in the script area. In the next page provide the parameters:
Object: Testpage.com
Counter: Pagespeed
Instance: Someinstance
Value: $Data/Property[@Name=’Pageloadtime’]$
Select the target we created the above and finish the wizard.
Example script to explain the used SCOM variables:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#Create SCOM Script api connection $api = New-Object -comObject "MOM.ScriptAPI" #Create property bag $bag = $api.CreatePropertyBag() #Eventlog event start script $api.LogScriptEvent("YourScriptName.ps1",3280,0,"Pagespeed script is starting") #The script $webClient = new-object System.Net.WebClient $webClient.Headers.Add("user-agent", "PowerShell Script") $startTime = get-date $output = $webClient.DownloadString("http://www.google.com/") $endTime = get-date $Prefix = ($endTime – $startTime).TotalSeconds $Loadtime = [math]::round("$prefix",2) #Add values to the bag $bag.AddValue("Pageloadtime",$Loadtime) #Return the bag $bag |