1

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

Rodolfo Donã Hosp
  • 1,037
  • 1
  • 11
  • 23

1 Answers1

1

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
tutunak
  • 61
  • 9
  • could you explain a little bit more? – user3642240 Mar 18 '19 at 10:50
  • This is information taken from official documentation Flexible user parameters Flexible user parameters accept parameters with the key. This way a flexible user parameter can be the basis for creating several items. Flexible user parameters have the following syntax: UserParameter=key[*],command you can read about this by link https://www.zabbix.com/documentation/3.0/manual/config/items/userparameters – tutunak Mar 18 '19 at 12:55
  • And I need to edit my script in order to accept the parameter, right? – user3642240 Mar 18 '19 at 13:55
  • Thank you, I've done that already but I'm facing another problem: The Zabbix Agent usually time out while executing the script; sometimes it executed the scripts and sent data to the server successful but most of the time, it fails. Please advice me. @tutunak – user3642240 Mar 19 '19 at 08:31
  • maximum timeout is 30 second for the item, or you can use trapper and script in cron or custom agent – tutunak Mar 19 '19 at 11:18