Monitoring Asterisk Status with MonAst

Opportunity Inspection
MonAst is positioned by developers as a monitoring tool that acts as an operator panel for Asterisk. Distributed under a BSD license. The project was written using Python (daemon for communicating with Asterisk via AMI), PHP, JS (AJAX).
Of the viewing options (in real-time mode) - the following:
- Work with several servers (by switching between them)
- Multiuser mode with access rights
- Mapping users and peers (SIP, IAX, DAHDI, Khomp, etc ...)
- Display active channels and calls (with channel name and CallerID)
- Conference channels (with display of connected users)
- Parked Calls
- Queues (with statistics, participants and expecting customers)
From the possibilities of performing operations:
- Making (initiating) calls
- Call transfer
- Call reset
- Call Park
- Listening to Calls (Spy Calls)
- Inviting participants to the conference
- Removing Conference Participants
- Adding users (or peers) as a member of any queue
- Removing members from a queue
- Arming and pausing queue participants
- Executing CLI Commands
As you can see - the list of features is quite extensive.
Installation
The experimental system we will have is clean Ubuntu 10.10 with basic programs and updates. MonAst does not have to be installed on a host with Asterisk. For example, I have MonAst locally on my laptop - and I perfectly monitor all our 6 servers with Asterisk.
Before proceeding with the installation of MonAst - go over the requirements.
Since the daemon used to exchange between Asterisk and MonAst (through the AMI - Asterisk Manager API) is written in Python, the first thing we do is check its presence in the system:
it@ubuntu-test ~ $ python --version
Python 2.6.6
If we see something like this, then everything is in order. If for some reason it is not there, we execute the command:
it@ubuntu-test ~ $ sudo apt-get update && sudo apt-get install python
We move on.
Since all this will be displayed through the web-interface, you need to have installed http server with php support, as well as php-pear. If this kit didn’t stand before, we execute the command (we’ll additionally install mc for easy navigation and editing):
it@ubuntu-test ~ $ sudo apt-get install apache2 php5 php-pear mc
And finally, installing dependencies for the product under discussion. This list is not large with us:
- Twisted Python 10.1+
- zope.interface 3.6+
- Starpy SVN-Trunk
- PHP PEAR Packages: (HTTP_Client)
The zope.interface package was already in the system (it was available out of the box).
We put the HTTP_Client package:
it@ubuntu-test:/usr/src$ sudo pear install HTTP_Client
WARNING: "pear/HTTP_Client" is deprecated in favor of "pear/HTTP_Request2"
WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-update pear.php.net" to update
WARNING: "pear/HTTP_Request" is deprecated in favor of "pear/HTTP_Request2"
WARNING: "pear/Net_URL" is deprecated in favor of "pear/Net_URL2"
downloading HTTP_Client-1.2.1.tgz ...
Starting to download HTTP_Client-1.2.1.tgz (10,202 bytes)
.....done: 10,202 bytes
downloading HTTP_Request-1.4.4.tgz ...
Starting to download HTTP_Request-1.4.4.tgz (17,109 bytes)
...done: 17,109 bytes
downloading Net_URL-1.0.15.tgz ...
Starting to download Net_URL-1.0.15.tgz (6,303 bytes)
...done: 6,303 bytes
downloading Net_Socket-1.0.10.tgz ...
Starting to download Net_Socket-1.0.10.tgz (5,429 bytes)
...done: 5,429 bytes
install ok: channel://pear.php.net/Net_URL-1.0.15
install ok: channel://pear.php.net/Net_Socket-1.0.10
install ok: channel://pear.php.net/HTTP_Request-1.4.4
install ok: channel://pear.php.net/HTTP_Client-1.2.1
As you can see, during the installation process it says that the package is outdated and offers to install a newer one:
it@ubuntu-test:/usr/src$ sudo pear install HTTP_Request2
We will install Twisted and StarPy packages from source. But during the installation, some more dependencies were revealed, which we are correcting (in passing, we will switch to superuser mode):
it@ubuntu-test:~$ sudo su
root@ubuntu-test:~$ cd /usr/src/
root@ubuntu-test:/usr/src# wget http://pypi.python.org/packages/source/T/Twisted/Twisted-12.0.0.tar.bz2#md5=cf49a8676c21c50faf1b42b528049471
root@ubuntu-test:/usr/src# wget http://downloads.sourceforge.net/project/starpy/starpy/1.0.0a13/starpy-1.0.0a13.tar.gz
root@ubuntu-test:/usr/src# tar -xvf Twisted-12.0.0.tar.bz2
root@ubuntu-test:/usr/src# tar -xvf starpy-1.0.0a13.tar.gz
root@ubuntu-test:/usr/src# apt-get install build-essential gcc-4.5 libssl-dev python-dev
root@ubuntu-test:/usr/src# cd Twisted-12.0.0
root@ubuntu-test:/usr/src/Twisted-12.0.0# python setup.py install
If we see the inscription “ Finished processing dependencies for Twisted == 12.0.0 ” - then the installation was successful and move on. If an error pops up, then rather some component is missing. Check the list - are all dependencies installed? Move on:
root@ubuntu-test:/usr/src/Twisted-12.0.0# cd ..
root@ubuntu-test:/usr/src# cd starpy-1.0.0a13
root@ubuntu-test:/usr/src/starpy-1.0.0a13# python setup.py install
root@ubuntu-test:/usr/src/starpy-1.0.0a13# cd ..
Well, the main hero of the occasion. At the time of writing, the current version is 3.0b4:
root@ubuntu-test:/usr/src# wget http://downloads.sourceforge.net/project/monast/Monast%20for%20Asterisk%201.4%2C%201.6%20and%201.8/3.0b4/monast-3.0b4.tar.gz
root@ubuntu-test:/usr/src# tar -xvf monast-3.0b4.tar.gz
root@ubuntu-test:/usr/src# cd monast-3.0b4
root@ubuntu-test:/usr/src/monast-3.0b4# ./install.sh
During the installation process, the script will ask a couple of questions regarding the paths. If the options proposed by him are satisfied, we agree. Otherwise, we prescribe our data. I just changed the path where the .php files go. It may seem that the installation is completed on this. But it was not there. The start script /etc/init.d/monast is installed only for SuSE, RedHat, Debian, Gentoo, Slackware, FreeBSD systems. But not Ubuntu and the like. Therefore, we copy the script from Debian and add it to the startup:
MonAst HTML path [/var/www/html/monast]: /var/www/asterisk/monast/
root@ubuntu-test:/usr/src/monast-3.0b4# cp contrib/init.d/rc.debian.monast /etc/init.d/monast
root@ubuntu-test:/usr/src/monast-3.0b4# chmod 755 /etc/init.d/monast
root@ubuntu-test:/usr/src/monast-3.0b4# update-rc.d monast defaults 91 60
Now the installation is over. You can go to the setting.
Customization
First of all, you need to configure Asterisk itself so that the sabzhe software can successfully connect and exchange information. On a server with Asterisk pass on the way / etc / asterisk / and edit the files manager.conf . If there are several servers, we make similar corrections for the necessary ones.
root@asterisk ~ $ mcedit /etc/asterisk/manager.conf
;
; AMI - The Asterisk Manager Interface
;
[general]
enabled = yes ; Активируем AMI
port = 5038 ; Порт, по которому к данному сервису будет подключаться MonAst
bindaddr = 0.0.0.0 ; Прослушиваем все интерфейсы в системе для принятия подключения
displayconnects = yes ; Показывать в консоли Asterisk о факте подключения
webenabled = no ; Выключаем встроенный в Asterisk static_http
allowmultiplelogin = yes ; Разрешаем вход вход под одним и тем же пользователем с разных мест.
timestampevents = yes ; Добавлять метку времени для событий
; debug = on ; Можно включить отладочный режим для сообщений AMI
[monast_user]
secret=qwerty123 ; Пароль для подключения
deny=0.0.0.0/0.0.0.0 ; Запрещаем подключение с любого адреса
permit=127.0.0.1/255.255.255.0 ; И постепенно разрешаем нужные
permit=192.168.1.10/255.255.255.0 ; Так разрешаем конкретный хост
permit=192.168.2.0/255.255.255.0 ; А вот так можно разрешить подсеть
writetimeout=100 ; Таймаут для посылки команд
; Разрешения для данного пользователя. Можно указать all, но так наглядней
read=system,call,log,verbose,command,agent,user,config,originate,reporting
write=system,call,log,verbose,command,agent,user,config,originate,reporting
Then reload the Asterisk configuration for the manager module:
root@asterisk$ asterisk -rx "manager reload"
This completes the setup of Asterisk. We proceed to the configuration of MonAst itself.
The file with the parameters is located on the path /etc/monast.conf . Him and rule. I will say in advance - there were no difficulties in setting up, the comments given in the file clearly describe one or another parameter. But for an example I will give my example file
root@ubuntu-test:/usr/src/monast-3.0b4# cd /etc/
root@ubuntu-test:/etc# mcedit monast.conf
# Copyright (c) 2008-2011, Diego Aguirre
# All rights reserved.
##
## Global Section
##
[global]
# Bind client connetions on host:port
bind_host = 127.0.0.1 ; Разрешаем подключения с локального хоста
bind_port = 5039 ; Порт для подключения к демону.
# Use client autentication on browser
auth_required = true ; Указываем сто аутентификация обязательна
## ===================================
##
## Servers Definitions
##
[server: Server1] ; Параметры для первого сервера
hostname = 192.168.1.1
hostport = 5038
username = monast_user
password = qwerty123
# Default user context
default_context = default
# Context to use in transfer calls
transfer_context = default
# Context and prefix for meetme
meetme_context = default
meetme_prefix =
[server: Server2] ; Параметры для второго сервера
hostname = 192.168.2.1
hostport = 5038
username = monast_user
password = qwerty123
# Default user context
default_context = default
# Context to use in transfer calls
transfer_context = default
# Context and prefix for meetme
meetme_context = default
meetme_prefix =
## ===================================
##
## Peers Definitions
##
[peers]
# sort peers (options: channel, callerid)
sortby = callerid
# default show/hide
default = show
# hide peer when default = show
;/SIP/user-1 = hide
# show peer when default = hide
;/SIP/user-2 = show
# always show peer.
;/SIP/user-3 = force
# force CallerID (only in forced mode)
;/SIP/user-4 = force,Diego Aguirre <5555>
# Create peer groups
;/@group/Group 1 = SIP/user-1,SIP/user-2
;/@group/Group 2 = SIP/user-3,SIP/user-4
## ===================================
##
## Meetmes / Conferences Definitions
##
[meetmes]
# default show/hide
default = hide
# hide meetme when default = show
;/1234 = hide
# show meetme when default = hide
;/1234 = show
# always show meetme
;/1234 = force
## ===================================
##
## Queues Definitions
##
[queues]
# defualt show/hide
default = hide
# show queue queue01
;/queue01 = show
# show queue queue02 with display name Support
;/queue02 = show,Support
# hide queue queue03
;/queue03 = hide
# Map Member name
;/@member/SIP/user-1 = Diego Aguirre <5555>
## ===================================
## Define users and roles to use on auth_required is set to true
## roles must be:
## originate : user can originate, transfer, park and drop calls
## agent : user cans add, remove, pause and unpause members on queues
## command : user can execute asterisk cli commands
## spy : user can start a spy
[user: admin] ; Мего-админ
secret = SuperPuperDruper
roles = originate,queue,command,spy
servers = ALL
[user: manager] ; Пользователь с возможностью просмотра обеих (всех) серверов
secret = password
roles = originate
servers = ALL
[user: server1] ; Пользователь с возможностью просмотра одного (первого) серверов
secret = 12345
roles = originate
servers = Server1
[user: server2] ; Пользователь с возможностью просмотра и выполнения команд на одном (втором) сервере
secret = 54321
roles = originate,command
servers = Server2
Save the changes and reboot the daemon:
root@ubuntu-test:/etc# /etc/init.d/monast restart
All. You can connect and check. We open the browser and in the address bar we drive in: http: // localhost / asterisk / monast /
If you set “ auth_required = true ” then enter the username, password and enjoy the working tool :)

