Prehistory
We have in the "state" of Asterisk 11 and FireBird 2.5 DBMS, in which PBX writes CDR. Infrequently, but it so happens that the record in the database stops, and we will know about it when you need to watch something in the CDR. Having seen that there are no records, we restart Asterisk, the record in the database is restored. Once again, without receiving important information from the CDRs, it was decided to somehow track the fact of recording / non-recording in the CDR.
We use Zabbix 3 as a monitoring system, so it was decided to write a simple Python script that will connect to FireBird and check the time of the last entry to the table from the CDR, if this time exceeds 30 minutes, the monitoring system will signal us.
Install Python 3
Asterisk is installed on the already old Centos 6.8, so first install fresh Python.
Downloading the most recent source code at the time of this writing:
')
wget http://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz -O /var/tmp/Python-3.6.1.tar.xz
Go to the above directory:
cd /var/tmp/Python-3.6.1
We carry out:
./configure
We collect:
make
Install:
make install
Python installs to the / usr / local / bin / python3 directory
Installing Python library to communicate with FireBird
You need to update or write the client library for our version of FireBird. You can 2.5.5, you can 3.0.2.
2.5.5. already, add libfbclient.so.3.0.2 to the same directory / usr / lib64, create libfbclient.so.3 symlinks, like existing ones, and replace the libfbclient.so symlink with the same one pointing to libfbclient.so.3 .
Pip with our latest version of python 3.6.1 already exists, called in the same way as python3 - pip3.
Install the library to work with FireBird on Linux:
pip install fdb
The script to connect to FireBird and get the result of the presence / absence of records in the CDR
In the connection string, of course, we indicate our data (IP, path, login, password).
Zabbix server
This article is not intended to teach how to use the monitoring system, so here everything is brief, to understand the process.
Create a new item on a node with Asterisk:

Add a trigger to the event:

Zabbix agent
Go to the server with Asterisk and edit the agent configuration.
At the end of the /etc/zabbix/zabbix_agentd.conf file, add the line:
UserParameter=CDRWrite.check[*], /path/to_scripts/script.py
And restart the agent:
service zabbix-agent restart
After done on Zabbix, the server should begin to receive data on the execution of the script. If the data is not written for more than 30 minutes (which is impossible in our case during business hours), the monitoring system will inform us about it.