It seems that recently e-mail is more suitable for spam than for operational alerts of the monitoring system. In this article, I will collect methods for receiving notifications on mobile devices - both via instant messengers and through traditional communication channels.
I will consider the solutions on the example of Zabbix, but they can be adapted to your favorite system, so long as she knows how to run scripts on the trigger.
It is really convenient to receive notifications in such corporate instant messenger as Slack, and thanks to the open API it's also easy. The API can be found in the official documentation , but I will show a couple of examples of implementation.
The easiest solution will be integration with the messenger through the Webhook mechanism. First you need to get on the site of the service in the section Incoming WebHooks a special address to which you can send requests even with the usual curl . Also there you can select the icon and channel to display messages by default.
Get the URL to send requests.
Now you need to add a script to Zabbix - by default, this is the / usr / local / share / zabbix / alertscripts folder , - enable its execution and configure the necessary parameters in it. The script and detailed configuration instructions are available on the GitHub in the zabbix-slack-alertscript repository .
Slack notifications.
A more interesting and difficult way to solve the problem is to create a full-fledged bot. Unlike the simple curl option, a bot can not only throw notifications, but also delete them when solving a problem.
You can familiarize yourself with the bot's source code and detailed setup instructions in the zabbix-notify repository on GitHub. In addition to Slack, this bot supports notifications in HipChat, the creation of new incidents and the resolution of old ones in the PagerDuty incident management system.
Receive notifications to this popular, but blocked on the territory of the Russian Federation, the messenger is also convenient, since the open API allows it. You can get acquainted with the possibilities of automation in the documentation on the official site.
For the simplest solution, you need to get your request token with the help of Father Bots - @BotFather . Using the commands / start and / newbot, the main bot will issue the coveted token.
We get a token for our bot-notifier.
Now you can send messages with requests through curl. As a complicated implementation, you can cite as an example a bot that sends not only notifications, but also schedules. Zabbix-in-Telegram's GitHub repository will help you get a bot.
Detailed instructions for a simple and slightly more complex script can be found in the material “Sending notifications and schedules from Zabbix to Telegram” .
This messenger, unfortunately, does not have a documented public API and is struggling with scripts on GitHub as part of the “anti-spam” framework. But there is a way out. You can use the standard solution " direct link ", described in the official FAQ. But then you need to keep the WhatsApp Web instance. Similarly, the autoclicker binding of the web version or the desktop application will work.
A slightly more interesting option would be to use the console “messenger” yowsup . The instant messenger itself is available in the GitHub repository of the same name . While the solution is working. But if WhatsApp suddenly decides to change its API, then it will take time to adapt.
Sending messages through the console.
More information on configuring the console script and Zabbix can be found in the article “ Receive notifications from Zabbix in WhatsApp ”.
If your engineer on duty spends a lot of time on social networks, you can send notifications to him directly in messages (or on the wall) on VKontakte.
First we need to create our application in the social network - to get the token. You can do this in the " My Applications " section. After creating a new application, we need to copy its ID in the “Settings” section and follow the link:
https://oauth.vk.com/authorize?client_id=appid&scope=notify,photos,friends,audio,video,notes,pages,docs,status,questions,offers,wall,groups,**messages**,notifications,stats,ads,offline&redirect_uri=http://api.vk.com/blank.html&display=page&response_type=token
Of course, instead of appid you need to substitute your ID. And if you just need to send messages - without notifying the friends of the engineer, if he does not respond, then it is enough to set messages in the parameters.
After confirming access, the following address will appear in the address bar:
https://api.vk.com/blank.html#access_token=81eff38378a3bbbcb5c7043a152a69fd04dca057ac821dd7afd7c2d8e35b60172d45a26599c08034cc40a&expires_in=0&user_id=123456
Where in the value of the access_token parameter will be the token we need.
Now, using the usual curl, you can send messages, and Zabbix can do this with a wrapper from a simple script.
With the step-by-step setting of notifications and the option of implementing the script, you can find out in the article “ We attach notifications to Zabbix in VKontakte ”.
If some retrograde is not alien to you, then Jabber still remains. Receive notifications to the old favorite messenger Zabbix allows out of the box. To do this, just set up an account in the properties of alerts:
Jabber account setup.
And specify the necessary JID in user properties. More information can be found in the official Zabbix documentation in the Jabber section. I’ll add that if you pre-register your Jabber account with the necessary transports, you can send messages via ICQ, IRC and other Mail.ru agents.
If you do not focus on fashionable and not very instant messengers, then you can receive notifications and simply via push technology. It is supported not only in mobile devices, but also in any Windows 10, as well as in Chrome and Firefox browsers.
Here we will have to either deploy our server and applications to send messages, or use paid services like Pushbullet , Pushsafer or Pushover . The technique is similar to the others: register, get a token, install applications or browser extensions and send a message helmet though the long-suffering curl.
The choice of a particular service depends on the price tag. In general, they all work about the same. Some services provide a limited number of free messages - for example, Pushbullet will have 100 messages per month.
Push notifications on Android.
An example of specific implementations can be found:
Notifications to instant messengers on phones are, of course, good. But only as long as the Zabbix server has access to the Internet. For guaranteed notification of failures in the network, it is better to use traditional communication channels.
Zabbix out of the box supports the ability to send SMS. Unfortunately, he can only do this through a serial interface. If you have a Siemens MC35 or something similar, you can familiarize yourself with the SMS sending settings in the Zabbix documentation in the SMS section.
In addition to this archaic option, you can use the service to send SMS like sms.ru. Fortunately, they all support all sorts of APIs. Some provide and e-mail gateway, and to configure notifications do not need to write scripts. The most important thing when choosing a gateway is to check it for SMS delivery delays.
Configure the script for SMS notifications.
An example of setting Zabbix can be found in the article “ Free Sending SMS Notifications to Zabbix ”.
Sending SMS through an external gateway will not solve the problem of the lack of Internet on the server, unlike sending through hardware devices with a SIM card. As a budget option, you can use a USB-modem - for example, Huawei e1550.
Step-by-step instructions can be found in the material “ Zabbix Alerts via sms using a GSM modem. Easy setup .
SMS can be skipped easily, but the phone call is already more difficult. Therefore, for especially urgent notifications, you can set up Zabbix for phone calls. Outputs, as usual, several.
A simple solution would be to use an external SIP server. This will require the PJSIP library, which can be used as a console SIP client. For generating a voice message, the text2wave utility from the Festival speech generation kit is suitable. After collecting everything in a heap and adding scripting magic, you can be awakened by a caring monitoring server.
The example of implementation is described in detail in the article “ Alerts from Zabbix by phone call ”.
An alternative would be to use your PBX based on Asterisk and access it using special call-files or via the AMI interface. Then, if you have a communication link independent of the Internet, such as an analog line or an E1 stream, you can listen to the problems of your server.
A description of the solution is available in the material “ Alerting for Zabbix problems by phone via Asterisk ”.
In the article I tried to provide links to major solutions for notifying engineers of problems. The main thing when designing a monitoring system is to take into account the possibility of the lack of Internet and not to forget about the duplicate system, answering the eternal question “ Quis custodiet ipsos custodes? ". And, of course, it is not necessary to turn the monitoring server into a spammer, otherwise notifications will become meaningless.
If you use some other way of notification - we are waiting for it in the comments.
Source: https://habr.com/ru/post/353652/
All Articles