Ubuntu系统配置Zabbix前端及中文乱码解决方案

         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)进入欢迎界面

Ubuntu系统配置Zabbix前端及中文乱码解决方案

2>.如下图所示,下拉进度条进行条件检查,如果所有的参数都是"OK",则可以进入下一步啦

Ubuntu系统配置Zabbix前端及中文乱码解决方案

3>.配置zabbix前端的数据库信息

Ubuntu系统配置Zabbix前端及中文乱码解决方案

4>.配置zabbix server信息

Ubuntu系统配置Zabbix前端及中文乱码解决方案

5>.将之前的配置review一下,做最后的确认若没有问题的话继续下一步

Ubuntu系统配置Zabbix前端及中文乱码解决方案

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'] = '';
$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 = '';
$ZBX_SERVER_NAME = 'Yinzhengjie\'s Zabbix Server'; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG;
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]#

[root@yinzhengjie.org.cn ~]# cat /usr/share/zabbix/conf/zabbix.conf.php

Ubuntu系统配置Zabbix前端及中文乱码解决方案

7>.安装完成后会自动跳转到登录界面

Ubuntu系统配置Zabbix前端及中文乱码解决方案

三.登录zabbix数据库

1>.使用默认的用户名(Admin)和密码(yinzhengjie)登录zabbix WebUI

Ubuntu系统配置Zabbix前端及中文乱码解决方案

2>.登录成功啦

Ubuntu系统配置Zabbix前端及中文乱码解决方案

四.修改Zabbix WebUI管理员的默认密码 

1>.如下图所示,登录zabbix WebUI后,点击右上角的小人图标

Ubuntu系统配置Zabbix前端及中文乱码解决方案

2>.如下图所示,点击"Change password"

Ubuntu系统配置Zabbix前端及中文乱码解决方案

3>.修改管理员用户的密码

Ubuntu系统配置Zabbix前端及中文乱码解决方案

五.配置ubuntu支持中文界面

1>.如下图所示,登录zabbix WebUI后,点击右上角的小人图标

Ubuntu系统配置Zabbix前端及中文乱码解决方案

2>.查看zabbix支持的语言

Ubuntu系统配置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
upgraded, newly installed, to remove and not upgraded.
Need to get , kB of archives.
After this operation, 20.1 MB of additional disk space will be used.
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 language-pack-zh-hans-base all 1:18.04+20180712 [1,692 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 language-pack-zh-hans all 1:18.04+20200123 [1,119 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 language-pack-zh-hant-base all 1:18.04+20180712 [1,221 kB]
Get: http://mirrors.aliyun.com/ubuntu bionic-proposed/main amd64 language-pack-zh-hant all 1:18.04+20200123 [778 kB]
Fetched , kB in 1s (, kB/s)
Selecting previously unselected package language-pack-zh-hans-base.
(Reading database ... files and directories currently installed.)
Preparing to unpack .../language-pack-zh-hans-base_1%3a18.+20180712_all.deb ...
Unpacking language-pack-zh-hans-base (:18.04+) ...
Selecting previously unselected package language-pack-zh-hans.
Preparing to unpack .../language-pack-zh-hans_1%3a18.+20200123_all.deb ...
Unpacking language-pack-zh-hans (:18.04+) ...
Replacing files in old package language-pack-zh-hans-base (:18.04+) ...
Selecting previously unselected package language-pack-zh-hant-base.
Preparing to unpack .../language-pack-zh-hant-base_1%3a18.+20180712_all.deb ...
Unpacking language-pack-zh-hant-base (:18.04+) ...
Selecting previously unselected package language-pack-zh-hant.
Preparing to unpack .../language-pack-zh-hant_1%3a18.+20200123_all.deb ...
Unpacking language-pack-zh-hant (:18.04+) ...
Replacing files in old package language-pack-zh-hant-base (:18.04+) ...
Setting up language-pack-zh-hant (:18.04+) ...
Setting up language-pack-zh-hant-base (:18.04+) ...
Generating locales (this might take a while)...
zh_HK.UTF-... done
zh_TW.UTF-... done
Generation complete.
Setting up language-pack-zh-hans (:18.04+) ...
Setting up language-pack-zh-hans-base (:18.04+) ...
Generating locales (this might take a while)...
zh_CN.UTF-... done
zh_SG.UTF-... done
Generation complete.
[root@yinzhengjie.org.cn ~]#

[root@yinzhengjie.org.cn ~]# apt-get -y install language-pack-zh*

Ubuntu系统配置Zabbix前端及中文乱码解决方案

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          #会弹出如下图所示的一个界面,选中语言。

Ubuntu系统配置Zabbix前端及中文乱码解决方案

  上一步配置后,会弹出如下图所示的对话框,继续选择"zh_CN.UTF-8"

Ubuntu系统配置Zabbix前端及中文乱码解决方案

7>.重启服务使得配置生效

[root@yinzhengjie.org.cn ~]# systemctl restart zabbix-server zabbix-agent apache2

Ubuntu系统配置Zabbix前端及中文乱码解决方案

8>.刷新zabbix WebUI网页

Ubuntu系统配置Zabbix前端及中文乱码解决方案

六.解决zabbix中文乱码问题

1>.选择中文语言支持

Ubuntu系统配置Zabbix前端及中文乱码解决方案

2>.如下图所示,出现乱码显式啦

Ubuntu系统配置Zabbix前端及中文乱码解决方案

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
upgraded, newly installed, to remove and not upgraded.
Need to get 74.8 kB of archives.
After this operation, kB of additional disk space will be used.
Get: 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 ( kB/s)
Selecting previously unselected package lrzsz.
(Reading database ... files and directories currently installed.)
Preparing to unpack .../lrzsz_0.12.21-~build0.18.04.1_amd64.deb ...
Unpacking lrzsz (0.12.-~build0.18.04.) ...############...............................................................................................................................................................................................................]
Setting up lrzsz (0.12.-~build0.18.04.) ...##############################################################################################............................................................................................................................]
Processing triggers for man-db (2.8.-2ubuntu0.) ...###########################################################################################################################################################################..........................................]
[root@yinzhengjie.org.cn ~]#
[root@yinzhengjie.org.cn ~]#

[root@yinzhengjie.org.cn ~]# apt -y install lrzsz

Ubuntu系统配置Zabbix前端及中文乱码解决方案

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
drwxr-xr-x root root Feb : ./
drwxr-xr-x root root Feb : ../
lrwxrwxrwx root root Feb : 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
drwxr-xr-x root root Feb : ./
drwxr-xr-x root root Feb : ../
lrwxrwxrwx root root Feb : graphfont.ttf -> /etc/alternatives/zabbix-frontend-font
-rw-r--r-- root root Mar 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 ~]#

Ubuntu系统配置Zabbix前端及中文乱码解决方案

5>.再次刷新Zabbix WebUI网页,中文字段显式正常啦

Ubuntu系统配置Zabbix前端及中文乱码解决方案

上一篇:【ubuntu】给新装好的UBUNTU系统配置静态IP


下一篇:Ubuntu系统配置apt-get软件更新源