当前位置: 亚洲城ca88 > 亚洲城 > 正文

网址并发数,怎么着用zabbix创立自定义监察和控

时间:2019-05-03 22:24来源:亚洲城
nginx配置新增加 location /php_fpm_status { allow 127.0.0.1; deny all; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }nginx需要reload 更加多Zabbix相关课程集

nginx配置新增加

location /php_fpm_status
        {
                allow 127.0.0.1;
                deny all;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
        }
nginx需要reload

更加多Zabbix相关课程集合: 

将此行注释去掉后,zabbix_agentd运营后会自动扫描/usr/local/etc/zabbix_agentd.conf.d/目录下具备的.conf文件,并加载。

测试看看能或无法获取到fpm的情状

curl 127.0.0.1/php_fpm_status
pool:                 www
process manager:      static
start time:           02/Jun/2017:17:45:05  0800
start since:          58677
accepted conn:        10753843
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       249
active processes:     1
total processes:      250
max active processes: 251
max children reached: 0
slow requests:        426

5: zabbix配置(vim /usr/local/zabbix/etc/zabbix_agentd.conf.d/fpm.conf):

图片 1

zabbix网页配置

fpm.status[conn]

 

督察fpm,首要教学监控动态并发数:
一: /usr/local/php/etc/php-fpm.conf fpm配置新增添:
pm.status_path = /php_fpm_status
fpm要求重启。

zabbix版本:3.0.三 操作系统:CentOS 7 mysql版本:5.7.1

肆、写脚本获取nginx的情事

监控脚本(/usr/local/zabbix/check_nginx.sh):
#!/bin/sh
#nginx status
#Active connections: 1 
#server accepts handled requests

#Reading: 0 Writing: 1 Waiting: 0 
while getopts "o:" opt
do
        case $opt in
                o ) option=$OPTARG;;
                ? )
                echo 'parameter is wrong!'
                exit 1;;
        esac
done
if [ ! "${option}" ];then
        echo "parameter is null"        
        exit 1
fi

if [[ ${option} == "active" ]];then
        curl -s 127.0.0.1/status |grep '^Active connections' |awk '{print $NF}'
elif [[ ${option} == "accepts" ]];then
        curl -s 127.0.0.1/status |awk 'NR==3'|awk '{print $1}'
fi

#!/bin/sh
#20170603 fpm status
#curl 127.0.0.1/php_fpm_status
#pool: www
#process manager: static
#start time: 02/Jun/2017:17:45:05 0800
#start since: 59022
#accepted conn: 10768453
#listen queue: 0
#max listen queue: 0
#listen queue len: 0
#idle processes: 249
#active processes: 1
#total processes: 250
#max active processes: 251
#max children reached: 0
#slow requests: 426
while getopts "o:" opt
do
case $opt in
o ) option=$OPTARG;;
? )
echo 'parameter is wrong!'
exit 1;;
esac
done
if [ ! "${option}" ];then
echo "parameter is null"
exit 1
fi

if [[ ${option} == "conn" ]];then
curl -s 127.0.0.1/php_fpm_status |grep '^accepted conn'|awk '{print $NF}'
elif [[ ${option} == "idle" ]];then
curl -s 127.0.0.1/php_fpm_status |grep '^idle processes'|awk '{print $NF}'
elif [[ ${option} == "active" ]];then
curl -s 127.0.0.1/php_fpm_status |grep '^active processes'|awk '{print $NF}'
fi

加上落成后得以见见新扩大监察和控制项如下:

6、zabbix网页配置

nginx.status[accepts] 整形(每秒差值)

督查fpm,首要教学监察和控制动态并发数

叁: 测试看看能还是不可能博得到fpm的图景
curl 127.0.0.1/php_fpm_status
pool: www
process manager: static
start time: 02/Jun/2017:17:45:05 0800
start since: 58677
accepted conn: 10753843
listen queue: 0
max listen queue: 0
listen queue len: 0
idle processes: 249
active processes: 1
total processes: 250
max active processes: 251
max children reached: 0
slow requests: 426

zabbix本人提供了很多可选的监督检查项,能够满意绝超越47%的监察必要。有时候是因为作业须求,需求自定义监察和控制项。 上边以成立mysql自定义监察和控制项为例,分享什么创设zabbix自定义监察和控制项。

