0

I am trying to fetch windows process metrics and facing some difficulties. To begin with I created a new template, added a discovery rule and named the key win.process.metrics

Then I created 2 item prototype with following key.

Type Zabbix Agent(Active): win.process.metrics[{#PID}]
Type Dependent Item: win.process.metrics[{#PROCESSNAME}]

I created 2 LLD macros for the same

{#PROCESSNAME} = $.ProcessName
{#PID}=$.Id

Then I created userparameter in zabbixAgent conf file

UserParameter=metric.process.discovery,powershell -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\Zabbix Agent\scripts\ProcessMetrics.ps1"

Content of the PowerShell script

Get-Process | Select ProcessName, Id, Description | ConvertTo-Json -Compress

Here is the sample result

[
  {"ProcessName":"chrome","Id":1232,"Description":"G oogle Chrome"},
  {"ProcessName":"chrome","Id":1500,"Description":"G oogle Chrome"}
]

When I enable the item prototype, I see that data is ingesting however for PID process I see item does allow parameters error

screenshot attached

I would like to know how can I ingest multiple key value pairs using one discovery rule. Is it possible in first place?

Appreciate your guidance in resolving this issue.

Gryu
  • 499
  • 1
  • 6
  • 14
Nav
  • 1
  • 2

2 Answers2

0

I would try to stop using user parameter, I've achieved similar results by enabling remote commands and using system.run as a main part of key, that way you don't have to use user parameters and you can acheive basically anything, you only have to be carefull when you try to use commans in key, but there are available some workaorunds. Feel free to ask more questions, I've been dealing with those type of problems for a while.

Paweł Zimny
  • 195
  • 4
  • 16
  • Thanks Pawel, can you share an example of how it will be done? – Nav Jul 31 '20 at 01:55
  • For example to get top X processes sorted by CPU usage I'm using this key system.run[[powershell.exe -nolog -command "((Get-Counter '\Process(*)\% Processor Time' -ErrorAction SilentlyContinue).Countersamples | Sort cookedvalue -Desc| Select -First 6|Format-Table -HideTableHeaders InstanceName, CookedValue);"]] You only have to remember to use double square brackets and enable remote commands. Using this approach sky is the limit, you can get anything you want from performance monitor. – Paweł Zimny Aug 04 '20 at 06:43
0

You are calling a user parameter metric.process.discovery with [PID] as a parameter in each item, but you didn't configure this userparameter to work with parameters. You just can run metric.process.discovery WITHOUT parameters.

What you expect to receive in each item ?

Kevin Yan
  • 1
  • 2
  • Thanks Kevin for the response, basically, i am trying to get per process metrics from windows system like CPU, Disk I/O, Network, RAM, etc. If i get only 1 metrics for example CPU, i can see the value, if i try to query any more values using item proto-type. I get error as stated above. If I try dependent item, then data isn't retrieved properly. – Nav Jul 31 '20 at 01:59