Monitoring for Asterisk by ZABBIX using AMI

How to monitor Asterisk

There are three main ways to monitor Asterisk.
Choose the method that suits your environment.

CLI (Command Line Interface)

Execute Asterisk CLI commands from zabbix-agent for monitoring.
Format the return value with grep or awk to make it into a form of data that can be imported into ZABBIX.

sudo asterisk -rx “core show calls” | grep active | awk ‘{ print $1 }’
10

SNMP (Simple Network Management Protocol)

SNMP (Simple Network Management Protocol) is used.
You need to have Net-SNMP installed and Asterisk ready to use SNMP.

snmpwalk -v2c -c public 127.0.0.1 .1.3.6.1.4.1.22736
.1.3.6.1.4.1.22736.1.5.4.1.4.3 = INTEGER: 2
.1.3.6.1.4.1.22736.1.5.4.1.4.4 = INTEGER: 2
.1.3.6.1.4.1.22736.1.5.4.1.4.5 = INTEGER: 1
.1.3.6.1.4.1.22736.1.5.4.1.4.6 = INTEGER: 1
.1.3.6.1.4.1.22736.1.5.4.1.5.1 = INTEGER: 1
…etc

AMI (Asterisk Manager Interface)

Originally, telnet 5038 is used, but Asterisk has a built-in HTTP/HTTPS server, so it is possible to use AMI via HTTP/HTTPS.

telnet 192.168.56.102 5038
Trying 192.168.56.102…
Connected to 192.168.56.102.
Escape character is ‘^]’.
Asterisk Call Manager/2.7.0
Action: Login
Username: zabbix
Secret: password
Response: Success
Message: Authentication accepted

Use AMI over HTTP(S)

The official site zabbix.com has a page for monitoring Asterisk using AMI over HTTP(S).
https://www.zabbix.com/integrations/asterisk
There is also a list of available data.

README.md

ZABBIX6.0
https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/tel/asterisk_http?at=release/6.0
ZABBIX5.4
https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/tel/asterisk_http?at=release/5.4

You should enable the mini-HTTP Server, add the option webenabled=yes in the general section of the manager.conf file and create Asterisk Manager user with system and command write permissions within your Asterisk instance.

Create an AMI user with webenabled=yes in the general section of manager.conf with system privileges and write privileges.

Create an AMI user

vi /etc/asterisk/manager.conf
[general]
enabled = yes
webenabled = yes
port = 5038
bindaddr = 0.0.0.0
displayconnects = yes
[zabbix]
secret = password
read=system
write=all
deny=0.0.0.0/0.0.0.0
permit=1.2.3.4/255.255.255.255
sudo asterisk -rx “core reload”

Official:sample of manager.conf
https://github.com/asterisk/asterisk/blob/master/configs/samples/manager.conf.sample

Setting for HTTP

vi /etc/asterisk/http.conf
[general]
enabled=yes
bindaddr=0.0.0.0
bindport=8088
tlsenable=yes          ; enable tls -- default no.
tlsbindaddr=0.0.0.0:10089
tlscertfile=/etc/asterisk/keys/asterisk.pem
tlsprivatekey=/etc/asterisk/keys/asterisk.key

Default is HTTP. You can also support HTTPS if you set http.conf as above.
An example of using 8088 for HTTP and 10089 for HTTPS.

Official:sample of http.conf
https://github.com/asterisk/asterisk/blob/master/configs/samples/http.conf.sample

Setting for Firewall

Allow communication from ZABBIX server on TCP5038 (AMI) TCP8088 (HTTP).
When using HTTPS, open TCP10089 in the above example.

Check using AMI from browser via HTTP

Login:
http://<IP>:8088/rawman?action=login&username=zabbix&secret=password

画像に alt 属性が指定されていません。ファイル名: amiping.png

Check for response:
http://<IP>:8088/rawman?action=ping

Saving cookies is required for testing with curl from the Linux terminal.

Import template to ZABBIX server

Download template_tel_asterisk_http.yaml and import it to ZABBIX server.

Assign templates to hosts and set macros

Assign templates to monitored hosts.
Change the macro.

  • {$AMI.SECRET} set password
  • {$AMI.URL} http(s)://<IP or FQDN>:8088/rawman

The template default AMI.URL is http://asterisk:8088/asterisk/rawman, but this is the case when prefix=asterisk is set in http.conf, so specify :8088/rawman.

Check data

How to monitoring

ZABBIX official Asterisk by HTTP template obtains call volume information such as active calls via AMI via HTTP(S).

The original AMI of TCP5038 is used for Asterisk’s life and death monitoring and response speed monitoring.
Since we are only checking whether there is a TCP connection response without authentication, an authentication error will be output to the log on the Asterisk side, but there is no problem.


tail -f /var/log/asterisk/full
[Jun 19 13:24:32] VERBOSE[16644] manager.c: Connect attempt from ‘40.81.xxx.yyy’ unable to authenticate
[Jun 19 13:24:33] VERBOSE[16645] manager.c: Connect attempt from ‘40.81.xxx.yyy’ unable to authenticate


TwitterFacebookLinkedInHatenaPocketCopy Link