/usr/local/php/etc/php-fpm.conf fpm配置新扩大

pm.status_path = /php_fpm_status
fpm需要重启。

Linux公社的RSS地址:

伍、web端增加监察和控制项: 在主机上增加监控项:
图片 2

三、测试下看看能或不可能博得nginx状态

curl 127.0.0.1/status

#!/bin/sh
#20170603 nginx status
#Active connections: 1
#server accepts handled requests
#1035268066 1035268066 1035136592
#Reading: 0 Writing: 1 Waiting: 0
while getopts "o:" opt
do
case $opt in
o ) option=$OPTARG;;
? )
echo 'parameter is wrong!'
exit 1;;
esac
done
if [ ! "${option}" ];then
echo "parameter is null"
exit 1
fi

if [[ ${option} == "active" ]];then
curl -s 127.0.0.1/status |grep '^Active connections' |awk '{print $NF}'
elif [[ ${option} == "accepts" ]];then
curl -s 127.0.0.1/status |awk 'NR==3'|awk '{print $1}'
fi

3、在/usr/local/etc/zabbix_agentd.conf.d/目录下增加监察和控制项配置文件get_mysql_status.conf,内容如下:

写脚本获取fpm的情景

监控脚本(/usr/local/zabbix/check_fpm.sh):
#!/bin/sh
#20170603 fpm status
#curl 127.0.0.1/php_fpm_status
#pool:                 www
#process manager:      static
#start time:           02/Jun/2017:17:45:05  0800
#start since:          59022
#accepted conn:        10768453
#listen queue:         0
#max listen queue:     0
#listen queue len:     0
#idle processes:       249
#active processes:     1
#total processes:      250
#max active processes: 251
#max children reached: 0
#slow requests:        426
while getopts "o:" opt
do
        case $opt in
                o ) option=$OPTARG;;
                ? )
                echo 'parameter is wrong!'
                exit 1;;
        esac
done
if [ ! "${option}" ];then
        echo "parameter is null"        
        exit 1
fi

if [[ ${option} == "conn" ]];then
curl -s 127.0.0.1/php_fpm_status |grep '^accepted conn'|awk '{print $NF}'
elif [[ ${option} == "idle" ]];then
curl -s 127.0.0.1/php_fpm_status |grep '^idle processes'|awk '{print $NF}'
elif [[ ${option} == "active" ]];then
curl -s 127.0.0.1/php_fpm_status |grep '^active processes'|awk '{print $NF}'
fi

4: 写脚本获取nginx的动静
监察和控制脚本(/usr/local/zabbix/check_nginx.sh):

剧本表达,脚本必要输入多少个参数分别是:mysql用户、mysql用户密码、mysql状态每一种目标如下: uptime:运营时间长度单位s、 threads:开启的对话数、 question(questions):服务器运转以来客户的主题材料(查询)数目 sq(Slow queries): 慢查询数量 open(opens):服务器已经开发的数额库表的数额 ftable(Flush tables):服务器已经实践的flush ...、refresh和reload命令的多寡 opent(open tables):通过命令是用的数据库的表的数据,以服务器运转上马 qps(Queries per second avg):select语句平均查询时间

2、nginx配置新增添

location /status {
                allow 127.0.0.1;
                deny all;
                stub_status on;
                access_log off;
        }
重启nginx:
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -s reload

ZABBIX 的事无巨细介绍:请点这里
ZABBIX 的下载地址:请点这里

Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf

五、zabbix配置(/usr/local/zabbix/etc/zabbix_agentd.conf.d/nginx.conf)

UserParameter=nginx.status[*],sh /usr/local/zabbix/check_nginx.sh -o $1
重启zabbix agentd(pkill zabbix_agentd; sleep 3; /usr/local/zabbix/sbin/zabbix_agentd )

二: nginx配置新增添:

原来的书文来自:

zabbix配置(vim /usr/local/zabbix/etc/zabbix_agentd.conf.d/fpm.conf)

UserParameter=fpm.status[*],sh /usr/local/zabbix/check_fpm.sh  -o $1
重启zabbix agent。pkill zabbix_agentd; sleep 3; /usr/local/zabbix/sbin/zabbix_agentd 

监察nginx,首要助教监控并发数:
一: nginx编写翻译参数:
--prefix=/usr/local/nginx --with-http_stub_status_module

