Ad Widget

Collapse

External scripts/commands paramater quoting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Spectroman
    Junior Member
    • Sep 2008
    • 17

    #1

    External scripts/commands paramater quoting

    Hello,

    I am migrating from zabbix 1.8 to 2.0 and I had a problem.

    As soon as I added templates with external commands with multiple parameters, that used to work on the 1.8 version, the same command start giving problems in the version 2.0.

    There reason I found is that, now all the parameters from the key got to execution fully quoted, where the command cannot see the individual parameters like before.

    Example:

    Version 1.8:
    check_dns[-H nl.local -Q SOA -z -W 300 -C 500 -a]

    the server will execute a command as:
    check_dns [hostname] -H nl.local -Q SOA -z -W 300 -C 500 -a

    (accordingly with documented feature: https://www.zabbix.com/documentation...xternal_checks )

    Now the same key in version 2.0, should be at least altered to:

    check_dns[{HOST.CONN} -H nl.local -Q SOA -z -W 300 -C 500 -a]

    according to: https://www.zabbix.com/documentation...types/external

    Then the server will double quote the whole parameter string as if it was only one parameter:
    check_dns "192.168.1.2 -H nl.local -Q SOA -z -W 300 -C 500 -a"

    Breaking the check completely.

    My solution was:

    edit in the source code the file : zabbix-2.0.4/src/zabbix_server/poller/checks_external.c

    and disable the quoting:

    /* param_esc = zbx_dyn_escape_string(param, "\"\\");*/
    param_esc = zbx_dyn_escape_string(param, "");
    /* zbx_snprintf_alloc(&cmd, &cmd_alloc, &cmd_offset, " \"%s\"", param_esc);*/
    zbx_snprintf_alloc(&cmd, &cmd_alloc, &cmd_offset, " %s", param_esc);

    then he will return to the previous behavior and work with the old style keys+parameters.

    Also is important to notice the text explaining the change is a bit wrong, as it states:
    " 5.3.2.4 External check parameter changes

    External check parameter handling was changed. Previously, only one parameter was accepted. Starting with Zabbix 2.0, the key syntax conforms to other types of items and multiple comma-separated parameters may be passed.

    Additionally, the hardcoded first parameter {HOST.CONN} for external checks has been removed and now external check parameters may be fully customised. Upgrade process adds this macro as a first parameter to all existing external checks.
    "
    from: https://www.zabbix.com/documentation...improved_items

    While the previous version accepted multiple parameters, the change improves escaping of values and introduces parameters separation with a comma, but before you could use multiple parameters without a comma.
  • tjuhasz
    Junior Member
    • Jan 2015
    • 1

    #2
    External scripts/commands paramater quoting

    Is there any other solution for this? The problem is still exists in Zabbix 2.2. Is it in the later version? I installed Zabbix from repository, so I could have not changed the source.

    Please let me know if there is any advice.

    Regards,

    Tamas Juhasz

    Comment

    Working...