Ad Widget

Collapse

How to get Zabbix push notifications on iPhone

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Maxesse
    Junior Member
    • Jul 2010
    • 7

    #1

    How to get Zabbix push notifications on iPhone

    Hi everybody,
    I've been using successfully push notifications instead of SMS (for free!) to monitor my Zabbix server.

    I thought I'd share my experience, I wrote a detailed blog post with the instructions today, hope it will be of help to somebody!!

    [URL broken]

    If you need any help feel free to answer this thread and I'll reply back.
    Last edited by dimir; 17-11-2020, 10:00.
  • danrog
    Senior Member
    • Sep 2009
    • 164

    #2
    We've been using prowl for quiet some time. And I agree, it works great. My script is a little different as it parses the severity from the message and converts it to something prowl will understand. It also uses the users own API key (added to the 'send to' field when the user adds media) to support multiple people. We will be moving off of prowl to Notifo once they have the Android client available (unless someone knows of a prowl compatible Android client :-) )

    Here is my quick and very dirty script, that has worked for almost a year without problems.

    Code:
    #!/bin/bash
    IFS=";"
    declare -a Array=($*)
    
    pri="${Array[0]}"
    api="${Array[1]}"
    mes="${Array[3]} ${Array[4]}"
    
    echo "DEBUG: ARGS: $@" >>/home/zabbix/bin/out.log
    echo "BEBUG: MESG: $mes" >>/home/zabbix/bin/out.log
    
    pri=`(echo -e $mes | grep "Trigger pri: " | cut -d":" -f2 | sed -e 's/^[ \t]*//')`
    
    case "$pri" in 
    0)
     pri=-2
    ;;
    1)
     pri=-2
    ;;
    2)
     pri=-1
    ;;
    3)
     pri=0
    ;;
    4)
     pri=1
    ;;
    5)
     pri=2
    ;;
    esac
    
    echo /home/zabbix/bin/prowl.pl -apikey=$api -priority=$pri -application=Zabbix -event="Zabbix Alert" -notification="$mes" >>/home/zabbix/bin/out.prowl
    /home/zabbix/bin/prowl.pl -apikey=$api -priority=$pri -application=Zabbix -event="Zabbix Alert" -notification="$mes" >>/home/zabbix/bin/out.prowl

    Comment

    • Maxesse
      Junior Member
      • Jul 2010
      • 7

      #3
      Very cool!

      That's brilliant, I didn't think of rummaging in the output log to extract the priority, I will improve my set up with your script for sure!

      Thanks again!!
      Max

      Comment

      • fmrapid
        Member
        • Aug 2010
        • 43

        #4
        Added to the wiki links to blog and forum

        I took the liberty of adding a link in the wiki concerning your scripts and how-to. You can update the wiki page with any new developments.

        Cheers,

        fmrapid

        Comment

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

          #5
          I also created a custom script as a media type. I then define for each user a different media type (SendToProwl) and put their API key in what was the "email address" field. Put this script in the AlertScriptsPath (mine is /home/zabbix/server/bin) along with the prowl.pl perl script and you're golden.

          Our messages look like this in the Action definition:
          Default Subject:
          Code:
          {TRIGGER.SEVERITY}: {HOSTNAME} {TRIGGER.NAME}
          Default Message:
          Code:
          Acknowledge here: https://zabbixhost.example.com/zabbix/index.php?login=1&request=/zabbix/acknow.php?triggers[]={TRIGGER.ID}
          DateTimeNOW: {DATE} {TIME}
          EventDateTIME: {EVENT.DATE} {EVENT.TIME}
          EventAge: {EVENT.AGE}
          ItemName: {ITEM.NAME}
          ItemLastValue: {ITEM.LASTVALUE}
          Comment: {TRIGGER.COMMENT}
          It works really well. We have a 2-way SSL encryption set up on our front-end so our iPhones can access our monitoring and screens from anywhere, securely!

          Code:
          #!/bin/bash
          
          ### Call prowl.pl
          #Usage:
          #    prowl.pl [options] event_information
          #
          #     Options:
          #       -help              Display all help information.
          #       -apikey=...        Your Prowl API key.
          #       -apikeyfile=...    A file containing your Prowl API key.
          #
          #     Event information:
          #       -application=...   The name of the application.
          #       -event=...         The name of the event.
          #       -notification=...  The text of the notification.
          #       -priority=...      The priority of the notification.
          #                          An integer in the range [-2, 2].
          
          PROWLPATH=/home/zabbix/server/bin
          
          APPLICATION="ZabbixServer"
          APIKEY=$1
          EVENT=$2
          NOTIFICATION=$3
          
          ### PRIORITY 
          #
          # Establish Priority based on the subject string (In our case $2, EVENT)
          
          #### Default value of 0 if not provided. An integer value ranging [-2, 2] representing:
          #### -2 Very Low
          #### -1 Moderate
          ####  0 Normal
          ####  1 High
          ####  2 Emergency
          ####
          #### Emergency priority messages may bypass quiet hours according to the user's settings.
          
          # Our Map:
          #### -2 Information
          #### -1 Warning
          ####  0 Average
          ####  1 High
          ####  2 Disaster
          ####
          
          HEADER=$(echo $EVENT | awk -F: '{print $1}')
          
          PRIORITY=0
          
          case "$HEADER" in
          
          "Info"|"Information"                            ) PRIORITY=-2 ;;
          "Warning"|"WARNING"                             ) PRIORITY=-1 ;;
          "Problem"|"PROBLEM"|"Average"|"AVERAGE"         ) PRIORITY=0 ;;
          "High"|"HIGH"                                   ) PRIORITY=1 ;;
          "Disaster"|"DISASTER"|"Emergency"|"EMERGENCY"   ) PRIORITY=2 ;;
          "Recovery"|"RECOVERY"                           ) exit 0 ;;
          esac
          
          ${PROWLPATH}/prowl.pl -apikey=${APIKEY} -application="${APPLICATION}" -event="${EVENT}" -notification="${NOTIFICATION}" -priority=${PRIORITY}
          Last edited by untergeek; 09-12-2010, 19:50. Reason: spell check :(

          Comment

          • Maxesse
            Junior Member
            • Jul 2010
            • 7

            #6
            Nice!

            That's very cool! I'm glad I started this thread, it's nice to see how the solution can be improved!
            I don't normally need access to zabbix externally, as the iPhone supports Cisco VPN, so in two clicks I'm connected inside the network, and that's how I browse to zabbix when needed.

            PS: I'll add a link to my blog pointing to this thread, since these developments are much improving the basic solution I posted the other day.

            Max

            Comment

            • mtier
              Junior Member
              • Nov 2010
              • 5

              #7
              We will release soon a first version of a Zabbix mobile client for iPhone, BB, Android and Windows Mobile maybe this interesting for you;-)


              Originally posted by Maxesse
              That's very cool! I'm glad I started this thread, it's nice to see how the solution can be improved!
              I don't normally need access to zabbix externally, as the iPhone supports Cisco VPN, so in two clicks I'm connected inside the network, and that's how I browse to zabbix when needed.

              PS: I'll add a link to my blog pointing to this thread, since these developments are much improving the basic solution I posted the other day.

              Max

              Comment

              • Maxesse
                Junior Member
                • Jul 2010
                • 7

                #8
                Originally posted by mtier
                We will release soon a first version of a Zabbix mobile client for iPhone, BB, Android and Windows Mobile maybe this interesting for you;-)
                I can't wait for that! I've been actually checking the app store at regular intervals every couple of months or so in the hope to find a zabbix app hehe.
                Instead so far there's just a lot of Nagios interfaces... So it'll be a very welcome addition to the store!

                Comment

                • qix
                  Senior Member
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Oct 2006
                  • 423

                  #9
                  Zabbix Mobile client

                  Hi All,

                  I've read this thread with great interest and have bought the Prowl app in the Appstore as well, I'll give it a try

                  I'd like to point out there already is a mobile client for Zabbix here: http://www.mozbx.net/.
                  I haven't tried it yet, but once I start playing with Prowl notifications, I'll see if I can integrate MoZBX into the package...
                  With kind regards,

                  Raymond

                  Comment

                  • Maxesse
                    Junior Member
                    • Jul 2010
                    • 7

                    #10
                    Very lazy me

                    Originally posted by qix
                    Hi All,

                    I've read this thread with great interest and have bought the Prowl app in the Appstore as well, I'll give it a try

                    I'd like to point out there already is a mobile client for Zabbix here: http://www.mozbx.net/.
                    I haven't tried it yet, but once I start playing with Prowl notifications, I'll see if I can integrate MoZBX into the package...
                    Hello! The only problem of that client is that it's a web app, not a native application, and to use it, you either have to publish your zabbix on the web, or host the web app yourself. I know I could do the latter, but being the lazy git I am I'd love to get a native app, connect with cisco vpn on the iphone and open the app straight away

                    Max

                    Comment

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

                      #11
                      I tried MoZBX and found it was too thin. I liked that it showed graphs and such, but I couldn't acknowledge alerts, it only displayed so many at a time, etc.

                      On top of it all was a requirement to set "php_value safe_mode off." I was not about to open up my production front-end to a PHP script which required me to set "php_value safe_mode off." I'm not a PHP coder, but I've looked over some of the arguments and I feel that if this was necessary to get the code to work properly, then I'm not sure how I feel about trusting the code.

                      Comment

                      • qix
                        Senior Member
                        Zabbix Certified SpecialistZabbix Certified Professional
                        • Oct 2006
                        • 423

                        #12
                        Works like a charm!

                        Like I said, I hadn't tried MoZBX yet.
                        From your opinions, I feel I should just wait a bit 'till a full fledged App arrives.
                        Safari on the iPhone handles the Zabbix pages well enough for now

                        I did get Prowl notifications working with the help of this thread, thanks everyone!
                        For now it just beats SMS text notifications (in costs anyway )

                        I'm working on a solid solution to get GTalk and MSN notifications as well.
                        With kind regards,

                        Raymond

                        Comment

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

                          #13
                          Good luck with MSN. I think you'll need a Java solution to do that. All of the perl ones are broken.

                          I have a GTalk script which I can post, if you're interested. It works quite well!

                          Comment

                          • qix
                            Senior Member
                            Zabbix Certified SpecialistZabbix Certified Professional
                            • Oct 2006
                            • 423

                            #14
                            Hi Untergeek,

                            I believe I have found a solution for almost every IM protocol (MSN, Jabber and GTalk, ICQ, Yahoo, IRC, AIM, Gadu-Gadu, Livejournal) in centerim. I've got it working with GTalk right now, but MSN seems broken in the version shipped with Debian Lenny.
                            The upstream code seems to have solved the problem, but I'll need to compile it manually. The packages from testing and unstable won't work (tried --force-depends ).

                            The nice thing about Centerim is that it can fire scripts on incoming IM messages. I want to have a look if I can hook it up with the Zabbix API interface so you can get more info about an event directly in your IM window

                            When I have a working solution, I'll post a new thread and my info on the Wiki.
                            With kind regards,

                            Raymond

                            Comment

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

                              #15
                              I'm curious. How do you use it to "send" messages. Is there a daemon constantly running? (I presume yes so that you can act on incoming). That sounds like it has the potential to be a security vulnerability.

                              Outbound only, however, sounds nice. How does it work?

                              Comment

                              Working...