1.腳本如下~
創(chuàng)新互聯(lián)公司是專業(yè)的龍崗網(wǎng)站建設(shè)公司,龍崗接單;提供成都網(wǎng)站制作、成都網(wǎng)站建設(shè),網(wǎng)頁設(shè)計,網(wǎng)站設(shè)計,建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進行龍崗網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!
- #!/bin/bash
- #=========================================
- #File: check_vm.sh
- #Description:
- #Author: smileliuyb
- #Modify: smileliuyb
- #Creation Date: 2013-1-14
- #Last Modified: 2013-1-14
- #=========================================
- #======check-arg===============
- if [[ $4 != "" ]];then
- echo $2 $4 | awk '$1 !~ /^[0-9]*[0-9,M,m,G,g]$/ || $2 !~ /^[0-9]*[0-9,m,g,M,G]$/{print "User like ./check_vm.sh -w freememory[M,G] -c freememory[M,G]";exit 3}'
- if [ $? -eq 3 ];then
- exit 3
- fi
- if [[ $1 == '-w' ]] && [[ $3 == '-c' ]];then
- warning=`echo $2 | awk '$1 ~ /[0-9]$/{print $1};$1 ~ /[m,M]$/{print $1*1024};$1 ~ /[g,G]$/{print $1*1024*1024}'`
- critical=`echo $4 | awk '$1 ~ /[0-9]$/{print $1};$1 ~ /[m,M]$/{print $1*1024};$1 ~ /[g,G]$/{print $1*1024*1024}'`
- elif [[ $1 == '-c' ]] && [[ $3 == '-w' ]];then
- warning=`echo $4 | awk '$1 ~ /[0-9]$/{print $1};$1 ~ /[m,M]$/{print $1*1024};$1 ~ /[g,G]$/{print $1*1024*1024}'`
- critical=`echo $2 | awk '$1 ~ /[0-9]$/{print $1};$1 ~ /[m,M]$/{print $1*1024};$1 ~ /[g,G]$/{print $1*1024*1024}'`
- else
- echo "User like ./check_vm.sh -w freememory[M,G] -c freememory[M,G]"
- exit 3
- fi
- else
- echo "User like ./check_vm.sh -w freememory[M,G] -c free[M,G]"
- exit 3
- fi
- #====see-mem and comparison with arg========
- freemem=`free -m | cut -d " " -f17`
- if [ $(( freemem*1024 )) -le $critical ];then
- echo "Insufficient memory,Only"$freemem"M are free!"
- exit 2
- elif [ $(( freemem*1024 )) -le $warning ];then
- echo "Memory Warning,Only"$freemem"M are free!"
- exit 1
- else
- echo "Memory OK"
- exit 0
- fi
網(wǎng)站欄目:為Nagios定義自定義腳本檢測內(nèi)存狀態(tài)
分享網(wǎng)址:http://www.rwnh.cn/article26/pcogjg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App開發(fā)、面包屑導航、Google、服務(wù)器托管、標簽優(yōu)化、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)