Zabbix初体验

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zabbix初体验相关的知识,希望对你有一定的参考价值。

 Zabbix介绍

 为什么要监控

我们的职责

1. 保障企业数据的安全可靠。

2. 为客户提供7*24小时服务

3. 不断提升用户体验

在关键时刻,提前提醒我们服务器要出问题了

当出问题之后,可以便于找到问题的根源

怎么来监控

远程管理服务器有远程管理卡,比如Dell idRACHP ILOIBM IMM

查看硬件的温度/风扇转速,电脑有鲁大师,服务器就有opmitool。使用ipmitool实现对服务器的命令行远程管理

ü  yum -y install OpenIPMI ipmitool  àIPMI在物理机可以成功,虚拟机不行

CPU性能好不好、忙不忙可以用lscpuuptimetophtop

内存够不够可以用free

磁盘剩多少写的快不快可以用dfddiotop

网络太卡找iftopnethogs

监控工具总览

mrtg     流量监控出图

nagios   监控

cacti    流量监控出图

zabbix   监控+出图,所有监控范畴,都可以整合到Zabbix中。

硬件监控:Zabbix  IPMI  Interface

系统监控:Zabbix  Agent  Interface

Java监控:Zabbix  JMX  Interfaca

网络设备监控:Zabbix  SNMP  Interface

应用服务监控:Zabbix  Agent  UserParameter

mysql数据库监控:percona-monitoring-plulgins

URL监控:Zabbix Web 监控

 Zabbix初体验

环境检查

[[email protected] ~]# getenforce

Disabled

[[email protected] ~]# systemctl status firewalld.service

firewalld.service - firewalld - dynamic firewall daemon

   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)

   Active: inactive (dead)

     Docs: man:firewalld(1)

[[email protected] ~]# hostname -I

10.0.0.61 172.16.1.61

安装zabbix服务端

安装zabbix官方源

