zabbix custom graphics
1. How to check zabbix graphics
Monitor—Graph—Find the host to see the graph—Select the graph to view—Apply
2. Solve the problem of garbled Chinese characters in zabbix graphics
这是由于zabbix默认的字体版本太老,不支持中文显示导致的,我们只需要将Windows主机上的字体复制一份到zabbix字体目录即可解决此问题
2.1. Prepare Microsoft Yahei fonts and upload them to the server
Windows微软雅黑字体目录位于C:\Windows\Fonts
复制微软雅黑至桌面,然后上传至zabbix服务器
微软雅黑字体文件名叫做msyh.ttc
上传至zabbix服务器
[root@zabbix-server ~]# rz -E
[root@zabbix-server ~]# mv msyh.ttc /usr/share/zabbix/assets/fonts/graphfont.ttf
mv:是否覆盖"/usr/share/zabbix/assets/fonts/graphfont.ttf"? y
2.2. Refresh the page to view the graphics
Garbled problem has been resolved
3. Customize sda disk usage graph
3.1. Create custom monitoring items
Create custom monitoring items, monitor sda disk usage
1.编写获取最新sda磁盘使用率监控至的脚本
[root@192_168_81_220 ~]# mkdir /etc/zabbix/scripts
[root@192_168_81_220 ~]# cd /etc/zabbix/scripts
[root@192_168_81_220 scripts]# vim sda_used.sh
#!/bin/bash
#此脚本用来监控sda /目录磁盘的使用率
disk_used=`df -hT | grep '/$' | awk '{print $(NF-1)}' | awk -F '%' '{print $1}'`
echo $disk_used
2.在配置文件中增减监控项
[root@192_168_81_220 ~]# vim /etc/zabbix/zabbix_agentd.d/user_monitor.conf
UserParameter=sda_used,sh /etc/zabbix/scripts/sda_used.sh
3.重启zabbix-agent
[root@192_168_81_220 ~]# systemctl restart zabbix-agent
3.2. Create monitoring items on the page
Configuration-host-monitoring item-create monitoring item
Name: sda disk usage
Key value: sda_used
Unit:% (The unit must be written here, because the script gets only a value)
Application Set: Disk Monitoring
3.3. Page creation trigger
Configuration—Host—Trigger—Create Trigger
Name: sda disk usage rate exceeds 80%
Severity: severe
Expression: {192.168.81.220:sda_used.last()}>=80
3.4. View the latest data of monitoring items
Click Monitoring—Latest Data—Select Machine—Filter Monitoring Items—Apply
Here you can see how important it is to fill in the unit when you just created the monitoring item.
3.5. Create custom graphics on the page
Configuration-host-graphics-create graphics
3.6. Graphic category explanation
Graphic type: normal (line chart), generally select normal
Stacked (Histogram)
Pie (Fan Chart)
3.7. Fill in custom graphic information
Graphic name: sda disk usage
Graphic category: Normal
Monitoring item: add the monitoring item just created
3.8. View graphics
Click Monitoring—Graph—Select Machine—Select the graph just created—Apply
It can be seen that the average value is 11%