Ad Widget

Collapse

Send notifies by xmpp (jabber)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sauron
    Senior Member
    • Jan 2005
    • 215

    #1

    Send notifies by xmpp (jabber)

    For this need installed sendxmpp

    Put xmpp.sh in zabbix scripts directory. Create config file sendxmpprc:
    Code:
    #account password
    [email protected] jabber
    chown and chmod this file to zabbix user/
    Code:
    chown zabbix sendxmpprc 
    chmod 0600 sendxmpprc
    create xmpp.sh:
    Code:
    #!/bin/sh
    echo "$3" | sendxmpp -f /path/sendxmpprc -s "$2" "$1"
    where path - path to sendxmpprc.

    chmod xmpp.sh:
    Code:
    
    
    Then add script in media, and add to need user notification.
  • cameronsto
    Senior Member
    • Oct 2005
    • 148

    #2
    This is very cool. For those trying to get this working, I had to install the Net::XMPP perl module by entering the cpan shell with:
    PHP Code:
    perl -MCPAN -e shell 
    then entering:
    PHP Code:
    install Net::XMPP 
    It will probably ask you to download a few other dependent modules, so enter yes for each of the prompts.

    The instructions available at the sendxmpp site cover how to install it from there.

    -cameron

    Comment

    • sauron
      Senior Member
      • Jan 2005
      • 215

      #3
      yep I'm use emerge sendxmpp

      Comment

      • cameronsto
        Senior Member
        • Oct 2005
        • 148

        #4
        Has anyone been able to get this to work with Google's Talk servers? I've tried many different scripts/libraries, but never get it to work. Seems like I can connect to jabber.org fine though.

        -cameron

        Comment

        • sauron
          Senior Member
          • Jan 2005
          • 215

          #5
          I'm think you need ssl enable connection

          Comment

          • DiedX
            Senior Member
            • Oct 2004
            • 106

            #6
            very, very cool indeed

            Thanks!
            https://www.diederik.nl

            Comment

            • Alexei
              Founder, CEO
              Zabbix Certified Trainer
              Zabbix Certified SpecialistZabbix Certified Professional
              • Sep 2004
              • 5654

              #7
              Would you be interested to have it implemented into ZABBIX core?
              Alexei Vladishev
              Creator of Zabbix, Product manager
              New York | Tokyo | Riga
              My Twitter

              Comment

              • Nate Bell
                Senior Member
                • Feb 2005
                • 141

                #8
                Originally posted by Alexei
                Would you be interested to have it implemented into ZABBIX core?
                Absolutely! I made a custom script similar to the one used here, and IMO jabber alerts are much more useful during working hours than email alerts, since they automatically pop up on your screen as soon as the trigger gets tripped. My coworkers love them (well, sort of, since the alerts usually mean something went wrong). But my Jabber script is a bit of a hack, and something more core to Zabbix would be great!

                Nate

                Comment

                • DiedX
                  Senior Member
                  • Oct 2004
                  • 106

                  #9
                  Makes that +1. I had this baby implemented yesterday, and it works like a charm
                  https://www.diederik.nl

                  Comment

                  • axel
                    Member
                    • Aug 2005
                    • 36

                    #10
                    Hi i have some problems wie use our own jabber server with only ssl.


                    zabbix@zabbix2:~$ sendxmpp -t -v -f /etc/zabbix/sendxmpprc asdasd
                    sendxmpp: config: 'password' => 'xxxxx'
                    sendxmpp: config: 'jserver' => 'abcd.net'
                    sendxmpp: config: 'port' => '5223'
                    sendxmpp: config: 'username' => 'axel'
                    Use of uninitialized value in string eq at /usr/bin/sendxmpp line 365.
                    Error 'Connect': [HASH(0x8778e18)]

                    My be a problem with tls ?

                    Comment

                    • sauron
                      Senior Member
                      • Jan 2005
                      • 215

                      #11
                      Originally posted by axel
                      Hi i have some problems wie use our own jabber server with only ssl.


                      zabbix@zabbix2:~$ sendxmpp -t -v -f /etc/zabbix/sendxmpprc asdasd
                      sendxmpp: config: 'password' => 'xxxxx'
                      sendxmpp: config: 'jserver' => 'abcd.net'
                      sendxmpp: config: 'port' => '5223'
                      sendxmpp: config: 'username' => 'axel'
                      Use of uninitialized value in string eq at /usr/bin/sendxmpp line 365.
                      Error 'Connect': [HASH(0x8778e18)]

                      My be a problem with tls ?
                      username' => '[email protected]'
                      username shuld contain server name and @

                      Comment

                      • roger69
                        Junior Member
                        • Feb 2006
                        • 8

                        #12
                        Google Talk

                        I found this page:



                        There are two different methods here, one using a Perl module, and another just relying on Net::XMPP, to send messages via XMPP through Google Talk.

                        Thought this might be useful. I was not able to get sendxmpp to work with Google Talk, but I am happily now using the Perl module and the provided sendgtalk.pl script to send notifications through Gtalk.

                        Comment

                        • erisan500
                          Senior Member
                          Zabbix Certified Specialist
                          • Aug 2005
                          • 285

                          #13
                          Has anyone got this working on Centos 4.3 ? I'm messing with this for 2 weeks now without success. Any help is highly appreciated.

                          Thanks in advance.

                          EriSan
                          EriSan
                          Zabbix Certified Specialist

                          Comment

                          • alexander
                            Junior Member
                            • Sep 2007
                            • 4

                            #14
                            need help with zabbix+xmpp

                            Sorry for my english.
                            I'm trying to set up jabber notification, but on

                            sendxmpp -u zabbix -p zabbix -j jabber alexander@jabber

                            i'v got:

                            Usage: Authen::SASL::Cyrus::client_new(pkg, parent, service, host, ...) at /usr/lib/perl5/vendor_perl/5.8.8/Authen/SASL.pm line 74.

                            could anybody help me with it?

                            Comment

                            • Flu
                              Junior Member
                              • Sep 2007
                              • 2

                              #15
                              My method

                              Here's how I accomplished Jabber notifications when trying to set this up on my Zabbix server, which is running Fedora 7. This technique is being used to send messages to an Openfire Jabber server on our local network, but I imagine it will work with most any Jabber server.

                              I ended up installing the python-xmpp RPM on Fedora with the yum install python-xmpp command. I believe the website for this package is located at http://xmpppy.sourceforge.net/. Anyhow, I then modified the xsend.py example application that comes with it and shoved it inside of the /usr/local/bin/ directory. Here is the modified program which I called jabber_send.py.

                              You'll need to alter the [email protected], sender_jabber_username and sender_jabber_password lines to match the appropriate sender account information on your Jabber server.


                              Code:
                              #!/usr/bin/python
                              # $Id: xsend.py,v 1.8 2006/10/06 12:30:42 normanr Exp $
                              import sys,os,xmpp,time
                              
                              if len(sys.argv) < 2:
                                  print "Syntax: jabber_send JID text"
                                  sys.exit(0)
                              
                              tojid=sys.argv[1]
                              text=' '.join(sys.argv[2:])
                              
                              
                              jidparams={}
                              
                              jid=xmpp.protocol.JID('[email protected]')
                              cl=xmpp.Client(jid.getDomain(),debug=[])
                              
                              jidparams['username']="sender_jabber_username"
                              jidparams['password']="sender_jabber_password"
                              jidparams['resource']="Zabbix"
                              
                              
                              con=cl.connect()
                              if not con:
                                  print 'could not connect!'
                                  sys.exit()
                              print 'connected with',con
                              auth=cl.auth(jidparams['username'],jidparams['password'],resource=jidparams['resource'])
                              if not auth:
                                  print 'could not authenticate!'
                                  sys.exit()
                              print 'authenticated using',auth
                              
                              #cl.SendInitPresence(requestRoster=0)   # you may need to uncomment this for old server
                              id=cl.send(xmpp.protocol.Message(tojid,text))
                              print 'sent message with id',id
                              
                              time.sleep(1)   # some older servers will not send the message if you disconnect immediately after sending
                              
                              #cl.disconnect()

                              Next I created the xmpp.sh script inside of the /var/lib/zabbix directory, containing the following code:

                              Code:
                              #!/bin/sh
                              # If no argument was given on the commandline, stop
                              if [ $# -lt 2 ];then
                                  echo "Not enough arguments provided to $0"
                                  exit
                              fi
                              
                              jabber_send.py "$1" "$3"
                              Finally, inside of the Zabbix web configuration utility, I added a new Script media type with Jabber Script as the description and entered xmpp.sh for the script name. In order for a user to get a Jabber notification, make sure you add the Jabber Script Media type to for the appropriate person under Administration/Users inside of the Zabbix web configuration panel.

                              There might be a much easier way to do this these days, but I set the above system up and it works flawlessly for me on my system.
                              Last edited by Flu; 07-09-2007, 15:24. Reason: Forgot to mention Openfire.

                              Comment

                              Working...