Ubuntu系统配置Zabbix前端及中文乱码解决方案
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.安装zabbix
博主推荐阅读: https://www.cnblogs.com/yinzhengjie2020/p/12302137.html https://www.cnblogs.com/yinzhengjie2020/p/12305427.html
二.配置zabbix前端(参考连接:https://www.zabbix.com/documentation/4.0/manual/installation/install#installing_frontend)
1>.访问zabbix的前端地址(http://zabix201.yinzhengjie.org.cn/zabbix/setup.php)进入欢迎界面
2>.如下图所示,下拉进度条进行条件检查,如果所有的参数都是"OK",则可以进入下一步啦
3>.配置zabbix前端的数据库信息
4>.配置zabbix server信息
5>.将之前的配置review一下,做最后的确认若没有问题的话继续下一步
6>.安装完成后,回自动将前端的配置信息存放在zabbix 服务器上,如下图所示。

[root@yinzhengjie.org.cn ~]# cat /usr/share/zabbix/conf/zabbix.conf.php <?php // Zabbix GUI configuration file. global $DB; $DB['TYPE'] = 'MYSQL'; $DB['SERVER'] = '172.200.5.201'; $DB['PORT'] = '3306'; $DB['DATABASE'] = 'zabbix'; $DB['USER'] = 'zabbix'; $DB['PASSWORD'] = 'yinzhengjie'; // Schema name. Used for IBM DB2 and PostgreSQL. $DB['SCHEMA'] = ''; $ZBX_SERVER = '172.200.5.201'; $ZBX_SERVER_PORT = '10051'; $ZBX_SERVER_NAME = 'Yinzhengjie\'s Zabbix Server'; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; [root@yinzhengjie.org.cn ~]# [root@yinzhengjie.org.cn ~]#
7>.安装完成后会自动跳转到登录界面
三.登录zabbix数据库
1>.使用默认的用户名(Admin)和密码(yinzhengjie)登录zabbix WebUI
2>.登录成功啦
四.修改Zabbix WebUI管理员的默认密码
1>.如下图所示,登录zabbix WebUI后,点击右上角的小人图标
2>.如下图所示,点击"Change password"
3>.修改管理员用户的密码
五.配置ubuntu支持中文界面
1>.如下图所示,登录zabbix WebUI后,点击右上角的小人图标
2>.查看zabbix支持的语言
3>.Ubuntu系统安装中文语言相关软件包

[root@yinzhengjie.org.cn ~]# apt-get -y install language-pack-zh* Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'language-pack-zh-hant-base' for glob 'language-pack-zh*' Note, selecting 'language-pack-zh-hans-base' for glob 'language-pack-zh*' Note, selecting 'language-pack-zh' for glob 'language-pack-zh*' Note, selecting 'language-pack-zh-base' for glob 'language-pack-zh*' Note, selecting 'language-pack-zh-hans' for glob 'language-pack-zh*' Note, selecting 'language-pack-zh-hant' for glob 'language-pack-zh*' The following NEW packages will be installed: language-pack-zh-hans language-pack-zh-hans-base language-pack-zh-hant language-pack-zh-hant-base 0 upgraded, 4 newly installed, 0 to remove and 136 not upgraded. Need to get 4,810 kB of archives. After this operation, 20.1 MB of additional disk space will be used. Get:1 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 language-pack-zh-hans-base all 1:18.04+20180712 [1,692 kB] Get:2 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 language-pack-zh-hans all 1:18.04+20200123 [1,119 kB] Get:3 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 language-pack-zh-hant-base all 1:18.04+20180712 [1,221 kB] Get:4 http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 language-pack-zh-hant all 1:18.04+20200123 [778 kB] Fetched 4,810 kB in 1s (4,037 kB/s) Selecting previously unselected package language-pack-zh-hans-base. (Reading database ... 70231 files and directories currently installed.) Preparing to unpack .../language-pack-zh-hans-base_1%3a18.04+20180712_all.deb ... Unpacking language-pack-zh-hans-base (1:18.04+20180712) ... Selecting previously unselected package language-pack-zh-hans. Preparing to unpack .../language-pack-zh-hans_1%3a18.04+20200123_all.deb ... Unpacking language-pack-zh-hans (1:18.04+20200123) ... Replacing files in old package language-pack-zh-hans-base (1:18.04+20180712) ... Selecting previously unselected package language-pack-zh-hant-base. Preparing to unpack .../language-pack-zh-hant-base_1%3a18.04+20180712_all.deb ... Unpacking language-pack-zh-hant-base (1:18.04+20180712) ... Selecting previously unselected package language-pack-zh-hant. Preparing to unpack .../language-pack-zh-hant_1%3a18.04+20200123_all.deb ... Unpacking language-pack-zh-hant (1:18.04+20200123) ... Replacing files in old package language-pack-zh-hant-base (1:18.04+20180712) ... Setting up language-pack-zh-hant (1:18.04+20200123) ... Setting up language-pack-zh-hant-base (1:18.04+20180712) ... Generating locales (this might take a while)... zh_HK.UTF-8... done zh_TW.UTF-8... done Generation complete. Setting up language-pack-zh-hans (1:18.04+20200123) ... Setting up language-pack-zh-hans-base (1:18.04+20180712) ... Generating locales (this might take a while)... zh_CN.UTF-8... done zh_SG.UTF-8... done Generation complete. [root@yinzhengjie.org.cn ~]#
4>.配置环境变量
[root@yinzhengjie.org.cn ~]# cat /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" [root@yinzhengjie.org.cn ~]# [root@yinzhengjie.org.cn ~]# vim /etc/environment [root@yinzhengjie.org.cn ~]# [root@yinzhengjie.org.cn ~]# cat /etc/environment #添加下面2行 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" LANG="ch_CN.UTF-8" LANGUAGE="ch_CN:zh:en_US:en" [root@yinzhengjie.org.cn ~]#
5>.选择编码"zh_CN.UTF-8"
[root@yinzhengjie.org.cn ~]# dpkg-reconfigure locales #会弹出如下图所示的一个界面,选中语言。
上一步配置后,会弹出如下图所示的对话框,继续选择"zh_CN.UTF-8"
7>.重启服务使得配置生效
[root@yinzhengjie.org.cn ~]# systemctl restart zabbix-server zabbix-agent apache2
8>.刷新zabbix WebUI网页
六.解决zabbix中文乱码问题
1>.选择中文语言支持
2>.如下图所示,出现乱码显式啦
3>.将window操作系统的字体上传到zabbix web所在服务器(温馨提示:字体是闭源的,请不要将windows操作系统的字体拿去商业化,否则可能会为你带来不必要的法律责任)

[root@yinzhengjie.org.cn ~]# apt -y install lrzsz Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: minicom The following NEW packages will be installed: lrzsz 0 upgraded, 1 newly installed, 0 to remove and 136 not upgraded. Need to get 74.8 kB of archives. After this operation, 531 kB of additional disk space will be used. Get:1 http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 lrzsz amd64 0.12.21-10~build0.18.04.1 [74.8 kB] Fetched 74.8 kB in 0s (281 kB/s) Selecting previously unselected package lrzsz. (Reading database ... 70740 files and directories currently installed.) Preparing to unpack .../lrzsz_0.12.21-10~build0.18.04.1_amd64.deb ... Unpacking lrzsz (0.12.21-10~build0.18.04.1) ...############...............................................................................................................................................................................................................] Setting up lrzsz (0.12.21-10~build0.18.04.1) ...##############################################################################################............................................................................................................................] Processing triggers for man-db (2.8.3-2ubuntu0.1) ...###########################################################################################################################################################################..........................................] [root@yinzhengjie.org.cn ~]# [root@yinzhengjie.org.cn ~]#
4>.将字体上传到zabbix默认的路径
[root@yinzhengjie.org.cn ~]# find / -name defines.inc.php /usr/share/zabbix/include/defines.inc.php [root@yinzhengjie.org.cn ~]# [root@yinzhengjie.org.cn ~]# grep -i graphfont /usr/share/zabbix/include/defines.inc.php define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name define('ZBX_FONT_NAME', 'graphfont'); [root@yinzhengjie.org.cn ~]# [root@yinzhengjie.org.cn ~]# find /usr/share/zabbix/ -name graphfont* /usr/share/zabbix/assets/fonts/graphfont.ttf [root@yinzhengjie.org.cn ~]# [root@yinzhengjie.org.cn ~]# ll /usr/share/zabbix/assets/fonts/ total 8 drwxr-xr-x 2 root root 4096 Feb 13 14:13 ./ drwxr-xr-x 5 root root 4096 Feb 13 14:12 ../ lrwxrwxrwx 1 root root 38 Feb 13 14:13 graphfont.ttf -> /etc/alternatives/zabbix-frontend-font [root@yinzhengjie.org.cn ~]# [root@yinzhengjie.org.cn ~]# cd /usr/share/zabbix/assets/fonts/ [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# rz [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# ll total 11520 drwxr-xr-x 2 root root 4096 Feb 13 16:27 ./ drwxr-xr-x 5 root root 4096 Feb 13 14:12 ../ lrwxrwxrwx 1 root root 38 Feb 13 14:13 graphfont.ttf -> /etc/alternatives/zabbix-frontend-font -rw-r--r-- 1 root root 11787328 Mar 1 2019 simkai.ttf [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# cp /usr/share/zabbix/include/defines.inc.php /usr/share/zabbix/include/defines.inc.php-`date +%F` [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# sed -r -i 's#graphfont#simkai#' /usr/share/zabbix/include/defines.inc.php [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# [root@yinzhengjie.org.cn /usr/share/zabbix/assets/fonts]# cd [root@yinzhengjie.org.cn ~]# [root@yinzhengjie.org.cn ~]# grep -i simkai /usr/share/zabbix/include/defines.inc.php define('ZBX_GRAPH_FONT_NAME', 'simkai'); // font file name define('ZBX_FONT_NAME', 'simkai'); [root@yinzhengjie.org.cn ~]# [root@yinzhengjie.org.cn ~]#
5>.再次刷新Zabbix WebUI网页,中文字段显式正常啦