首先看下内存信息吧
[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
根据情况取值比如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
}