2014年8月8日 星期五

SCOM - Created a sample MP to create the performance data based on WMI Query



1. Create a Probe-Based (script) performance collection rule & Set Target as Windows Computer
2. Select Management Pack and Set the Rule Name.
3. Set the Schedule
4. Type the Name and extension of the script, such as DiskSizeCollectionScript.vbs, timeout value and copy the below script.
5. Set Timeout to the length of time in seconds, minutes, hours, or days, the script can run before it is terminated.
6. On the Performance Mapper page, map parameters from the script to fields [Parameters are case sensitive]
Object : Disk_Name
Counter : Disk_Size
Instance : $Data/Property[@Name='drive']$
Value : $Data/Property[@Name='diskSize']$

7. Click Ok and create


'======================Script ================
Dim oAPI, oBag , oArgs , objShell,disksizeGB

' Set SCOM parameters
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oArgs = WScript.Arguments

Set objShell = Wscript.CreateObject("Wscript.Shell")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colVolume = objWMIService.ExecQuery("Select * from Win32_Volume")

For each objVolume in colVolume
disksizeGB=round(objVolume.Capacity/1024/1024/1024,0)

Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue ("DiskName", objVolume.Caption)
Call oBag.AddValue ("DiskSize", diskSizeGB)
Call oAPI.Return(oBag) 

Next
'======================End======================

沒有留言:

張貼留言