I'm trying to use Zabbix for monitoring CPU usage by different processes on Windows Server. Processes to monitor are not determined upfront. I want to use LLD to monitor top 3 CPU demanding processes.
Currently I've created a discovery rule that returns top 3 CPU demanding processes at given moment, for example:
{
{
"name":"DistributedCacheService",
"value":"9238.09375"
},
{
"name":"System",
"value":"6649.234375"
},
{
"name":"svchost",
"value":"5224.40625"
}
}
Then I've created macros using json paths and item prototype and that's where i started to experience problems. I'm using earlier created LLD macro for item name and I'm using system.run command for obtaning a value in key field. Item name is supposed to process name and item key, value is supposed the CPU usage by that process. [enter image description here][1] [1]: https://isstatic.aoverflow.com/HuNbd.png
When testing discovery rule and item prototype everything runs fine, but when i try to run that discovery rule I get an error
"Cannot create item: item with the same key "system.run[powershell.exe -nolog -command "(Get-Process | Sort-Object CPU -desc | Select-Object -index 0 | Format-Table -Aut...]" already exists."
Firstly, there is no other item with the same key.
Secondly, when my discovery rule will detect other processes, there will have to be created other items with the same key. Other names, but the same key
Is it even possible to create processes CPU usage monitoring using LLD? I don't want to be stuck with predefined processes, I would like to have them dynamicly added with LLD.
Zabbix requires keys be unique for a single host, so you'll run into problems when there is more than one of the same named process if you store processes by name (https://www.zabbix.com/documentation/current/manual/config/items/item)
Process names don't need to be unique, so Get-Process returns objects with duplicate ProcessName values.
You can add
-Unique
to theselect
cmdlet to drop duplicates. This might hide data you want to log.The Zabbix team looks like they provided a workaround to this problem here: https://support.zabbix.com/browse/ZBXNEXT-164
UserParameter=top,top -n 1 -b|head -20
For each item that you've create, you have to create a new keyitem, for example get.top.proccess.[{#Name}]. This way each item has a different keyitem becase the variable changes.