Just another WordPress site

Skype messages from Zabbix

Introduction

At Jamendo we use Skype a lot. Therefore i thought, that it would be nice to get Skype instant messages from the Zabbix Server. My requirements were:

  1. must run on Ubuntu Server
  2. no X.org, KDE or Gnome – it must be a light solution!
  3. just install packages with apt (except for skype) – don’t want to update some software by hand.
  4. init.d script, that starts the “skype notification service”

Installing the skype notification software

Installing the basic components:

# installing the user, that runs the service
useradd skype
# installing the x server
apt-get install xvfb
apt-get install fluxbox x11vnc
# installing skype requirements
apt-get install dbus
apt-get install libasound2 libqt4-dbus libqt4-network libqtcore4 libqtgui4 libxss1 libpython2.6 libqt4-xml libaudio2 libmng1 fontconfig liblcms1
apt-get install lib32stdc++6 lib32asound2 ia32-libs libc6-i386 lib32gcc1
# wget http://www.skype.com/go/getskype-linux-beta-ubuntu-32 -O skype-linux-beta.deb
wget http://www.skype.com/go/getskype-linux-beta-ubuntu-64 -O skype-linux-beta.deb
# if there are other unresolved dependencies install missing packages using apt-get install and then install the skype deb package again
dpkg -i skype-linux-beta.deb
# installing Skype4py
wget 'http://sourceforge.net/projects/skype4py/files/skype4py/1.0.31.0/Skype4Py-1.0.31.0.tar.gz/download?use_mirror=switch'
tar -xzf Skype4Py-1.0.31.0.tar.gz
cd Skype4Py-1.0.31.0/
python setup.py install

Now we have all the things we need.
The next step we perform as skype user!
Just unpack these skypescripts.tar into the skype home directory.

Setting up the skype notification service

Please ensure, that you have vncviewer installed on your (local) ubuntu workstation.

  1. Log in to your server: ssh -L 5900:127.0.0.1:5900 ‘skype@your.zabbix.server’
  2. start xfvb, fluxbox and skype: ./start-server.sh start
  3. start the vnc server: ./start-vnc.sh start
  4. on your local ubuntu workstation you start vnc-viewer: vncviewer 127.0.0.1
  5. You should now be seeing the fluxbox desktop and skype
  6. Enter the username and password and ensure, that the credentials get saved.
  7. Go to settings and set the following options
    1. no chat history
    2. just people on my list can write me
    3. just people on my list can call me
  8. Send your first skype message on the server as skype user: ./sendim.sh ‘USERNAME’ ‘HELLO WORLD’
  9. Skype asks now, if skype4py should be allowed. Click on remember and allow!
  10. stop the vnc-server: ./start-vnc.sh stop

Now the skype service is up and running.

Configuring the zabbix server

That’s the easy part.

  1. Just check in your zabbix_server.conf to where the AlertScriptsPath points to.
  2. Then add a symbolic link of sendim.sh in this directory. ( Zabbix calls the script like this: scriptname username subject message )
  3. Go to the zabbix frontend and create the new Skype media type:
    • Description: Skype
    • Type: Script
    • Script name: sendim.sh
  4. Finally, set up your skype address in your profile and check if you have an action, that sends messages to your all medias or skype media.

And that’s it, you should now receive messages from Zabbix. Just test by crashing your infrastructure… ;)

