Zabbix Monitoring — คู่มือติดตั้ง Zabbix 7.x
Zabbix vs Prometheus+Grafana

ผมใช้ทั้ง Zabbix และ Prometheus+Grafana ในงานจริงทั้งคู่มีจุดเด่นต่างกัน Zabbix เป็น all-in-one monitoring platform ที่มี data collection, alerting, visualization ในตัวเดียวเหมาะสำหรับ traditional infrastructure monitoring (servers, network devices, SNMP) Prometheus+Grafana เหมาะสำหรับ cloud-native, containers, microservices
สำหรับองค์กรที่มี mixed environment ทั้ง physical servers, VMs, network switches, routers ผมแนะนำ Zabbix เพราะ SNMP support ดีกว่ามาก auto-discovery ทำงานได้ดีกับ traditional infrastructure และ agent-based monitoring ละเอียดกว่า
ติดตั้งด้วย Docker Compose
# docker-compose.yml — Zabbix 7.x Production
services:
zabbix-db:
image: postgres:16-alpine
environment:
POSTGRES_DB: zabbix
POSTGRES_USER: zabbix
POSTGRES_PASSWORD: ZabbixDbPass2026!
volumes:
- zabbix-db-data:/var/lib/postgresql/data
restart: unless-stopped
zabbix-server:
image: zabbix/zabbix-server-pgsql:7.0-alpine-latest
environment:
DB_SERVER_HOST: zabbix-db
POSTGRES_USER: zabbix
POSTGRES_PASSWORD: ZabbixDbPass2026!
ZBX_CACHESIZE: 256M
ZBX_HISTORYCACHESIZE: 64M
ZBX_TRENDCACHESIZE: 32M
ZBX_VALUECACHESIZE: 128M
ZBX_STARTPOLLERS: 20
ZBX_STARTPOLLERSUNREACHABLE: 5
ports:
- "10051:10051"
volumes:
- zabbix-alertscripts:/usr/lib/zabbix/alertscripts
- zabbix-externalscripts:/usr/lib/zabbix/externalscripts
depends_on:
- zabbix-db
restart: unless-stopped
zabbix-web:
image: zabbix/zabbix-web-nginx-pgsql:7.0-alpine-latest
environment:
ZBX_SERVER_HOST: zabbix-server
DB_SERVER_HOST: zabbix-db
POSTGRES_USER: zabbix
POSTGRES_PASSWORD: ZabbixDbPass2026!
PHP_TZ: Asia/Bangkok
ports:
- "8080:8080"
- "8443:8443"
depends_on:
- zabbix-server
- zabbix-db
restart: unless-stopped
volumes:
zabbix-db-data:
zabbix-alertscripts:
zabbix-externalscripts:
เริ่มต้นใช้งาน
เริ่ม Zabbix stack
docker compose up -d
รอ 1-2 นาที แล้วเข้า Web UI
http://server-ip:8080
Default login: Admin / zabbix
เปลี่ยน password ทันที!
เนื้อหาเกี่ยวข้อง — ทำความเข้าใจ เหรียญ luna classic วันนี้
ดู logs
docker compose logs -f zabbix-server
ติดตั้ง Agent 2
# Ubuntu 24.04
wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest+ubuntu24.04_all.deb
dpkg -i zabbix-release_latest+ubuntu24.04_all.deb
apt update
apt install zabbix-agent2 zabbix-agent2-plugin-*
# ตั้งค่า
# /etc/zabbix/zabbix_agent2.conf
Server=10.10.10.251 # Zabbix Server IP
ServerActive=10.10.10.251 # Active checks
Hostname=web-server-01 # ต้องตรงกับชื่อใน Zabbix
ListenPort=10050
# PluginTimeout สำหรับ plugins
Plugins.Mysql.Sessions.default.Uri=tcp://localhost:3306
Plugins.Mysql.Sessions.default.User=zabbix_monitor
Plugins.Mysql.Sessions.default.Password=MonitorPass123
# เริ่ม agent
systemctl enable --now zabbix-agent2
# ตรวจสอบ
zabbix_agent2 -t system.uptime
zabbix_agent2 -t vfs.fs.size[/, pused]
Firewall Rules
# บน monitored host
ufw allow from 10.10.10.251 to any port 10050
# บน Zabbix Server
ufw allow 10051/tcp
Built-in Templates ที่สำคัญ
# Templates ที่ผมใช้บ่อย:
# - Linux by Zabbix agent → CPU, RAM, Disk, Network
# - MySQL by Zabbix agent 2 → Queries, Connections, Replication
# - Nginx by Zabbix agent 2 → Requests, Connections, Status
# - Docker by Zabbix agent 2 → Container stats
# - Linux filesystems by Zabbix agent → Disk discovery
# - ICMP Ping → Network availability
# เพิ่ม host ผ่าน CLI (Zabbix API)
curl -s -X POST http://zabbix:8080/api_jsonrpc.php \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "host.create",
"params": {
"host": "web-server-01",
"groups": [{"groupid": "2"}],
"interfaces": [{
"type": 1,
"main": 1,
"useip": 1,
"ip": "10.10.10.101",
"dns": "",
"port": "10050"
}],
"templates": [{"templateid": "10001"}]
},
"auth": "YOUR_API_TOKEN",
"id": 1
}'
Network Discovery
Configuration > Discovery > Create discovery rule
แนะนำเพิ่มเติม — iCafeForex
Name: LAN Discovery
IP range: 10.10.10.1-254
Update interval: 1h
Checks:
- Zabbix agent "system.uname" (port 10050)
- SNMP v2 "sysName" (port 161)
- ICMP ping
Discovery actions:
- Add host
- Add to group "Discovered hosts"
- Link template "Linux by Zabbix agent"
สร้าง Triggers
# ตัวอย่าง trigger expressions
# CPU สูงกว่า 90% นานกว่า 5 นาที
avg(/web-server-01/system.cpu.util,5m)>90
# RAM ใช้มากกว่า 90%
vm.memory.utilization[web-server-01]>90
# Disk เหลือน้อยกว่า 10%
last(/web-server-01/vfs.fs.size[/, pfree])<10
# Service ไม่ทำงาน
last(/web-server-01/net.tcp.service[http,,80])=0
# No data จาก agent มากกว่า 5 นาที
nodata(/web-server-01/agent.ping,5m)=1
Alert via LINE Notify
#!/bin/bash
# /usr/lib/zabbix/alertscripts/line-notify.sh
TOKEN="$1"
SUBJECT="$2"
MESSAGE="$3"
curl -s -X POST https://notify-api.line.me/api/notify \
-H "Authorization: Bearer " \
-d "message=
"
# ตั้งค่าใน Zabbix:
# Administration > Media types > Create
# Name: LINE Notify
# Type: Script
# Script name: line-notify.sh
# Parameters: {ALERT.SENDTO}, {ALERT.SUBJECT}, {ALERT.MESSAGE}
Monitor Switches และ Routers

