Zabbix的配置和使用(一)
服务端和客户端安装完成之后,接下来该到Web界面的管理后台去配置Zabbix了,因为目前还没有任何数据。下面介绍下Zabbix的配置与使用。顺便说下主动模式与被动模式。主动或被动是相对客户端来讲的:
[*]被动模式:服务端会主动连接客户端获取监控项目数据,客户端被动地接收连接,并把监控信息传递给服务端
[*]主动模式:客户端会主动把监控数据汇报给服务端,服务端只负责接收即可。
[*]当客户端数量非常多时,建议使用主动模式,这样可以降低服务端的压力。
[*]服务端有公网ip,客户端只有内网ip,但却能连外网,这种场景适合主动模式。
一、忘记admin密码
Zabbix管理员用户默认为:admin,密码:zabbix,建议修改成复杂密码。如果忘记密码可以按照下面方法重置密码:
# mysql -uroot -pzlinux123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.Commands end with ; or \g.
Your MySQL connection id is 1795
Server version: 5.6.36-log MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> update zabbix.users set passwd=md5('zlinux123456') where alias='admin';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1Changed: 1Warnings: 0
这样admin密码就改为zlinux123456了。
二、添加主机
1、添加主机群
http://i2.运维网.com/images/blog/201804/13/c4e54401a05e05a9bde214f3cb598ac1.png
http://i2.运维网.com/images/blog/201804/13/7244e8a768723363f4bc6c7cd3fa5a05.png
2、添加主机
http://i2.运维网.com/images/blog/201804/13/2b338ac94bf231597b2930cd532d92f7.png
http://i2.运维网.com/images/blog/201804/13/fe623b3a0151158c26d12a8a69d0405b.png
点击添加按钮之后看到:
http://i2.运维网.com/images/blog/201804/13/53d9e3fa1fb080e911dbd8782670159f.png
其中出现几个概念:
[*]应用集 : 应用集就是多个监控项的组合,比如CPU相关的应用集、内存相关的应用集,应用集里面有具体的监控项。
[*]监控项: 监控项就是要监控的项目,比如内存使用、cpu等。
[*]触发器: 触发器是针对某个监控项做的告警规则,如磁盘使用量超过80%就触发了告警规则,然后就告警。
[*]图形: 监控报表以图形的形式表现出来。
[*]自动发现: 自动发现 是zabbix特有的一个机制,它会自动地去发现服务器上监控项目,比如网卡浏览就可以自动发现网卡设备并监控起来。
[*]web监测: web监测可以去监控指定网站的某个URL访问是否正常,比如状态码是否为200,或者访问时间是否超过某个设定的时间段。
三、添加模版
1、自定义模版
http://i2.运维网.com/images/blog/201804/13/5f493eeffe24d9e57b9da77300221439.png
http://i2.运维网.com/images/blog/201804/13/40b6a5e620e0489ffcb622818e74ef99.png
点击添加之后:
http://i2.运维网.com/images/blog/201804/13/73a1df5965cc7806cd0099c043ebcf0d.png
2、配置监控项目(复制监控项目到zlinux)
http://i2.运维网.com/images/blog/201804/13/b589fb124c24b04960f83e8427de0031.png
http://i2.运维网.com/images/blog/201804/13/2b1cbfcfd33d4d61d050395b4a039a26.png
http://i2.运维网.com/images/blog/201804/13/d2e172f1eb635d06f9e9a5457abcfadb.png
http://i2.运维网.com/images/blog/201804/13/9eada980cffc8931225ee403be92f5cf.png
http://i2.运维网.com/images/blog/201804/13/29fd652ed6a29593dcdeb7b141f13e0b.png
http://i2.运维网.com/images/blog/201804/13/7c7a8fff9eda76cbbd28b5e1b9a80d95.png
http://i2.运维网.com/images/blog/201804/13/ab9512e2e6521f6a5476e1090912b8ff.png
然后返回主机可以看到监控项多了4项:
http://i2.运维网.com/images/blog/201804/13/2bbd5db8f36b3bf99f936fb290365a1d.png
3、自动发现
找到Template OS Linux 点击右侧的自动发现,参考Mounted filesystem discovery 和 Network interface discovery定义规则。
下面方法可以定义监控项,触发器 、图形 、自动发现等。
1、先删除自定义模版的监控项:
http://i2.运维网.com/images/blog/201804/13/bccdb14da34c5ae37d03a0dc07d72394.png
2、自定义模版添加模版链接:
http://i2.运维网.com/images/blog/201804/13/72d5e74f07f461f8ed29533cf5b632c1.png
3、取消链接(不会清除监控项等)
http://i2.运维网.com/images/blog/201804/13/4104a16170064dc8dd95e65babbc7d79.png
http://i2.运维网.com/images/blog/201804/13/25a34a5027d830e70a89e9b0e3ab5002.png
4、选择监控项(留下以下):
http://i2.运维网.com/images/blog/201804/13/4eedb6ac582215a5d74d080a1499bf9c.png
5、删除应用集(留下以下):
http://i2.运维网.com/images/blog/201804/13/46efab117c51142e4439c03adc78f3a6.png
6、删除其他:
http://i2.运维网.com/images/blog/201804/13/a106334f8308caae29ac7108884f7569.png
操作到这步,新模板已经建立好了,然后再把主机和模板结合起来,细化相关的监控项。
http://i2.运维网.com/images/blog/201804/13/a607d1e23ecf9606f6db05ee177f295e.png
http://i2.运维网.com/images/blog/201804/13/eaa369fffe0ff83e8174539d4ff1a91d.png
7、查看相关监控:
http://i2.运维网.com/images/blog/201804/13/8ef24f05e2f60f8b515a6f5d27b6cc6e.png
http://i2.运维网.com/images/blog/201804/13/5a0a9c8930a70c03d91f1c5f62eeb351.png
http://i2.运维网.com/images/blog/201804/13/3556c0d2a695279de071990ecbc7e65c.png
四、处理乱码
http://i2.运维网.com/images/blog/201804/13/83822859e0361a615a6cb5e6b96a5c40.png
出现这些小方块,是因为在zabbix的字体库中没有中文字体,需要从windows上借用一个过来。
# vim /usr/share/zabbix/include/defines.inc.php //搜素ZBX_FONTPATH
define('ZBX_FONTPATH', realpath('fonts')); // where to search for font (GD > 2.0.18)
define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name
它定义的路径是“fonts”,它是一个相对路径,绝对路径为/usr/share/zabbix/fonts,而字体文件为“ZBX_GRAPH_FONT_NAME” 所定义的“graphfont”,它是一个文件,绝对路径为 /usr/share/zabbix/fonts/graphfont
# ls -l /usr/share/zabbix/fonts/
总用量 0
lrwxrwxrwx 1 root root 33 4月12 14:56 graphfont.ttf -> /etc/alternatives/zabbix-web-font
#这是个软链接
然后在windows下C:\Windows\Fonts,随意找一个中文字体库,上传到Linux中/usr/share/zabbix/fonts/,并且设置软链接:
# ls -l /usr/share/zabbix/fonts/
总用量 0
lrwxrwxrwx 1 root root 33 4月12 14:56 graphfont.ttf -> /etc/alternatives/zabbix-web-font
# cd /usr/share/zabbix/fonts/
# ls
graphfont.ttf
# rz
# mv graphfont.ttf graphfont.ttf.bak
# ln -s simsun.ttc graphfont.ttf
# ls
graphfont.ttfgraphfont.ttf.baksimsun.ttc
# ls -l
总用量 14968
lrwxrwxrwx 1 root root 10 4月13 17:42 graphfont.ttf -> simsun.ttc
lrwxrwxrwx 1 root root 33 4月12 14:56 graphfont.ttf.bak -> /etc/alternatives/zabbix-web-font
-rw-r--r-- 1 root root 15323200 6月11 2009 simsun.ttc
刷新网页:
http://i2.运维网.com/images/blog/201804/13/5cd028da635a4d81fbf031d0dfad96c3.png
查看监测数据:
http://i2.运维网.com/images/blog/201804/13/bb23dc39aa6a3b0dac7955dba6850675.png
http://i2.运维网.com/images/blog/201804/13/c6b8d442ad005c36cea8e822dfa576f3.png
自动发现:
http://i2.运维网.com/images/blog/201804/13/03f5a1bbfec856a325a10fcd6e00d6bf.png
自动发现是由,更新周期决定的,如上图所示,更新时间是1h,所以每一小时更新一次。
页:
[1]