zabbix 监控lnmp

添加监控服务httpd

点server2 -> 模板 -> 选择 -> Template App HTTP Service

zabbix监控LNMP架构
zabbix监控LNMP架构
zabbix监控LNMP架构

Nginx:

[[email protected] ~]# tar zxf nginx-1.16.0.tar.gz 
[[email protected] ~]# yum install gcc make pcre-devel zlib-devel -y
[[email protected] nginx-1.16.0]# vim auto/cc/gcc 

zabbix监控LNMP架构

[[email protected] nginx-1.16.0]# ./configure --prefix=/usr/local/nginx  --with-http_stub_status_module
[[email protected] nginx-1.16.0]# make && make install

配置文件,开启nginx服务

[[email protected] nginx-1.16.0]# vim /usr/local/nginx/conf/nginx.conf
        location /status {
                stub_status on;    ##用于查看nginx信息
                access_log off;
                allow 127.0.0.1;
                deny all;
        }
[[email protected] nginx-1.16.0]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[[email protected] nginx-1.16.0]# /usr/local/nginx/sbin/nginx 

使用curl查看

[[email protected] nginx-1.16.0]# curl http://127.0.0.1/status
Active connections: 1 
server accepts handled requests
 2 2 1 
Reading: 0 Writing: 1 Waiting: 0 

#过滤出活跃连接数

[[email protected] nginx-1.16.0]# curl -s http://127.0.0.1/status | grep Active | awk '{print $3}'
#过滤出请求次数
curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $1}'

#添加监控项

[[email protected] nginx-1.16.0]# cd /etc/zabbix/zabbix_agentd.d/
[[email protected] zabbix_agentd.d]# ls
userparameter_mysql.conf
[[email protected] zabbix_agentd.d]# scp userparameter_mysql.conf userparameter_nginx.conf 
[[email protected] zabbix_agentd.d]# vim userparameter_nginx.conf 
UserParameter=nginx.active,curl -s http://127.0.0.1/status | grep Active | awk '{print $3}'
UserParameter=nginx.access,curl -s http://127.0.0.1/status | awk NR==3 | awk '{print $1}'

[[email protected] zabbix_agentd.d]# systemctl restart zabbix-agent

在server1 测试

[[email protected] ~]# zabbix_get -s 172.25.76.2 -p 10050 -k "nginx.active"
1
[[email protected] ~]# zabbix_get -s 172.25.76.2 -p 10050 -k "nginx.access"
19

在web中添加
添加监控项
zabbix监控LNMP架构
zabbix监控LNMP架构

zabbix监控LNMP架构
zabbix监控LNMP架构
zabbix监控LNMP架构
#改字体

[[email protected] fonts]# ls
graphfont.ttf  simkai.ttf
[[email protected] fonts]# pwd
/usr/share/zabbix/fonts
[[email protected] include]# pwd
/usr/share/zabbix/include
[[email protected] include]# vim defines.inc.php 
:$s/graphfont/simkai/g

zabbix监控LNMP架构

因为zabbix自带的项目太少所以向zabbix监控中导入模版监控mysql的模版percona

配置mysql

[[email protected] zabbix_agentd.d]# mkdir /var/lib/zabbix
[[email protected] zabbix_agentd.d]# cd /var/lib/zabbix/
[[email protected] zabbix]# vim .my.cnf
[mysql]
host = localhost
user = root
password = redhat
socket = /var/lib/mysql/mysql.sock

[mysqladmin]
host = localhost
user = root
password = redhat
socket = /var/lib/mysql/mysql.sock


[[email protected] zabbix]# systemctl restart zabbix-agent
[[email protected] zabbix安装包]# rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm 
[[email protected] zabbix安装包]# cd /var/lib/zabbix/
[[email protected] zabbix]# ls
percona
[[email protected] zabbix]# cd percona/templates/
[[email protected] templates]# ls
userparameter_percona_mysql.conf
zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml
[[email protected] templates]# cp userparameter_percona_mysql.conf  /etc/zabbix/zabbix_agentd.d/

[[email protected] percona]# cd scripts/
[[email protected] scripts]# vim ss_get_mysql_stats.php.cnf
<?php
$mysql_user = 'root';
$mysql_pass = 'redhat';
[[email protected] scripts]# systemctl restart zabbix-agent

#测试

[[email protected] zabbix_agentd.d]# /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh gg
19

倒入模板
zabbix监控LNMP架构
添加模板

zabbix监控LNMP架构

zabbix监控LNMP架构

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-05
  • 2021-12-09
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2021-04-28
  • 2021-08-22
  • 2021-08-08
  • 2022-02-10
  • 2022-12-23
  • 2021-08-04
相关资源
相似解决方案