zhangsanfeng88 发表于 2019-1-12 13:47:12

nagios 监控xenserver cpu资源

cat check_xen_cpu.sh
#!/bin/sh

function usage()
{
      msg="$0 : use to check xenserver cpu usage for nagios"
      echo "****************************************************"
      echo -e "\033[1;94m${msg}\033[0m"
      echo -e "Usage:"
      echo -e "       $0 [-w warning -c critical]"
      echo -e "       $0 -w 80 -c 90 "
      echo "****************************************************"
}
if [ $# -eq 0 ];then
      warning=0.85
      critical=0.95
elif [ "$1" = "-w" ];then
      warning=`echo $2`
      shift
      shift
      if [ "$1" != "-c" ];then
                usage
                exit 1
      fi
      critical=`echo $2`
      shift
      shift
else
usage
exit 1
fi
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3

uuid_list=`xe host-cpu-list | grep uuid | awk '{print $5}'`
i=1
for uuid in $uuid_list
do
cpu_usage[$i]=`xe host-cpu-param-get param-name=utilisation uuid=$uuid`
let i=i+1
done
cpu_total=`echo ${cpu_usage[@]} | awk '{for(i=0;i
页: [1]
查看完整版本: nagios 监控xenserver cpu资源