Search code examples
jsonkeyzabbixlld

Zabbix discovery rules - how to fill in key item


I'm new in Zabbix and I'm having a problem. I run a script in power shell and get this sample data:

{
        "data":[
                {
                        "{#BZSENDPORTNAME}":"Com_Onshore_SDE",
                        "{#BZSENDPORTSTATUS}":"3"},
                    {
                        "{#BZSENDPORTNAME}":"Com_Onshore_Backup",
                        "{#BZSENDPORTSTATUS}":"3"},
                    {
                        "{#BZSENDPORTNAME}":"Remit_ForecastMeter",
                        "{#BZSENDPORTSTATUS}":"3"}]}

Here is just a sample, there are around more than 40 pair of port name and port status. I've already created a discovery rule in Zabbix server and I hope it can automatically create items with their names are {#BZSENDPORTNAME} and their values are {#BZSENDPORTSTATUS}. For example: item Com_Onshore_SDE ; value = 3. I created a discovery here. Then I get the result like this:

enter image description here

The name of the items are what I expected but the key contains the value of the port status I would like the port status is the value of the item, not the key. And also it shows the error "Item does not allow parameter". The Zabbix agent config file is: UserParameter=custom.discovery,powershell.exe -NoProfile -ExecutionPolicy Bypass -file "C:\Zabbix\Scripts\Get-BZSendMultiPortsInfo-test.ps1"

Please help me with this. Many thanks


Solution

  • You should use [*] in your user parameter and add $1 and $2 to end of string:

    UserParameter=custom.discovery[*],powershell.exe -NoProfile -ExecutionPolicy Bypass -file "C:\Zabbix\Scripts\Get-BZSendMultiPortsInfo-test.ps1" $1 $2