问题描述
在 Graph 中,无法显示中文字体(字体变成“方块”或者完全不显示),如下图所示:
问题原因
这并不是“乱码”,而是字体缺失。在 Zabbix 中,使用图片呈现图表数据,而在图片上渲染字体时需要找到对应的字体文件。如果没有正确配置字体(字体不支持中文或者无法找到字体),则无法在图片中渲染字体,此时将显示方块或这完全空白。
解决方案
在代码中搜索 ttf 关键字,然后逐步追查到字体加载路径。
Debian and Zabbix ???
#!/bin/sh
# 安装包含中文字体的字体
apt-get install fonts-wqy-microhei
# update alternative zabbix-frontend-font
update-alternatives –install /usr/share/zabbix/fonts/graphfont.ttf \
zabbix-frontend-font /usr/share/fonts/truetype/wqy/wqy-microhei.ttc 10
# 配置使用wqy-microhei.ttc字体
update-alternatives –config zabbix-frontend-font
CentOS and Zabbix
适用于 CentOS 6.9、CentOS 7.x 发行版:
#!/bin/sh
# 你也可以使用自己喜欢的字体,随便吧,要有中文字体
yum install -y wqy-microhei-fonts.noarch
# CentOS release 6.9 (Final) and Zabbix 4.2
update-alternatives –install /usr/share/zabbix/assets/fonts/graphfont.ttf \
zabbix-web-font /usr/share/fonts/wqy-microhei/wqy-microhei.ttc 10
# CentOS Linux release 7.5.1804 (Core) and Zabbix 4.0.1
update-alternatives –install /usr/share/zabbix/assets/fonts/graphfont.ttf \
zabbix-web-font /usr/share/fonts/wqy-microhei/wqy-microhei.ttc 10
# 配置选择字体
update-alternatives –config zabbix-web-font
附件说明
实际上操作了这一波就是修改了 /u[……]
READ MORE