• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            大龍的博客

            常用鏈接

            統計

            最新評論

            nagios監控腳本編寫-監控cpu使用率--->來源自網上,但最新本的nagios有問題,下面是修改后的。

            學習本腳本時,請關注which command與while getopts命令。
            通過使用/usr/bin/procinfo或/usr/bin/sar命令獲取數據。
            以下腳本源自:exchange.nagios.org。

            #!/bin/sh
            # Filename: check_cpu.sh
            # Version 0.0.2 - Jan/2009
            # Changes: improved grabbing of the idle cpu time
            #
            # by Thiago Varela - thiago@iplenix.com

            procinfo=`which procinfo 2>/dev/null`
            sar=`which sar 2>/dev/null`

            function help {
             echo -e "\n\tThis plugin shows the % of used CPU, using either procinfo or sar (whichever is available)\n\n\t$0:\n\t\t-c <integer>\tIf the % of used CPU is above <integer>, returns CRITICAL state\n\t\t-w <integer>\tIf the % of used CPU is below CRITICAL and above <integer>, returns WARNING state\n"
             exit -1
            }

            # Getting parameters:
            while getopts "w:c:h" OPT; do
             case $OPT in
              "w") warning=$OPTARG;;
              "c") critical=$OPTARG;;
              "h") help;;
             esac
            done

            # Checking parameters:
            ( [ "$warning" == "" ] || [ "$critical" == "" ] ) && echo "ERROR: You must specify warning and critical levels" && help
            [[ "$warning" -ge  "$critical" ]] && echo "ERROR: critical level must be highter than warning level" && help

            # Assuring that the needed tools exist:
            ( ( [ -f $procinfo ] && command="procinfo") ||  [ -f $sar ] ) || \
             ( echo "ERROR: You must have either procinfo or sar installer in order to run this plugin" && exit -1 )

            # Doing the actual check:
            ( [ "$command" == "procinfo" ] && idle=`$procinfo | grep idle | cut -d% -f1 | awk '{print $NF}' | cut -d. -f1`) || \
             idle=`$sar | tail -1 | awk '{print $7}' | cut -d. -f1`

            used=`expr 100 - $idle`

            # Comparing the result and setting the correct level:
            if [[ $used -ge $critical ]]; then
                    msg="CRITICAL"
                    status=2
            else if [[ $used -ge $warning ]]; then
                    msg="WARNING"
                    status=1
                 else
                    msg="OK"
                    status=0
                 fi
            fi

            # Printing the results:
            echo "$msg - CPU used=$used% idle=$idle% | 'CPU Usage'=$used%;$warning;$critical;"

            # Bye!
            exit $status

            使用示例:
            一、被監控機端
            將腳本保存在被監控機的/usr/local/nagios/libexec目錄中。
            #chown nagios.nagios check_cpu.sh

            編輯/usr/local/nagios/etc/nrpe.cfg,增加如下命令行:
            command[check_cpu_233]=/usr/local/nagios/libexec/check_cpu.sh -w 60 -c 80

            二、監控機端
            增加如下的服務監測
            define service{
               host_name              client-233
               use                           generic-service
               check_command       check_nrpe!check_cpu_233
               service_description    check_cpu_233
               notifications_enabled  1
               event_handler_enabled  1
               notification_period    24x7
               check_period           24x7
               max_check_attempts     3
               check_interval         5
               contact_groups         tech-admins
               retry_check_interval   2
               notification_options   w,u,c
            }

            posted on 2011-10-26 20:54 大龍 閱讀(1477) 評論(0)  編輯 收藏 引用

            來源自網上,但最新本的nagios有問題,下面是修改后的。" trackback:ping="http://m.shnenglu.com/fwxjj/services/trackbacks/159149.aspx" /> -->
            久久99精品久久久久久齐齐| 亚洲AV日韩精品久久久久久| 国产精品美女久久久久网| 国产精品久久波多野结衣| segui久久国产精品| 狠狠色婷婷久久综合频道日韩| 久久婷婷五月综合成人D啪| 久久国产免费| 亚洲综合熟女久久久30p| 亚洲国产天堂久久综合网站| 欧美一级久久久久久久大| 久久精品亚洲一区二区三区浴池 | 无码人妻久久一区二区三区| 国产高潮国产高潮久久久| 蜜桃麻豆www久久国产精品| 久久精品亚洲一区二区三区浴池 | 久久久噜噜噜久久中文福利| 亚洲欧美日韩精品久久| 亚洲欧美日韩中文久久| 久久国产一片免费观看| 欧美久久综合性欧美| 久久久久亚洲av无码专区| 2019久久久高清456| 99久久婷婷国产综合精品草原| 精品国产99久久久久久麻豆 | 欧美日韩精品久久久免费观看| 久久99精品国产自在现线小黄鸭 | 精品久久综合1区2区3区激情| 无码伊人66久久大杳蕉网站谷歌| 国产真实乱对白精彩久久| 久久久国产乱子伦精品作者| 欧美精品九九99久久在观看| 国产精品九九久久精品女同亚洲欧美日韩综合区| 老男人久久青草av高清| 97香蕉久久夜色精品国产 | 亚洲色欲久久久久综合网| 99热精品久久只有精品| 天天久久狠狠色综合| 99久久久精品| 国产精品免费久久久久久久久| 久久精品国产亚洲一区二区三区|