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網頁,中文字段顯式正常啦