Nagios-NRPE
Nagios 守护进程在 NRPE(Nagios 远程插件执行器)中运行检查远程计算机。它允许您在其他计算机上远程运行 Nagios 插件。您可以监控远程计算机的指标,例如磁盘使用情况、CPU 负载等。它还可以通过一些 Windows 代理插件检查远程 Windows 计算机的指标。
让我们看看如何在需要监控的客户端机器上逐步安装和配置NRPE。
步骤 1 - 运行以下命令在要监控的远程 Linux 计算机上安装 NRPE。
sudo apt-get install nagios-nrpe-server nagios-plugins
步骤 2 - 现在,在服务器目录中创建一个主机文件,并放置主机的所有必要定义。
sudo gedit /usr/local/nagios/etc/servers/ubuntu_host.cfg
# Ubuntu Host configuration file
define host {
use linux-server
host_name ubuntu_host
alias Ubuntu Host
address 192.168.1.10
register 1
}
define service {
host_name ubuntu_host
service_description PING
check_command check_ping!100.0,20%!500.0,60%
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Check Users
check_command check_local_users!20!50
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Local Disk
check_command check_local_disk!20%!10%!/
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Check SSH
check_command check_ssh
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
define service {
host_name ubuntu_host
service_description Total Process
check_command check_local_procs!250!400!RSZDT
max_check_attempts 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
notification_interval 2
notification_period 24x7
notifications_enabled 1
register 1
}
步骤 3 - 运行下面所示的命令来验证配置文件。
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
步骤 4 - 如果没有错误,请重新启动 NRPE、Apache 和 Nagios。
service nagios-nrpe-server restart service apache2 restart service nagios restart
步骤 5 - 打开浏览器并转到 Nagios Web 界面。可以看到需要监控的主机已经添加到Nagios核心服务中。同样,您可以添加更多由 Nagios 监控的主机。
