Ad Widget

Collapse

Zabbix calling people .. ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tarsinion
    Junior Member
    • Aug 2009
    • 28

    #1

    Zabbix calling people .. ?

    Hi guys,

    just wondering: Anybody of you have a solution where zabbix is acutally calling out to a phone number? I mean really text2voice or at least just a "warning" soundfile?

    Backround: We do monitor freezers and time is very importend when it comes to reaction time. Getting a mail or sms during night is just not enough.

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

    #2
    It can be easily scripted using Festival.
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    • Tarsinion
      Junior Member
      • Aug 2009
      • 28

      #3
      Thanks a lot for the hint. i guess there is no "how-to" out there yet?
      So its just a connected phone+festival and some scripts?

      Comment

      • danrog
        Senior Member
        • Sep 2009
        • 164

        #4
        We do this for disasters and triggers not ack'd after a certain period.

        I used pjsua (others exist but this seemed to work better for us) and this tcl script I created (which is just sending keystrokes to pjsua). It was too difficult to setup text to voice (with regards to a SIP phone in linux and auto playing a wav, I've tried SIPp but it was not 100% reliable), so we just play a pre-recorded message (created on my mac with 'say'). I then have a custom media type that simply writes out the engineers phone number to the spool directory, and this script picks it up (which is run in via a screen session just in case we need to debug stuff).

        Code:
        #!/usr/bin/tclsh8.4
        package require Expect
        
        
        exp_version -exit 5.0
        exp_internal 0
        log_user 0
        set timeout 15
        set dir "/var/spool/pjsip/"
        
        proc callNumber { number } {
            send "ha\r"
            sleep 1
            send "m\r"
            sleep 1
            send "sip:$number@yoursipserver\r"
            send_user " Calling $number\n"
        }
        
        proc callCheck { number } {
            set timeout 2
            expect -re ".*CONFIRMED.*" { return 0 }
            return 1
        }
        
        ### main
        
        set pid [spawn /home/zabbix/bin/pjsua --config-file=/home/zabbix/bin/pjsua.conf]
        set my_id $spawn_id
        expect -re {
           timeout {
              return 1
           }
           ".*status=200.*" { send_user "Registration successful\n" }
        }
        
        while (1) {
           foreach n [glob -nocomplain [file join $dir *]] {
            if {[file isfile $n]} {
            set callstate 1
            send_user "Found a number to call: $n\n"
            set phone [lindex [file split $n] 4]
            while ($callstate) {
             sleep 5
             callNumber $phone
             sleep 12
             set callstate [ callCheck $phone ]
             if { $callstate == 1 } then {
              send_user " Retrying: Call did not make it to $phone\n"
             } else {
              send_user " Call was successful to $phone, moving on.\n"
              file delete /var/spool/pjsip/$phone
              break
             }
            }
            sleep 15
            send "\rha\r"
            }
           }
         sleep 10
        }
        Last edited by danrog; 24-03-2010, 12:44.

        Comment

        • Tarsinion
          Junior Member
          • Aug 2009
          • 28

          #5
          That solution would be great for us - still the road is not very clear to me.

          * You quote out the phone number to: /var/spool/pjsip/$phone ?
          *The script is running in cron and picking up numbers from the dir?

          What kind of dialing device are you using? Just a normal cell phone for text messages attached should do?

          Thanks :-)

          Comment

          • danrog
            Senior Member
            • Sep 2009
            • 164

            #6
            Sorry if it wasn't clear. We actually make a phone call to someone's cell phone via SIP and play a prerecorded wav once the call is picked up. The SIP call originates from the zabbix server (where the SIP phone is installed) to our internal IP PBX (Cisco Call Manager) using the linux cli based SIP phone pjsua. This SIP phone allows us to make as many calls out to any phone number without having to reregister the SIP client on every call (which was my problem with using SIPp). The tcl script attached earlier acts like an automated dialier; it runs in the foreground of a screen session (screen creates a pseudo terminal that allows the user to disconnect from it without killing the running jobs [sort of like running "prog &" but more flexible]) and inputs a pre-defined set of commands to pjsua. Once its running, the script loops indefinitely and parses files found the spool directory and uses that info to to generate pjsua commands.

            Hope this helps.

            Comment

            • Tarsinion
              Junior Member
              • Aug 2009
              • 28

              #7
              danrog thanks very much for your help and your patience.
              This gives me a more details view of the way ahead.
              I just had a look into pjsip, which is actually a great idea. Using a sip provider is just perfect, as zabbix is running as a VM so attaching serial modem / phone is pain in the a**.

              So its possible use any SIP provider right? I'm thinking of sipgate.

              Steps are now:
              * Installing and configurating pjsip on debian
              * Testing with prerecorded wave file

              I'm still not quite sure what zabbix is doing. Are you just writing out the numbers of the engineer to the directory?

              Comment

              • Tarsinion
                Junior Member
                • Aug 2009
                • 28

                #8
                ... after a lot of "try and error" working . I will try to write down all steps in a small howto, your script included if you don't mind.

                Thanks

                Comment

                • isaaclw
                  Junior Member
                  • Sep 2011
                  • 1

                  #9
                  Did you manage to get it working?

                  My issue right now is mostly in the audio file to pjsua part, and unfortunately I'm not familiar enough with tcl to understand what you did. Could you point out exactly how you connected the file to pjsua? (even if it's just narrowing it down to the smaller portion of code)

                  Comment

                  • Tarsinion
                    Junior Member
                    • Aug 2009
                    • 28

                    #10
                    ... well this is the sip configuration i'm using which works pretty fine for me.

                    #
                    Logging options:
                    #
                    --log-level 5
                    --app-log-level 4
                    --null-audio
                    #
                    # Network settings:
                    #
                    --local-port 5060
                    --no-tcp
                    #
                    # Media settings:
                    #
                    --snd-auto-close 1
                    --rtp-port 4000

                    #
                    # User agent:
                    #
                    --max-calls 4


                    # Authentifikation
                    --id sip:[email protected]
                    --registrar sip:sipgate.de
                    --realm *
                    --username [email protected]
                    --password xxxxx

                    # Audio Settings
                    --null-audio
                    --auto-play
                    --play-file=/home/alarm.wav
                    #--use-timer
                    #--duration=15
                    #--stun-srv=stun.sipgate.net

                    Comment

                    • puchrojo
                      Junior Member
                      • Aug 2013
                      • 4

                      #11
                      /var/spool/pjsip Format

                      I try to follow the step and wonder if Tarsinion manage to write the howto. Actually I have no Idea how are the format from the files on /var/spool/pjsip. I guest it will be with echo or a script as a media file on Zabbix.

                      Thanks

                      Comment

                      • Tarsinion
                        Junior Member
                        • Aug 2009
                        • 28

                        #12
                        @puchrojo

                        .. i really never had the time to write the howto - is there any way i can help? The script and zabbix calling prozess is still working fine here.
                        I love beeing called from my own created wave file "best of star trek quotes" ;-).

                        Comment

                        • AlBoPo
                          Junior Member
                          • Aug 2018
                          • 23

                          #13
                          Hello,
                          I try to implement the same functionnality with pjsip 2.8.
                          I've installed everything and set my provider credentials.
                          I effectively get the "sip:[email protected]: registration success, status=200 (OK)" message but when I make a new call with 'm' command, I get the following result:

                          09:54:24.651 pjsua_app.c .......Call 0 state changed to CALLING
                          >>> 09:54:24.680 pjsua_core.c .RX 338 bytes Response msg 100/INVITE/cseq=30335 (rdata0x7f8dd8005fb8) from UDP 91.121.129.159:5060:
                          SIP/2.0 100 Trying
                          Call-ID: MSEy6HWhVCHvb5OHrE84QbwNoHSQ2Jh4
                          CSeq: 30335 INVITE
                          From: <sip:[email protected]>;tag=4NPJjCyyh4dM jS jYeXeVQHN7FPh.JmjL
                          To: <sip:[email protected]>
                          Via: SIP/2.0/UDP 192.168.105.22:5060;received=192.168.105.22;rport= 5060;branch=z9hG4bKPju9NmG52XGDEzV4GY14dybGXBfy.O-DVe
                          Content-Length: 0


                          --end msg--
                          09:54:24.680 pjsua_core.c .RX 378 bytes Response msg 403/INVITE/cseq=30335 (rdata0x7f8dd8005fb8) from UDP 91.121.129.159:5060:
                          SIP/2.0 403 not registered
                          Call-ID: MSEy6HWhVCHvb5OHrE84QbwNoHSQ2Jh4
                          CSeq: 30335 INVITE
                          From: <sip:[email protected]>;tag=4NPJjCyyh4dM jS jYeXeVQHN7FPh.JmjL
                          To: <sip:[email protected]>;tag=02-27643-7660779d-25de5bfd4
                          Via: SIP/2.0/UDP 192.168.105.22:5060;received=192.168.105.22;rport= 5060;branch=z9hG4bKPju9NmG52XGDEzV4GY14dybGXBfy.O-DVe
                          Content-Length: 0


                          --end msg--
                          09:54:24.680 pjsua_core.c ..TX 375 bytes Request msg ACK/cseq=30335 (tdta0x7f8dd8007f88) to UDP 91.121.129.159:5060:
                          ACK sip:[email protected] SIP/2.0
                          Via: SIP/2.0/UDP 192.168.105.22:5060;rport;branch=z9hG4bKPju9NmG52X GDEzV4GY14dybGXBfy.O-DVe
                          Max-Forwards: 70
                          From: sip:[email protected];tag=4NPJjCyyh4dMjSjY eXeVQHN7FPh.JmjL
                          To: sip:[email protected];tag=02-27643-7660779d-25de5bfd4
                          Call-ID: MSEy6HWhVCHvb5OHrE84QbwNoHSQ2Jh4
                          CSeq: 30335 ACK
                          Content-Length: 0


                          --end msg--
                          09:54:24.680 pjsua_app.c .....Call 0 is DISCONNECTED [reason=403 (not registered)]
                          09:54:24.680 pjsua_app_common.c .....
                          [DISCONNCTD] To: sip:[email protected]
                          Call time: 00h:00m:00s, 1st res in 36 ms, conn in 0ms


                          As you can see, it seems that making I receive a '403 not registered' message. What does it mean?

                          If I use CSipSimple from the same network calling the same phone number, everything is ok.

                          Any idea?
                          Last edited by AlBoPo; 30-11-2018, 14:41.

                          Comment

                          Working...