Nagios Monitors host memory usage

Source: Internet
Author: User

#!/bin/bashstat_ok=0stat_warning=1stat_critical=2stat_unknown=3total_mem= ' free -m |awk  ' NR==2{ print $2} ' used_mem= ' free -m |awk  ' nr==3{print $3} '  free_mem=$[$total _mem  -  $used _mem]use_percent= ' echo  $total _mem  $used _mem|awk  ' {print  ($2 / $1) * [+] ' use_per= ' echo  $use _percent|awk  ' {print int ($)} ' Help ()  {         echo  "USAGE: ' basename $0 '  [-w] <used percent> [-c] &NBSP;&LT;USED&NBSP;PERCENT&GT;&NBSP;[-H] "        exit -1}warning =80critical=90while getopts  "W:c:h"  optdo        case   $opt  in                &NBSP;W)       warning= $OPTARG                          ;; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;C)        critical= $OPTARG                          ;; &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;H)        help                         ;;                 *)        unkown= $OPTARG                          echo  "Error,plase check  for help,usage:./' basename $0 '  -h '                          exit  $STAT _unknown                          ;;         esacdoneif [  $use _per -lt  $warning  ]; then        echo  "Ok - total: $total _mem mb,used:$ Used_mem mb,free: $free _mem mb | total_mem= $total _mem used_mem= $used _mem free_mem = $free _mem "        exit  $STAT _okelif [  $use _per - ge  $warning  ] && [  $use _per -lt  $critical  ]then                  echo  "WarninG - total: $total _mem mb,used: $used _mem mb,free: $free _mem mb | total_mem=$ total_mem used_mem= $used _mem free_mem= $free _mem "                  exit  $STAT _warningelse                  echo  "critical -  Total: $total _mem mb,used: $used _mem mb,free: $free _mem mb | total_mem= $total _mem  used_mem= $used _mem free_mem= $free _mem "                  exit  $STAT _critical        fi

Nagios monitors host memory usage

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.