nagios插件之监控内存使用率(centos7)

centos7使用的free命令版本更新后,和centos6的显示结果有差异,导致check_mem.sh脚本执行失败,研究调整后执行正常,上传不了,check_mem_r7.sh新版本,check_mem.sh老版本。

 

[root@TSP-GGLC-MQAINT ]# free -V
procps version 3.2.8

[root@TSP-GGLC-MQAINT ]# free -m
             total       used       free     shared    buffers     cached
Mem:         64418       9374      55044          0        319       8019
-/+ buffers/cache:       1035      63383
Swap:         9999          0       9999
[root@TSP-GGLC-MQAINT ]# 

[root@onlinestore-nginx02 ]# free -V
free from procps-ng 3.3.10

[root@onlinestore-nginx02 ]# free -m
              total        used        free      shared  buff/cache   available
Mem:          63867        1503         526        3099       61837       58827
Swap:         36863          17       36846
[root@onlinestore-nginx02 ]# 


调整内容如下:井号开头是原来的,下面行是新增的

 

 

memory=$(free -mt)
 (( DEBUG )) && echo "memory=$memory"

##phyTotal=$(cut -d' ' -f  8 <<< $memory)
phyTotal=$(echo $memory | cut -d ' ' -f 8)
 (( DEBUG )) && echo "phyTotal=$phyTotal"
##swpTotal=$(cut -d' ' -f 19 <<< $memory)
swpTotal=$(echo $memory | cut -d ' ' -f 15)
 (( DEBUG )) && echo "swpTotal=$swpTotal"
##phyShared=$(cut -d' ' -f 11 <<< $memory)
phyShared=$(echo $memory | cut -d' ' -f 11)
 (( DEBUG )) && echo "phyShared=$phyShared"
##phyBuffers=$(cut -d' ' -f 12 <<< $memory)
phyBuffers=$(awk '{if($1~"Buffers:") printf("%d\n",$2/1024)}' /proc/meminfo)
 (( DEBUG )) && echo "phyBuffers=$phyBuffers"
##phyCached=$(cut -d' ' -f 13 <<< $memory)
phyCached=$(awk '{if($1~"^Cached:") printf("%d\n",$2/1024)}' /proc/meminfo)
 (( DEBUG )) && echo "phyCached=$phyCached"
##phyUsed=$(cut -d' ' -f 16 <<< $memory)
phyUsed=$(echo $memory | cut -d ' ' -f 9)
 (( DEBUG )) && echo "phyUsed=$phyUsed"
##phyAllUsed=$(cut -d' ' -f 9 <<< $memory)
phyAllUsed=$(echo $memory | cut -d' ' -f 9)
 (( DEBUG )) && echo "phyAllUsed=$phyAllUsed"
##swpUsed=$(cut -d' ' -f 20 <<< $memory)
swpUsed=$(echo $memory | cut -d' ' -f 16)
 (( DEBUG )) && echo "swpUsed=$swpUsed"

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值