Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Zabbix adds nginx_status status monitoring

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Nginx added status monitoring to add locationlocation / status {in the nginx configuration file

Stub_status on

Access_log off

}

Add monitoring scripts on the agent side

#! / bin/bash

# Description:zabbix monitors nginx performance and process status

# Note: this script needs to be configured before being monitored: go! Control side, otherwise ping detection will get results that do not conform to expectations

HOST= "192.168.171.146"

PORT= "80"

# detect whether the nginx process exists

Function ping {

/ sbin/pidof nginx | wc-l

}

# testing nginx performance

Function active {

/ usr/bin/curl "http://$HOST:$PORT/status/" 2 > / dev/null | grep 'Active' | awk' {print $NF}'

}

Function reading {

/ usr/bin/curl "http://$HOST:$PORT/status/" 2 > / dev/null | grep 'Reading' | awk' {print $2}'

}

Function writing {

/ usr/bin/curl "http://$HOST:$PORT/status/" 2 > / dev/null | grep 'Writing' | awk' {print $4}'

}

Function waiting {

/ usr/bin/curl "http://$HOST:$PORT/status/" 2 > / dev/null | grep 'Waiting' | awk' {print $6}'

}

Function accepts {

/ usr/bin/curl "http://$HOST:$PORT/status/" 2 > / dev/null | awk NR==3 | awk'{print $1}'

}

Function handled {

/ usr/bin/curl "http://$HOST:$PORT/status/" 2 > / dev/null | awk NR==3 | awk'{print $2}'

}

Function requests {

/ usr/bin/curl "http://$HOST:$PORT/status/" 2 > / dev/null | awk NR==3 | awk'{print $3}'

}

# execute function

, 1

Remote testing

Sh / etc/zabbix/zabbix_agentd.d/ngx_status.sh active

Server-side testing

Zabbix_get-s 192.168.169.98-k nginx.status [active]

Modify agent configuration file

Timeout = 30

UnsafeUserParameters=1

UserParameter=nginx.status [*], / etc/zabbix/zabbix_agentd.d/ngx_status.sh $1

Restart the client service zabbix-agent restart

New monitoring items for zabbix:

Add triggers and graphics

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report