zoukankan      html  css  js  c++  java
  • 监控nginx

    vi nginx_status.sh

    #!/bin/bash 

    HOST="127.0.0.1"

    PORT="9222"

    # 检测nginx进程是否存在

    function ping {

        /sbin/pidof nginx | wc -l

    }

    # 检测nginx性能

    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}'

    }

    # 执行function

    $1

    vi zabbix_agentd.conf

    UserParameter=nginx.status[*],/data/soft/zabbix/zabbix/scripts/nginx_status.sh $1

  • 相关阅读:
    MySQL
    MySQL -数据库备份
    MySQL
    MySQL
    MySQL
    MySQL
    MySQL
    MySQL
    MySQL
    53端口反弹shell
  • 原文地址:https://www.cnblogs.com/charon2/p/10349732.html
Copyright © 2011-2022 走看看