Monitoring ASTERISK telephony system with ZABBIX via HTTP - Omid-Mohajerani/VoIP-Monitoring GitHub Wiki

Step 1 - Zabbix monitoring software installation

I'm using Debian 12 for my ZABBIX Server and Im using Digital Ocean Cloud Platform Provider.

Set system locale

dpkg-reconfigure locales

Im choosing "en_US.UTF-8" as my locale.

Database Installation:

You need to install the MariaDB database before you want to start installing ZABBIX monitoring software. Its good idea to update your OS before installation as well:

sudo apt update -y
sudo apt upgrade -y
sudo apt install mariadb-server -y

And secure your MariaDB installation

sudo mariadb-secure-installation

Zabbix installation

Here you can find the official installation guide:

ZABBIX server installation on DEBIAN 12

I just copied here the same instruction for my own usage. Always use the above link to have the latest changes:

Install the Zabbix repo and package

wget https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb
dpkg -i zabbix-release_6.4-1+debian12_all.deb
apt update -y 
apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent -y 

Database creation for ZABBIX

mysql -uroot -p
create database zabbix character set utf8mb4 collate utf8mb4_bin;
create user zabbix@localhost identified by 'password';
grant all privileges on zabbix.* to zabbix@localhost;
set global log_bin_trust_function_creators = 1;
quit;

Import ZABBIX DB schema

zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

Disable log_bin_trust_function_creators option after importing database schema.

mysql -uroot -p
set global log_bin_trust_function_creators = 0;
quit;

Configure the database for the Zabbix server:

vim /etc/zabbix/zabbix_server.conf
DBPassword=password

Start Zabbix server and agent processes

systemctl restart zabbix-server zabbix-agent apache2
systemctl enable zabbix-server zabbix-agent apache2

Open Zabbix UI web page

The default URL for Zabbix UI when using Apache web server is http://host/zabbix Zabbix default web username: Admin ( capital A) Zabbix default web password: zabbix


Step 2 - Zabbix Agent installation

For Monitoring usual metrics such as hard disk usage, CPU usage, etc we will use Zabbix Agent. I'm using Debian 12 for my asterisk server so here is how to:

Installing Zabbix Repo and Zabbix Agent

wget https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb
dpkg -i zabbix-release_6.4-1+debian12_all.deb
apt update -y
apt install zabbix-agent -y

Edititing Zabbix agent configuration file

vim /etc/zabbix/zabbix_agentd.conf
 

Changing zabbix-agent Sever parameters

Change "Server" and "Server Active" from "127.0.0.1" to your Zabbix server IP Address.

Server=167.172.168.221
ServerActive=167.172.168.221

Change hostname

To the hostname of your Linux system. The default is "Zabbix server" that you need to change it

hostname=Asterisk-SERVER-01

Enabling and starting Service

enable zabbix-agent service

systemctl enable zabbix-agent

start zabbix-agent service

systemctl start zabbix-agent

Verify if the zabbix-agent service is running

root@Asterisk:~# systemctl status zabbix-agent
● zabbix-agent.service - Zabbix Agent
     Loaded: loaded (/lib/systemd/system/zabbix-agent.service; enabled; preset: enabled)
     Active: active (running) since Wed 2023-08-02 17:02:42 UTC; 7min ago
   Main PID: 1505 (zabbix_agentd)
      Tasks: 6 (limit: 1107)
     Memory: 6.1M
        CPU: 100ms
     CGroup: /system.slice/zabbix-agent.service
             ├─1505 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
             ├─1506 "/usr/sbin/zabbix_agentd: collector [idle 1 sec]"
             ├─1507 "/usr/sbin/zabbix_agentd: listener #1 [waiting for connection]"
             ├─1508 "/usr/sbin/zabbix_agentd: listener #2 [waiting for connection]"
             ├─1509 "/usr/sbin/zabbix_agentd: listener #3 [waiting for connection]"
             └─1510 "/usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]"

Step 3 - Asterisk Configuration

AMI Configuration

AMI stands for Asterisk Manager Interface and we will use it here to Monitor our Asterisk Instance. In order to enable and create an AMI user edit /etc/asterisk/manager.conf and add the following entries. Feel Free to change the password if you do not want your server to get F:):):)

vim /etc/asterisk/manager.conf

Change the following configurations:

[general]
enabled = yes
webenabled = yes

port = 5038
bindaddr = 0.0.0.0

and add AMI user definition at the end of the file:

[zabbix]
secret = bJuhBy7F
deny=0.0.0.0/0.0.0.0
permit=167.172.168.221/255.255.255.0
read = system,call,log,verbose,agent,user,config,dtmf,reporting,cdr,dialplan
write = system,call,agent,user,config,command,reporting,originate,message

And reload the manager

asterisk -rx "manager reload"

To verify if your AMI user created successfully you can use "manager show users" asterisk command:

root@Asterisk:/var/log/zabbix# asterisk -rx "manager show users"

username
--------
zabbix
-------------------
1 manager user configured.
root@Asterisk:/var/log/zabbix#

Enable Asterisk HTTP Server

vim /etc/asterisk/http.conf

And Change the following configurations. bindaddr = your asterisk server ip address

enabled=yes
bindaddr=164.92.175.156
bindport=8088

and reload your asterisk

asterisk -rx "reload"

Step 4 - IPTABLES

Allow traffic from your Zabbix Server:

iptables -I INPUT -s 164.92.175.156 -j ACCEPT

Step 5 - Adding Host in Zabbix

Its a lot of steps to explain here :) please check my video here:

⚠️ **GitHub.com Fallback** ⚠️