ตั้งค่า SNMP v3 บน switch (ตัวอย่าง Cisco)
เนื้อหาเกี่ยวข้อง — ทำความเข้าใจ แพทเทลกราฟ — คู่มือฉบับสมบูรณ์ 2026
snmp-server group MONITOR v3 priv
snmp-server user zabbix MONITOR v3 auth sha AuthPass123 priv aes 128 PrivPass123
เพิ่ม host ใน Zabbix:
SNMP interface:
IP: 10.10.10.1
Port: 161
SNMP version: SNMPv3
แนะนำเพิ่มเติม — อ่านเพิ่มเติมที่ SiamCafeBook
Security name: zabbix
Security level: authPriv
เนื้อหาเกี่ยวข้อง — ดูเพิ่มเติมเรื่อง kanban agile คือ
Authentication protocol: SHA
Authentication passphrase: AuthPass123
Privacy protocol: AES128
Privacy passphrase: PrivPass123
Templates สำหรับ network devices:
- Cisco IOS by SNMP
- Generic by SNMP (interfaces, CPU, memory)
- HP/Aruba by SNMP
ใช้ API จาก Python
#!/usr/bin/env python3
"""zabbix_report.py — สร้าง report จาก Zabbix API"""
import requests
import json
ZABBIX_URL = "http://zabbix.example.com:8080/api_jsonrpc.php"
API_TOKEN = "YOUR_API_TOKEN"
def zabbix_api(method: str, params: dict) -> dict:
payload = {
"jsonrpc": "2.0",
"method": method,
"params": params,
"auth": API_TOKEN,
"id": 1
}
resp = requests.post(ZABBIX_URL, json=payload)
return resp.json().get("result", [])
# ดู hosts ที่มี problems
problems = zabbix_api("problem.get", {
"output": ["eventid", "name", "severity"],
"recent": True,
"sortfield": "eventid",
"sortorder": "DESC",
"limit": 20
})
for p in problems:
severity = ["Not classified","Info","Warning","Average","High","Disaster"][int(p["severity"])]
print(f"[{severity}] {p['name']}")
# ดู hosts ทั้งหมด
hosts = zabbix_api("host.get", {
"output": ["hostid", "host", "status"],
"selectInterfaces": ["ip"]
})
for h in hosts:
ip = h["interfaces"][0]["ip"] if h["interfaces"] else "N/A"
status = "Enabled" if h["status"] == "0" else "Disabled"
print(f"{h['host']} ({ip}) - {status}")
การนำความรู้ไปประยุกต์ใช้งานจริง
แหล่งเรียนรู้ที่แนะนำ ได้แก่ Official Documentation ที่อัพเดทล่าสุดเสมอ Online Course จาก Coursera Udemy edX ช่อง YouTube คุณภาพทั้งไทยและอังกฤษ และ Community อย่าง Discord Reddit Stack Overflow ที่ช่วยแลกเปลี่ยนประสบการณ์กับนักพัฒนาทั่วโลก
เปรียบเทียบข้อดีและข้อเสีย
จากตารางเปรียบเทียบจะเห็นว่าข้อดีมีมากกว่าข้อเสียอย่างชัดเจน โดยเฉพาะในแง่ของประสิทธิภาพและความสามารถในการ Scale สำหรับข้อเสียส่วนใหญ่สามารถแก้ไขได้ด้วยการเรียนรู้อย่างเป็นระบบและวางแผนทรัพยากรให้เหมาะสม
Zabbix monitor ได้กี่ hosts?
Zabbix รองรับหลายหมื่น hosts บน hardware ที่เหมาะสม Server เดียวกับ 4 cores, 16GB RAM, SSD สามารถ monitor 500-1,000 hosts ได้สบายสำหรับ 5,000+ hosts ต้องใช้ Zabbix Proxy กระจายโหลดผมเคยรัน Zabbix monitor 3,000+ hosts ด้วย server specs 16 cores, 64GB RAM, NVMe
เนื้อหาเกี่ยวข้อง — อ่านต่อ: swift code krungsri bank
Zabbix กับ Nagios อันไหนดีกว่า?
Zabbix ดีกว่า Nagios ในเกือบทุกด้านในปี 2026 Web UI ดีกว่ามาก, auto-discovery ดีกว่า, template system ดีกว่า, SNMP support ดีกว่า Nagios ยังมีข้อดีคือ ecosystem ของ plugins เยอะมากแต่ Zabbix มี built-in features ที่ครอบคลุมโดยไม่ต้องพึ่ง plugins
ใช้ Zabbix กับ Grafana ด้วยกันได้ไหม?
ได้ครับ Grafana มี Zabbix data source plugin ทำให้ดึง data จาก Zabbix มาสร้าง dashboards ที่สวยกว่า Zabbix built-in dashboards ได้ผมใช้ Zabbix เป็น data collection + alerting engine และ Grafana สำหรับ visualization
Database ควรใช้ MySQL หรือ PostgreSQL?
Zabbix 7.x รองรับทั้งคู่แต่ PostgreSQL มี performance ดีกว่าสำหรับ large installations โดยเฉพาะ partitioning และ compression ที่ Zabbix ใช้ประโยชน์ได้เต็มที่สำหรับ MySQL ก็ใช้ได้ดีถ้า tune InnoDB buffer pool ให้เหมาะสม
สรุป
Zabbix 7.x เป็น enterprise monitoring platform ที่สมบูรณ์ที่สุดในโลก open-source รองรับ agent-based, SNMP, IPMI, JMX, HTTP monitoring มี auto-discovery, templates, triggers, alerting ครบทุกอย่างฟรีไม่มีค่า license
สำหรับองค์กรที่ต้องการ monitor servers, network devices, applications ทั้งหมดจากจุดเดียว Zabbix เป็นตัวเลือกที่ดีที่สุดเริ่มจากติดตั้ง Docker Compose ตามบทความนี้ติดตั้ง agents บน hosts แล้ว link templates ก็เริ่มใช้งานได้ทันทีครับ
อ่านเพิ่มเติม: สอนเทรด Forex | XM Signal | IT Hardware | อาชีพ IT | SiamCafe Book | iCafe Cloud





