1. 通过共享SSH KEYS 和check_by_ssh 插件来运行远程主机上的插件。
这种方式性能高,尤其是监控的主机数量达到一定规模时候性能较好。
2.通过NRPE addon,NRPE插件可以允许你执行远程主机的plugins
如下图,受控端会运行一个nrpe的daemon,监控服务端则通过执行check_nrpe来调用远程主机的npre插件并调用check_命令,并返回数据
yum install gcc openssl-devel
添加普通账户icinga
#> /usr/sbin/useradd icinga #> passwd icinga
#> tar jxvf nagios-cn-plugins-1.5.tar.bz2 #> cd nagios-cn-plugins-1.5 #> ./configure --prefix=/usr/local/icinga --with-cgiurl=/icinga/cgi-bin --with-package-name=icinga-plugins #> make #> make install文档中configure时候还加了 --with-icinga-user=icinga --with-icinga-group=icinga ,我发现加了也不认,似乎也没什么用,加了反而报:
configure: WARNING: unrecognized options: --with-icinga-user, --with-icinga-group,没什么区别
#> tar xvzf icinga-nrpe-2.14.tar.gz #> cd icinga-nrpe-2.14 #> /configure #> make all #> make install #> make install-plugin #> make install-daemon #> make install-daemon-config #> make install-init
configure过程的输出信息确认如下:
General Options: ------------------------- NRPE port: 5666 NRPE user: icinga NRPE group: icinga Icinga user: icinga Icinga group: icinga
添加服务器地址
#> vi /usr/local/icinga/etc/nrpe.cfg #> allowed_hosts=127.0.0.1,IPADDRESS增加command字段来添加要监控的服务
command[check_users]=/usr/local/icinga/libexec/check_users -w 5 -c 10 command[check_load]=/usr/local/icinga/libexec/check_load -w 15,10,5 -c 30,25,20 command[check_hda1]=/usr/local/icinga/libexec/check_disk -w 20% -c 10% -p /dev/hda1 command[check_zombie_procs]=/usr/local/icinga/libexec/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/local/icinga/libexec/check_procs -w 150 -c 200 command[check_ssh]=/usr/local/icinga/libexec/check_ssh -H localhost command[check_swap]=/usr/local/icinga/libexec/check_swap -w 20% -c 10% command[check_mysql]=/usr/local/icinga/libexec/check_mysql -H localhost -uroot -ptomcat2008 command[check_apache]=/usr/local/icinga/libexec/check_apachestatus -H localhost -p 80 command[check_ntp]=/usr/local/icinga/libexec/check_ntp -H localhost -w 0.5 -c 1 command[check_snmp]=/usr/local/icinga/libexec/check_snmp_service -H localhost -C monitor_energysh
service icinga-nrpe start
检测服务端check_nrpe与客户端运行的nrpedaemon之间的通信
/usr/local/icinga/libexec/check_nrpe -H ClientIPADDRESS如果不通,可以关闭防火墙和selinux试试。
[/settings/default] ; ALLOWED HOSTS - A comaseparated list of allowed hosts. You can use netmasks (/ syntax) or * to create ranges. allowed hosts = 10.1.81.199
vi /usr/local/icinga/etc/icinga.cfg
#cfg_file=/usr/local/icinga/etc/objects/windows.cfg去掉这里的#
vi /usr/local/icinga/etc/objects/windows.cfg定义host和service等
define host{ ; Inherit default values from a Windows server template use windows-server ; make sure you keep this line! host_name winserver alias My Windows Server address 192.168.1.2 }默认已经有了,设置IP等
vi /usr/local/icinga/etc/objects/commands.cfg
define command{ command_name check_nt command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s $USER9$ -v $ARG1$ $ARG2$ }改为,这里使用空密码
# 'check_nt' command definition define command{ command_name check_nt command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s "" -v $ARG1$ $ARG2$ }重启icinga,测试是否好用
/usr/local/icinga/libexec/check_nt -H <ip address> -p <port> -s <password> -v UPTIME