Zabbix UI based on Telegram bot
This telegram bot provides some basic information from Zabbix:
- hosts search
- items and latest data
- graphs based on latest data
- recent problems
This bot can replace Zabbix web frontend in cases when you want to see some info quickly on your smartphone, no need to open desktop browser.
Some GIF animated demonstration here: https://gifyu.com/image/EQdk
PhpZabbixApi library communicates with Zabbix API.
Graphs are retrieved from Zabbix using wget with some URL (emulating user entering web interface) as Zabbix API does not provide ability of getting latest data based graphs.
php-telegram-bot library communicates with Telegram API.
- bot itself needs:
- PHP (tested on 5.6.40)
- php-mbstring
- wget
- Zabbix Server (tested on 3.4.3 and 4.2.0) with access to API URL from where your bot is hosted
-
Create your telegram bot with BotFather, setup a webhook URL to your server:
https://your-bot.example.com/bot.php
-
Unpack files to your server
-
Install Composer and project dependencies:
php composer.phar require
-
Replace some files with ones in
custom
folder:CallbackqueryCommand.php
=>vendor/longman/telegram-bot/src/Commands/SystemCommands/CallbackqueryCommand.php
ZabbixApi.class.php
=>vendor/confirm-it-solutions/php-zabbix-api/build/ZabbixApi.class.php
ZabbixApiAbstract.class.php
=>vendor/confirm-it-solutions/php-zabbix-api/build/ZabbixApiAbstract.class.php
-
Adjust
settings.php
to your environment:- Zabbix URL, user and password
- bot token and name
- IDs of Telegram users who are allowed to use bot. You can get Telegram ID easily by sending
/whoami
command to the bot.
-
For making graphs, you may need to adjust
$zabbix_graph_url_template
insettings.php
according to your Zabbix version. Graph URLs for 3.4.3 and 4.2.0 versions are already tested.
- To search, type
/search <something>
and you will get hosts having<something>
in visible names. Then use inline buttons to get items, latest data and graphs. - To get list of recent problems, use
/problems
command. - See
settings.php
to adjust bot's behavior.
- Impersonation (telegram users <=> Zabbix users with privileges respected)
- Show host group and some host macros
- Code redesign to support callback query commands more accurately