zabbix监控nginx mysql 服务添加

[root@test2 ~]# rpm -ivh nginx-1.8.0-1.el7.ngx.x86_64.rpm

[root@test2 ~]# cd /etc/nginx/

[root@test2 nginx]# cd conf.d/

[root@test2 conf.d]# vim default.conf

[root@test2 conf.d]# nginx -t

[root@test2 conf.d]# systemctl start nginx.service

ot@test2 conf.d]# curl 127.0.0.1/status

[root@test2 conf.d]# cd /etc/zabbix/zabbix_agentd.d/

[root@test2 zabbix_agentd.d]# cp userparameter_mysql.conf userparameter_nginx.conf 

[root@test2 zabbix_agentd.d]# curl -s http://127.0.0.1/status | grep Active | awk '{print $3}'   ##获得返回值即可

[root@test2 zabbix_agentd.d]# vim userparameter_nginx.conf

删除其余的
UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active | awk '{print $3}'

[root@test2 zabbix_agentd.d]# systemctl restart zabbix-agent.service

 

 

test1:

[root@test1 3.4]# rpm  -ivh zabbix-get-3.4.6-1.el7.x86_64.rpm

[root@test1 3.4]# zabbix_get -s 172.25.8.12 -p 10050 -k "nginx.active" ##有返回值即可

 

 

web界面

 

创建监控项

配置--主机--监控项--创建监控

 

创建图形

配置--主机--图形--创建图形

 

 

 

添加自定义配置文件

[root@test2 zabbix_agentd.d]# vim userparameter_nginx.conf

[root@test2 zabbix_agentd.d]# systemctl restart zabbix-agent.service

 

 

test1:

[root@test1 3.4]# zabbix_get -s 172.25.8.12 -p 10050 -k "nginx.active"

1

[root@test1 3.4]# zabbix_get -s 172.25.8.12 -p 10050 -k "nginx.accepts"

51

[root@test1 3.4]# zabbix_get -s 172.25.8.12 -p 10050 -k "nginx.handled"

52

[root@test1 3.4]# zabbix_get -s 172.25.8.12 -p 10050 -k "nginx.requests"

54

 

 

 

web:

监控向添加

图形添加

预览

 

 

mysql:

 

web

主机zabbix server添加模版

DBmysql

 

图形查看

[root@test1 3.4]# mkdir /var/lib/zabbix

[root@test1 3.4]# cd /var/lib/zabbix/

[root@test1 zabbix]# vim .my.cnf

[root@test1 zabbix]# systemctl restart zabbix-agent.service

 

percona

 

rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm

[root@test1 ~]# cd /var/lib/zabbix/percona/templates/

[root@test1 templates]# cp userparameter_percona_mysql.conf  /etc/zabbix/zabbix_agentd.d/

[root@test1 templates]# cd /etc/zabbix/zabbix_agentd.d/

[root@test1 zabbix_agentd.d]# rpm -q php-mysql

[root@server1 zabbix_agentd.d]# cat userparameter_percona_mysql.conf | wc -l

cd /var/lib/zabbix/percona/scripts/

vim ss_get_mysql_stats.php.cnf

<?php

$mysql_user = 'root';

$mysql_pass = 'redhat';

[root@test1 zabbix_agentd.d]# mysqladmin -uroot password westos

[root@test1 zabbix_agentd.d]# mysql -uroot -pwestos

[root@test1 scripts]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg

[root@test1 scripts]# cd /tmp/

[root@test1 tmp]# chown zabbix.zabbix localhost-mysql_cacti_stats.txt

[root@test1 tmp]# ll localhost-mysql_cacti_stats.txt

[root@test1 tmp]# cd /etc/zabbix/zabbix_agentd.d/

[root@test1 zabbix_agentd.d]# zabbix_get -s 127.0.0.1 -p 10050 -k 'MySQL.Key-read-requests'

 

 

web界面

在模版中导入

猜你喜欢

转载自www.cnblogs.com/zhengyipengyou/p/9826723.html