最简单的nagios监控内存插件(shell)
2012-12-12 20:40
477 查看
首先看下内存信息吧
[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 249 235 14 0 3 96
-/+ buffers/cache: 134 114
Swap: 2047 43 2003
一句话思路,取可用内存值(free)
free -m | awk 'NR==3{print $4}' 简单的取第三行第四列的值
#!/bin/bash
a=`free -m | awk 'NR==3{print $4}'`
if [ $a -ge 100 ]; then 大于等于100
echo $a
exit 0
elif [ $a -lt 100 ] && [ $a -gt 50 ];then 大于50小于100
echo $a
exit 1
else
echo $a
exit 2
fi
根据情况取值比如mem_free + cached,也可写成根据百分比判断
保存自定义插件到nagios下的插件目录 /usr/local/nagios/libexec/check_mem
配置/usr/local/nagios/etc/objects/localhost.cfg
define host {
host_name shenmeh
alias server1
address 192.168.1.129
check_command check-host-alive
notification_options d,r
check_interval 1
max_check_attempts 2
contact_groups admins
notification_interval 1
notification_period 24x7
}
define service {
host_name shenmeh
service_description server1_apache_mem
check_period 24x7
normal_check_interval 2
retry_check_interval 1
max_check_attempts 2
notification_period 24x7
notification_options w,u,c,r
check_command check_mem
}
配置/usr/local/nagios/etc/objects/commands.cfg
# 'check_mem' command definition
define command{
command_name check_mem
command_line $USER1$/check_mem
}
本文出自 “拿了你的泥” 博客,请务必保留此出处http://shenmeh.blog.51cto.com/6231527/1087477
[root@localhost ~]# free -m
total used free shared buffers cached
Mem: 249 235 14 0 3 96
-/+ buffers/cache: 134 114
Swap: 2047 43 2003
一句话思路,取可用内存值(free)
free -m | awk 'NR==3{print $4}' 简单的取第三行第四列的值
#!/bin/bash
a=`free -m | awk 'NR==3{print $4}'`
if [ $a -ge 100 ]; then 大于等于100
echo $a
exit 0
elif [ $a -lt 100 ] && [ $a -gt 50 ];then 大于50小于100
echo $a
exit 1
else
echo $a
exit 2
fi
根据情况取值比如mem_free + cached,也可写成根据百分比判断
保存自定义插件到nagios下的插件目录 /usr/local/nagios/libexec/check_mem
配置/usr/local/nagios/etc/objects/localhost.cfg
define host {
host_name shenmeh
alias server1
address 192.168.1.129
check_command check-host-alive
notification_options d,r
check_interval 1
max_check_attempts 2
contact_groups admins
notification_interval 1
notification_period 24x7
}
define service {
host_name shenmeh
service_description server1_apache_mem
check_period 24x7
normal_check_interval 2
retry_check_interval 1
max_check_attempts 2
notification_period 24x7
notification_options w,u,c,r
check_command check_mem
}
配置/usr/local/nagios/etc/objects/commands.cfg
# 'check_mem' command definition
define command{
command_name check_mem
command_line $USER1$/check_mem
}
本文出自 “拿了你的泥” 博客,请务必保留此出处http://shenmeh.blog.51cto.com/6231527/1087477
相关文章推荐
- shell脚本监控linux系统内存使用情况的方法(不使用nagios监控linux)
- 【sehll学习】linux运维一个简单shell脚本监控系统内存
- Shell脚本编写Nagios插件监控程序资源占用
- nagios 监控内存的插件
- nagios插件之监控内存使用率(centos7)
- nagios 监控内存-增加新插件方法
- nagios下 监控内存的插件
- nagios 监控内存-增加新插件方法 check_mem
- Nagios监控内存插件check_mem
- 关于nagios系统下使用shell脚本自定义监控插件的编写
- Nagios监控内存插件check_mem配置
- Shell脚本编写Nagios插件监控程序资源占用
- 关于nagios系统下使用shell脚本自定义监控插件的编写
- nagios插件-监控tcp状态连接数shell脚本
- 关于nagios系统下使用shell脚本自定义监控插件的编写
- nagios 监控内存-增加新插件方法
- shell脚本监控linux系统内存使用情况的方法(不使用nagios监控linux)
- nagios监控redis内存使用情况脚本--shell实现
- nagios 监控内存的插件
- 基于nagios的监控环境(四):第三方插件监控流量、CPU、内存、进程