• <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)計(jì)

            最新評論

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

            學(xué)習(xí)本腳本時(shí),請關(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 大龍 閱讀(1474) 評論(0)  編輯 收藏 引用

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

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


            亚洲伊人久久综合影院| 久久精品99久久香蕉国产色戒 | 久久精品aⅴ无码中文字字幕不卡| 亚洲七七久久精品中文国产| 最新久久免费视频| 久久亚洲精精品中文字幕| 国产精品久久久久9999| 久久久久九九精品影院| 久久免费看黄a级毛片| 精品久久久久久无码中文字幕一区| 国产精品久久自在自线观看| 999久久久国产精品| 久久国产亚洲精品| 欧美亚洲国产精品久久蜜芽| 欧美久久亚洲精品| 国产精品久久久久久吹潮| 久久久久亚洲精品无码网址| 人妻无码久久一区二区三区免费| 国产精品青草久久久久福利99| 伊人久久大香线蕉综合Av| 国内精品欧美久久精品| 国产精品无码久久综合| 婷婷久久综合| 狠狠人妻久久久久久综合| 国产∨亚洲V天堂无码久久久| 热99RE久久精品这里都是精品免费 | 久久免费国产精品一区二区| 国内精品综合久久久40p| 久久中文精品无码中文字幕| 久久久久夜夜夜精品国产| 久久久久亚洲AV片无码下载蜜桃 | 一本一本久久A久久综合精品| 久久国产精品国语对白| Xx性欧美肥妇精品久久久久久| 97热久久免费频精品99| AAA级久久久精品无码片| 久久亚洲国产成人精品性色| 久久综合久久自在自线精品自| 久久久久亚洲AV成人网人人网站 | 国产精品久久久久久久久软件| 久久精品一区二区影院|