📜 ⬆️ ⬇️

Monitoring Asterisk Status with MonAst

The search for a convenient solution for monitoring multiple Asterisk servers led to a wonderful tool:
Monast Logo

Opportunity inspection


MonAst is positioned by developers as a monitoring tool that acts as an operator panel for Asterisk. Distributed under BSD license. The project is written using Python (daemon to communicate with Asterisk by AMI), PHP, JS (AJAX).

From the viewing options (in real-time mode) - the following:

Of the possibilities of operations:

As you can see - the list of possibilities is quite extensive.

Installation


Experimental system, we will have a clean Ubuntu 10.10 with basic programs and updates. MonAst does not have to be installed on a host with Asterisk. I, for example, have MonAst locally on a laptop - and I perfectly monitor all our 6 servers with Asterisk.
Before you start installing MonAst - let's go over the requirements.
Since the daemon through which the exchange between Asterisk and MonAst (using the Asterisk Manager API AMI) is written in Python, we first 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 - execute the command:
 it@ubuntu-test ~ $ sudo apt-get update && sudo apt-get install python 

Moving on.
Since all this will be displayed via the web-interface, you need to have an http server installed with php support, as well as php-pear. If this kit did not previously exist - execute the command (in addition we put mc - for ease of 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 small with us:
  1. Twisted Python 10.1+
  2. zope.interface 3.6+
  3. Starpy SVN-Trunk
  4. PHP PEAR Packages: (HTTP_Client)

The zope.interface package was already in the system (was available out of the box).
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 

Packages Twisted and StarPy will be installed from source. But during the installation, dependencies also emerged, which we are fixing (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 go on. If an error pops up, then rather some component is missing. Check the list - are all dependencies installed? Go ahead:
 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 offered to them suit - we agree. Otherwise we register our data. I just changed the way where the .php files go
MonAst HTML path [/var/www/html/monast]: /var/www/asterisk/monast/

It may seem that the installation is complete. But it was not there. The startup script /etc/init.d/monast is set only for SuSE, RedHat, Debian, Gentoo, Slackware, FreeBSD systems. But not Ubuntu and the like. Therefore, copy the script from Debian and add it to the autoload:
 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 proceed to the setting.
')

Customization


First of all, you need to configure Asterisk itself so that the sabzhevo software can successfully connect and exchange information. On the server with Asterisk, click the path / etc / asterisk / and edit the file manager.conf . If there are several servers, we make such 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 

After that, we will reload the Asterisk configuration for the manager module:
 root@asterisk$ asterisk -rx "manager reload" 

This completes the Asterisk setup. Go to the configuration of the MonAst'a.
The file with the parameters is located on the path /etc/monast.conf . Him and rule. I will say in advance that there were no difficulties in setting up, the comments in the file clearly describe this or that parameter. But for example, give my sample 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 ;<Server Name>/SIP/user-1 = hide # show peer when default = hide ;<Server Name>/SIP/user-2 = show # always show peer. ;<Server Name>/SIP/user-3 = force # force CallerID (only in forced mode) ;<Server Name>/SIP/user-4 = force,Diego Aguirre <5555> # Create peer groups ;<Server Name>/@group/Group 1 = SIP/user-1,SIP/user-2 ;<Server Name>/@group/Group 2 = SIP/user-3,SIP/user-4 ## =================================== ## ## Meetmes / Conferences Definitions ## [meetmes] # default show/hide default = hide # hide meetme when default = show ;<Server Name>/1234 = hide # show meetme when default = hide ;<Server Name>/1234 = show # always show meetme ;<Server Name>/1234 = force ## =================================== ## ## Queues Definitions ## [queues] # defualt show/hide default = hide # show queue queue01 ;<Server Name>/queue01 = show # show queue queue02 with display name Support ;<Server Name>/queue02 = show,Support # hide queue queue03 ;<Server Name>/queue03 = hide # Map Member name ;<Server 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 

Everything. You can connect and check. Open the browser and type in the address bar: http: // localhost / asterisk / monast /
If you put " auth_required = true " then enter the login, password - and enjoy the work tool :)
MonAst Mixed Pannels
Important note. In the “without authentication” mode, all those who work in the MonAst operator panel have full rights, i.e. are "super users". And as we know, “Weapons given in unskillful hands can harm”. Be careful.
Also in the /var/www/asterisk/monast/lib/config.php file there are the address and port parameters where the monast.py daemon is running, the settings for displaying debug and cli tabs , as well as some equally interesting parameters.
Feature Overview
Now let's go over the possibilities of this software.
After logging in to the web-interface, we see several tabs. And to be more precise:

Understanding the possibilities is not difficult and, perhaps, it will be even better if you yourself run and try out the available functions - so you will clearly understand what works. But I still describe a couple of interesting ones :)
Origin call (call initiation) . It is clear from the function name - it is possible to connect an extension to any number (if it, the number, can be handled by your dial plan). To perform the function, you need to right-click (hereinafter referred to as PCM) on the account you need and select the corresponding item. In the window that appears, enter the desired number and, voila - the telephone is ringing at the selected person, he picks up the phone and Asterisk connects it with the number we have displayed. You can also drag one account to another with the mouse, and by agreeing to initiate a connection between them.
Meetme Rooms (conference room) . 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 (listen to the call) . What she does? From the name you can understand - it allows you 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 checking agents. In the process of conversation, the interlocutors do not even suspect about the fact of listening. At least I, testing this opportunity, did not hear any signal or notification. In order for the user of the panel to have the right to listen - you need to have spy in the roles field of his access rights. Therefore, in order to restrict the use of this function with bad intent - enable authentication to access the panel and grant the rights to use it only to trusted users. Head of the department, for example :)

Conclusion


MonAst, as well as alternative projects with similar functionality (FOP, Links, etc.) clearly has a right to exist and, accordingly, use in the workflow.
Ease of use, relative ease of installation and configuration, monitoring multiple servers from one location - all this, in most cases, will be more than enough.

Links




UPD: Fixed a couple of annoying errors in the text.

Source: https://habr.com/ru/post/143053/


All Articles