Important note. In the "without authentication" mode, everyone who works in the MonAst operator panel has full rights, i.e. are "superusers." And as we know, “Weapons given to inept hands can do harm.” Be careful.
Also in the /var/www/asterisk/monast/lib/config.php file there are address and port parameters, where the monast.py daemon works, parameters for displaying debug and cli tabs , as well as some no less interesting parameters.
Features Overview
Now, let’s go over the capabilities of this software product.
After entering the web-interface we see several tabs. And to be more precise:
- Mixed Pannels - A tab with almost all sections at once. Convenience lies in the fact that you can display only the necessary ones and, without switching, see the necessary information in one place.
- Peers / Users - View and manage accessible peers and users.
- Meetme Rooms - View and manage your conferences
- Channels / Calls - View and manage active calls and raised channels.
- Parked Calls - View and manage your parked calls
- Queues - View and manage call queues
- Asterisk CLI - Asterisk command line. If the user has the right to execute commands in the console, then it is here that you can enter something similar to “core show version” :)
It’s not difficult to figure out the possibilities and, perhaps, it will be even better if you yourself go over and try out the available functions - so you will clearly understand what and how it works. But I still describe a couple of interesting ones :)
Originate call (call initiation) . From the name of the function it is clear - you can connect the internal subscriber with some number (if he, the number, can be processed by your dialplan). To perform the function, you need to right-click (hereinafter referred to as PCM) on the desired account and select the appropriate item. In the window that appears, enter the desired number and, voila - the telephone is ringing from the selected person, he picks up the phone and Asterisk connects it to the number that we have displayed. You can also drag one account to another with the mouse and, having agreed, initiate a connection between them.
Meetme Rooms (conference room) . By going to this section, you can manage already created conferences, or create a new one and invite certain participants there. To create your conference, go to the appropriate section, click “ Create Dynamic Meetme ” and enter the requested information in the window. Clicked “OK” - and the process went-went :)
Spy (listening to a call). What she does? From the name you can understand - makes it possible to connect to the selected conversation and listen to the speech stream. The function can be useful when used in call centers for monitoring and verifying agents. At the same time, during the conversation, the interlocutors do not even suspect the fact of listening. At least I, when testing this feature, did not hear any signal or notification. In order for the panel user to have the right to listen, it is necessary that spy be present in the roles field of his access rights . Therefore, in order to limit the use of this function with bad intent, enable authentication to access the panel and give the rights to use it only to trusted users. Head of department, for example :)
Conclusion
MonAst, like alternative projects with similar functionality (FOP, Links, etc.) clearly has the right to exist and, accordingly, to use in the workflow.
Ease of use, relative ease of installation and configuration, monitoring multiple servers from one place - all this, in most cases, will be more than enough.
References
- Official site of the project: http://monast.sourceforge.net/
- Python Twisted Project Page: http://twistedmatrix.com
- Starpy for Twisted Project Page: http://sourceforge.net/projects/starpy/
UPD: Fixed a couple of annoying text errors.