成都网站建设设计

将想法与焦点和您一起共享

nagios插件监控cpu,可pnp画图-创新互联

check_cpu 是依据从exchange.nagios.org 的脚本修改的。使用原始脚本结构,函数名称、参数也没怎么变化,有看到的,勿拍砖。

10年积累的做网站、成都网站制作经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有浉河免费网站建设让你可以放心的选择与我们合作。

#!/bin/bash

ST_OK=0

ST_WR=1

ST_CR=2

ST_UK=3

PROGNAME=`basename $0`

warning=$2

critical=$4

process=$6

get_wcdiff() {

  if [ ! -z "$warning" -a ! -z "$critical" ]

  then

    wclvls=1

    if [ ${warning} -gt ${critical} ]

    then

      wcdiff=1

    fi

  elif [ ! -z "$warning" -a -z "$critical" ]

  then

    wcdiff=2

  elif [ -z "$warning" -a ! -z "$critical" ]

  then

    wcdiff=3

  fi

}

val_wcdiff() {

  if [ "$wcdiff" = 1 ]

  then

    echo "Please adjust your warning/critical thresholds. The warning must be lower than the critical level!"

    exit $ST_UK

  elif [ "$wcdiff" = 2 ]

  then

    echo "Please also set a critical value when you want to use warning/critical thresholds!"

    exit $ST_UK

  elif [ "$wcdiff" = 3 ]

  then

    echo "Please also set a warning value when you want to use warning/critical thresholds!"

    exit $ST_UK

  fi

}

get_vals() {

  tmp_output=$(top -n 1 -b | grep $process )

  top_cpu=$(echo ${tmp_output} | awk '{print $9}')

  int_cpu=$(echo ${top_cpu%.*})

}

do_perfdata() {

perfdata="cpu=${top_cpu}%"

}

get_wcdiff

val_wcdiff

get_vals

do_perfdata

if [ -n "$warning" -a -n "$critical" ]

then

  if [ "$int_cpu" -ge "$warning" -a "$int_cpu" -lt "$critical" ]

  then

    echo "WARNING - ${perfdata} | ${perfdata}"

exit $ST_WR

  elif [ "$int_cpu" -ge "$critical" ]

  then

    echo "CRITICAL - ${perfdata} | ${perfdata}"

exit $ST_CR

  else

    echo "OK - ${perfdata} | ${perfdata} "

exit $ST_OK

  fi

else

  echo "Usage Example: $PROGNAME -w 3 -c 12 -p firefox "

  exit $ST_OK

fi

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前标题:nagios插件监控cpu,可pnp画图-创新互联
标题URL:http://chengdu.cdxwcx.cn/article/dgdppi.html