📜 ⬆️ ⬇️

Zabbix and free SMS

When the Google Calendar had the opportunity to receive free SMS notifications, I think all the developers thought that this could be screwed to their scripts. Many have not found the time and effort to do this, so I provide a PHP script for sending free SMS to myself, and for greater advantage I will screw it to the Zabbix monitoring system. I hope after these words, all system administrators have thought about how great it will be to receive SMS when a server drops out of the network, someone steps on the network wire, the router reboots or the temperature in the server room rises.

Zabbix version

This version is intended for SMS notification when an event occurs by triggering. Zabbix allows you to customize filtering by importance (for example, it will not send informational events).
1.Google Account Setup
  1. Go to Calendar > Settings> Settings for mobile devices.
  2. Specify your phone number, confirm by receiving a test SMS.
2. Install and configure the script
  1. Connect to Zabbix server via SSH or WinSCP.
  2. Locate the alertscripts folder from the possible options:
    • / usr / local / share / zabbix / alertscripts
    • / etc / zabbix / alertscripts
    • / home / zabbix / bin /
  3. Unpacking http://mamaev.pro/zabbix/fsms_zabbix.zip [~ 6 MB] in the alertscripts folder.
  4. I recommend putting the group and the “zabbix” ovner and rights 0755 on all the contents.
  5. In the file zabbix_fsms.php indicate:
    • time zone
    • place (optional)
    • phone number
    • username and password from Gmail.com
    Please note that for each recipient you need to create your own case with parameters.
  6. To check, you can execute the script console:
    / usr / local / share / zabbix / alertscripts / zabbix_fsms 795112345678 Console Test Ok
    Where 795112345678 is your phone number, and / usr / local / share / zabbix / alertscripts / is the path you found in the second step to alertscripts. As a result, SMS should come.
3. Configure Zabbix
  1. In Zabbix, go to Administration> Media types> Create media type.
  2. Specify
    options click Save.
  3. Go to Profile> Media> Add.
  4. Specify Type: FSMS; SendTo: your mobile number; When active and Use if severity to taste.
  5. Setup complete! To test, you can turn off a pair of routers to create a trigger that will work in a minute, for example, "{hostname: agent.ping.nodata (1m)} = 0".

Version for Web Developers

Difference from Zabbix version: used as a regular script, not a console, the code is combed for developers. http://mamaev.pro/zabbix/fsms_webdev.zip [5.8 MB]
The script is developed using the Zend Framework.
Attention, this is my first article, I accept all comments with pleasure.
UPD: The user br0ziliy uses Python to implement free SMS via Google Calendar, we look at SMS notifications from Nagios with little blood .

')

Source: https://habr.com/ru/post/146509/


All Articles