您好,登录后才能下订单哦!
Nagios安装配置教程(六)nagiosql的安装
Nagios的监控配置信息都存放于文件中,配置和修改都需要手工编辑文件,十分不便,尤其当监控的内容增多时,问题就更加明显。NagiosQL是一个基于Web方式的Nagios配置管理工具,它使用PHP语言开发,可运行在Apache下,后台使用Mysql数据库。提供了可视化的配置环境(基于Web方式),可以在web页面里添加主机、服务、主机组、服务组、命令、通知组。。。。。等等;重要的,NagiosQL也是一个开源软件。
安装PEAR Module: HTML_Template_IT 1.1
安装以下项目前,请确保安装 php-pear 安装命令yum install php-pear
通过 pear install HTML_Template_IT 命令进行安装
如果出现无法找到HTML_Template_IT包的现象
到PEAR 官网下载最新的HTML_Template_IT包 http://pear.php.net/package/PEAR 放到如下目录:/usr/share/pear/PEAR/PackageFile/
cp /root/shared/HTML_Template_IT-1.3.0.gz /usr/share/pear/PEAR/PackageFile/
再次运行以下命令 安装成功
pear install HTML_Template_IT-1.3.0.gz
安装php 的 SSH2扩展
1.用rpm -qa openssl 、rpm -qa openssl-devel命令 查看是否安装openssl openssl-devel 两个
2.编译安装libssh3
cd /usr/local/soft/
wget http://www.libssh3.org/download/libssh3-1.2.9.tar.gz
tar zxvf libssh3-1.2.9.tar.gz
cd libssh3-1.2.9
./configure
make
make install
3.编译安装ssh3(官网http://www.php.net/ssh3)
安装前请确保安装php-devel
cd /usr/local/soft/
wget http://pecl.php.net/get/ssh3-0.11.2.tgz
tar zxvf ssh3-0.11.2.tgz
cd ssh3-0.11.2
phpize(如果没有找到该命令,请确定是否安装的是php-devel)
./configure --with-ssh3
make
cp modules/ssh3.so /usr/lib/php/modules/
echo "extension=ssh3.so" >> /etc/php.ini
4.重启php
service httpd restart
修改php时差及标准时间
php默认date.timezone为utc,改为date.timezone = PRC
vim /etc/php.ini
找到date.timezone 将值修改为PRC 并去掉;号
重启php service httpd restart
安装nagiosql 主程序
相关环境
Nagios根位置:/usr/local/nagios
Nagios配置文件位置:/usr/local/nagios/etc
Nagios的用户和用户组:nagios|nagios
apache的启动用户和用户组:apache|apache
安装主程序
解压nagiosql_320.tar.gz到/usr/local/nagios/nagiosql下
cd /usr/local/nagios/
cp /root/shared/nagiosql_320.tar.gz ./
tar -zxvf nagiosql_320.tar.gz
mv nagiosql32 nagiosql
修改用户权限
chown -R nagios:nagios /usr/local/nagios/nagiosql
chmod 777 /usr/local/nagios/nagiosql
修改config目录的访问权限,以使apache对其具有写权限,、
chmod -R 777 /usr/local/nagios/nagiosql/config
创建配置文件目录,并修改权限
cd /usr/local/nagios/nagiosql/
mkdir etc
cd etc
mkdir backup hosts import services
cd backup
mkdir hosts services
对nagiosql下的etc进行权限设置
chown -R apache:apache etc
在install下创建ENABLE_INSTALLER文件
cd /usr/local/nagios/nagiosql/install
touch ./ENABLE_INSTALLER
修改apache的httpd.conf文件,部署web服务,添加如下内容。
apache配置文件位置vim /etc/httpd/conf/httpd.conf
Alias /nagiosQL "/usr/local/nagios/nagiosql"
<Directory "/usr/local/nagios/nagiosql">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
重启php service httpd restart
通过IE浏览器进入如下地址http://<IP>/ nagiosQL,其中IP是apache服务主机的IP地址,开始下一步的安装
修改基本系统配置:
【管理】-【Config targets】-【修改】
如下:
【基目录】/usr/local/nagios/nagiosql/
【主机目录】/usr/local/nagios/nagiosql/etc/hosts/
【服务目录】/usr/local/nagios/nagiosql/etc/services/
【备份目录】/usr/local/nagios/nagiosql/etc/backup/
【主机备份目录】/usr/local/nagios/nagiosql/etc/backup/hosts/
【服务备份目录】/usr/local/nagios/nagiosql/etc/backup/services/
【Nagios基目录】/usr/local/nagios/etc/
【导入路径】/usr/local/nagios/etc/objects/
【Nagios命令文件】/usr/local/nagios/var/rw/nagios.cmd
【Nagios执行文件】/usr/local/nagios/bin/nagios
【Nagios进程文件】/usr/local/nagios/var/nagios.lock
【Nagios配置文件 】/usr/local/nagios/etc/nagios.cfg
导入nagios配置到Nagiosql里
点击工具→导入数据→按住ctrl,选择以下组件,然后点击导入
commands.cfg
contacts.cfg
templates.cfg
timeperiods.cfg
更改Nagiosql的权限
chown -R nagios.nagios /usr/local/nagios/nagiosql/
chmod -R 777 /usr/local/nagios/nagiosql/
写入配置文件
写入检测数据
根据所导入的数据生成hosts、hostgroup、services、servicegroup之类文件,点击工具→Nagios控制→写入检测数据→提交
此时会在/usr/local/nagios/nagiosql/下生成如下文件
hostgroups.cfg
hosttemplates.cfg
servicegroups.cfg
servicetemplates.cfg
在/usr/local/nagios/nagiosql/etc/hosts/目录生成对应已有主机台数数量的主机配置文件
在/usr/local/nagios/nagiosql/etc/services/目录中生成services的文件
写入其他数据
根据所导入的数据生成command、timeperiods.cfg、contacts.cfg 等文件,点击工具→Nagios控制→写入其他数据→提交
此时会在/usr/local/nagios/nagiosql/目录中生成如下文件
commands.cfg
contacts.cfg
timeperiods.cfg
servicetemplates.cfg
关闭nagios配置文件,应用Nagiosql配置文件
#cfg_file=/usr/local/nagios/etc/objects/commands.cfg
#cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
#cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
#cfg_file=/usr/local/nagios/etc/objects/templates.cfg
以下项打开,没有的添加
cfg_file=/usr/local/nagios/nagiosql/commands.cfg
cfg_file=/usr/local/nagios/nagiosql/contactgroups.cfg
cfg_file=/usr/local/nagios/nagiosql/contacts.cfg
cfg_file=/usr/local/nagios/nagiosql/contacttemplates.cfg
cfg_file=/usr/local/nagios/nagiosql/hostdependencies.cfg
cfg_file=/usr/local/nagios/nagiosql/hostescalations.cfg
cfg_file=/usr/local/nagios/nagiosql/hostextinfo.cfg
cfg_file=/usr/local/nagios/nagiosql/hostgroups.cfg
cfg_file=/usr/local/nagios/nagiosql/hosttemplates.cfg
cfg_file=/usr/local/nagios/nagiosql/servicedependencies.cfg
cfg_file=/usr/local/nagios/nagiosql/serviceescalations.cfg
cfg_file=/usr/local/nagios/nagiosql/serviceextinfo.cfg
cfg_file=/usr/local/nagios/nagiosql/servicegroups.cfg
cfg_file=/usr/local/nagios/nagiosql/servicetemplates.cfg
cfg_file=/usr/local/nagios/nagiosql/timeperiods.cfg
cfg_dir=/usr/local/nagios/nagiosql/etc/hosts/
cfg_dir=/usr/local/nagios/nagiosql/etc/services/
登录Nagiosql界面,添加主机和服务器
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。