[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

获取http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

警告:/var/tmp/rpm-tmp.pYOCq8: V4 DSA/SHA1 Signature, 密钥 ID 79ea5ed4: NOKEY

准备中...                          ################################# [100%]

正在升级/安装...

   1:zabbix-release-3.0-1.el7         ################################# [100%]

[[email protected] ~]# yum install zabbix-server-mysql zabbix-web-mysql

作为依赖被安装:

  OpenIPMI-libs.x86_64 0:2.0.19-15.el7                  OpenIPMI-modalias.x86_64 0:2.0.19-15.el7               

  dejavu-fonts-common.noarch 0:2.33-6.el7                  dejavu-sans-fonts.noarch 0:2.33-6.el7                 

  fontpackages-filesystem.noarch 0:1.44-8.el7              fping.x86_64 0:3.10-4.el7                             

  httpd.x86_64 0:2.4.6-67.el7.centos.6                     httpd-tools.x86_64 0:2.4.6-67.el7.centos.6            

  iksemel.x86_64 0:1.4-6.el7                               libX11.x86_64 0:1.6.5-1.el7                           

  libX11-common.noarch 0:1.6.5-1.el7                       libXau.x86_64 0:1.0.8-2.1.el7                         

  libXpm.x86_64 0:3.5.12-1.el7                             libpng.x86_64 2:1.5.13-7.el7_2                        

  libxcb.x86_64 0:1.12-1.el7                               libzip.x86_64 0:0.10.1-8.el7                          

  mailcap.noarch 0:2.1.41-2.el7                            net-snmp-libs.x86_64 1:5.7.2-28.el7                   

  php.x86_64 0:5.4.16-42.el7                               php-bcmath.x86_64 0:5.4.16-42.el7                      

  php-cli.x86_64 0:5.4.16-42.el7                           php-common.x86_64 0:5.4.16-42.el7                     

  php-gd.x86_64 0:5.4.16-42.el7                            php-ldap.x86_64 0:5.4.16-42.el7                       

  php-mbstring.x86_64 0:5.4.16-42.el7                      php-mysql.x86_64 0:5.4.16-42.el7                      

  php-pdo.x86_64 0:5.4.16-42.el7                           php-xml.x86_64 0:5.4.16-42.el7                        

  t1lib.x86_64 0:5.1.2-14.el7                              unixODBC.x86_64 0:2.3.1-11.el7                        

  zabbix-web.noarch 0:3.0.13-2.el7

Yum安装数据库

数据库安装

[[email protected] ~]# yum -y install mariadb-server

[[email protected] ~]# systemctl start mariadb.service

[[email protected] ~]# ls /var/lib/mysql/

aria_log.00000001  ibdata1      ib_logfile1  mysql.sock          test

aria_log_control   ib_logfile0  mysql        performance_schema

创建数据库,权限

[[email protected] ~]# mysql

 

MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;

Query OK, 1 row affected (0.00 sec)

 

MariaDB [(none)]> grant all privileges on zabbix.* to [email protected] identified by 'zabbix';

Query OK, 0 rows affected (0.00 sec)

 

MariaDB [(none)]> exit

Bye

导入数据库sql文件

[[email protected] ~]# zcat /usr/share/doc/zabbix-server-mysql-3.0.13/create.sql.gz|mysql -uzabbix -pzabbix zabbix


配置zabbix-server

配置zabbix server连接mysql

[[email protected] ~]# sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf

[[email protected] ~]# grep  "^[a-Z]" /etc/zabbix/zabbix_server.conf

LogFile=/var/log/zabbix/zabbix_server.log

LogFileSize=0

PidFile=/var/run/zabbix/zabbix_server.pid

DBName=zabbix

DBUser=zabbix

DBPassword=zabbix

SNMPTrapperFile=/var/log/snmptrap/snmptrap.log

Timeout=4

AlertScriptsPath=/usr/lib/zabbix/alertscripts

ExternalScripts=/usr/lib/zabbix/externalscripts

LogSlowQueries=3000

修改默认时区

[[email protected] ~]# sed -i.ori '18a php_value date.timezone  Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf

启动服务

[[email protected] ~]# systemctl start zabbix-server

[[email protected] ~]# systemctl start httpd

查看是否启动

[[email protected] ~]# tailf /var/log/zabbix/zabbix_server.log

 17821:20180112:105043.229 server #17 started [timer #1]

 17822:20180112:105043.242 server #18 started [http poller #1]

 17823:20180112:105043.243 server #19 started [discoverer #1]

 17826:20180112:105043.254 server #21 started [history syncer #2]

 17827:20180112:105043.255 server #22 started [history syncer #3]

 17825:20180112:105043.257 server #20 started [history syncer #1]

 17833:20180112:105043.282 server #24 started [escalator #1]

 17832:20180112:105043.286 server #23 started [history syncer #4]

 17834:20180112:105043.288 server #25 started [proxy poller #1]

 17838:20180112:105043.303 server #26 started [self-monitoring #1]

开机自启

[[email protected] ~]# systemctl enable zabbix-server.service httpd.service mariadb.service

 Zabbix网页操作

 打开网页

技术分享图片

加上端口与密码   

密码zabbix

技术分享图片

 站点取名

技术分享图片

 登录

技术分享图片


 翻译成中文

技术分享图片

技术分享图片

客户端部署

服务端客户端都要装,都要监控

[[email protected] ~]# echo "192.168.11.200 repo.zabbix.com" >> /etc/hosts

[[email protected] ~]#  rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

获取http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm

警告:/var/tmp/rpm-tmp.bs0Ggb: V4 DSA/SHA1 Signature, 密钥 ID 79ea5ed4: NOKEY

准备中...                          ################################# [100%]

正在升级/安装...

   1:zabbix-release-3.0-1.el7         ################################# [100%]

 客户端软件

[[email protected] ~]# yum -y install zabbix-agent

修改配置文件

[[email protected] ~]# sed -i.ori 's#Server=127.0.0.1#Server=172.16.1.61#' /etc/zabbix/zabbix_agentd.conf

 启动

[[email protected] ~]# systemctl start zabbix-agent.service

 测试客户端是否可用

服务端

[[email protected] ~]# yum install -y zabbix-get

[[email protected] ~]# zabbix_get -s 172.16.1.61 -p 10050 -k "system.cpu.load[all,avg1]"

0.060000

[[email protected] ~]# zabbix_get -s 172.16.1.21 -p 10050 -k "system.cpu.load[all,avg1]"

0.000000

Web添加服务端

技术分享图片

点进原有的zabbix-server主机

技术分享图片

技术分享图片

技术分享图片

刷新出绿色就好了、

技术分享图片

技术分享图片

技术分享图片

技术分享图片

技术分享图片

技术分享图片

解决乱码

[[email protected] ~]# yum -y install wqy-microhei-fonts

[[email protected] ~]# \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf

技术分享图片

技术分享图片

监控的时间越长,东西显示的更多

以上是关于Zabbix初体验的主要内容,如果未能解决你的问题,请参考以下文章

2.跟老韩学Python之hello初体验

Hadoop初体验

PetaPoco初体验(转)

我的Go+语言初体验—— 一个Golang开发者的Go+初体验

PHP初体验

maven初体验