• <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://www.shnenglu.com/fwxjj/services/trackbacks/159149.aspx" /> -->
            国产精品久久毛片完整版| 国产精品久久99| 国内精品伊人久久久久妇| 久久国产精品无| 色偷偷88888欧美精品久久久| AV无码久久久久不卡蜜桃| 国产亚洲色婷婷久久99精品| 老司机国内精品久久久久| 亚洲国产精品综合久久一线| 乱亲女H秽乱长久久久| 久久久久国产精品麻豆AR影院| 人妻少妇精品久久| 精品一区二区久久| 日产精品久久久久久久| 亚洲欧美精品伊人久久| 欧美精品国产综合久久| 99久久精品无码一区二区毛片| 久久国产色av免费看| 国产精品永久久久久久久久久| 77777亚洲午夜久久多人| 国产精品99久久久久久宅男| 欧美噜噜久久久XXX| 少妇无套内谢久久久久| 亚洲狠狠久久综合一区77777 | 国产精品久久久福利| 久久精品人妻中文系列| 久久久久这里只有精品| 国内精品久久久久久久coent | 国产午夜福利精品久久2021| 精品久久久中文字幕人妻 | 狠狠色综合久久久久尤物| 精品国产乱码久久久久久郑州公司| 久久精品国产99久久久古代| 久久免费99精品国产自在现线| 久久伊人精品青青草原高清| 久久夜色精品国产欧美乱| 久久精品国产免费观看三人同眠| 亚洲色欲久久久久综合网| 伊人久久大香线蕉无码麻豆| 午夜福利91久久福利| 久久性精品|