centos6.3,nginx环境(192.168.1.103)参考http://angus717.blog.51cto.com/1593644/999037 nginx部分。
cat /var/www/html/cacti/scripts/nginx_status.sh
# $1 Monitor Server addr
TEMPFILE=`mktemp /tmp/$1_nginx_status.XXXXXXXX`
wget -O $TEMPFILE http://$1/$NGINX_STATSUS 2&> /dev/null
nginx_reading=`tail -1 $TEMPFILE | awk '{print $2}'`
nginx_writing=`tail -1 $TEMPFILE | awk '{print $4}'`
nginx_waiting=`tail -1 $TEMPFILE | awk '{print $6}'`
nginx_accepts=`sed -n "3p" $TEMPFILE | awk '{print $1}'`
nginx_handled=`sed -n "3p" $TEMPFILE | awk '{print $2}'`
nginx_requests=`sed -n "3p" $TEMPFILE | awk '{print $3}'`
echo nginx_accepts:$nginx_accepts nginx_handIed:$nginx_handled nginx_requests:$nginx_requests nginx_active:$nginx_active nginx_reading:$nginx_reading nginx_writing:$nginx_writing nginx_waiting:$nginx_waiting
1,设置数据输入方式
点击Data Input Methods--->add; 设置如下
点create;由于我的脚本需要传递一个参数和输出7个参数,所有在点完create后要设置Input Fields,Output Fields,如下面3个图
点Data Templates-->Add
点Data Sources-->add,如下选择
点save
4,设置绘图模版
Graph Templates-->add,如下图
5,绘图
Graph Management-->add