zabbix内容整理
来源:互联网 发布:ec软件使用 编辑:程序博客网 时间:2024/06/07 14:48
PS:我是在红帽7.2版本与6.5版本上进行操作的
Zabbix server:node5:172.25.44.15:rhel7.2
Zabbix agent:server6:172.25.44.6:rhel6.5
Zabbix agent:server7:172.25.44.7:rhel6.5
##########################
######## 一.安装zabbix #########
##########################
一.安装zabbix
[root@node5 ~]# lszabbix_el7[root@node5 ~]# cd zabbix_el7/
需要先安装这个
[root@node5 ~]# yum install -y php-bcmath-5.4.16-36.el7_1.x86_64.rpm[root@node5 ~]# yum install -y php-mbstring-5.4.16-36.el7_1.x86_64.rpm
否则报错如下:
Error: Package: zabbix-web-3.2.6-1.el7.noarch (/zabbix-web-3.2.6-1.el7.noarch)
Requires: php-bcmath
Error: Package: zabbix-web-3.2.6-1.el7.noarch (/zabbix-web-3.2.6-1.el7.noarch)
Requires: php-mbstring
You could try using –skip-broken to work around the problem
You could try running: rpm -Va –nofiles –nodigest
[root@node5 zabbix_el7]# yum install -y zabbix-server-mysql-3.2.6-1.el7.x86_64.rpm zabbix-release-3.2-1.el7.noarch.rpm zabbix-agent-3.2.6-1.el7.x86_64.rpm zabbix-web-3.2.6-1.el7.noarch.rpm zabbix-web-mysql-3.2.6-1.el7.noarch.rpm iksemel-1.4-2.el7.centos.x86_64.rpm
(2)安装apache
[root@node5 ~]# yum install -y httpd
二. 数据库
1.数据库的安装
[root@node5 ~]# yum install -y mariadb-server
Installed: mariadb-server.x86_64 1:5.5.44-2.el7Dependency Installed: mariadb.x86_64 1:5.5.44-2.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBD-MySQL.x86_64 0:4.023-5.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7
2.数据库授权
[root@node5 ~]# systemctl start mariadb[root@node5 ~]# systemctl enable mariadb
[root@node5 ~]# mysqlMariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'redhat';
@@此时数据库情况:
MariaDB [(none)]> show databases;
+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || test || zabbix |+--------------------+5 rows in set (0.00 sec)
此时数据库中还没有表
MariaDB [(none)]> use zabbix;MariaDB [zabbix]> show tables;Empty set (0.00 sec)
3.向zabbix数据库中导入表
[root@node5 ~]# zcat /usr/share/doc/zabbix-server-mysql-3.2.6/create.sql.gz | mysql -uzabbix -p zabbixEnter password: ->> redhat(即zabbix用户的数据库登陆密码)
@@查看数据库同步情况:
[root@node5 zabbix-server-mysql-3.2.6]# mysqlMariaDB [(none)]> use zabbixMariaDB [zabbix]> show tables;+----------------------------+| Tables_in_zabbix |+----------------------------+| acknowledges || ...... || triggers || users || users_groups || usrgrp || valuemaps |+----------------------------+127 rows in set (0.00 sec)MariaDB [zabbix]> select * from valuemaps;+------------+---------------------------------------+| valuemapid | name |+------------+---------------------------------------+| 4 | APC Battery Replacement Status || 5 | APC Battery Status || 7 | Dell Open Manage System Status || 6 | HP Insight System Status || 17 | HTTP response status code || 2 | Host availability || 14 | Maintenance status || 9 | SNMP device status (hrDeviceStatus) || 11 | SNMP interface status (ifAdminStatus) || 8 | SNMP interface status (ifOperStatus) || 1 | Service state || 12 | VMware VirtualMachinePowerState || 13 | VMware status || 15 | Value cache operating mode || 16 | Windows service startup type || 3 | Windows service state || 10 | Zabbix agent ping status |+------------+---------------------------------------+17 rows in set (0.00 sec)
@@成功!
4.更改zabbix配置文件
[root@node5 ~]# vim /etc/zabbix/zabbix_server.confDBPassword=redhat
5.开启zabbix服务,并设置为开机自启动
[root@node5 ~]# systemctl start zabbix-server[root@node5 ~]# systemctl enable zabbix-server[root@node5 ~]# systemctl start zabbix-agent[root@node5 ~]# systemctl enable zabbix-agent
6.更改配置文件:修改时区
[root@node5 ~]# vim /etc/httpd/conf.d/zabbix.conf 19行: php_value date.timezone Asia/Shanghai
7.开启apache服务
[root@node5 ~]# systemctl start httpd[root@node5 ~]# systemctl enable httpd
8.做解析
[root@node5 ~]# cat /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6172.25.44.6 server6172.25.44.7 server7172.25.44.15 node5
9.在网页上查看
访问: http://172.25.44.15/zabbix
自动跳转到: http://172.25.44.15/zabbix/users.php
后面状态都为OK:
这里的Password是数据库中zabbix用户的密码(我这里为redhat):
给Zabbix server起个名字:建议使用Zabbix server(我这里手残就直接写了主机名,不过没太大影响,只需在配置文件/etc/zabbix/zabbix_agentd.conf中更改Hostname=node5):
zabbix安装前信息的总结:
安装完成:
用户登录(这里我用的超户,密码是zabbix):
登陆成功后进入的zabbix界面:
之后,我把英文界面改成中文
具体更改方式详细见:
http://blog.csdn.net/yy_qingmofeige/article/details/77460456
======================================
##########################
######## 二.节点的发现 #########
##########################
一.开启另一台虚拟机并进行相关配置
1.安装zabbix
[root@server6 zabbix_el6]# yum install -y zabbix-agent-3.2.6-1.el6.x86_64.rpm
2.修改配置文件
[root@server6 ~]# vim /etc/zabbix/zabbix_agentd.confServer=172.25.44.15 ##*为zabbix server(node5)的IP地址*ServerActive=127.0.0.1 ##*本机IP*Hostname=server6 ##这个hostname必须要与本机hostname保持一致
3.开启服务并设置其开机自启动
[root@server6 ~]# /etc/init.d/zabbix-agent start[root@server6 ~]# chkconfig zabbix-agent on
4.服务端口
zabbix_agentd 在10050端口,zabbix_server在10051端口
二.发现主机
1.此时把server6配置好打开后zabbix监控捕获不到,原因是没有打开自动发现规则
进行配置并更新,应用:
并配置动作如下并更新,应用:
重启zabbix-agent和zabbix-server服务
查看主机列表,发现server6(zabbix-adent)被发现了
可以查看监控的图形显示
下面我们手动添加一个主机
首先禁用自动发现规则与动作
再删除server6
点击“创建主机”
点击选择后会出现以下内容,选择你要添加的模版
注:如果新添加的主机“ZBX”不是绿色的话,刷新一下就好了
2.下面重新自动发现主机
先打开自动发现和动作
[root@server5 zabbix_el6]# yum install -y zabbix-agent-3.2.6-1.el6.x86_64.rpm[root@server5 zabbix_el6]# vim /etc/zabbix/zabbix_agentd.conf [root@server5 zabbix_el6]# /etc/init.d/zabbix-agent start
等一小段时间才可以。。。。
注意:主机在zabbix-server端一定要有解析!,否则不会出现主机名如下:
删掉重新发现
3.Zabbix-get获取数据:
[root@server6 ~]# yum install -y nginx-1.8.0-1.el6.ngx.x86_64.rpm[root@server6 ~]# /etc/init.d/nginx start[root@server6 ~]# vim /etc/nginx/conf.d/default.conf加入以下内容(可以显示状态页): location /status { stub_status on; access_log off; allow 127.0.0.1; deny all; }[root@server6 ~]# /etc/init.d/nginx reload
现在可以访问状态页了:
[root@server6 ~]# curl http://127.0.0.1/statusActive connections: 1 server accepts handled requests 4 4 4 Reading: 0 Writing: 1 Waiting: 0
过滤信息:
[root@server6 ~]# curl -s http://127.0.0.1/status | grep Active | awk '{print $NF}'1
[root@server6 zabbix_agentd.d]# lsuserparameter_mysql.conf[root@server6 ~]# cd /etc/zabbix/zabbix_agentd.d[root@server6 zabbix_agentd.d]# cp userparameter_mysql.conf nginx.conf[root@server6 zabbix_agentd.d]# lsnginx.conf userparameter_mysql.conf[root@server6 zabbix_agentd.d]# vim nginx.conf [root@server6 zabbix_agentd.d]# cat nginx.conf UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active | awk '{print $NF}'[root@server6 zabbix_agentd.d]# /etc/init.d/zabbix-agent restartShutting down Zabbix agent: [ OK ]Starting Zabbix agent: [ OK ]
注:这个-k==-key ,可以是server6nginx.conf文件中UserParameter的值。
[root@node5 zabbix_el7]# rpm -ivh zabbix-get-3.2.6-1.el7.x86_64.rpm[root@node5 zabbix_el7]# zabbix_get -s 172.25.44.6 -k nginx.active 1
4.下面利用zabbix在网页上设置来获取信息:
点击右上角的“创建监控项”
可以在监控项列表中找到它:
下面创建图形:
点击右上角“创建图形”
注意:添加监控项时要在有上角进行选择(我就是一开始不知道在这里卡了好久都找不到我之前创建的Nginx Active [T _ T])
创建好了之后在这里会有显示:
此时会有图形显示:
我们可以进行一个测试,看一下图像的变化:
[kiosk@foundation44 ~]$ ab -c 100 -n 100000 http://172.25.44.6/index.html
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 172.25.44.6 (be patient)Completed 10000 requestsCompleted 20000 requestsCompleted 30000 requestsCompleted 40000 requestsCompleted 50000 requestsCompleted 60000 requestsCompleted 70000 requestsCompleted 80000 requestsCompleted 90000 requestsCompleted 100000 requestsFinished 100000 requestsServer Software: nginx/1.8.0Server Hostname: 172.25.44.6Server Port: 80Document Path: /index.htmlDocument Length: 612 bytesConcurrency Level: 100Time taken for tests: 11.336 secondsComplete requests: 100000Failed requests: 0Write errors: 0Total transferred: 84400000 bytesHTML transferred: 61200000 bytesRequests per second: 8821.34 [#/sec] (mean)Time per request: 11.336 [ms] (mean)Time per request: 0.113 [ms] (mean, across all concurrent requests)Transfer rate: 7270.71 [Kbytes/sec] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 0 1 1.9 1 50Processing: 1 10 7.4 8 114Waiting: 0 9 7.7 8 113Total: 4 11 7.1 9 114Percentage of the requests served within a certain time (ms) 50% 9 66% 14 75% 15 80% 15 90% 16 95% 17 98% 24 99% 38 100% 114 (longest request)
之后我们完善一下文件,把网页状态的所有信息都拿出来:
[root@server6 zabbix_agentd.d]# vim nginx.conf [root@server6 zabbix_agentd.d]# cat nginx.conf
UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active | awk '{print $NF}'UserParameter=nginx.reading,curl -s http://127.0.0.1/status | grep Reading | awk '{print $2}'UserParameter=nginx.writing,curl -s http://127.0.0.1/status | grep Writing | awk '{print $4}'UserParameter=nginx.waiting,curl -s http://127.0.0.1/status | grep Waiting | awk '{print $6}'
[root@server6 zabbix_agentd.d]# /etc/init.d/zabbix-agent restart
在node5进行测试:
[root@node5 zabbix_el7]# zabbix_get -s 172.25.44.6 -k nginx.active1[root@node5 zabbix_el7]# zabbix_get -s 172.25.44.6 -k nginx.waiting0[root@node5 zabbix_el7]# zabbix_get -s 172.25.44.6 -k nginx.writing1
在网页上对zabbix进行模版的编辑:
或者可以直接导入写好的模版:
主机链接模版:
在监控项中选中刚开始创建的那个模版,点击删除:
重新配置监控项:
照上述方法进行其他监控项的添加,最后监控项列表是这样的:
创建图形:
图形监控结果:
持续更新中。。。
- zabbix内容整理
- zabbix数据库备份整理
- Zabbix 报警邮件内容带附件解决方法
- zabbix监控mysql相关配置内容
- Zabbix
- zabbix
- zabbix
- zabbix
- zabbix
- zabbix
- ZABBIX
- zabbix
- ZABBIX
- Zabbix
- zabbix
- Zabbix
- zabbix
- zabbix
- Android 应用通过init.rc启动service去执行具有root权限sh脚本
- 1.4变量与数组.md
- dubbo的优点
- OC协议和id
- linux文件系统分类和特点
- zabbix内容整理
- 1.5运算符.md
- 微服务时代---Dubbo(一)
- Jobdu1102 畅通工程(并查集)
- 我要高效学习
- 路径
- HDU6150 Vertex Cover
- ORACLE10G+asm+RAC集群(linux)
- 笔面试题相关知识点整理(一)--隐式类型转换