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

            來源自網上,但最新本的nagios有問題,下面是修改后的。" trackback:ping="http://www.shnenglu.com/fwxjj/services/trackbacks/159149.aspx" /> -->
            婷婷久久香蕉五月综合加勒比| 久久se这里只有精品| 噜噜噜色噜噜噜久久| 亚洲欧美伊人久久综合一区二区 | 久久免费视频一区| 久久99国产综合精品| 久久婷婷人人澡人人| 中文字幕久久精品无码| 久久久中文字幕日本| 性高湖久久久久久久久| 性做久久久久久久久久久| 久久久久国产一级毛片高清版| 性高湖久久久久久久久AAAAA| 久久超乳爆乳中文字幕| 人妻精品久久久久中文字幕一冢本| 国产精品99久久久久久宅男小说| 无码精品久久一区二区三区 | 亚洲AV成人无码久久精品老人| 国産精品久久久久久久| 久久精品国产亚洲欧美| 国产精品久久波多野结衣| 久久国产热精品波多野结衣AV| 热综合一本伊人久久精品| 国产福利电影一区二区三区久久老子无码午夜伦不| 久久人妻少妇嫩草AV蜜桃| 久久精品中文无码资源站| 亚洲AV伊人久久青青草原| 国产L精品国产亚洲区久久| 久久久91精品国产一区二区三区| 久久天天躁狠狠躁夜夜avapp| 中文字幕日本人妻久久久免费| 久久青青草视频| 久久人做人爽一区二区三区| 香蕉aa三级久久毛片| 无码国内精品久久综合88 | yellow中文字幕久久网| 久久精品国内一区二区三区| 欧美亚洲国产精品久久蜜芽| 国产免费久久精品99久久| 久久精品国产精品亚洲下载| 国产精品久久久香蕉|