Nagios 监控 Httpd 并发数插件

时间:2015-07-07 16:41:12   收藏:0   阅读:314
  1. 工作需要监控Httpd并发数,找不到合适的插件,花时间研究了一下Nagios监控内存的脚本,做了一些修改,完成了脚本。
    监控内存脚本:
    http://www.cnblogs.com/Mrhuangrui/p/4585615.html
  2. 监控Http并发数脚本代码如下:
    技术分享
    #!/bin/bash
    
    if [ "$1" = "-w" ] && [ "$2" -gt "0" ] && [ "$3" = "-c" ] && [ "$4" -gt "0" ]; then
    
            ip_conns=`netstat -na |grep ESTABLISHED |wc -l`
    
    
            if [ "$ip_conns" -ge "$4" ]; then
                    echo "HttpProcessList: CRITICAL connet counts is: $ip_conns |TOTAL=$ip_conns;"
                    $(exit 2)
            elif [ "$ip_conns" -ge "$2" ]; then
                    echo "HttpProcessList: WARNING connet counts is: $ip_conns |TOTAL=$ip_conns;"
                    $(exit 1)
            else
                    echo "HttpProcessList: OK connet counts is: $ip_conns |TOTAL=$ip_conns;"
                    $(exit 0)
            fi
    
    else
            echo "CheckHttpProcessList Error"
    fi
    CheckHttpdProcessList Code

    测试脚本./Check_httpd_processList.sh -w 60 -c 90

  3. 监控服务器测试
    cd /usr/lib64/nagios/plugins/
    ./check_nrpe -H 10.10.0.116 -c checkHttpdProcesslist

  4. 脚本中运用到了比较运算符
    Shell运算符详解
    http://blog.csdn.net/ithomer/article/details/6836382

原文:http://www.cnblogs.com/Mrhuangrui/p/4627225.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!