1Nconf简介:

NConf是一个用来配置Nagios监控软件的Web工具。它不同于类似的工具,它能够提供企业级功能,如模板、依赖、并能够配置一个大型分布式的Nagios服务器拓扑结构。它可以让你毫不费力地保持一个分布式的Nagios拓扑。具有一个用户友好的GUI,其特点是主机和服务的模板,图形依赖浏览器,多个身份验证模式,一个Nagios配置的提供者,一个CSV文件导入和Perl数据库API,其数据架构是可定制和可扩展。

Nconfnagios插件库推荐的一款配置程序,网址是http://www.nconf.org

2Nconf的安装

安装过程比较简单,可以直接看解压后的README帮助文档,

此篇文档的红色字代表我的输入命令,可作参考。

 

# cat README 看安装文档 

1.Download and unpack 下载并安装软件包 

Download and unpack the NConf archive to your webserver's document root folder.

 
  
  1. #tar -zxf nconf-1.2.6-0.tgz -C /var/www/html  

2. Set permissions 设置权限 以下目录的属主属组修改为apache

Make sure the following directories are writable for your webserver user:

./config

./output

./static_cfg

./temp

 
  
  1. #chown -R apache:apache config/ temp/ static_cfg/ output/ bin/  

3. Create the database 创建所需要的 库

Create a new MySQL database for NConf, create a user to access the database, grant the appropriate privileges (make sure InnoDB for MySQL is set up properly prior to creating the database).

On the commandline, you would proceed like this:

$> mysql -u root -p

Enter password:

mysql> CREATE DATABASE DBNAME;

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON `DBNAME`.* TO 'DB_USER'@'localhost' IDENTIFIED BY 'DB_PASS';

Please refer to the MySQL manual on how to set up InnoDB (the steps might vary depending on your OS distribution).

例如:

 

 
  
  1. #mysql -u root -p 
  2. mysql>create database nconf; 
  3. mysql>GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER ON nconf.* TO nconf@'localhost' IDENTIFIED BY '123456';  
  4. mysql>flush privileges; 

4. Create the database structure 导入nconf库的结构

$> mysql -u DBUSER -p DBNAME < INSTALL/create_database.sql

 
  
  1. # mysql -u nconf -p nconf< INSTALL/create_database.sql 

5. Configure NConf 修改配置文件

Copy the contents of ./config.orig to ./config. Make sure you also copy the hidden files.

Edit ./config/mysql.php, set at least the following values:

DBHOST

DBNAME

DBUSER

DBPASS

Edit ./config/nconf.php, set at least the following values:

NCONFDIR

NAGIOS_BIN

 

 
  
  1. # vim config/mysql.php 
  2.    define('DBHOST', 'localhost'); 
  3.    define('DBNAME', 'nconf'); 
  4.    define('DBUSER', 'nconf');  
  5.    define('DBPASS', '123456'); 
  6. # vim config/nconf.php  
  7.    define('NCONFDIR', '/var/www/html/nconf'); 
  8.    define('NAGIOS_BIN', '/usr/local/nagios/bin/nagios'); 

6. Clean up 清除安装和更新页面

Remove the INSTALL and UPDATE folders, as well as the INSTALL.php and UPDATE.php scripts.

 
  
  1. #rm INSTALL INSTALL.PHP UPDATE UPDATE.PHP

7. Get OS logo icons (optional, but nice) 下载 LOGO 图片

If you like, download the OS logo icons and unpack them to ./img/logos/base/

The icons can be downloaded here:

http://www.monitoringexchange.org/p/47

8. Authentication 也可以认证

If you need authentication, configure ./config/authentication.php appropriately.

打开nconf 

 

在浏览器输入http://YOUR-IP/nconf 打开nconf的主页面,显示的页面如下:

3nconf的配置

   点【Hosts 】 后面的 【Add】 添加主机

图形界面添加主机服务之后 点击【Generate Nagios config 】 检查配置 并生成配置文件在ncon/output目录下

 

可以看到,每检查一次无误 就生成一个配置文件 最新的为NagiosConfig.tgz

[root@localhost ADD-ONS]# ./deploy_local.sh 执行这个脚本 把最新的配置文件部署到nagios应用程序

nagios已经重读了配置文件,不用重新启动刷新nagios页面 就可以看到新添加的主机服务等

4、Nconf的脚本

# cd ../ADD-ONS/ 脚本目录   可以看到4个脚本一个php命令 

backup_db.sh deploy_local.sh history_cleanup.sh incoming_config.php stale_service.sh

 

 
  
  1. backup_db.sh //备份数据库的脚本,可以写入任务计划定期实现数据库的备份 
  2.  
  3. deploy_local.sh  //把NagiosConfig.tgz 图形界面配置生成的配置文件导入到nagios中 
  4.  
  5. history_cleanup.sh   //清楚数据库中History 表中多少天之前的历史 
  6.  
  7. incoming_config.php 命令 //可以把nconf生成的配置文件传到远程主机上 
  8.  
  9. stale_service.sh //返回服务是陈旧的 

后记:

    这只是一些简单的入门设置,nconf还有更强大的认证功能本文没有详细介绍,后期将继续更新。不断改进。