zabbix_sender syntax for discovery rules

Steffen Nieuwenhoven picture Steffen Nieuwenhoven · Mar 20, 2014 · Viewed 7.6k times · Source

I have successfully installed a zabbix environment. Now I want to use zabbix_sender, to send data from a third party program to zabbix. I created a host “api_test”, and an item “test item ” with the key “java.test.item”. Sending

zabbix_sender -z localhost -p 10051 -s "api_test" -k java.test.item -o 1234

from the linux server works perfectly and adds a dataset as expected. The problem is, that I would like to use a discovery item, and I cannot find the right syntax for zabbix_sender. Here is how I configured the discovery rule:

Discovery rule configuration

And this is the Item Prototype:

Item Prototype configuration

I expected the following query to add an Item based on the item prototype, but nothing happens:

zabbix_sender -z localhost -p 10051 -s "api_test" -k java.th.discovery -o '{"data":[{"{#THNAME}:"test_thread"}]}'

I also tried with different quotations marks (single, double, without), but nothing seems to work. Consequently, the following query I tried afterwards fails:

zabbix_sender -z localhost -p 10051 -s "api_test" -k java.th.ex["test_thread"] -o 98765

Question is: where am I mistaken? I guess it is the discovery rule, or the zabbix_sender syntax for discovery, but I cannot find anything in the documentation.

Any help is appreciated!

Answer

asaveljevs picture asaveljevs · Mar 20, 2014

Steffen, your configuration in Zabbix frontend is correct.

However, there is a mistake in JSON syntax that you use in the command line. Double quotes after {#THNAME} are missing:

{"data":[{"{#THNAME}:"test_thread"}]}

You should see the error message about it in discovery list:

enter image description here

It should work after that issue is fixed. If not, please provide details about your "@Thread for discovery" macro and the error message that you get.