💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
开启Nginx的Status页 ```shell location /ngx_status { stub_status on; access_log off; #allow 127.0.0.1; #deny all; } ``` 编写客户端脚本ngx_status.sh ``` #!/bin/bash # DateTime: 2015-10-25 HOST="127.0.0.1" PORT="80" # 检测nginx进程是否存在 function ping { /sbin/pidof nginx | wc -l } # 检测nginx性能 function active { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep 'Active' | awk '{print $NF}' } function reading { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep 'Reading' | awk '{print $2}' } function writing { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep 'Writing' | awk '{print $4}' } function waiting { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| grep 'Waiting' | awk '{print $6}' } function accepts { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| awk NR==3 | awk '{print $1}' } function handled { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| awk NR==3 | awk '{print $2}' } function requests { /usr/bin/curl "http://$HOST:$PORT/ngx_status/" 2>/dev/null| awk NR==3 | awk '{print $3}' } # 执行function $1 ``` 增加自定义文件 ```shell UserParameter=nginx.status[*],/app/scripts/ngx-status.sh $1 ``` Zabbix Server测试 ```shell zabbix_get -s 192.168.0.229 -k nginx.status[active] ``` 导入模板 备注:模板中的某些值是差值,要注意哦。 备注:本文内容来自于《运维生存时间》