6.在被监控机器上安装nrpe
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
出错: checking for SSL libraries... configure: error: Cannot find ssl libraries
解决,创建一个user/lib/libssl.so=>/usr/lib/x86_64-linux-gnu/libssl.so的简单符号连接:
ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/libssl.so
这里/usr/lib/x86_64-linux-gnu/libssl.so目录可能不是这一个,可以通过命令whereis ssl来查看,32位ubuntu上可能是/usr/lib/i386-linux-gnu/libssl.so
重新
./configure
编译安装:
make all
make install-plugin
make install-daemon
make install-daemon-config
9.将被监控机器需要监控的内容添加到监控服务器nagios的配置文件中
以标准的localhost.cfg为基础创建被监控机配置文件linuxmachine1.cfg
cp /usr/local/nagios/etc/objects/localhost.cfg /usr/local/nagios/etc/machines/linuxmachine1.cfg
vi /usr/local/nagios/etc/machines/linuxmachine1.cfg
内容如下(红色为需要修改的地方):
# Define a host for the machine
define host{
use linux-server ; Name of host template to use
host_name linux-machine1
alias linux-machine1
address 192.168.0.103
}
# Define an hostgroup for Linux machines
define hostgroup{
hostgroup_name linux-machines-group1 ; The name of the hostgroup
alias Linux Machines Group1 ; Long name of the group
members linux-machine1 ; Comma separated list of hosts that belong to this group
}
# SERVICE DEFINITIONS
# Define a service to "ping" the target machine
define service{
use generic-service ; Name of service template to use
host_name linux-machine1
service_description PING
check_command check_nrpe!check_ping
}
# Define a service to check the disk space of the root partition
# Warning if < 20% free, critical if
# < 10% free space on partition.
define service{
use generic-service ; Name of service template to use
host_name linux-machine1
service_description Root Partition
check_command check_nrpe!check_disk
}
# Define a service to check the number of currently logged in
# Warning if > 20 users, critical
# if > 50 users.
define service{
use generic-service ; Name of service template to use
host_name linux-machine1
service_description Current Users
check_command check_nrpe!check_users
}
# Define a service to check the number of currently running procs
# Warning if > 250 processes, critical if
# > 400 users.
define service{
use generic-service ; Name of service template to use
host_name linux-machine1
service_description Total Processes
check_command check_nrpe!check_procs
}
# Define a service to check the load on the machine.
define service{
use generic-service ; Name of service template to use
host_name linux-machine1
service_description Current Load
check_command check_nrpe!check_load
}
# Define a service to check the swap usage the machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free
define service{
use generic-service ; Name of service template to use
host_name linux-machine1
service_description Swap Usage
check_command check_nrpe!check_swap
}
# Define a service to check SSH on the machine.
# Disable notifications for this service by default, as not all users may have SSH enabled.
define service{
use generic-service ; Name of service template to use
host_name linux-machine1
service_description SSH
check_command check_nrpe!check_ssh
notifications_enabled 0
}
# Define a service to check HTTP on the machine.
# Disable notifications for this service by default, as not all users may have HTTP enabled.
define service{
use generic-service ; Name of service template to use
host_name linux-machine1
service_description HTTP
check_command check_nrpe!check_http
notifications_enabled 0
}
保存退出,将该文件路径添加到nagios配置文件/usr/local/nagios/etc/nagios.cfg中
vi /usr/local/nagios/etc/nagios.cfg
添加: cfg_file=/usr/local/nagios/etc/machines/linuxmachine1.cfg
添加监听该linux-group1的用户信息
vi /usr/local/nagios/etc/objects/contacts.cfg
修改nagiosadmin信息为:
define contact{
contact_name nagiosuser1 ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email xxx@163.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}}
修改contactgroup如下:
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosuser1
}
10.配置完成,验证配置有无错误
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
没有错误的话,重新启动nagios
killall nagios
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
查看运行状态: /usr/local/nagios/bin/nagiostats
11.重新启动apache2,页面访问查看
service apache2 restart
访问http://nagios主机ip/nagios, 输入用户名nagiosuser1 密码,查看页面: