Nagios Monitoring XenServer Memery

Source: Internet
Author: User

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 [  "$"  =  "-W"  ];then        warning= ' echo $2 '          shift        shift         if [  "$"  !=  "-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&nbsp"$ 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;p rint 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


This article from "Month Child" blog, declined reprint!

Nagios Monitoring XenServer Memery

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.