Ad Widget

Collapse

Questions on Trigger Actions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stu42j
    Junior Member
    • Feb 2010
    • 9

    #1

    Questions on Trigger Actions

    It appears that Zabbix will only run one instance of an action script at a time, even if there are multiple triggers with the same action. Is this correct?

    It also seems that Zabbix will retry the notification 4 times? Is this configurable? Also, how does Zabbix determine if the script was successful? Is there a particular way the script can return an error?
  • alixen
    Senior Member
    • Apr 2006
    • 474

    #2
    Originally posted by stu42j
    It appears that Zabbix will only run one instance of an action script at a time, even if there are multiple triggers with the same action. Is this correct?
    Unless I misunderstand your question, this is not correct.
    Action will be executed for each trigger.
    If 10 triggers fire up at the same time, action script will be executed 10 times.

    Originally posted by stu42j
    It also seems that Zabbix will retry the notification 4 times? Is this configurable?
    From Zabbix source code:
    Code:
    frontends/php/include/defines.inc.php:  define('ALERT_MAX_RETRIES',             3);
    include/common.h:#define ALERT_MAX_RETRIES      3
    So you are right, notification will be executed at most 4 times (first try + 3 retries).
    This value is hardcoded; you will have to recompile in order to change it.

    Originally posted by stu42j
    Also, how does Zabbix determine if the script was successful? Is there a particular way the script can return an error?
    At first, I supposed that Zabbix checked script exit value.
    But after checking source code in src/zabbix_server/alerter/alerter.c:
    Code:
                    pid = zbx_fork();
                    if(0 != pid)
                    {
                            waitpid(pid,NULL,0);
                    }
                    else
                    {
                            .... child process execution ....
                    }
                    res = SUCCEED;
    exit value from child process is forgotten since return value from 'waitpid' is ignored and result is always set to SUCCEED.
    So I assume that retries work only for internal actions (email, IM, jabber) but not for external scripts.

    regards,
    Alixen
    http://www.alixen.fr/zabbix.html

    Comment

    • stu42j
      Junior Member
      • Feb 2010
      • 9

      #3
      [QUOTE=alixen;60591]Unless I misunderstand your question, this is not correct.
      Action will be executed for each trigger.
      If 10 triggers fire up at the same time, action script will be executed 10 times.

      If the action script takes a while to complete, I can see that there is only one process running and the actions for other triggers are listed as pending.

      Thank you for your answers on my other questions.

      Comment

      • alixen
        Senior Member
        • Apr 2006
        • 474

        #4
        Originally posted by stu42j
        If the action script takes a while to complete, I can see that there is only one process running and the actions for other triggers are listed as pending.

        Thank you for your answers on my other questions.
        OK, I misunderstood your question.
        Since Zabbix doesn't check action script return value, you could run it in background so that zabbix is not blocked waiting for its end.

        If your action script looks like:
        Code:
        #! /bin/sh
        ....
        long_running_command
        exit
        You can replace it with:
        Code:
        #! /bin/sh
        ....
        nohup long_running_command > /dev/null 2>&1 &
        exit
        Regards,
        Alixen
        http://www.alixen.fr/zabbix.html

        Comment

        Working...