Comments on: "Skype messages from Zabbix" (15)

  1. you rock. i don’t know what zabbix is, but I found this on google when i was just about to give up and followed your directions to make it work on ubuntu. worked like a charm – thanks!

    skype: please make this simpler

  2. Clement Wong said:

    Hi,

    Thanks a lot as I have been trying to make this.
    VNC has a bit problem here when i tried to make it work in Debian 6 XenServer 5.5 DomU, do you have experience with it?
    Is it possible to skype without gui?
    I was thinking to make it work with http://eion.robbmob.com before you post this. Could it be a better (lighter) way?

    BR,
    Clement

    • Actually, there should be no problem. My installation is also running on Xen. Did you run “./vnc-start.sh” start on the server and “vncviewer” on the local workstation? Did you setup the ssh port forwarding?

      about: http://eion.robbmob.com/
      nice. it seems to be similiar to Skype4Py.

      • Clement Wong said:

        Yes, I did exactly what you post, but it came out an empty desktop.
        Can you take a look?
        I really can’t do anything more.
        My skype id is clement.hk

        THANKS!!

        About http://eion.robbmob.com/ , I thought if we use this one then we don’t need to use any GUI isn’t that true?

        Clement

      • just right click on the desktop open a shell and start type with the following command “skype &”

      • Clement Wong said:

        Hi,

        THANKS A LOT,
        it worked after I reinstall the whole system.
        1 thing that you didn’t mention,
        skype4py 1.0.32.0 is not working well, need to use old version skype4py 1.0.31.0.
        wondered why you use 1.0.31

  3. Clement Wong said:

    a few more things,
    apt-get install dbus-x11 python-dbus ia32-lib*

  4. Hello,

    Do you know if there is possible to get a call from skype or any other voip software to a regular phone from zabbix?

    I`d like to ensure that when some alerts became i get a call in my cell phone for example.

    Thx!

    • mweber said:

      Check out the Skype4py Documentation. You can fully remote controll your skype with it. I’m quite sure, that you can also trigger a “call my phone” action. :) In case you want to send SMS it works like this:

      import Skype4Py
      import sys
      # Create an instance of the Skype class.
      skype = Skype4Py.Skype()
      # Connect the Skype object to the Skype client.
      skype.Attach()
      number = sys.argv[1]
      msg = ' '.join(sys.argv[2:])
      # create SMS object
      message = skype.CreateSms(Skype4Py.smsMessageTypeOutgoing, number)
      message.Body =  msg # set value of body
      message.Send() # send message

      • Clement Wong said:
        import Skype4Py
        import sys
        import time
         
        starttime = time.time()
        CallStatus = 0
         
        CallIsFinished = set ([Skype4Py.clsFailed, Skype4Py.clsFinished, Skype4Py.clsMissed, Skype4Py.clsRefused, Skype4Py.clsBusy, Skype4Py.clsCancelled]);
         
        Finished = False
         
        def OnCall(call, status):
                global CallStatus
                global Finished
                CallStatus = status
                if status == Skype4Py.clsInProgress:
                        Finished = True
                        call.Finish()
                if status == Skype4Py.clsRefused:
                        Finished = True
         
        while Finished == False:
                skype = Skype4Py.Skype()
                skype.OnCallStatus = OnCall
                skype.Attach()
                skype.PlaceCall(sys.argv[1])
         
                while not CallStatus in CallIsFinished:
                        time.sleep(0.1)
         
                if Finished == False:
                        if (time.time() - starttime) > 300:
                                Finished = True
                        else:
                                time.sleep(10)
                                CallStatus = 0

        This will rang for 5 mins if no pick up or refuse.

  5. Good work!

    But maybe anybody know solution without X server’s? Can I send message from console? (still googling this question)

    • Yes, you can send messages from console by using:
      ./sendim.sh ‘USERNAME’ ‘HELLO WORLD’

      As long as skype4py needs skype, you need an xserver so that skype starts up…

  6. benjamin said:

    I already setup skype on centos and run script:
    ./sendim.sh ‘USERNAME’ ‘HELLO WORLD’
    and then remember API. (and add profile with skype ID in my account).
    But can not receive message from skype.

  7. Hi,

    We have created a more advanced, easier to use Skype bot which has HTTP interfaces for sending chat notifications.

    https://github.com/opensourcehacker/sevabot

    The bot installation is partially based instructions described in this blog post. Zabbix monitoring alerts are naturally supported – Skype does not need to be running on the same server as Zabbix. In fact Skype can be run on your desktop.

    Also the bot supports things like issue tracker notifications, custom shell scripts and stuff.

Leave a comment for: "Skype messages from Zabbix"

You must be logged in to post a comment.