Master Zabbix: From Installation to Advanced Monitoring and Alerting
This comprehensive guide explains why monitoring is essential, describes reliability metrics, walks through Zabbix installation, web UI configuration, custom monitoring, trigger creation, alert integration, distributed monitoring, SNMP support, and large‑scale server monitoring using scripts, APIs, and auto‑discovery.
1. Monitoring Overview
1.1 Why Monitor
Monitoring alerts you when a server encounters problems, helps you locate the root cause, and ensures website/server availability.
1.1.1 Website Availability
High Availability (HA) is measured by the number of nines (e.g., 3‑5 nines) representing the percentage of uptime over a year. The table below shows the maximum downtime for each level:
1 nine (90%): 36.5 days per year 2 nines (99%): 3.65 days per year 3 nines (99.9%): 8.76 hours per year 4 nines (99.99%): 52.6 minutes per year 5 nines (99.999%): 5.26 minutes per year 6 nines (99.9999%): 31 seconds per year
1.2 What to Monitor
Monitor anything that can be queried via commands, including hardware, services, and remote management cards (e.g., Dell iDRAC, HP iLO, IBM IMM).
2. Installing Zabbix
2.1 Environment Check
Ensure the target system meets the prerequisites (see image).
2.2.1 Installation Methods
Compile from source (complex, many services)
YUM installation (clean environment)
Use a YUM repository (e.g.,
http://www.cnblogs.com/clsn/p/7866643.html)
2.2.2 Quick Server Installation Script
(Images show the script execution.)
2.2.3 Quick Agent Deployment Script
(Images show the script execution.)
2.3 Connectivity Test
2.3.1 Install zabbix-get on the server
yum install zabbix-get(Image of successful installation.)
3. Web Interface Operations
3.1 Zabbix Web Installation
3.1.1 Access via Browser
Navigate to
http://10.0.0.61/zabbix/setup.phpand follow the wizard. Select MySQL, enter the password, and keep the default host and port values.
(Screenshots of each step are provided.)
3.2 Adding Monitoring Information
3.2.1 Modify Zabbix Server Host
Configuration → Hosts → Edit. Set the host name to match the actual hostname; the visible name is for display in the UI.
3.2.2 Add a New Host
Configuration → Hosts → Create Host. Enable the host and associate the Template OS Linux template.
3.2.3 View Monitoring Items
Monitoring → Latest Data → filter by IP or name to see all items.
3.2.4 View Graphs
Monitoring → Graphs → select the host to view collected metrics.
4. Custom Monitoring and Alerting
4.1 Custom Monitoring
The built‑in template Template OS Linux (Template App Zabbix Agent) provides CPU, memory, disk, and network monitoring. Example requirement: trigger an alarm when more than three users are logged in.
4.2 Implementing Custom Monitoring
4.2.1 Custom Syntax
(Image showing the syntax editor.)
4.2.2 Agent Registration
(Image of the registration process.)
4.2.3 Server‑Side Registration (Web UI)
Configuration → Templates → Create Template → add an application set, create a monitoring item (e.g.,
login-user), define a trigger expression, and create a graph.
4.2.4 View Graphs
(Image of the custom graph.)
4.3 Alerting
4.3.1 Third‑Party Alert Platform
OneAlert (
http://www.onealert.com) provides SMS, WeChat, QQ, and phone notifications with scheduling and escalation.
4.3.2 OneAlert Configuration
Add an application named zabbix and configure WeChat alerts.
4.3.3 Install OneAlert Agent
(Image of the installation steps.)
4.3.4 Delete OneAlert Agent
Remove the script from media types, delete the user, user group, and actions associated with the agent.
4.3.5 Trigger Response
When a trigger changes state, Zabbix sends alerts via email and WeChat.
Note: Emails are sent only when the status changes (OK→PROBLEM or PROBLEM→OK).
4.4 Monitoring Visualization
4.4.1 Aggregated Graphs
Use Latest Data → Graphs to create combined graphs with custom names.
4.4.2 Slideshows
Monitoring → Composite Graph → Slideshows to create auto‑playing presentations.
4.5 Template Sharing
Export hosts from the host page, then import them on another Zabbix instance. Shared templates are available at
https://github.com/zhangyao8/zabbix-community-repos.
5. Full‑Network Server Monitoring
5.1 Requirements
Monitor 100 existing servers, covering CPU, memory, disk, and network interfaces.
5.2 Planning
Clone existing hosts
Use auto‑registration and auto‑discovery
Call Zabbix API via curl or Python
5.3 Specific Implementation
5.3.1 Hardware, System, Network Monitoring
Monitor all virtual machines, switches, routers (via port traffic or SNMP), and use SNMP for network devices.
5.3.2 Application Service Monitoring
Backup servers: monitor rsync port 873 or simulate file transfer.
NFS servers: monitor RPC port 111 or
showmount -e.
MySQL servers: monitor port 3306, use built‑in MySQL template or custom keys.
Web servers: monitor port 80, HTTP status codes, or use Zabbix web checks.
Reverse proxy (e.g., Nginx, PPTP) and NTP (UDP 123).
Nginx connection states via custom keys.
5.3.3 Generic Monitoring Methods
Port monitoring:
netstat | wc -lProcess monitoring:
ps -ef | grep <process> | wc -lSimulated client usage:
curlfor HTTP,
select/insertfor MySQL,
set/getfor Memcached.
5.4 Full‑Network Deployment
5.4.1 Auto‑Discovery Rules
Create auto‑discovery rules and associated actions to automatically add discovered hosts.
5.4.2 Monitoring Backup Servers
Use
net.tcp.listen[port]keys and create a template.
5.4.3 Monitoring NFS Servers
Use
proc.num[,, ,]to count NFS processes.
5.4.4 Monitoring MySQL Servers
Add MySQL credentials to the built‑in MySQL key, then monitor port 3306.
[root@m01 ~]# zabbix_get -s 172.16.1.51 -p 10050 -k "net.tcp.port[,3306]"
# Returns 1 if the TCP connection can be established, 0 otherwise5.4.5 Monitoring Web Servers
Use
proc.num[,, ,nginx]and
net.tcp.port[,80]keys.
5.4.6 Monitoring URLs
Create a simple HTML page (e.g.,
echo ok >> /application/nginx/html/www/check.html) and use Zabbix web checks.
5.4.7 Monitoring Reverse Proxy Servers
Create a custom user parameter (e.g.,
UserParameter=keep-ip,ip a | grep 10.0.0.3 | wc -l) and test with
zabbix_get.
5.4.8 Monitoring Nginx Connection States
Add the following user parameters to
/etc/zabbix/zabbix_agentd.d/userparameter_nginx_status.conf:
UserParameter=nginx_active,curl -s 127.0.0.1/status | awk '/Active/ {print $NF}'
UserParameter=nginx_accepts,curl -s 127.0.0.1/status | awk 'NR==3 {print $1}'
UserParameter=nginx_handled,curl -s 127.0.0.1/status | awk 'NR==3 {print $2}'
UserParameter=nginx_requests,curl -s 127.0.0.1/status | awk 'NR==3 {print $3}'
UserParameter=nginx_reading,curl -s 127.0.0.1/status | awk 'NR==4 {print $2}'
UserParameter=nginx_writing,curl -s 127.0.0.1/status | awk 'NR==4 {print $4}'
UserParameter=nginx_waiting,curl -s 127.0.0.1/status | awk 'NR==4 {print $6}'Test with
zabbix_get -s <host> -p 10050 -k "nginx_waiting".
6. Auto‑Discovery and Auto‑Registration
6.1 Overview
Auto‑discovery lets the Zabbix server actively scan the network and register hosts, while auto‑registration lets agents push their information to the server.
6.2 Passive Auto‑Discovery
Configure discovery rules in the web UI (Configuration → Auto‑Discovery → Local network), set IP ranges, delays, and actions to add and enable discovered hosts.
7. Distributed Monitoring and SNMP
7.1 Distributed Monitoring
Deploy Zabbix proxies to offload the server. Example topology: Zabbix Server → Proxy → Agents in one data center; another Proxy → Agents in a second data center.
7.1.2 Configuring a Zabbix Proxy
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
yum install zabbix-proxy-mysql -y
yum -y install mariadb-server
systemctl start mariadb.service
mysql -e "create database zabbix_proxy character set utf8 collate utf8_bin;"
mysql -e "grant all privileges on zabbix_proxy.* to zabbix@'localhost' identified by 'zabbix';"
zcat /usr/share/doc/zabbix-proxy-mysql-3.0.13/schema.sql.gz | mysql -uzabbix -pzabbix zabbix_proxy
sed -i '162a DBPassword=zabbix' /etc/zabbix/zabbix_proxy.conf
sed -i 's#Server=127.0.0.1#Server=172.16.1.61#' /etc/zabbix/zabbix_proxy.conf
sed -i 's#Hostname=Zabbix proxy#Hostname=cache01#' /etc/zabbix/zabbix_proxy.conf
systemctl restart zabbix-proxy.serviceUpdate agents to point to the proxy (modify
Serverand
ServerActivein
/etc/zabbix/zabbix_agentd.conf).
7.2 SNMP Monitoring
7.2.1 Install SNMP Tools
yum -y install net-snmp net-snmp-utils7.2.2 Configure SNMP
sed -i '57a view systemview included .1' /etc/snmp/snmpd.conf
systemctl start snmpd.service7.2.3 Test SNMP
snmpwalk -v 2c -c public 127.0.0.1 sysName
# Expected output: SNMPv2-MIB::sysName.0 = STRING: m017.2.4 Add SNMP Host in Zabbix UI
Create a new host, select an SNMP template, and provide the SNMP community string. The host will appear with SNMP‑collected items.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.