一。 环境:

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

  1. [root@localhost objects]# vim /etc/nagios/nagios.cfg    //修改以下内容
  2. process_performance_data=1                             //由0改为1
  3. host_perfdata_command=process-host-perfdata            //前面的注释拿掉
  4. service_perfdata_command=process-service-perfdata      //注释拿掉
  5. enable_environment_macros=1                            //如果有注释拿掉

     2,修改commands.cfg

         注释掉原有对process-host-perfdata和process-service-perfdata,重新定义

  1. [root@localhost objects]# vim /etc/nagios/objects/commands.cfg
  2. define command {
  3. command_name    process-service-perfdata
  4. command_line    /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl
  5. }
  6. define command {
  7. command_name    process-host-perfdata
  8. command_line    /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl -d HOSTPERFDATA
  9. }

     3、修改配置文件templates.cfg

  1. [root@localhost objects]# vim /etc/nagios/objects/templates.cfg
  2. define host {
  3. name       hosts-pnp
  4. register   0
  5. action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
  6. process_perf_data               1
  7. }
  8. define service {
  9. name       srv-pnp
  10. register   0
  11. action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
  12. process_perf_data               1
  13. }

     4,修改服务器配置文件localhost.cfg

  1. [root@localhost objects]# vim /etc/nagios/localhost.cfg
  2. define host{
  3. use                     linux-server,hosts-pnp
  4. host_name               localhost
  5. alias                   localhost
  6. address                 127.0.0.1
  7. }
  8. define service{
  9. use                             local-service,srv-pnp
  10. host_name                       localhost
  11. service_description             PING
  12. check_command                   check_ping!100.0,20%!500.0,60%
  13. }

上面只是例举了一个,你可以都加一下。

在网上好多关于pnp4nagios的文章,都是要把mv misccommands.cfg-sample misccommands.cfg 生成配置文件,我是yum安装的,安装目录下根本没有sample这样的东西

  1. [root@localhost objects]# tree /etc/pnp4nagios/
  2. /etc/pnp4nagios/
  3. ├── background.pdf
  4. ├── check_commands
  5. │   ├── check_all_local_disks.cfg
  6. │   ├── check_nrpe.cfg
  7. │   └── check_nwstat.cfg
  8. ├── config.php
  9. ├── misccommands.cfg
  10. ├── nagios.cfg
  11. ├── npcd.cfg
  12. ├── pages
  13. │   └── web_traffic.cfg
  14. ├── pnp4nagios_release
  15. ├── process_perfdata.cfg
  16. └── rra.cfg

所在我根本没有配置任何东西。

       5,重启nagios,启动npcd

  1. [root@localhost pnp4nagios]# /etc/init.d/npcd start
  2. [root@localhost pnp4nagios]# /etc/init.d/nagios restart

五。 登陆错误处理:

登陆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

最新文章

  1. HTML5开发笔记:初窥CANVAS,上传canvas图片到服务器
  2. Mysql日常开发注意要点
  3. 第一个简单的DEMO
  4. Qt_5_3_MSVC2012-编译QFtp-qt5编译QFtp
  5. javaScript return false
  6. 【转】工科男IT职场求生法则
  7. Java Set接口
  8. quartz spring
  9. 阿里云ECS每天一件事D5:安装php5.4.34
  10. Android 实现简单天气应用
  11. 笔记之Cyclone IV 第一卷第一章FPGA 器件系列概述
  12. 在C#中winform程序中应用nlog日志工具
  13. 关于Unicode,字符集,字符编码
  14. 关于nginx中不用.htaccess 用在ningx.conf中配置的问题
  15. maven入门概念及使用
  16. 监控服务器配置(五)-----Redis_exporter安装配置
  17. 作业 -- 几道简单的Python题
  18. windows修改PowerShell(命令提示符)默认中文编码方式
  19. 复习-css控制文本字体属性
  20. springboot @RequestBody使用JsonSerialize与 JsonDeserialize自定义转参数,处理Date日期格式

热门文章

  1. js 的数据类型转换
  2. 小米2s换了屏幕后不能近距离对焦,拆过后无法对焦?
  3. 连接Oracle数据库的OracleHelper.cs
  4. 使用c#检测文件正在被那个进程占用
  5. 用css3写出来的进度条
  6. sersync 实时同步工具
  7. [总结]Android系统体系结构
  8. [ Web Service ] [ SOAP ] [ JSON ] [ XML ] 格式轉換
  9. http://phantomjs.org/page-automation.html
  10. android studio 打开github开源代码