• <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 大龍 閱讀(1476) 評論(0)  編輯 收藏 引用

            來源自網上,但最新本的nagios有問題,下面是修改后的。" trackback:ping="http://m.shnenglu.com/fwxjj/services/trackbacks/159149.aspx" /> -->
            亚洲精品乱码久久久久久久久久久久 | 久久久久久久综合狠狠综合| 狠狠精品久久久无码中文字幕| 国产激情久久久久影院老熟女免费 | 亚洲香蕉网久久综合影视| 亚洲精品无码久久久久sm| 久久久久国产精品熟女影院| 97久久精品国产精品青草| 91精品国产综合久久精品| 久久伊人色| 97超级碰碰碰久久久久| 久久婷婷五月综合色99啪ak| 欧美大香线蕉线伊人久久| 久久精品国产影库免费看| 亚洲精品国产自在久久| 韩国三级大全久久网站| 国产精品成人久久久| 91久久国产视频| 午夜天堂精品久久久久| 久久久免费观成人影院| 精品永久久福利一区二区| 久久久午夜精品福利内容| 久久久久久狠狠丁香| 亚洲第一极品精品无码久久 | 久久久WWW成人免费毛片| 久久99精品久久久久久动态图| 狠狠色丁香婷婷久久综合| 久久九九久精品国产| 久久亚洲欧美日本精品| 91精品国产高清91久久久久久| 亚洲AV日韩精品久久久久久久| 九九精品久久久久久噜噜| 久久久免费观成人影院| 品成人欧美大片久久国产欧美... 品成人欧美大片久久国产欧美 | 国产成人精品久久综合| 国产精品禁18久久久夂久| av色综合久久天堂av色综合在| 一个色综合久久| 久久精品国产亚洲AV忘忧草18 | 久久久久国产一级毛片高清板 | 国产成人久久精品二区三区|