Ad Widget

Collapse

Actions - Event acknowledged = "Ack"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eskytthe
    Senior Member
    Zabbix Certified Specialist
    • May 2011
    • 363

    #16
    Thanks for a quick responds!
    Yes it seems the forum blog is away??. Did have some old links to you blog, but they do not work now. I have just drop a question for the blog on the IRC forum, hope I get some positive back.
    /Erik

    Comment

    • eskytthe
      Senior Member
      Zabbix Certified Specialist
      • May 2011
      • 363

      #17
      So old forum blog have been disabled because of spam. I have asked Alexei about read-only/other access possiblities.

      /Erik

      Comment

      • untergeek
        Senior Member
        Zabbix Certified Specialist
        • Jun 2009
        • 512

        #18
        Since my old forum blog is gone, I'm posting diffs here. Also attached is rehistory.php, which I use in my email and prowl alerts to provide clickable links to acknowledge, view latest data and graphs. It's referenced in these diffs, so I thought it should be mentioned and attached.

        The subsections to identify a parent group and correlate it to a user group can be modified as you like (e.g., Network %dministrators can be changed to something of your choosing, with the matching group).

        acknow.php
        PHP Code:
        107a108,166
        // These are now set in acknow.inc.php, e.g.
        // $Name = "Zabbix Server";
        // $groupid_searchstr = 'GROUP';
        // $external_url_host = 'EXTERNAL_URL_HOST';
        $myeventdata DBfetch(DBselect('select objectid,clock from events where eventid='.$_REQUEST['eventid']));
        $mytriggerid $myeventdata['objectid'];
        $mytriggerdata DBfetch(DBselect('select * from triggers where triggerid='.$mytriggerid));
        $mytriggerdesc expand_trigger_description_by_data($mytriggerdata);
        $itemidres DBfetch(DBselect('select itemid from (select itemid from functions where triggerid=(select objectid from events where eventid=' $_REQUEST['eventid'] .') order by itemid) where rownum=1'));
        $itemdata DBfetch(DBselect('select hostid,key_ from items where itemid='.$itemidres['itemid']));
        $hosts DBfetch(DBselect('select host from hosts where hostid='.$itemdata['hostid']));
        $groupidsql "select usrgrpid from usrgrp where NAME LIKE '%{$groupid_searchstr}%'";
        $groupres DBfetch(DBselect($groupidsql));
        $groupidlist $groupres['usrgrpid'];
        $hostgroupsql DBselect('select name,groupid from groups where groupid in (select groupid from hosts_groups where hostid='.$itemdata['hostid'].')');
        $hostgroupidsbyname = array();
        > while(
        $tmpresult DBfetch($hostgroupsql)){
        >   
        $hostgroupidsbyname[$tmpresult['name']] = $tmpresult['groupid'];
        >   if(
        $tmpresult['name'] == 'Network Hardware'){
        >     
        $netgroupidsql "select usrgrpid from usrgrp where NAME LIKE 'Network %dministrators'";
        >     
        $netgroupres DBfetch(DBselect($netgroupidsql));
        >     
        $groupidlist $groupidlist ',' $netgroupres['usrgrpid'];
        >   }
        >   if(
        $tmpresult['name'] == 'Hosted Hardware'){
        >     
        $unixgroupidsql "select usrgrpid from usrgrp where NAME LIKE 'UNIX %dministrators'";
        >     
        $unixgroupres DBfetch(DBselect($unixgroupidsql));
        >     
        $groupidlist $groupidlist ',' $unixgroupres['usrgrpid'];
        >   }
        > }
        $icmpposition strpos($itemdata['key_'],'icmpping');
        > if(
        $icmpposition == '0'){
        >   
        $unixgroupidsql "select usrgrpid from usrgrp where NAME LIKE 'UNIX %dministrators'";
        >   
        $unixgroupres DBfetch(DBselect($unixgroupidsql));
        >   
        $groupidlist $groupidlist ',' $unixgroupres['usrgrpid'];
        > }
        $send_to_query DBselect('select distinct m.sendto from media m, media_type mt, users_groups ug, users u where u.userid=ug.userid and ug.usrgrpid in (' $groupidlist ') and m.userid=ug.userid and m.userid=u.userid and mt.mediatypeid=1 and m.mediatypeid=1');
        $my_mail_body "Acknowledge: https://".$external_url_host."/zabbix/acknow.php?eventid=" $_REQUEST['eventid'] . "\r\n";
        $my_mail_body .= "DateTimeNOW: " date("o.m.d H:i:s") . "\r\n";
        $my_mail_body .= "EventDateTime: " date("o.m.d H:i:s"$myeventdata['clock']) . "\r\n";
        $my_mail_body .= "Graph: https://".$external_url_host."/zabbix/rehistory.php?triggerid=" $mytriggerid "&displaytype=graph \r\n";
        $my_mail_body .= "Latest Data: https://".$external_url_host."/zabbix/rehistory.php?triggerid=" $mytriggerid "\r\n\r\n";
        > if(isset(
        $_REQUEST['eventid'])){
        >   
        $db_acks get_acknowledges_by_eventid($_REQUEST['eventid']);
        >   if(
        $db_acks){
        >     while(
        $db_ack DBfetch($db_acks)){
        >       
        $mydate date("o.m.d H:i:s"$db_ack['clock']);
        >       
        $my_mail_body .= $db_ack['alias'] . " at " $mydate "\r\n";
        >       
        $my_mail_body .= $db_ack['message'] . "\r\n\r\n";
        >     }
        >   }
        >   
        $subject "Acknowledged: " $hosts['host'] . " " $mytriggerdesc;
        >   
        $emailsql "select smtp_email from media_type where type=0 and mediatypeid=1 and smtp_server='localhost' and rownum=1";
        >   
        $emaildata DBfetch(DBselect($emailsql));
        >   
        $header "From: "$Name " <" $emaildata['smtp_email'] . ">\r\n";
        >   while(
        $myrecipient DBfetch($send_to_query)){
        >     
        mail($myrecipient['sendto'], $subject$my_mail_body$header);
        >   }
        > }

        acknow.inc.php
        The SQL alteration provides a guarantee that the results come in the proper sequence, time-wise.
        PHP Code:
         21a22,24
        $Name "Zabbix Server";
        $groupid_searchstr 'GROUP';
        $external_url_host 'EXTERNAL_URL_HOST';
        35c38
        <     return DBselect("SELECT a.*, u.alias FROM acknowledges a LEFT JOIN users u ON u.userid=a.userid  WHERE a.eventid=$eventid");
        ---
        >     return 
        DBselect("SELECT a.*, u.alias FROM acknowledges a LEFT JOIN users u ON u.userid=a.userid  WHERE a.eventid=$eventid ORDER by clock desc"); 
        Attached Files

        Comment

        • alexarean
          Junior Member
          • Jan 2012
          • 5

          #19
          trying now

          Comment

          • Jaeius
            Junior Member
            • Dec 2011
            • 8

            #20
            Email Acknowledgment

            hi,

            I have a workaround that sends an email for each acknowledged trigger.
            It works for single and bulk acknowledgement. An email would be sent for each checkbox ticked at the Triggers page.


            The work around involves adding a few lines (less than 6) to acknow.php and adding an additional .php file at the includes folder.


            I can post the code here if anybody is interested.
            Last edited by Jaeius; 12-03-2012, 08:52.

            Comment

            • eskytthe
              Senior Member
              Zabbix Certified Specialist
              • May 2011
              • 363

              #21
              Yes please share the code Jaeius
              BR
              Erik

              Comment

              • Jaeius
                Junior Member
                • Dec 2011
                • 8

                #22
                Zabbix Email Acknowledgement

                Here are the steps in adding the feature (have tested this on 1.8.2 & 1.8.10):

                1. An Email Media type should be existing.(of course )

                2. Create the USER that will receive the Acknowledgement.
                - Create a user with Alias 'Email Ack Recipient' (a must)
                - Add Email media to this user.

                3. Upload the attached file 'tr_ack_email.inc.php' to the include/ directory.

                4. Edit the 'acknow.php' file
                .
                .
                .
                31>ob_start();
                32>$time_ack = time(); //## EMAIl ACK ##
                33>include_once('include/page_header.php');
                34>require_once('include/tr_ack_email.inc.php'); //## EMAIl ACK ##
                .
                .
                .
                104> $eventsData = array(
                105> 'eventids' => zbx_objectValues($_REQUEST['events'], 'eventid'),
                106> 'message' => $_REQUEST['message']
                107> );
                108> $evs_open = get_eventid_clock_by_triggerid($_REQUEST['triggers']); //## EMAIl ACK ##
                109> $result = CEvent::acknowledge($eventsData);
                .
                .
                .
                119> if(isset($_REQUEST['saveandreturn'])){
                120> while($ev_open = DBfetch($evs_open) ){
                121> send_email_ack($ev_open['objectid'], $ev_open['eventid'],$ev_open['clock'], $time_ack, $USER_DETAILS['name']." ".$USER_DETAILS['surname'] );//## EMAIl ACK ##
                122> }
                123>
                124> ob_end_clean();
                125> redirect($_REQUEST['backurl']);
                .
                .
                .
                There. I hope the formatting goes well.
                Attached Files

                Comment

                • Jaeius
                  Junior Member
                  • Dec 2011
                  • 8

                  #23
                  Where you guys able to successfully integrate the code?
                  I'm glad to help if you experience any issues.

                  Comment

                  • eskytthe
                    Senior Member
                    Zabbix Certified Specialist
                    • May 2011
                    • 363

                    #24
                    Thanks for your post and share of you code Jaeius!
                    Well I have been delayed - but plan to use it for integration with our ticket system - update of tickets with ack info etc.
                    BR
                    Erik

                    Comment

                    • dermoon
                      Junior Member
                      • Jun 2012
                      • 8

                      #25
                      Anyone got this working on Zabbix 2.0?

                      Comment

                      • Jaeius
                        Junior Member
                        • Dec 2011
                        • 8

                        #26
                        improved code

                        I haven't tested this on 2.0 yet.

                        I have an improved code which would not send notifications for alerts in maintenance and would be a lot faster even on large installations.

                        This week would be very busy for me. I'll post the updated codes next week and hope its tested with Z 2.0.

                        Comment

                        • Jaeius
                          Junior Member
                          • Dec 2011
                          • 8

                          #27
                          Improved code for Zabbix 2.0

                          Hi everyone!

                          Here is the updated code for Zabbix 2.0.
                          Same installation procedure. The 'Email Ack Receiver' and 'Email Ack Sender' must be properly defined with valid email addresses.

                          Installation:
                          1. Create the 'Email Ack Receiver' user and 'Email Ack Sender' media type.
                          2. Update your acknow.php with my code attached.
                          3. Upload to include/ folder the tr_email_ack.inc.php


                          I have this working on several of my Zabbix installations.
                          Just shoot a message if you guys have a hard time making it work for you.
                          Attached Files

                          Comment

                          • progman
                            Junior Member
                            • Nov 2012
                            • 1

                            #28
                            Used that.
                            Thanks

                            patched patch to be able work with postgres

                            Works as desired.

                            Comment

                            • mpolitaev
                              Member
                              • Jun 2015
                              • 32

                              #29
                              Not work in Zabbix 2.2.8. Anyone have successfull applied this patch for this version?

                              Help)

                              Comment

                              • jackie
                                Member
                                • Jan 2016
                                • 37

                                #30
                                We are looking at migrating from nagios to zabbix, and this is a feature we really need.

                                We are running zabbix 2.4 with postgresql 9.4. Has anyone had any experience installing this patch with that setup? Any changes needed?

                                Thanks for any info,
                                Jackie

                                Comment

                                Working...