Ad Widget

Collapse

Asterisk Test Calls?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MTWiley
    Junior Member
    • Jul 2011
    • 16

    #1

    Asterisk Test Calls?

    I think this might be getting to be a bit too specific to asterisk to get hekp on the Zabbix forums, but I thought I'd ask anyways. We'd like to be able to make a test call every 10 minutes and be notified if the call fails. We're already monitoring Asterisk with Zabbix by checking the number of sip and iax2 trunks as well as monitoring the number of active calls using the following.


    Code:
    UserParameter=sudo asterisk -rvvvvvx 'sip show registry'|grep Registered |wc -l
    UserParameter=sudo asterisk -rvvvvvx 'iax2 show registry'|grep Registered |wc -l
    UserParameter=sudo asterisk -rvvvvvx 'core show channels'|grep --text -i 'active call'|awk '{print $1}'
    Does anyone know of a way to accomplish making an outside call and setting off a trigger if the call is unsuccessful?
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #2
    You may need to use a combination of cron, an external script, zabbix sender and nodata(900).

    Have cron kick off a script which will perform a test call, and report it's success/failure. It will then use zabbix_sender to push the data to the Zabbix server. On the Zabbix server you can trigger if you have no data for 15 minutes (nodata(900)), or if the last result is whatever you designate to be your error code.
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

    Comment

    • MTWiley
      Junior Member
      • Jul 2011
      • 16

      #3
      Originally posted by nelsonab
      You may need to use a combination of cron, an external script, zabbix sender and nodata(900).

      Have cron kick off a script which will perform a test call, and report it's success/failure. It will then use zabbix_sender to push the data to the Zabbix server. On the Zabbix server you can trigger if you have no data for 15 minutes (nodata(900)), or if the last result is whatever you designate to be your error code.
      Okay, I've done a bit more, but I'm kind of stuck. I wrote put together the following script from bits and pieces that I've found.

      Code:
      #!/bin/bash
      
      DATE=`date +%d%m%Y-%H%M`
      FILENAME="$DATE".call
      
      echo "Channel: Local/1234567890@from-internal" >> /tmp/$FILENAME
      echo "Application: Playback" >> /tmp/$FILENAME
      echo "Data: hello-world" >> /tmp/$FILENAME
      echo "MaxRetries: 2" >> /tmp/$FILENAME
      echo "RetryTime: 30" >> /tmp/$FILENAME
      echo "Priority: 1" >> /tmp/$FILENAME
      echo "Archive: Yes" >> /tmp/$FILENAME
      # This line only works when running as root. Using chmod instead as a workaround.
      # chown asterisk:asterisk /tmp/$FILENAME
      chmod 777 /tmp/$FILENAME
      mv /tmp/$FILENAME /var/spool/asterisk/outgoing/
      sleep 10
      cat /var/spool/asterisk/outgoing_done/$FILENAME |grep Status:|awk '{print $2}'
      The script successfully calls an outside number and returns either Success, Expired or Failure, depending on whether or not the test call went through.

      I tried adding this script to the UserParameters, unfortunately it just instantly returns ZBX_NOTSUPPORTED. I've been rereading your advice and it mentioned the zabbix_sender but I can't seem to figure out how to run the zabbix_sender in linux. I've done it in windows, but I either didn't install it or just keep looking in the wrong place. Would you be able to help point me in the right direction of where it should be? I've checked /usr/local/bin/zabbix_sender & /usr/local/sbin/zabbix_sender with no luck, is it someplace else by default? or is it maybe something that I have to explicitly install?

      Update:

      I got it working. I added to the script and here's the final version, I just made it an active check and run it via cron every 10 minutes.

      Code:
      #!/bin/bash
      
      DATE=`date +%d%m%Y-%H%M`
      FILENAME="$DATE".call
      
      echo "Channel: Local/1234567890@from-internal" >> /tmp/$FILENAME
      echo "Application: Playback" >> /tmp/$FILENAME
      echo "Data: hello-world" >> /tmp/$FILENAME
      echo "MaxRetries: 2" >> /tmp/$FILENAME
      echo "RetryTime: 30" >> /tmp/$FILENAME
      echo "Priority: 1" >> /tmp/$FILENAME
      echo "Archive: Yes" >> /tmp/$FILENAME
      chmod 777 /tmp/$FILENAME
      mv /tmp/$FILENAME /var/spool/asterisk/outgoing/
      sleep 10
      STATUS=`cat /var/spool/asterisk/outgoing_done/$FILENAME |grep Status:|awk '{print $2}'`
      /etc/zabbix/./zabbix_sender -z [zabbix server ip address] -p [zabbix server port(default 10051)] -s [monitored host name] -k [key] -o $STATUS
      rm /var/spool/asterisk/outgoing_done/$FILENAME
      Hopefully somebody else will find this if they're ever looking to setup a similar outbound test call.
      Last edited by MTWiley; 11-08-2011, 23:51.

      Comment

      Working...