分布式监控zabbix配置使用
程序员文章站
2022-07-11 11:47:03
...
下一张继续zabbix:监控zabbix–percona插件,zabbix-proxy代理
地址:https://blog.csdn.net/su_use/article/details/81713928
1、安装:
[aaa@qq.com pub]# ls
php-bcmath-5.4.16-36.el7_1.x86_64.rpm
php-mbstring-5.4.16-36.el7_1.x86_64.rpm
[aaa@qq.com pub]# yum install php*
---
[aaa@qq.com zibb]# ll
total 5080
-rwxrwxrwx 1 ftp ftp 41292 Aug 14 06:13 fping-3.10-1.el7.x86_64.rpm
-rwxrwxrwx 1 ftp ftp 50452 Aug 14 06:13 iksemel-1.4-2.el7.centos.x86_64.rpm
-rwxrwxrwx 1 ftp ftp 369416 Aug 14 06:13 zabbix-agent-3.4.6-1.el7.x86_64.rpm
-rwxrwxrwx 1 ftp ftp 2068572 Aug 14 06:13 zabbix-server-mysql-3.4.6-1.el7.x86_64.rpm
-rwxrwxrwx 1 ftp ftp 2648144 Aug 14 06:13 zabbix-web-3.4.6-1.el7.noarch.rpm
-rwxrwxrwx 1 ftp ftp 6692 Aug 14 06:13 zabbix-web-mysql-3.4.6-1.el7.noarch.rpm
[aaa@qq.com zibb]# yum install *
---
2、安装数据库:
[root@server1 ~]# yum install -y mariadb-server
[root@server1 ~]# systemctl start mariadb
[root@server1 ~]# mysql_secure_installation
[root@server1 ~]# mysql -uroot -pwestos
----
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.01 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'westos';
Query OK, 0 rows affected (0.00 sec)
导入zabbix数据:
[root@server1 ~]# cd /usr/share/doc/zabbix-server-mysql-3.4.6/
[root@server1 zabbix-server-mysql-3.4.6]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@server1 zabbix-server-mysql-3.4.6]# zcat create.sql.gz | mysql -uzabbix zabbix -p
Enter password: #等待一会
配置zxbbix-server
[root@server1 zabbix]# vim zabbix_server.conf
-----
125 DBPassword=westos
133 DBSocket=/var/lib/mysql/mysql.sock
-----
修改zabbix的web(php)配置
[aaa@qq.com zabbix]# vim /etc/httpd/conf.d/zabbix.conf
-----
php_value date.timezone Asia/Shanghai
-----
[root@server1 Desktop]# systemctl start zabbix-server
[root@server1 Desktop]# systemctl start httpd
浏览器访问172.25.5.1/zabbix
上边步骤如果都OK将可以正常登录(初始用户名密码Admin/zabbix)
zabbix主页面
添加server机:
server2 测试,安装zabbix-agent
[root@server2 ~]# ls
zabbix-agent-3.4.6-1.el6.x86_64.rpm
[root@server2 ~]# rpm -ivh zabbix-agent-3.4.6-1.el6.x86_64.rpm
warning: zabbix-agent-3.4.6-1.el6.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ########################################### [100%]
1:zabbix-agent ########################################### [100%]
[root@server2 ~]#
配置agent
[root@server2 ~]# vim /etc/zabbix/zabbix_agentd.conf
----
Server=172.25.5.1
ServerActive=172.25.5.1
Hostname=server2
-----
[root@server2 ~]# /etc/init.d/zabbix-agent start
Starting Zabbix agent: [ OK ]
[root@server2 ~]#
zabbix-server端配置发现规则
配置 -> 自动发现 -> 配置好之后启用规则。
配置 -> 动作 -> 配置好之后启用动作
这样就能发现agent节点了,但这样配置有时不能很好的发现agent,
自动注册
agent端主动注册
配置 -> 动作 -> 右上角自动注册 -> 配置好之后启用动作
自动发现的server
自定义监控模板nginx:
[root@server2 ~]# ls
nginx-1.8.0-1.el6.ngx.x86_64.rpm
[root@server2 ~]# yum install nginx-1.8.0-1.el6.ngx.x86_64.rpm
[root@server2 ~]# vim /etc/nginx/conf.d/default.conf
------
location /status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
-----
[root@server2 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@server2 ~]# nginx
[root@server2 ~]#
添加zabbix-agent配置:
[root@server2 ~]# cd /etc/zabbix/zabbix_agentd.d/
[root@server2 zabbix_agentd.d]# ls
userparameter_mysql.conf
[root@server2 zabbix_agentd.d]# cp userparameter_mysql.conf userparameter_nginx.conf
[root@server2 zabbix_agentd.d]# vim userparameter_nginx.conf
[root@server2 zabbix_agentd.d]# cat userparameter_nginx.conf
UserParameter=nginx.active,curl -s http://127.0.0.1/status | awk 'NR==1' | awk '{print $3}'
UserParameter=nginx.accept,curl -s http://127.0.0.1/status | awk 'NR==3' | awk '{print $1}'
UserParameter=nginx.handle,curl -s http://127.0.0.1/status | awk 'NR==3' | awk '{print $2}'
UserParameter=nginx.request,curl -s http://127.0.0.1/status | awk 'NR==3' | awk '{print $3}'
[root@server2 zabbix_agentd.d]# /etc/init.d/zabbix-agent restart
Shutting down Zabbix agent: [ OK ]
Starting Zabbix agent: [ OK ]
[root@server2 zabbix_agentd.d]#
添加nginx:监控:
添加图形:
下一篇: ZABBIX分布式监控系统配置(三)