Zabbix ile Profesyonel IT Monitoring Sistemi Kurulumu
zafer ak
Yazar
Zabbix, kurumsal düzeyde açık kaynak bir monitoring çözümüdür. Sunucular, ağ cihazları, uygulamalar ve hizmetleri izlemek için kullanılır.
Zabbix Özellikleri
- Esneklik: Agent, SNMP, IPMI, JMX desteği
- Ölçeklenebilirlik: Binlerce host izleme
- Auto-discovery: Otomatik cihaz keşfi
- Template sistemi: Yeniden kullanılabilir yapılandırma
- Alerting: Email, SMS, Slack, webhook
- API: Otomasyon imkanı
Zabbix Server Kurulumu
# Repository ekleme
wget https://repo.zabbix.com/zabbix/6.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
sudo dpkg -i zabbix-release_6.4-1+ubuntu22.04_all.deb
sudo apt update
# Kurulum
sudo apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
# MySQL veritabanı
mysql -u root -p
CREATE DATABASE zabbix CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'zabbix'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost';
quit;
# Schema import
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql -u zabbix -p zabbix
Server Yapılandırması
# /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=password
# Cache ayarları
CacheSize=128M
HistoryCacheSize=64M
TrendCacheSize=16M
# Başlat
sudo systemctl enable zabbix-server zabbix-agent nginx php8.1-fpm
sudo systemctl start zabbix-server zabbix-agent nginx php8.1-fpm
Zabbix Agent Kurulumu
# İzlenecek sunuculara agent kurulumu
sudo apt install zabbix-agent2
# Yapılandırma
sudo nano /etc/zabbix/zabbix_agent2.conf
# /etc/zabbix/zabbix_agent2.conf
Server=192.168.1.100
ServerActive=192.168.1.100
Hostname=web-server-01
# Özel item'lar için
UserParameter=custom.metric,/path/to/script.sh
# Başlat
sudo systemctl enable zabbix-agent2
sudo systemctl start zabbix-agent2
Host Ekleme
- Configuration → Hosts → Create host
- Host name ve Groups belirleyin
- Interfaces → Agent IP ekleyin
- Templates sekmesinden template atayın
- Add ile kaydedin
Yararlı Template'ler
- Linux by Zabbix agent: CPU, RAM, Disk, Network
- Windows by Zabbix agent: Windows metrikleri
- MySQL by Zabbix agent: MySQL izleme
- Nginx by Zabbix agent: Nginx metrikleri
- Docker by Zabbix agent 2: Container izleme
Trigger Oluşturma
# Trigger expression örnekleri
# CPU %90 üstünde 5 dakika
avg(/Linux by Zabbix agent/system.cpu.util,5m)>90
# RAM %80 üstünde
last(/Linux by Zabbix agent/vm.memory.util)>80
# Disk %85 üstünde
last(/Linux by Zabbix agent/vfs.fs.size[/,pused])>85
# Host ulaşılamaz
nodata(/Linux by Zabbix agent/agent.ping,5m)=1
Action ve Notification
Configuration → Actions → Trigger actions:
# Email notification
Name: Send alerts to admins
Conditions:
- Trigger severity >= High
Operations:
- Send message to user groups: Administrators
- Send only to: Email
# Message template
Subject: Problem: {TRIGGER.NAME}
Message:
Host: {HOST.NAME}
Problem: {TRIGGER.NAME}
Severity: {TRIGGER.SEVERITY}
Time: {EVENT.TIME}
SNMP ile Ağ İzleme
# Switch/Router için SNMP template
1. Host ekle
2. Interface: SNMP
3. SNMP community: public
4. Template: Template Network Generic Device
veya Template Cisco IOS
Auto Discovery
# Network discovery rule
Configuration → Discovery → Create discovery rule
Name: LAN Discovery
IP range: 192.168.1.1-254
Checks:
- Zabbix agent "system.uname"
- SNMP v2c
Actions:
- Add host
- Add to host group
- Link template
API Kullanımı
# Python ile Zabbix API
from pyzabbix import ZabbixAPI
zapi = ZabbixAPI("http://zabbix.example.com")
zapi.login("Admin", "password")
# Host listesi
hosts = zapi.host.get(output=["hostid", "name"])
for host in hosts:
print(host["name"])
# Problem listesi
problems = zapi.problem.get(output="extend")
for problem in problems:
print(problem["name"])
Sonuç
Zabbix, kurumsal IT altyapısı için kapsamlı bir monitoring çözümüdür. Doğru yapılandırma ile tüm sistemlerinizi proaktif olarak izleyebilir ve sorunları erkenden tespit edebilirsiniz.