-エージェント側(server-agent)
1. php-fpmをダウンロードして設定します
[root@centos7 ~]# yum -y install php-fpm
[root@centos7 ~]# vim /etc/php-fpm.d/www.conf # 打开php-fpm的状态页面
- 以下を追加するだけです
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 512
pm.start_servers = 32
pm.min_spare_servers = 32
pm.max_spare_servers = 64
pm.max_requests = 1500
pm.status_path = /qfedu_monitor_page
slowlog = /var/log/php-fpm/$pool-slow_log
request_slowlog_timeout = 3
request_terminate_timeout = 20
catch_workers_output = no
security.limit_extensions = ""
2. php-fpmサービスを開きます
[root@centos7 ~]# systemctl start php-fpm
3. nginxを設定し、プロキシphpを設定し、php-fpmのステータスページを一致させます
[root@centos7 ~]# vim /etc/nginx/nginx.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
if ( $uri ~ "^/qfedu_monitor_page" ){
break; } # 避免监控的特殊URL被业务上的 REWRITE 规则重写
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|html)$ {
# 静态资源匹配
expires 1d; # 设置浏览器的缓存有效时间
}
location ~ /qfedu_monitor_page {
include /etc/nginx/fastcgi_params; # yum 安装方式
# include fastcgi.conf; # 编译安装用 fastcgi.conf 注意配置文件路径
fastcgi_pass 127.0.0.1:9000;
}
location / {
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params; # yum 安装方式
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
# include fastcgi.conf; # 编译安装用 fastcgi.conf 注意配置文件路径
fastcgi_pass 127.0.0.1:9000; # 使用了PHP-FPM 9000 端口的 POOL 配置。
}
4.ステータス情報ページをWebサイトのルートディレクトリにコピーします
[root@centos7 ~]# cp /usr/share/fpm/status.html /usr/share/nginx/html/
5. nginxサービスを開く
[root@centos7 ~]# systemctl start nginx
6.エージェント側で、ユーザーパラメータを設定します。
1.クエリip / url(192.168.49.171/qfedu_monitor_page)
2.設定
[root@centos7 ~]# cd /etc/zabbix/zabbix_agentd.d/
[root@centos7 ~]# vim php_status.conf
#
UserParameter=php-status[*], curl -s http://127.0.0.1/qfedu_monitor_page | awk '/^$1/{print $$NF}'
3.サービスを再起動します
[root@centos7 ~]# systemctl restart zabbix-agent
4. zabbix-server側で、このユーザーパラメータを使用してキーをクエリします
[root@centos7 ~]# zabbix_get -s 192.168.152.154 -p 10050 -k "php-status[accepted conn]"
7.テンプレートを作成し、テンプレートに4つのアイテム監視アイテムを作成し、定義されたユーザーパラメータを使用します
1.テンプレートを作成する
2.定義したユーザーパラメータを使用して、テンプレートのアイテム監視アイテムを構成します。
fpm.stats [合計プロセス]
3.いくつかのアイテム監視アイテムのクローンを作成します(名前とキー値を変更するだけです)
fpm.stats [アクティブなプロセス]
fpm.stats [最大アクティブプロセス]
fpm.stats [アイドルプロセス]
6.ホストホストリンクテンプレート
7.グラフを表示する
①php-fpmトータルプロセス
②php-fpmアクティブプロセス
③php-fpmmax active processes
④php-fpmアイドルプロセス
8.他のユーザーが使用できるテンプレートをエクスポートします
- 下部にあるエクスポート