nagiosql是一个web配置nagios的工具,可以用web页面里添加主机、服务、主机组、服务组、命令、通知组。。。。。等等
首先我们在已经安装好apache、php、nagios目录位置如下:
apache /home/nagios/httpd
php /home/nagios/php
nagios /home/nagios/nagios
php /home/nagios/php
nagios /home/nagios/nagios
先按nagiosql官方的需求说明:
Requirements
- Webserver e.g. Apache 1.x or above
- PHP 4.3 or above
- MySQL 4.1 or above
- Nagios 2 or above
- PEAR Module: HTML_Template_IT 1.1 or above
- PHP Extension: gettext --with-gettext使用这个参数启用
- PHP Extension: mysql --with-mysql使用这个参数启用
- PHP Extension: ftp --enable-ftp使用这个参数启用
- Javascript enabled at your Webbrowser
1、注意在编译php时候要将gettext、mysql、ftp三个扩展启用。
2、安装pear模块方法如下:
[nagios@test-22 ~]$ /home/nagios/php/bin/pear install HTML_Template_IT
3、下载nagiosql并解压到htdocs目录中,下载地址如下
http://www.nagiosql.org/download.html
4、创建nagiosql的配置文件目录
[nagios@test-22 ~]$ mkdir /home/nagios/nagiosql; \
mkdir /home/nagios/nagiosql/hosts; \
mkdir /home/nagios/nagiosql/services; \
mkdir /home/nagios/nagiosql/backup; \
mkdir /home/nagios/nagiosql/backup/hosts; \
mkdir /home/nagios/nagiosql/backup/services; \
mkdir /home/nagios/nagiosql/import
mkdir /home/nagios/nagiosql/hosts; \
mkdir /home/nagios/nagiosql/services; \
mkdir /home/nagios/nagiosql/backup; \
mkdir /home/nagios/nagiosql/backup/hosts; \
mkdir /home/nagios/nagiosql/backup/services; \
mkdir /home/nagios/nagiosql/import
5、先使用旧的配置文件,/home/nagios/nagios/etc/nagios.cfg文件配置文件使用原来的。(hosts和services配置同以前手动配置相同)
################################################################
cfg_file=/home/nagios/nagios/etc/objects/commands.cfg
cfg_file=/home/nagios/nagios/etc/objects/contacts.cfg
cfg_file=/home/nagios/nagios/etc/objects/timeperiods.cfg
cfg_file=/home/nagios/nagios/etc/objects/templates.cfg
################################################################
cfg_file=/home/nagios/nagios/etc/objects/gzmachine_services.cfg
cfg_file=/home/nagios/nagios/etc/objects/gzmachine_hosts.cfg
cfg_file=/home/nagios/nagios/etc/objects/gzmachine_hostgroup.cfg
cfg_file=/home/nagios/nagios/etc/objects/gzmachine_servicegroup.cfg
################################################################
cfg_file=/home/nagios/nagios/etc/objects/commands.cfg
cfg_file=/home/nagios/nagios/etc/objects/contacts.cfg
cfg_file=/home/nagios/nagios/etc/objects/timeperiods.cfg
cfg_file=/home/nagios/nagios/etc/objects/templates.cfg
################################################################
cfg_file=/home/nagios/nagios/etc/objects/gzmachine_services.cfg
cfg_file=/home/nagios/nagios/etc/objects/gzmachine_hosts.cfg
cfg_file=/home/nagios/nagios/etc/objects/gzmachine_hostgroup.cfg
cfg_file=/home/nagios/nagios/etc/objects/gzmachine_servicegroup.cfg
################################################################
6、将nagiosql解压到htdocs目录中
[nagios@test-22 ~]$ cd /home/nagios/httpd/htdocs
[nagios@test-22 htdocs]$ rm -rf nagiosql3
[nagios@test-22 htdocs]$ unzip ~/pkgs/nagiosql303.zip
7、在nagiosql的install目录中touch一个ENABLE_INSTALLER文件(该文件启用安装向导)
[nagios@test-22 htdocs]$ cd nagiosql3/install/
[nagios@test-22 install]$ touch ENABLE_INSTALLER
[nagios@test-22 htdocs]$ rm -rf nagiosql3
[nagios@test-22 htdocs]$ unzip ~/pkgs/nagiosql303.zip
7、在nagiosql的install目录中touch一个ENABLE_INSTALLER文件(该文件启用安装向导)
[nagios@test-22 htdocs]$ cd nagiosql3/install/
[nagios@test-22 install]$ touch ENABLE_INSTALLER
8、选择语言
在出现的向导页面中的Setup Language项选择Chinese(Simplified)》点击开始新安装
在出现的向导页面中的Setup Language项选择Chinese(Simplified)》点击开始新安装
9、安装检查
向导会自动检查php环境和系统权限。都通过就》点击下一步
10、系统设置部分(按下面的格式填入配置,然后》点击下一步)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MySQL服务器 127.0.0.1
MySQL服务器端口 3306
数据库名 db_nagiosql_v3
NagiosQL数据库用户 nagiosql_user
NagiosQL数据库密码 nagiosql_pass
如果数据库存在是否删除? (如果是第一次安装不需要打勾)
Mysql管理用户 root
MySQL管理密码 root
向导会自动检查php环境和系统权限。都通过就》点击下一步
10、系统设置部分(按下面的格式填入配置,然后》点击下一步)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MySQL服务器 127.0.0.1
MySQL服务器端口 3306
数据库名 db_nagiosql_v3
NagiosQL数据库用户 nagiosql_user
NagiosQL数据库密码 nagiosql_pass
如果数据库存在是否删除? (如果是第一次安装不需要打勾)
Mysql管理用户 root
MySQL管理密码 root
初始Nagios登录 admin
初始NagiosQL密码 admin
请重复输入密码 admin
初始NagiosQL密码 admin
请重复输入密码 admin
Nagios参考配置文件
导入Nagios参考配置 (如果是新手,可以导入进行学习)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
导入Nagios参考配置 (如果是新手,可以导入进行学习)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11、提示安装完成
NagiosQL Installation: 完成安装
12、删除ENABLE_INSTALLER后》点击完成
[nagios@test-22 install]$ rm /home/nagios/httpd/htdocs/nagiosql3/install/ENABLE_INSTALLER
[nagios@test-22 install]$ rm /home/nagios/httpd/htdocs/nagiosql3/install/ENABLE_INSTALLER
13、导入现有nagios的配置文件到nagiosql配置文件中
访问 http://192.168.4.131:8080/nagiosql3/index.php访问你安装好的nagiosql
14、配置nagios和nagiosql的关联(配置路径)
点击
管理》域》点击右边的
localhost进行
修改
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
域* localhost
描述* Local installation
服务器名* localhost
方法 Fileaccess
描述* Local installation
服务器名* localhost
方法 Fileaccess
配置目录
基目录* /home/nagios/nagiosql
主机目录* /home/nagios/nagiosql/hosts/
服务目录* /home/nagios/nagiosql/services/
备份目录* /home/nagios/nagiosql/backup/
主机备份目录* /home/nagios/nagiosql/backup/hosts/
服务备份目录* /home/nagios/nagiosql/backup/services/
Nagios基目录* /home/nagios/nagios/etc
导入路径 /home/nagios/nagiosql/import/
基目录* /home/nagios/nagiosql
主机目录* /home/nagios/nagiosql/hosts/
服务目录* /home/nagios/nagiosql/services/
备份目录* /home/nagios/nagiosql/backup/
主机备份目录* /home/nagios/nagiosql/backup/hosts/
服务备份目录* /home/nagios/nagiosql/backup/services/
Nagios基目录* /home/nagios/nagios/etc
导入路径 /home/nagios/nagiosql/import/
Nagios命令文件 /home/nagios/nagios/var/rw/nagios.cmd
Nagios执行文件 /home/nagios/nagios/bin/nagios
Nagios进程文件 /home/nagios/nagios/var/nagios.lock
Nagios执行文件 /home/nagios/nagios/bin/nagios
Nagios进程文件 /home/nagios/nagios/var/nagios.lock
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
完成上面的填入后》点击完成。
15、导入Nagios配置到nagiosql中
点击
工具》导入数据》按住Crtl后多先以下这些文件》点击导入。
commands.cfg gzmachine_hostgroup.cfg gzmachine_servicegroup.cfg templates.cfg
contacts.cfg gzmachine_hosts.cfg gzmachine_services.cfg timeperiods.cfg
commands.cfg gzmachine_hostgroup.cfg gzmachine_servicegroup.cfg templates.cfg
contacts.cfg gzmachine_hosts.cfg gzmachine_services.cfg timeperiods.cfg
16、为nagiosql添加好权限
[nagios@test-22 ~]$ chown -R nagios.nagios /home/nagios/nagiosql
[nagios@test-22 ~]$ chmod -R 775 /home/nagios/nagiosql
[nagios@test-22 ~]$ chown -R nagios.nagios /home/nagios/nagiosql
[nagios@test-22 ~]$ chmod -R 775 /home/nagios/nagiosql
17、写入nagiosql配置文件
17.1、
写入检测数据(会根据所导入的数据生成hosts、hostgroup、services、servicegroup之类文件)
点击
工具》Nagios控制》写入检测数据》提交
此时会在/home/nagios/nagiosql目录中生成如下文件
hostgroups.cfg
hosttemplates.cfg
servicegroups.cfg
servicetemplates.cfg
在/home/nagios/nagiosql/hosts目录生成对应已有主机台数数量的主机配置文件
在/home/nagios/nagiosql/services目录中生成services的文件
17.2、 写入其他数据(会根据所导入的数据生成command、timeperiods.cfg、contacts.cfg 等文件)
此时会在/home/nagios/nagiosql目录中生成如下文件
hostgroups.cfg
hosttemplates.cfg
servicegroups.cfg
servicetemplates.cfg
在/home/nagios/nagiosql/hosts目录生成对应已有主机台数数量的主机配置文件
在/home/nagios/nagiosql/services目录中生成services的文件
17.2、 写入其他数据(会根据所导入的数据生成command、timeperiods.cfg、contacts.cfg 等文件)
点击
工具》Nagios控制》写入其它数据》提交
此时会在/home/nagios/nagiosql目录中生成如下文件
commands.cfg
contacts.cfg
timeperiods.cfg
servicetemplates.cfg
.
.
.
.
commands.cfg
contacts.cfg
timeperiods.cfg
servicetemplates.cfg
.
.
.
.
18、关闭nagios配置文件,应用nagiosql配置文件
[nagios@test-22 ~]$ vim /home/nagios/nagios/etc/nagios.cfg
[nagios@test-22 ~]$ vim /home/nagios/nagios/etc/nagios.cfg
将以下项注释掉(nagios原来的配置文件,因为已经导入到nagiosql配置中,所以需要关闭)
################################################################
#cfg_file=/home/nagios/nagios/etc/objects/commands.cfg
#cfg_file=/home/nagios/nagios/etc/objects/contacts.cfg
#cfg_file=/home/nagios/nagios/etc/objects/timeperiods.cfg
#cfg_file=/home/nagios/nagios/etc/objects/templates.cfg
################################################################
#cfg_file=/home/nagios/nagios/etc/objects/gzmachine_services.cfg
#cfg_file=/home/nagios/nagios/etc/objects/gzmachine_hosts.cfg
#cfg_file=/home/nagios/nagios/etc/objects/gzmachine_hostgroup.cfg
#cfg_file=/home/nagios/nagios/etc/objects/gzmachine_servicegroup.cfg
################################################################
#cfg_file=/home/nagios/nagios/etc/objects/commands.cfg
#cfg_file=/home/nagios/nagios/etc/objects/contacts.cfg
#cfg_file=/home/nagios/nagios/etc/objects/timeperiods.cfg
#cfg_file=/home/nagios/nagios/etc/objects/templates.cfg
################################################################
#cfg_file=/home/nagios/nagios/etc/objects/gzmachine_services.cfg
#cfg_file=/home/nagios/nagios/etc/objects/gzmachine_hosts.cfg
#cfg_file=/home/nagios/nagios/etc/objects/gzmachine_hostgroup.cfg
#cfg_file=/home/nagios/nagios/etc/objects/gzmachine_servicegroup.cfg
################################################################
将以下项打开(naigosql配置文件,用于替代nagios的配置文件)
################################################################
cfg_ dir=/home/nagios/nagiosql/hosts/
cfg_ dir=/home/nagios/nagiosql/services/
cfg_file=/home/nagios/nagiosql/commands.cfg
cfg_file=/home/nagios/nagiosql/contactgroups.cfg
cfg_file=/home/nagios/nagiosql/contacts.cfg
cfg_file=/home/nagios/nagiosql/contacttemplates.cfg
cfg_file=/home/nagios/nagiosql/hostdependencies.cfg
cfg_file=/home/nagios/nagiosql/hostescalations.cfg
cfg_file=/home/nagios/nagiosql/hostextinfo.cfg
cfg_file=/home/nagios/nagiosql/hostgroups.cfg
cfg_file=/home/nagios/nagiosql/hosttemplates.cfg
cfg_file=/home/nagios/nagiosql/servicedependencies.cfg
cfg_file=/home/nagios/nagiosql/serviceescalations.cfg
cfg_file=/home/nagios/nagiosql/serviceextinfo.cfg
cfg_file=/home/nagios/nagiosql/servicegroups.cfg
cfg_file=/home/nagios/nagiosql/servicetemplates.cfg
cfg_file=/home/nagios/nagiosql/timeperiods.cfg
################################################################
################################################################
cfg_ dir=/home/nagios/nagiosql/hosts/
cfg_ dir=/home/nagios/nagiosql/services/
cfg_file=/home/nagios/nagiosql/commands.cfg
cfg_file=/home/nagios/nagiosql/contactgroups.cfg
cfg_file=/home/nagios/nagiosql/contacts.cfg
cfg_file=/home/nagios/nagiosql/contacttemplates.cfg
cfg_file=/home/nagios/nagiosql/hostdependencies.cfg
cfg_file=/home/nagios/nagiosql/hostescalations.cfg
cfg_file=/home/nagios/nagiosql/hostextinfo.cfg
cfg_file=/home/nagios/nagiosql/hostgroups.cfg
cfg_file=/home/nagios/nagiosql/hosttemplates.cfg
cfg_file=/home/nagios/nagiosql/servicedependencies.cfg
cfg_file=/home/nagios/nagiosql/serviceescalations.cfg
cfg_file=/home/nagios/nagiosql/serviceextinfo.cfg
cfg_file=/home/nagios/nagiosql/servicegroups.cfg
cfg_file=/home/nagios/nagiosql/servicetemplates.cfg
cfg_file=/home/nagios/nagiosql/timeperiods.cfg
################################################################
19、登入nagiosql的web界面,就可以添加主机和服务了。
下面我们试着添加一台主机:
19.1、点击管理》监督》主机》添加
保存后》
写入配置》管理》工具》Nagios控制》写入检测数据》提交》重新启动Nagios》提交
我们添加的主机就出现了。。。。哈哈
我们添加的主机就出现了。。。。哈哈
参考安装过程: http://www.nagiosql.org/faq/31-general-documentation/71-nagiosql3-documentation.html#Download