Install zabbix latest version with Telegram Notifications

Install Zabbix Server & FrontEnd Zabbix

Install repo:

# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm

Install package untuk zabbix server dan zabbix frontend based on PostgreSQL database:

# yum install postgresql-server zabbix-server-pgsql zabbix-agent epel-release zabbix-web-pgsql zabbix-nginx-conf

Setup DB PostgreSQL:

# postgresql-setup initdb

Start postgresql service:

# systemctl start postgresql && systemctl enable postgresql

setting trust user:

# vi /var/lib/pgsql/data/pg_hba.conf
host all all 127.0.0.1/32 md5
host all all ::1/128 md5

create user postgresql untuk zabbix:

$ sudo -u postgres createuser --pwprompt zabbix
$ sudo -u postgres createdb -O zabbix zabbix

Import data zabbix:

$ zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix

setting database:

# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=<password>

restart services

# systemctl restart zabbix-server zabbix-agent nginx php-fpm postgresql

enable startup services:

# systemctl enable zabbix-server zabbix-agent nginx php-fpm

akses frontend zabbix ke localhost/zabbix atau url yg relevan disesuaikan dg kondisi jaringan.

Menambahkan Host Monitoring

Install zabbix agent di server yg akan dimonitor.

Install repo dan agent:

# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
# yum install zabbix zabbix-agent

setting zabbix_agentd.conf

#Server=[zabbix server ip]
#Hostname=[ Hostname of client system ]

Server=192.168.1.100
Hostname=Server1

start services:

service zabbix-agent restart

lalu bisa menambahkan host, template, trigger, item, dll:

image

beberapa template yang bisa dipakai untuk monitoring:

image

Install Telegram Notifications:

Unduh file

# wget -c "https://git.cdp.li/polcape/zabbix/-/raw/master/telegram-notify/zabbix-telegram.sh"

edit file zabbix-telegram.sh

sesuaikan variable dibawah ini:

ZBX_URL with the Zabbix address or URL
USERNAME and PASSWORD for access to Zabbix GUI (this user must have the permission to see the graph)
BOT_TOKEN with the TokenID obtained from BotFather
SEND_GRAPH and SEND_MESSAGE flag to enable the two features
ZABBIXVERSION34 if the version of Zabbix is >= 3.4.1
WIDTH to increase the width of graph image
PERIOD to set the seconds to see in the graph

simple test via cli:

./zabbix-telegram.sh id_user_telegram "OK Disaster Subject" "Message Item Graphic: [10490]"

Tambahkan Media Types:

image

save dan test untuk memastikan script bisa jalan.

Tambahkan akses ke user yg dipakai di variable zabbix-telegram.sh diatas:

image

Create Action untuk mengirimkan alert:

image

jangan lupa save dan test terlebih dahulu:

Alert di zabbix:

image

Alert di Telegram:

image

Pros:

  • Konfigurasi lebih mudah melalui web frontend.
  • Dokumentasi lengkap
  • Bisa Active check, Passive check baik lewat agent atau snmpd.
  • Integrasi banyak yg disupport

Cons: - beberapa template, rule alert, atau trigger agak rumit. perlu ketelitian. - tidak bisa one setup langsung selesai bisa dimonitoring, tetapi mesti disetting satu persatu untuk services, dll.

Ref: