一。 环境:
1. centos 6.4
2. 设置hostname 并且安装好apache
3. 关闭selinux及iptables
二。 安装nagios服务器端:
1. rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
2. yum -y install nagios nagios-plugins-all nagios-plugins-nrpe nrpe php
3. chkconfig httpd on && chkconfig nagios on
4. service httpd start && service nagios start
5. 设置nagiosadmin密码:
htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
6. 登陆:开浏览器,输入密码,在host里面应该有“localhost”这台机器
http://{your_ip_address}/nagios
三。 安装pnp4nagios:
1. yum install pnp4nagios rrdtool
四。配置pnp4nagios:
1,修改nagios.cfg
2,修改commands.cfg
注释掉原有对process-host-perfdata和process-service-perfdata,重新定义
3、修改配置文件templates.cfg
4,修改服务器配置文件localhost.cfg
上面只是例举了一个,你可以都加一下。
在网上好多关于pnp4nagios的文章,都是要把mv misccommands.cfg-sample misccommands.cfg 生成配置文件,我是yum安装的,安装目录下根本没有sample这样的东西
所在我根本没有配置任何东西。
5,重启nagios,启动npcd
五。 登陆错误处理:
登陆http://{your_ip_address}/nagios,发现密码认证不对,请修改以下内容:
vi /etc/httpd/conf.d/pnp4nagios.conf
把 AuthUserFile /etc/nagios/passwd 修改为
AuthUserFile /etc/nagios/htpasswd.users
完工,小太阳可以看到,并且点击开来。
六。 配置调试命令
/usr/bin/nagios -v /etc/nagios/nagios.cfg
[root@nagios-mendian mendian]# /usr/bin/nagios -v /etc/nagios/nagios.cfg
Nagios Core 3.2.3
Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 10-03-2010
License: GPL
Website: http://www.nagios.org
Reading configuration data...
Read main config file okay...
Processing object config file '/etc/nagios/objects/commands.cfg'...
Processing object config file '/etc/nagios/objects/contacts.cfg'...
Processing object config file '/etc/nagios/objects/timeperiods.cfg'...
Processing object config file '/etc/nagios/objects/templates.cfg'...
Processing object config file '/etc/nagios/objects/localhost.cfg'...
Processing object config directory '/etc/nagios/mendian'...
Processing object config file '/etc/nagios/mendian/BeiJingXiLu.cfg'...
Read object config files okay...
Running pre-flight check on configuration data...
Checking services...
Checked 8 services.
Checking hosts...
Warning: Host 'BeiJingXiLu' has no services associated with it!
Checked 2 hosts.
Checking host groups...
Checked 1 host groups.
Checking service groups...
Checked 0 service groups.
Checking contacts...
Checked 1 contacts.
Checking contact groups...
Checked 1 contact groups.
Checking service escalations...
Checked 0 service escalations.
Checking service dependencies...
Checked 0 service dependencies.
Checking host escalations...
Checked 0 host escalations.
Checking host dependencies...
Checked 0 host dependencies.
Checking commands...
Checked 24 commands.
Checking time periods...
Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...
Total Warnings: 1
Total Errors: 0