1、目标
获取nginx运行状态
2、脚本说明
elink是一个文本浏览器,需要事先安装;
nginx要配置好status模块。
3、脚本内容
#!/bin/bash
# Set Variables
#定义host、端口、和nginxstatus的访问路径
HOST=127.0.0.1
webstatus=nginx-status
PORT="80"
# Functions to return nginx stats
function active {
elinks -no-home -source "" | grep 'Active' | awk '{print $NF}'
}
function reading {
elinks -no-home -source "" | grep 'Reading' | awk '{print $2}'
}
function writing {
elinks -no-home -source "" | grep 'Writing' | awk '{print $4}'
}
function waiting {
elinks -no-home -source "" | grep 'Waiting' | awk '{print $6}'
}
function accepts {
elinks -no-home -source "" | awk NR==3 | awk '{print $1}'
}
function handled {
elinks -no-home -source "" | awk NR==3 | awk '{print $2}'
}
function requests {
elinks -no-home -source "" | awk NR==3 | awk '{print $3}'
}
# Run the requested function
$1
阅读(1713) | 评论(0) | 转发(0) |