分类: BSD
2010-08-24 20:56:11
下面为NRPE监控配置
在被监控主机上:
1.增加用户
pw adduser nagios
设置密码
passwd nagios
2.安装nagios插件
Tar –zxvf nagios-plugins-***.tar.gz. cd nagios-plugins-*** ./configure –prefix=/usr/local/nagios make && make install chown nagios:nagios /usr/local/nagios chown –R nagios:nagios /usr/local/nagios/libexec |
安装nrpe(监控机上也要安装)
Tar –zxvf nrpe-***.targ.gz Cd nrpe-2.8.1 ./configure Make all Make install-plugin Make install-daemon Make install-daemon-config |
在监控与被监控机上启动NRPE:
/usr/local/nagios/bin/nrpe –c /usr/local/nagios/etc/nrpe.cfg –d /usr/local/nagios/libexec/check_nrpe –H localhost /usr/local/nagios/libexec/check_nrpe –h查看这个命令的用法。可以看到用法是check_nrpe –H 被监控的主机 -c 要执行的监控命令。 |
在监控机上执行:
/usr/local/nagios/libexec/check_nrpe –H 121.9.211.41(此IP为被监控机上IP),此时返回NRPE v2.12这个版本号则证明主被监控机之间已经建立起信任。否则一定要在被监控机上添加监控机的IP,以被信任。 allowed_hosts=127.0.0.1,121.9.211.44(这里添加的是主监控机的IP) |
在主监控机上操作:
mkdir -p /usr/local/nagios/etc/groups mkdir -p /usr/local/nagios/etc/servers/ 修改nagios.cfg文件,在其中添加两行, cfg_dir=/usr/local/nagios/etc/servers cfg_dir=/usr/local/nagios/etc/groups
ee /usr/local/nagios/etc/groups/servicegroup.cfg
然后在/usr/local/nagios/etc/servers目录建立被监控主机的配置文件,其实把/usr/local/nagios/etc/objects/localhost.cfg(linux系统)或/usr/local/nagios/etc/objects/windows.cfg(windows系统)这两个模板文件copy一份作修改即可。如cp localhost.cfg ../servers/121.cfg,修改其中的内容则可以监控121这台主机。 |
Nagios的启动与关闭
验证nagios配置文件 /usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg 在确认无报错的情况下就可以启动nagios /usr/local/nagios/bin/nagios –d /usr/local/nagios/etc/nagios.cfg /usr/local/etc/rc.d/nagios restart|reload|stop|start 评估启动时间: /usr/local/nagios/bin/nagios –s /usr/local/nagios/etc/nagios.cfg