nagios 監控xenserver memery

來源:互聯網
上載者:User

標籤:nagios xen memery

cat check_xen_mem.sh#!/bin/shfunction usage(){        msg="$0 : use to check xenserver memery 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.95elif [ "$1" = "-w" ];then        warning=`echo $2`        shift        shift        if [ "$1" != "-c" ];then                usage                exit 1        fi        critical=`echo $2`        shift        shiftelseusage exit 1fiSTATE_OK=0STATE_WARNING=1STATE_CRITICAL=2STATE_UNKNOWN=3uuid_list=`xe host-list | grep uuid | awk ‘{print $5}‘`i=1for uuid in $uuid_listdoeach_mem_total[$i]=`xe host-param-get param-name=memory-total uuid=$uuid`each_mem_free[$i]=`xe host-param-get param-name=memory-free uuid=$uuid`let i=i+1donemem_total=`echo ${each_mem_total[@]} | awk ‘{for(i=0;i<NF;i++) total+=$i; print total/1024/1024/1024}‘`mem_free=`echo ${each_mem_free[@]} | awk ‘{for(i=0;i<NF;i++) free+=$i;print free/1024/1024/1024}‘`#mem_usage=$(((mem_total-mem_free)/mem_total))mem_usage=`awk -v a=$mem_total -v b=$mem_free ‘BEGIN{printf "%.2f",(a-b)/a }‘`host_num=${#each_mem_total[@]}performance="$host_num host; usage: $mem_usage; free: $mem_free | mem_usage=$mem_usage;$warning;$critical;0;100;mem_free=$mem_free;;;;;"function cmp_data(){if [ $1 \< $2 ];thenecho "OK $performance"exit_code=$STATE_OKelif [ $1 \> $3 ];thenecho "CRITICAL $performance"exit_code=$STATE_CRITICALelseecho "WARNING $performance"exit_code=$STATE_WARNINGfi}cmp_data $mem_usage $warning $criticalexit $exit_code


本文出自 “月童” 部落格,謝絕轉載!

nagios 監控xenserver memery

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.