• <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>

            大龍的博客

            常用鏈接

            統(tǒng)計

            最新評論

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

            學(xué)習(xí)本腳本時,請關(guān)注which command與while getopts命令。
            通過使用/usr/bin/procinfo或/usr/bin/sar命令獲取數(shù)據(jù)。
            以下腳本源自: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

            使用示例:
            一、被監(jiān)控機(jī)端
            將腳本保存在被監(jiān)控機(jī)的/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

            二、監(jiān)控機(jī)端
            增加如下的服務(wù)監(jiān)測
            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 大龍 閱讀(1478) 評論(0)  編輯 收藏 引用

            來源自網(wǎng)上,但最新本的nagios有問題,下面是修改后的。" trackback:ping="http://www.shnenglu.com/fwxjj/services/trackbacks/159149.aspx" /> -->

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久综合给合综合久久| 久久久无码精品亚洲日韩按摩| 大香网伊人久久综合网2020| 国产高清美女一级a毛片久久w| 欧美日韩中文字幕久久伊人| 久久综合视频网| 色欲久久久天天天综合网| 91久久精品电影| 99久久综合国产精品免费| 人妻无码久久一区二区三区免费| 亚洲国产精品久久电影欧美| 中文国产成人精品久久不卡| 亚洲级αV无码毛片久久精品| 久久精品国产精品青草| 精品午夜久久福利大片| 精品无码人妻久久久久久| 久久久国产乱子伦精品作者| 久久免费国产精品一区二区| 久久久久综合网久久| 久久久久亚洲AV成人片| 狠狠色狠狠色综合久久| 少妇人妻88久久中文字幕| 国产亚洲美女精品久久久2020| 亚洲精品视频久久久| 亚洲国产香蕉人人爽成AV片久久 | 伊人久久大香线焦AV综合影院| 国产精品99久久久久久猫咪| 久久久久高潮综合影院| 天天躁日日躁狠狠久久| 久久人人爽人人爽人人片AV不 | 久久精品a亚洲国产v高清不卡| 亚洲精品乱码久久久久久久久久久久 | 久久人人超碰精品CAOPOREN | 欧美伊香蕉久久综合类网站| A狠狠久久蜜臀婷色中文网| 久久精品一区二区三区中文字幕 | 亚洲国产另类久久久精品| 精品一区二区久久| 久久国产精品无码HDAV| 久久久噜噜噜久久| 久久精品国产亚洲Aⅴ蜜臀色欲|