Ad Widget

Collapse

external scripts and exit codes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • moses.moore
    Junior Member
    • Dec 2014
    • 24

    #1

    external scripts and exit codes

    I'm writing a new external script. It works pretty well, and I can test it with `zabbix_agentd -t 'app_thing[param1]`. I'm glad it can do freeform text and not depend on restrictive formats.

    I insist on stuff that I write to fail gracefully, so I'm testing with bad data, and expecting that the Zabbix agent will recognize that something failed. In the external script I use error messages and "exit 1" where 1 is something not 0, as is normal in writing shell scripts.

    Here's a dummy external script
    Code:
    #!/bin/sh
    [ "$1" == 'ping' ] && echo 1 && exit 0
    echo "ERR_invalid_param" && exit 1
    So when I try testing with valid data:
    Code:
    $ zabbix_agentd -t 'app_thing[ping]'
    app_thing[ping]          [t|1]
    So far so good. Now trying with something that should throw an error:
    Code:
    $ zabbix_agentd -t 'app_thing[xyzzy]'
    app_thing[xyzzy]         [t|ERR_invalid_param]
    I'm confused because I expected that 't' (true) to be a 'f' (false) because the external script returned a non-zero exit code.

    When writing a Zabbix external script, how should I signal to the zabbix agent that the external script failed? Maybe I need to write to stderr instead, leaving stdout empty? Does the zabbix agent always return 't' to the server even if the external script fails?
  • Atsushi
    Senior Member
    • Aug 2013
    • 2028

    #2
    exit code is not handling.

    By using a script such as the following, what do not you create a trigger to be considered an error if the value is 0?

    Code:
    #!/bin/sh
    [ "$1" == 'ping' ] && echo 1 && exit 0
    echo 0
    That 't' is not 'true'.
    't' is data type for 'text'.
    Please try get values for other keys.

    ex.
    'u' : Unsigned int 64
    'd' : Double
    's' : String

    Comment

    • moses.moore
      Junior Member
      • Dec 2014
      • 24

      #3
      What is the difference between 's' string and 't' text?

      Could you remind to me where in the Zabbix documentation is described " 't' is data type for text" ?

      I found https://www.zabbix.com/documentation...types/external
      but this page does not describe 't'.

      Comment

      • Atsushi
        Senior Member
        • Aug 2013
        • 2028

        #4
        zabbix_agentd's '-t' option is just for testing.
        You do not need to be checked that charactor before '|'.
        If you want more details, please check the zabbix_agentd program source.

        src/libs/zbxsysinfo/sysinfo.c : function test_parameter()

        That difference with 's' and 't' is short string or large text data.
        I think that difference like a data type with VARCHAR(255) and TEXT on DBMS.

        Comment

        Working...