配置客户端上面的nrpe
vim
/usr/local/nagios/etc/nrpe
.cfg
command
[check_users]=
/usr/local/nagios/libexec/check_users
-w 5 -c 10
command
[check_load]=
/usr/local/nagios/libexec/check_cpu
.sh -w 80% -c 90%
command
[check_sda1]=
/usr/local/nagios/libexec/check_disk
-w 20% -c 10% -p
/dev/sda1
command
[check_sda2]=
/usr/local/nagios/libexec/check_disk
-w 20% -c 10% -p
/dev/sda2
command
[check_zombie_procs]=
/usr/local/nagios/libexec/check_procs
-w 5 -c 10 -s Z
command
[check_total_procs]=
/usr/local/nagios/libexec/check_procs
-w 150 -c 200
command
[check_swap]=
/usr/local/nagios/libexec/check_swap
-w 20% -c 10%
command
[check_iostat]=
/usr/local/nagios/libexec/check_iostat
.sh -d sda -w 6 -c 10
command
[check_mysql]=
/usr/local/nagios/libexec/check_mysql
-H 192.168.0.22 -u nagios -p 123456 -d nagios
command
[check_nginx]=
/usr/local/nagios/libexec/check_nginx
.sh -u 192.168.0.22 -p
/status
-w 4000 -c 5000
command
[check_mem]=
/usr/local/nagios/libexec/check_memory
.pl -f -w 20 -c 10
command
[check_ip_conn]=
/usr/local/nagios/libexec/ip_conn
.sh 200 250
command
[check_ssh]=
/usr/local/nagios/libexec/check_tcp
-p 22 -w 1.0 -c 10.0
配置完成后,重启nrpe
kill
`
ps
aux |
grep
nrpe |
grep
-
v
grep
|
awk
'{print $2}'
`
/usr/local/nagios/bin/nrpe
-c
/usr/local/nagios/etc/nrpe
.cfg -d
服务端配置:
监控服务端本机的配置:
vim
/usr/local/nagios/etc/objects/localhost
.cfg
修改里面的配置,最后修改完成的配置如下
define host{
use linux-server
host_name localhost
alias
localhost
address 127.0.0.1
icon_image server.gif
statusmap_image server.gd2
2d_coords 500,200
3d_coords 500,200,100
}
define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias
Linux Servers ; Long name of the group
members * ; Comma separated list of hosts that belong to this group
}
define servicegroup{
servicegroup_name 全部联通性检查
alias
联通性检查
members localhost,PING,nagios-client,PING
}
define service{
use
local
-service ; Name of service template to use
host_name *
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use
local
-service ; Name of service template to use
host_name localhost
service_description 根分区
check_command check_local_disk!20%!10%!/
}
define service{
use
local
-service ; Name of service template to use
host_name localhost
service_description 登录用户数
check_command check_local_users!20!50
}
define service{
use
local
-service ; Name of service template to use
host_name localhost
service_description 进程总数
check_command check_local_procs!250!400!RSZDT
}
define service{
use
local
-service ; Name of service template to use
host_name localhost
service_description 系统负荷
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
define service{
use
local
-service ; Name of service template to use
host_name localhost
service_description 交换空间利用率
check_command check_local_swap!20!10
}
define service{
use
local
-service ; Name of service template to use
host_name localhost
service_description SSH
check_command check_tcp!22!1.0!10.0
notifications_enabled 0
}
服务器监控客户端的配置:
保存退出后复制这个文件一份,作为nagios-client的监控模版文件
cp
/usr/local/nagios/etc/objects/localhost
.cfg
/usr/local/nagios/etc/objects/nagios-client
.cfg
vim
/usr/local/nagios/etc/objects/nagios-client
.cfg 修改完成后的配置如下
define host{
use linux-server
host_name nagios-client
alias
nagios-client
address 192.168.0.22
icon_image server.gif
statusmap_image server.gd2
2d_coords 500,200
3d_coords 500,200,100
}
define service{
use
local
-service ; Name of service template to use
host_name *
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description boot分区
check_command check_nrpe!check_sda1
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description 根分区
check_command check_nrpe!check_sda2
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description 登录用户数
check_command check_nrpe!check_users
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description 进总程数
check_command check_nrpe!check_total_procs
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description CPU平均负载
check_command check_nrpe!check_load
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description 虚拟内存
check_command check_nrpe!check_swap
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description SSH
check_command check_nrpe!check_ssh
notifications_enabled 0
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description 僵死进程数
check_command check_nrpe!check_zombie_procs
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description iostat
check_command check_nrpe!check_iostat
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description mysql
check_command check_nrpe!check_mysql
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description nginx
check_command check_nrpe!check_nginx
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description memory
check_command check_nrpe!check_mem
}
define service{
use
local
-service ; Name of service template to use
host_name nagios-client
service_description IP连接数
check_command check_nrpe!check_ip_conn
}