centos nagios监控linux主机监控内存脚本
2017-04-01 09:35
543 查看
阅读目录说明一、nrpe.cfg中添加脚本二、添加具体脚本三、重启nrpe四、在监控端添加监控项
说明:实际内存使用量超过80%警告;超过90%严重警告
说明
工作包括两部分 监控端(一二三)和 被监控端(四)一、nrpe.cfg中添加脚本
nrpe.cfg中添加命令索引二、添加具体脚本
check_used_mem.sh# $1 = 80warn=$1
# $2 = 90critical=$2#free -m#--------------------------------------------------------------------------------# total used free shared buff/cache available#Mem: 3781 1506 557 16 1716 2000#Swap: 3983 0 3983#第二行 第二列total=`free -m | sed -n '2p' | awk '{print $2}'`#第二行 第三列used=`free -m| sed -n '2p' | awk '{print $3}'`#第二行 第四列free=`free -m| sed -n '2p' | awk '{print $4}'`let "c=$used*100/$total"if [[ $c -lt $warn ]]thenecho "used/total($c%) < $warn% [free:$free MB,used:$used MB,total:$total MB]"exit 0elif [[ $c -lt $critical ]]thenecho "used/total($c%) ≥$warn% [free:$free MB,used:$used MB,total:$total MB]"exit 1elseecho "used/total($c%) ≥$critical% [free:$free MB,used:$used MB,total:$total MB]"exit 2fi解释:1. free用来查看内存的使用情况total 内存总数: 3072used 已经使用的内存数: 2459free 空闲的内存数: 612shared 当前已经废弃不用,总是0buffers: Buffer Cache内存数: 13220cached: Page Cache内存数: 2720160关系:total = used + free2. sed -n '2p'指的是查找第二行3. awk '{print $2} 指的是第二列,其中默认以空格分隔。可以利用-F指定分隔符
$echo 1b234b56b7 | awk -F 'b' '{print $2}'2344. 实用[[ ]],< 用来比较字符串;-lt 用来比较数字
三、重启nrpe
四、在监控端添加监控项
define service {use local-servicehost_name server1,server2service_description 内存check_command check_nrpe!check_used_memnotifications_enabled 1}
相关文章推荐
- nagios监控linux主机监控内存脚本
- shell脚本监控linux系统内存使用情况的方法(不使用nagios监控linux)
- shell脚本监控linux系统内存使用情况的方法(不使用nagios监控linux)
- centos6.2 使用nagios nrpe监控本地与远程Linux主机
- centos6.4 x64 Nagios监控平台:监控linux主机的CPU温度
- 在nagios中使用python脚本监控linux主机
- nagios配置——添加linux主机监控 推荐
- 网络监控软件Nagios, Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设备,打印机等。在系统或服务状态异常时发出邮件或短信报
- Nagios之NRPE监控Linux/UNIX主机
- [Linux] linux服务器主机性能、空间监控脚本
- nagios-创建内存监控脚本及监控内存
- 【Shell/Python】Linux 进程自动监控bash shell脚本 监控VPS服务器负载/CPU及内存占用 自动重启
- linux系统CPU,内存,磁盘,网络流量监控脚本
- nagios监控Linux主机
- Nagios配置——添加Linux主机监控
- Nagios监控内存脚本(include warning and critical)
- nagios监控linux主机及服务信息
- nagios脚本监控内存使用情况
- Nagios监控平台之五:监控linux主机的CPU温度
- linux 监控内存变化脚本