Observium Monitoring Asterisk

From KlavoWiki
Jump to navigationJump to search

Install xinetd

yum -y install xinetd
service xinetd start

xinetd config

vi /etc/xinetd.d/observium_agent

Add the following to the content

service app-asterisk
{
        type           = UNLISTED
        port           = 36602
        socket_type    = stream
        protocol       = tcp
        wait           = no
        user           = root
        server         = /usr/bin/observium_agent/asterisk

        # configure the IPv[4|6] address(es) of your Observium server here:
        only_from      = 192.168.19.9

        # Don't be too verbose. Don't log every check. This might be
        # commented out for debugging. If this option is commented out
        # the default options will be used for this service.
        log_on_success =

        disable        = no
}

xinetd script

mkdir /usr/bin/observium_agent
vi /usr/bin/observium_agent/asterisk

Add the following to the file

#!/bin/bash

####### Asterisk Telephony Server
if [ -a /usr/sbin/asterisk ]
then
  echo '<<<app-asterisk>>>'
  ACTIVECHAN=$(asterisk -rx 'core show channels' | grep 'active channels' |  cut -d' ' -f1)
  ACTIVECALL=$(asterisk -rx 'core show channels' | grep 'active call' |  cut -d' ' -f1)
  IAXCHANNELS=$(asterisk -rx 'iax2 show channels' | grep active |  cut -d' ' -f1)
  SIPCHANNELS=$(asterisk -rx 'sip show channels' | grep active |  cut -d' ' -f1)
  SIPTOTALPEERS=$(asterisk -rx 'sip show peers' | grep 'sip peers' | cut -d' ' -f1)
  SIPONLINE=$(asterisk -rx 'sip show peers' |  grep -o '[0-9]* online' | head -1 | cut -d' ' -f1)
  IAXTOTALPEERS=$(asterisk -rx 'iax2 show peers' | grep 'iax2 peers' | cut -d' ' -f1)
  IAXONLINE=$(asterisk -rx 'iax2 show peers' |  grep -o '[0-9]* online' | head -1 | cut -d' ' -f1)

  echo "activechan:$ACTIVECHAN"
  echo "activecall:$ACTIVECALL"
  echo "iaxchannels:$IAXCHANNELS"
  echo "sipchannels:$SIPCHANNELS"
  echo "sippeers:$SIPTOTALPEERS"
  echo "sippeersonline:$SIPONLINE"
  echo "iaxpeers:$IAXTOTALPEERS"
  echo "iaxpeersonline:$IAXONLINE"

fi

Make the asterisk script executable

chmod +x /usr/bin/observium_agent/asterisk