메모리 사용률 수집 규칙 VB Script (VBS) - SCOM SystemCenter2009. 7. 14. 16:13
Rule > New > Probe based > Script(performance)
Object, Counter, Instance 적당한 값
Value: $Data/Property[@Name='% Used Memory']$
--------------------------------------------------------------------------------
UsedMemoryPercent.vbs
Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
dim hostName,strComputer
dim tMemoryKB,FreeMemoryKB,MemoryUsage
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
tMemoryKB = 0
Set colItems = objWMIService.ExecQuery("select * from Win32_OperatingSystem")
For Each objItem in colItems
tMemoryKB = objItem.TotalVisibleMemorySize
next
Set colItems = objWMIService.ExecQuery("select FreePhysicalMemory from Win32_OperatingSystem")
For Each objItem in colItems
FreeMemoryKB= objItem.FreePhysicalMemory
next
MemoryUsage = ((tMemoryKB - FreeMemoryKB)/tMemoryKB) * 100
Call oBag.AddValue("% Used Memory",MemoryUsage)
Call oAPI.Return(oBag)