So from that point I knew I should use the “UserParamater” to get them. Additional issue, and very obvious, is that those PIDs are changing with every OS reboot. The solution is a script in powershell that you can run after each reboot, for ex. in “task scheduler”. It will create/update *.vbs scripts that are responsible for gathering the data about the memory utilization, of course zabbix_agentd.conf has to contain lines like:
UserParameter=GetMemoryVCS02DB,%systemroot%\system32\cscript.exe /nologo c:\zabbix\OracleServiceVCS02DB.vbs
to refer to those scripts. Script is very simple and looks like this:
$services = (gwmi WIn32_Service | where {$_.name -match "OracleService"})
foreach ($service in $services) {
$f = $service.name + ".vbs"
$p = $service.ProcessID
If ($f) {Clear-Content $f}
out-file -filepath $f -append -inputobject 'Set objWMI = GetObject("winmgmts:\\.\root\cimv2")'
out-file -filepath $f -append -inputobject "Set colObjects = objWMI.ExecQuery(`"SELECT * FROM Win32_Process WHERE ProcessID =`'$p`'`")"
out-file -filepath $f -append -inputobject 'For Each Item in colObjects'
out-file -filepath $f -append -inputobject 'wScript.Echo Item.WorkingSetSize'
out-file -filepath $f -append -inputobject 'Next'
}
Brak komentarzy:
Prześlij komentarz