图表预览:

一、 nginx编写翻译参数

监察nginx,首要教学监察和控制并发数

--prefix=/usr/local/nginx --with-http_stub_status_module

zabbix编写翻译参数的查阅:

/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.8.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module

陆: zabbix网页配置:
fpm.status[conn]

图片 3

四: 写脚本获取fpm的情形
监督检查脚本(/usr/local/zabbix/check_fpm.sh):

#zabbix_get -s 127.0.0.1 -k get_mysql_status[root,weiming,open]
   679

5: zabbix配置(/usr/local/zabbix/etc/zabbix_agentd.conf.d/nginx.conf):
UserParameter=nginx.status[*],sh /usr/local/zabbix/check_nginx.sh -o $1
重启zabbix agentd(pkill zabbix_agentd; sleep 3; /usr/local/zabbix/sbin/zabbix_agentd )

变成:

location /php_fpm_status
{
allow 127.0.0.1;
deny all;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
nginx需要reload

#!/bin/sh

case $3 in
uptime)
mysqladmin -u$1 -p$2 status 2>/dev/nul | awk -F '[:| ]'  '{print $2}'
;;
threads)
mysqladmin -u$1 -p$2 status 2>/dev/nul | awk -F '[:| ]'  '{print $4}'
;;
question)
mysqladmin -u$1 -p$2 status 2>/dev/nul | awk -F '[:| ]'  '{print $6}'
;;
sq)
mysqladmin -u$1 -p$2 status 2>/dev/nul | awk -F '[:| ]'  '{print $9}'
;;
open)
mysqladmin -u$1 -p$2 status 2>/dev/nul | awk -F '[:| ]'  '{print $11}'
;;
ftable)
mysqladmin -u$1 -p$2 status 2>/dev/nul | awk -F '[:| ]'  '{print $14}'
;;
opent)
mysqladmin -u$1 -p$2 status 2>/dev/nul | awk -F '[:| ]'  '{print $17}'
;;
qps)
mysqladmin -u$1 -p$2 status 2>/dev/nul | awk -F '[:| ]'  '{print $22}'
;;
*)

location /status {
allow 127.0.0.1;
deny all;
stub_status on;
access_log off;
}
重启nginx:
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -s reload

4、重启zabbix_agent和zabbix_server,使用zabbix_get测试,如下:

UserParameter=fpm.status[*],sh /usr/local/zabbix/check_fpm.sh -o $1
重启zabbix agent。pkill zabbix_agentd; sleep 3; /usr/local/zabbix/sbin/zabbix_agentd

背景:

正文永恒更新链接地址

得以完结步骤:

zabbix编写翻译参数的查看:
/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.8.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module

情状认证:

贰: nginx配置新增

1、修改 zabbix_agentd.conf,添加zabbix_agent 配置目录,以下是自家本机的zabbix的布局: 将以下行的注明去掉

三: 测试下看看能还是无法获取nginx状态
curl 127.0.0.1/status

贰、编写监察和控制脚本/usr/local/zabbix/zabbix-script/get_mysql_status.sh,脚本如下(脚本存放目录能够自定义):

陆: zabbix网页配置:
nginx.status[accepts] ×××(每秒差值)

#Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf

在Ubuntu 1陆.0四服务器上安装Zabbix 三.2 
CentOS 7LNMP情状搭建Zabbix三.0 
Ubuntu 1陆.0肆安装配备监督种类Zabbix二.四 
Zabbix监察和控制装置配备及警报配置 
Zabbix触发器表明式详解
Ubuntu 1陆.0四下安装配置Zabbix三.0 
CentOS 7 下 Zabbix 3.0安装详解
Zabbix 3.2.6 通过Orabbix监控Oracle数据库 
Zabbix3.四增添Web监测功用
Zabbix告警发送邮件时顺便质量图
Zabbix3.0编写翻译晋级历程记录
Debian 9.2安装Zabbix 3.4.2

增加图形:

图片 4

UserParameter=get_mysql_status[*],/usr/local/zabbix/zabbix-script/get_mysql_status.sh $1 $2 $3

图片 5

编辑:亚洲城 本文来源:网址并发数,怎么着用zabbix创立自定义监察和控

关键词: 亚洲城ca88