Wonderful monitoring system
Zabbix offers out of the box several ways to notify the administrator about any problems: e-mail, SMS and Jabber.
In this topic, I will tell you how to make friends with Zabbix and Asterisk-based PBX. When an abnormal situation occurs, the robot will call you and speak a message describing the problem.
')
Why do you need it
Email alerts work well when there are few of them. With a large number of letters there is a chance to miss a critical error. Therefore, it is logical to set up e-mail alerts for all levels of problems, and for SMS, only the most critical ones.
But, unfortunately, not all fellow administrators have a budget for the purchase of a GMS modem and payment for SMS. Sending SMS via online services is not reliable, because we may drop the channel to the Internet. A notification through your PBX will be free. You can set up a call to an internal number in the office, a group of subscribers or to a mobile one. If the PBX is connected to a physical telephone line, then it will not be a problem for the channel to drop onto the Internet.
How it works
On the net I found a
pair of examples of scripts to solve this problem. However, both of them have significant drawbacks: they use PHP (why?) And do not know how to read the text of the message - only a standard message that there is some kind of problem.
Our script will work like this:
- when alert occurs, Zabbiks runs a bash script;
- bash-script prepares a call-file for Asterisk and an error message in text form;
- files are sent via SCP to the Asterisk server;
- SSH on Asterisk runs text2wave, which reads the text into a wav file;
- The wav file and the call file are copied to the corresponding Asterisk folders;
- Asterisk sees files, makes a call and plays the message.
The whole process takes only 1-2 seconds.
Script
Zabbiks can run scripts when problems occur. The scripts are in the folder specified in the Zabbix server config variable AlertScriptsPath.
Like all such scripts, our script should take 3 parameters: the addressee, message subject, message text.
We configure servers
It all depends on the OS / distribution you are using, so I cannot give 100% accurate recommendations.
In short, firstly, we need to install the text2wave program (the
Festival package) on Asterisk, if desired, to install a Russian voice.
Secondly, you need to configure passwordless SSH authentication between Zabbix and Asterisk. You can use
this instruction (paragraphs 1-6). The key will have to do without passphrase. You can set up authentication for users, under which Zabbix and Asterisk work, and get others, but in the second case sudo will be used in the script.
Also make sure that Asterisk has all the rights to the created call-file.
If necessary, get a separate extension from which the call will occur.
Once everything is set up, you can test the script by running it from the console:
./call_sip.sh "" ""
If it fails, we pick the logs of Zabbix, ssh and Asterisk. I spent most of my time setting up sudo and ssh, as it were.
Configuring Zabbix
The easiest:
In Administration - Media types we create a new alert type.

For the necessary users (Administration - Users) in the Media tab we indicate their phone. This can be either an internal number or a mobile number - in accordance with the dial plan of your PBX.
In Actions we edit or create a new action, specifying the notifying users. I recommend setting the message header to {TRIGGER.STATUS} {TRIGGER.NAME} {HOSTNAME}, so that it is clear on which machine the trouble occurred.
Total
We received another channel alert administrators in addition to e-mail and SMS.