[ZBX-4725] Discovery rule "external check" does not work if item parameter is a macro Created: 2012 Mar 02 Updated: 2017 May 30 Resolved: 2012 Mar 14 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Proxy (P), Server (S) |
Affects Version/s: | 2.0.0rc1 |
Fix Version/s: | 2.0.0rc1 |
Type: | Incident report | Priority: | Major |
Reporter: | Simon Kowallik | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 0 |
Labels: | discovery, lld, macros | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified |
Description |
When creating a discovery rule inside a template with type "external check" and using a macro like {HOST.IP} as a parameter to pass to the specified script in the key, zabbix fails to match the returned JSON.Example: key is: script.name[{HOST.IP} ,param1,param2] Template is assigned to host with IP 198.18.0.123. zabbix_server.log (Debug:4) says: 11507:20120302:191438.614 In substitute_key_macros() data:'script.name[ {HOST.IP},param1,param2]'11504:20120302:191438.614 End of get_values():0 11507:20120302:191438.614 In substitute_simple_macros() data:'{HOST.IP} ' 11504:20120302:191438.614 sleeping for 1 seconds 11507:20120302:191438.614 In get_value_external() key:'script.name[{HOST.IP} ,param1,param2]' 11507:20120302:191438.705 query [txnlev:1] [commit;] 11507:20120302:191438.708 End of DBlld_process_discovery_rule() Zabbix expects the script to return a JSON object with object name "script.name[{HOST.IP} ,param1,param2]" where the script would return "script.name[198.18.0.123,param1,param2]". That makes macros unusable as a parameter to the script. The script would never know what macro was supplied, just the value of the macro. I believe this is a bug.
Kind regards, |
Comments |
Comment by Oleksii Zagorskyi [ 2012 Mar 04 ] |
Yes, the macro {HOST.IP<1-9>} should be supported for "Item key's parameters" |
Comment by Simon Kowallik [ 2012 Mar 04 ] |
Dear Oleksiy, {HOST.IP<1-9>} is supported. That's not the point.The point is, that when using a macro the script will receive the macro value. In case of {HOST.IP<1-9>} it will be an IP address. Zabbix currently expects the script to return the configured key exactly like this: 'script.name[ {HOST.IP},param1,param2]' The script returns the IP instead of the macro, like this: 'script.name[198.18.0.123,param1,param2]' Zabbix should deal with that. br |
Comment by richlv [ 2012 Mar 04 ] |
could you please clarify where exactly are you using the string "script.name[ {HOST.IP},param1,param2]" ? |
Comment by Simon Kowallik [ 2012 Mar 04 ] |
In the key field, as documented. ----------------------------------------------------------------------------------------------------------------------------------------------------------------- Zabbix will call the script like: Log > 11507:20120302:191438.615 In zbx_popen() command:'/opt/zabbix/share/zabbix/externalscripts/script.name "198.18.0.123" "param1" "param2"' Naturally the script would return this JSON object: "{#MYVALUE}": "1000" }, { "{#MYINDEX1} ": "2", }, { "{#MYINDEX1}": "3", "{#MYVALUE} ": "3000" Log > 11507:20120302:191438.705 query [txnlev:1] [update items set lastclock=1330712078,lastns=704097134,error='Cannot find the "script.name[{HOST.IP} ,param1,param2]" key in received JSON object' where itemid=22508] When the script returns the macro name in the JSON object it works. Working JSON object, returned by the script. ,param1,param2]": [ "{#MYVALUE}": "1000" }, { "{#MYINDEX1} ": "2", }, { "{#MYINDEX1}": "3", "{#MYVALUE} ": "3000" |
Comment by richlv [ 2012 Mar 04 ] |
hmm. why use the macro at all then ? also, it's better to attach images directly to the issue, that way they are more permanent (and imageshack is terrible, i can never get the full size image there ) |
Comment by Simon Kowallik [ 2012 Mar 04 ] |
Well I use the macro because I define this discovery rule inside a Template. And I would like to assign that Template to a lot of devices. Attaching an Image does not work for me. Java Clipboard Copy&Paste is not very nice. Sorry. |
Comment by richlv [ 2012 Mar 04 ] |
at the top of this issue, there should be "more actions -> attach files" |
Comment by Simon Kowallik [ 2012 Mar 04 ] |
The script needs an IP address or Hostname to connect to. That's why it needs a macro, or IP, or Host. |
Comment by richlv [ 2012 Mar 04 ] |
ah, right, sorry - missed the fact that it's an external check. |
Comment by Alexander Vladishev [ 2012 Mar 06 ] |
Fixed in the development branch svn://svn.zabbix.com/branches/dev/ZBX-4725 Fixed documentation: Now, a JSON object should contain not an item key but "data". For example: old JSON object ":"eth0"}, {" {#IFNAME}":"eth1"}]}new: {"data":[{"{#IFNAME} ":"lo"}, {" {#IFNAME}":"eth0"}, {"{#IFNAME}":"eth1"}]} |
Comment by Oleksii Zagorskyi [ 2012 Mar 06 ] |
Sasha, regarding this changes, will trunk agents 1.9.x-1.9.9 (agents compiled before this change) work with latest revisions of zabbix server ? <Sasha> Yes, all agents should be recompiled too. LLD checks won't work with the old 1.9.9 agent and the new 1.9.10 server. |
Comment by dimir [ 2012 Mar 13 ] |
Fix components. |
Comment by dimir [ 2012 Mar 13 ] |
Brilliant, works like a charm. |
Comment by Alexander Vladishev [ 2012 Mar 13 ] |
Fixed in the version pre-2.0.0rc1, r26035. |
Comment by dimir [ 2012 Mar 14 ] |
Reopening to fix title. |
Comment by dimir [ 2012 Mar 14 ] |
Fix title |
Comment by dimir [ 2012 Mar 14 ] |
Close issue |
Comment by Oleksii Zagorskyi [ 2012 Mar 15 ] |
Just a note for my latest comment: If use zabbix agent versions 1.9.1-1.9.9 (beta versions) with zabbix server version 2.0.x then LLD will not work and every discovery rule will have this error description: |
Comment by Kenneth Palmertree [ 2014 Jul 14 ] |
This looks like it broke again in 2.2.4. Was working in 2.2.3. External scripts using macros in lld keys get json errors back. |
Comment by Oleksii Zagorskyi [ 2014 Jul 14 ] |
Kenneth, if it is then you would need to create another ZBX report. |