Nagios - NRPE



Nagios 守护进程会在 NRPE(Nagios 远程插件执行程序)中对远程机器执行检查。它可让你在其他机器上远程运行 Nagios 插件。你可以监控远程机器度量指标,如磁盘使用情况、CPU 负载等。通过一些 Windows 代理附加组件,它还可以检查远程 Windows 机器度量指标。

Plugin Executor

让我们一步步了解如何在需要监控的客户端机器上安装和配置 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
verification of configuration

步骤 4 − 如果没有错误,重新启动 NRPE、Apache 和 Nagios。

service nagios-nrpe-server restart
service apache2 restart
service nagios restart

步骤 5 − 打开浏览器并进入 Nagios Web 界面。你可以看到需要监控的主机已添加到 Nagios 核心服务。同样,你可以添加更多主机,让 Nagios 监控。

Nagios web interface
广告