Ad Widget

Collapse

Alert emails & escallation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmz
    Junior Member
    • Jun 2005
    • 26

    #1

    Alert emails & escallation

    I just started using zabbix last week, and find it a great tool that I am enjoying getting use to how it works.

    One question: how do the alerts & outgoing messages work?

    I see all my traps going on/off for either tests or real events, however no alerts are being sent out.

    I have the following action set for all triggers:
    All UNIX administrators ON/OFF 30 *Automatically generated* Change

    I have myself in the unix administrators group, and have made sure that my media is properly defined as well as the systems media.

    I am running the code available in cvs (1.1 alpha 11), and I enjoy debugging stuff.

    Being curious, I did some searching through the server code and couldn't find any of the compiled applications that actually insert anything into tables. How does it create an alert if there are none inserted into the database?

    Also, is there anywhere a discussion, diagram, HOWTO on how the escallation rules/paths work?

    I'm sure I'll learn more as I use it more, but I need to get email alerts out otherwise my clients will think their stuff isn't being monitored (and an automated "at" spool job doesn't work

    Thanks!!

    David M. Zendzian
    dmz
  • araw
    Member
    • May 2005
    • 31

    #2
    Sorry, can't answer exactly how they work, but just a suggestion .... wrap your own media scripts so you can log attempts to send alerts, you can atleast determine exactly where and what is going out. I didn't get time to fully delve into how they work, because at the time sending of emails just didn't seem to work at all.

    mysql> SELECT * FROM media_type;
    +-------------+------+-------------+-------------+-----------+-----------------------+--------------+
    | mediatypeid | type | description | smtp_server | smtp_helo | smtp_email | exec_path |
    +-------------+------+-------------+-------------+-----------+-----------------------+--------------+
    | 1 | 1 | Email | localhost | localhost | [email protected]l | sendemail.sh |
    | 2 | 1 | SMS Alert | | | | sendsms.sh |
    +-------------+------+-------------+-------------+-----------+-----------------------+--------------+
    2 rows in set (0.01 sec)


    [root zabbix]# cat sendemail.sh
    #!/bin/sh
    # Colin Stubbs <[email protected]>

    PATH=/bin:/sbin:/usr/bin:/usr/sbin
    LOGFILE="/var/log/zabbix/sendemail.log"

    # Log it
    echo "'$3' | /bin/mail -s '$2' '$1'" >> ${LOGFILE}

    # Send it
    echo "$3" | /bin/mail -s "Zabbix: $2" "$1"

    # EOF

    [root zabbix]# cat sendsms.sh
    #!/bin/sh
    # Colin Stubbs <[email protected]>

    PATH=/bin:/sbin:/usr/bin:/usr/sbin
    LOGFILE="/var/log/zabbix/sendsms.log"

    #echo "Recipient='$1' Subject='$2' Message='$3'" >> ${LOGFILE}

    MOBILE_NUMBER=`echo "$1" | sed s#\s##`

    # Log it
    echo "echo 'Zabbix: $2 - $3' | /usr/bin/gnokii --sendsms '${MOBILE_NUMBER}'" >>${LOGFILE}

    # Send it
    echo "Zabbix: $2 - $3" | /usr/bin/gnokii --sendsms "${MOBILE_NUMBER}" 1>>${LOGFILE} 2>&1

    # EOF

    Comment

    • dmz
      Junior Member
      • Jun 2005
      • 26

      #3
      Alerts

      Maybe someone can point out where in the code that the alerts are generated and put into the database && || alerts are sent out.

      I've looked through the code some but just can't seem to find where the alerts are created. Maybe if I understood that some then I could get them working.

      As it is, i'm a weekend away from going back to bigbrother or another system if i can't get it to send out alerts.

      Comment

      • araw
        Member
        • May 2005
        • 31

        #4
        There's four points at which the code will break and run update_triggers_thread() which eventually leads to alerts being sent if necessary:

        ----
        src/zabbix_server/server.c: get_values_thread()
        ||
        src/zabbix_server/server.c: main_nodata_loop()
        ||
        src/zabbix_server/server.c: update_triggers_thread()
        ||
        src/zabbix_server/pinger.c: process_value()
        ----
        ->
        include/functions.c: update_triggers_thread()
        ->
        include/functions.c: apply_actions_thread()
        ->
        include/functions.c: send_to_user_thread()
        ->
        include/functions.c: send_to_user_medias_thread()
        ->
        include/db.c: DBadd_alert_thread()
        ->
        src/zabbix_server/alerter.c: main_alerter_loop()
        ->
        src/zabbix_server/alerter.c: send_alert()


        Actually, I missed some code in there also.

        update_triggers_thread() splits to DBupdate_trigger_value_thread() also, relevent because this seems to be where the actual alarm gets added to the DB.

        include/db.c:
        #ifdef ZABBIX_THREADS
        int DBupdate_trigger_value_thread(MYSQL *database,int triggerid,int value,int clock)
        {
        char sql[MAX_STRING_LEN];

        zabbix_log(LOG_LEVEL_DEBUG,"In update_trigger_value[%d,%d,%d]", triggerid, value, clock);
        add_alarm_thread(database, triggerid,value,clock);

        snprintf(sql,sizeof(sql)-1,"update triggers set value=%d,lastchange=%d where triggerid=%d",value,clock,triggerid);
        DBexecute_thread(database,sql);

        if(TRIGGER_VALUE_UNKNOWN == value)
        {
        snprintf(sql,sizeof(sql)-1,"update functions set lastvalue=NULL where triggerid=%d",triggerid);
        DBexecute_thread(database,sql);
        }

        zabbix_log(LOG_LEVEL_DEBUG,"End of update_trigger_value()");
        return SUCCEED;
        }
        #endif

        #ifdef ZABBIX_THREADS
        int add_alarm_thread(MYSQL *database, int triggerid,int status,int clock)
        {
        char sql[MAX_STRING_LEN];

        zabbix_log(LOG_LEVEL_DEBUG,"In add_alarm()");

        if(latest_alarm_thread(database, triggerid,status) == SUCCEED)
        {
        return SUCCEED;
        }

        snprintf(sql,sizeof(sql)-1,"insert into alarms(triggerid,clock,value) values(%d,%d,%d)", triggerid, clock, status);
        zabbix_log(LOG_LEVEL_DEBUG,"SQL [%s]",sql);
        DBexecute_thread(database, sql);

        zabbix_log(LOG_LEVEL_DEBUG,"End of add_alarm()");

        return SUCCEED;
        }
        #endif
        Last edited by araw; 12-06-2005, 09:06.

        Comment

        Working...