Our client needed this type of monitoring to do reports based on this data, so we did these SCOM RULES based on scripts.
One little notice before we start with the scripts: some people ask us what "Call oAPI.LogScriptEvent" does. The answer is that this call writes an event with number 2000 in the agent machine and it is useful for debugging.
If you don´t know or you don´t remember how to associate a script to SCOM RULE here is an old post talking about this topic.
Here are the scripts, I hope they will be as useful to you as they were to us.
Memory_Pool_XXX.vbs
'SCOM 2012 script memory performance by command line match
Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Perfvalue=0
Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
Set colObjects = objWMI.ExecQuery("Select * From Win32_Process where name = ""w3wp.exe"" ") ' Mas ajustado
For Each Item in colObjects
if inStr(Item.commandline, "www_POOL_XXX") then
i=i+1 'Debug
commandline=Item.commandline 'Debug
Call oAPI.LogScriptEvent("MyPerfCollectionScript.vbs", 2000, 4 ,"Working Set size in WMI: " & Item.WorkingSetSize & "Process Id: " & item.ProcessID )
Perfvalue=Item.WorkingSetSize
nombre=item.Name 'DEBUG
End If
Next
Set objSysInfo = CreateObject( "WinNTSystemInfo" )
strComputerName = objSysInfo.ComputerName
Call oBag.AddValue("ComputerName",strComputerName)
execresult="valor final " + PerfValue + " comando " + commandline + "Nombre proceso: "+ nombre 'Debug
Call oAPI.LogScriptEvent("MyPerfCollectionScript.vbs", 2000, 4 ,"Reported value: " & execresult ) 'Debug
Call oAPI.LogScriptEvent("MyPerfCollectionScript.vbs", 2000, 4 ,"Numero procesos encontrados: " & i) 'Debug
Call oBag.AddValue("Perfvalue",Perfvalue)
Call oAPI.Return(oBag)
CPU_Pool_XXX.vbs
'SCOM 2012 script CPU performance by command line match
Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Set objWMI = GetObject("winmgmts:\\.\root\cimv2")
Set colObjects = objWMI.ExecQuery("Select * From Win32_Process where name = ""w3wp.exe""")
For Each Item in colObjects
if inStr(Item.commandline, "www_POOL_XXX") then
processIDstr=Item.ProcessId
Set colObjects2=objWMI.ExecQuery("Select * From Win32_PerfFormattedData_PerfProc_Process") 'Mejora
For Each Item2 in colObjects2
if inStr(Item2.IDProcess, processIDstr) then
PerfValue=item2.PercentProcessorTime
End If
Next
End If
Next
Call oBag.AddValue("PerfValue",PerfValue)
Call oAPI.Return(oBag)
No comments:
Post a Comment