Ad Widget

Collapse

Zabbix Alerts via ICQ

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • just2blue4u
    Senior Member
    • Apr 2006
    • 347

    #1

    Zabbix Alerts via ICQ

    Hi everybody!

    Until now we always got alerts by eMail and Windows Popup. Problem is, when a Windows PopUp comes up, you can't type anything in that Windows machine until the popup's ok-button is pressed!

    So i created a system to send zabbix alerts per icq.

    1st: Get an ICQ Account for your zabbix server

    2nd: install tcl on your server (if not installed)

    3rd: install the text-based icq-client "climm" on your zabbix server. it must have tcl support activated (FC6 RPM did so)

    4th: On first start of climm, enter the ICQ UIN and password you registerd for the server if you are on climm's console and type
    Code:
    msg <your icq uin> <message>
    You should get the message (if you are logged in into zabbix) to your account. then exit climm.
    3rd: further testing: on linux console, exec:
    Code:
    climm -u <zabbixserver's ICQ UIN> -p <password> -C 'msg <your icq uin> <message>; exit'
    climm should connect to icq, send the message, and exit again.
    4th: create the following tcl-script (this is your unix -> ICQ gateway):
    Code:
    # Verbindet sich mit ICQ, horcht an Socket und sendet Nachrichten per ICQ weiter
    
    ###
    #
    # Globals
    #
    # ICQ UIN des Admins
    # (bekommt Nachrichten beim Starten und Stoppen des ICQ-Forwarders)
    set admin "<your ICQ UIN>"
    
    ###
    #
    # Funktionen
    #
    # Startet die Socket
    proc serverOpen {channel addr port} {
        global connected
        set connected 1
        fileevent $channel readable "readLine Server $channel"
    #    puts "Client verbunden, warte auf Daten..."
    #    puts "Client verbunden"
    }
    
    # Liest Zeilen aus der Socket
    proc readLine {who channel} {
        global out didRead admin
        gets $channel line
        if {"$line" == ""} {
            fileevent $channel readable {}
            after idle {
    #               puts "Idle, warte auf Verbindung..."
                    set didRead 1
            }
        } elseif {$line == "kill"} {
            set killmsg "kill-Befehl erhalten, Server wird gestoppt!"
            climm exec "msg $admin $killmsg"
            puts $channel $msg
            flush $channel
            exit
        } else {
            climm exec "msg $line"
            #after 3000
    #       puts "out: \"$antwort\""
    #       puts $channel "$antwort"
    #       flush $channel;
            set didRead 1
        }
    }
    #
    ###
    #
    # Hauptprogramm
    #
    # Socket als verfügbar markieren
    set connected 0
    
    # Server an Port 33000 starten
    set server [socket -server serverOpen 33000]
    puts "ICQ-Forwarder gestartet, horche auf Port 33000"
    climm exec "msg $admin ICQ-Forwarder gestartet."
    while [ vwait out ] {
            vwait connected
            vwait didRead
            unset connected didRead
    }
    I placed it in /bin/icq-forwarder. Open the file and enter your ICQ UIN in the global section ("set admin ...").

    5th: this is your zabbix alert script (client), so place it in your zabbix binary dir (e.g. /home/zabbix/bin/icq-clientscript.sh)
    Code:
    #!/usr/bin/tclsh
    #
    # (Test-)Client: Sendet Daten an den Server
    #
    
    # zu Socket verbinden, Referenz in Variable "sock" speichern
    set sock [socket -async 127.0.0.1 33000]
    
    # Wenn Kommandozeilenparameter vorhanden,
            # Dann diese in Var. "eingabe" schreiben
            # Sonst an StdIn auf Eingabe warten und in Var schreiben
    if {$argc > 0} {
            set eingabe "$argv"
    } else {
            puts "Bitte Daten eingeben, \"kill\" stoppt den Server:"
            set eingabe [gets stdin]
    }
    
    # Inhalt aus "eingabe" an Socket senden
    puts $sock "$eingabe"
    flush $sock
    
    #puts "Serverantwort:"
    #set len [gets $sock ausgabe]
    #puts "in : \"$ausgabe\""
    
    # Client beenden
    close $sock
    exit
    take care of the file access: both must be executable, the clientscript should belong to user zabbix.

    6th: now try this:
    Code:
    climm -u <zabbixserver's ICQ UIN> -p <password> -C 'tclscript /bin/icq-forwarder'
    If everything works fine, you should see this line:
    Code:
    ICQ-Forwarder gestartet, horche auf Port 33000
    . you also should have got a message via icq saying 'ICQ-Forwarder gestartet. '. If so, your icq-forwarder is running, connected to zabbix, and listening on a local socket (port 33000). you may want to check this using
    Code:
    [root@server ~]# netstat -ap|grep climm
    tcp        0      0 *:33000                     *:*                         LISTEN      31143/climm
    7th: open a new console as user zabbix (or su -l zabbix) and change to your zabbix script dir (~/bin/). Now send a message to the ICQ-Forwarder using the local port 33000:
    Code:
    [zabbix@server bin]$ ./icq-clientscript.tcl <your ICQ UIN> <your message>
    8th: If this works as well, you can configure this script as an alert script in zabbix frontend. Please search this forum if you don't know how to do that.

    9th: stopping the forwarder:
    directly in the console by pressing [strg]+[c] 2 times, or by sending "kill" with the clientscript:
    Code:
    [zabbix@server bin]$ ./icq-clientscript.tcl kill
    finally: As you might have noticed, the climm icq client needs a console. so you best install screen, then create a new virtual console
    Code:
    [root@server ~]# screen -S icqforwarder
    in that console you can run the forwarder with the command posted above. You can now leave the virtual console
    Code:
    [Strg]+[a]+[d]
    . You can access it again with
    Code:
    screen -r icqforwarder
    Hope it works for you.
    THIS IS ONLY POOOOOORLY TESTED! USE ON YOUR OWN RISK!!!

    If some of you are interested in this, i'll spend more time in this (improve this tutorial, improve handling (start/stopping), write english comments, do some debugging, etc...)


    Best regards

    Heiner

    PS: Sorry for my writing: It's after 5 and i can't wait getting home for weekend!
    PPS: If someone can tell me, how to create the screen, start the forwarder and detatch the screen in 1 line, please post here!
    "screen -dmS works, but i don't get the forwarder running... how do i tell screen?
    Last edited by just2blue4u; 18-01-2008, 18:17.
    Big ZABBIX is watching you!
    (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)
  • cstackpole
    Senior Member
    Zabbix Certified Specialist
    • Oct 2006
    • 225

    #2
    If some of you are interested in this, i'll spend more time in this (improve this tutorial, improve handling (start/stopping), write english comments, do some debugging, etc...)
    Yes please!
    I just saw this and have been experimenting on my own. I am itching to get home and try this. So if you have any updates or improvements, please post. :-D

    Also, have you added this to the wiki? If not, you should.

    I will run through this later and let you know how it goes.
    Thanks!

    Comment

    • just2blue4u
      Senior Member
      • Apr 2006
      • 347

      #3
      No updates so far!

      I tried further modifications the whole monday after but i didn't get it running like i wanted it to. that frustrated me so much, that i moved it beside.

      Maybe you can try this for yourself and tell me how far you come. Let me know, and maybe we can finish this thing together?

      If you have any help/translations, ask!
      Big ZABBIX is watching you!
      (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)

      Comment

      • cstackpole
        Senior Member
        Zabbix Certified Specialist
        • Oct 2006
        • 225

        #4
        OK well I am afraid to say that this is probably not the response either of us wanted but here it goes.

        1) I completely misunderstood this post. This method is about setting up an alternative messaging system from the one already included within Zabbix (which was what I was attempting to use).

        2) I figured 'what the hey, I will try it anyway'. However, I am having issues installing climm. The package does not exist in Debian Lenny but I found on the main website for climm that they have their own repo, however, packages are missing that prevent installation. So I tried compiling it from source but I am not getting very far right now.

        With regards to the first point, why are you (and from a quick GIS so many others) implementing your own messaging instead of using the Jabber built into Zabbix? Is it really bad or something?

        Having never really messed around with Jabber/instant messaging at all, it's taking me a while to learn all the parts and get it set up. I was kinda hoping that this would help get me the rest of the way...

        Sorry...don't think I was any help at all.

        Comment

        • just2blue4u
          Senior Member
          • Apr 2006
          • 347

          #5
          Climm worked fine for me! (on Fedora 6 and CentOS5).
          I didn't ever use Jabber.

          We use ICQ/AIM here at work, and i
          - don't want to run a second IM
          - don't want to use a Multi-Protocol-IM (didn't find a REALLY good one so far)
          - didn't find a way to use Jabber within ICQ

          That are the reasons why i tried setting up my alternative here.
          Maybe i get time to work on on this.
          If anyone's interested, i of course will try to help...
          Big ZABBIX is watching you!
          (... and my 48 hosts, 4513 items, 1280 triggers via zabbix v1.6 on CentOS 5.0)

          Comment

          • zseed
            Junior Member
            • Aug 2011
            • 3

            #6
            When i run climm and after successful login enter command in climm
            tclscript /bin/icq-forwarder
            all work fine.

            But when i use command
            climm -u <zabbixserver's ICQ UIN> -p <password> -C 'tclscript /bin/icq-forwarder'
            climm run script before getting online status and i can't send messages.

            climm version 0.7.1

            Which one command i need use for climm login and then run tclscript?
            I need one step solution for automatically run climm in listener mode.

            Comment

            Working...