NagiosQL安装


    NagiosQL和Nconf是比较好用的Nagios配置工具。

一、安装NagiosQL
1、在服务器终端运行以下命令:
##YUM安装PHP模块
yum -y install --disablerepo=* --enablerepo=remi php-pecl-ssh2


##下载解压NagiosQL
cd /usr/local/src
wget -nc http://softlayer-dal.dl.sourceforge.net/project/nagiosql/nagiosql/NagiosQL%203.2.0/nagiosql_320.tar.gz
tar -zxvf nagiosql_[0-9]*.tar.gz
mv -f nagiosql32 nagiosql

cp -nr nagiosql /var/www/html/nagiosql
chown -R apache:www /var/www/html/nagiosql
chmod -R g+w /var/www/html/nagiosql


##修正PHP程序错误
#You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`value' at line 4
#http://www.nagiosql.org/forum8/general-questions/3251-add-host-you-have-an-error-in-your-sql-syntax.html
sed -i 's/AND `access_group` IN ($strAccess) ORDER BY `value";/AND `access_group` IN ($strAccess) ORDER BY `value`";/' \
/var/www/html/nagiosql/functions/nag_class.php


##创建NagiosQL导出Nagios/Icinga配置文件目录
mkdir -p /etc/nagiosql/{hosts,services,backup,import}
mkdir -p /etc/nagiosql/backup/{hosts,services}
chown -R apache:www /etc/nagiosql/
chmod -R g+w /etc/nagiosql/


##修改Icinga配置文件权限
chown -R icinga:www /usr/local/icinga/etc/
chmod -R g+w /usr/local/icinga/etc/

chown -R icinga:www /usr/local/icinga/var/rw/
chmod -R g+w /usr/local/icinga/var/rw/


chown -R icinga:www /usr/local/icinga/var/spool/checkresults
chmod -R g+w /usr/local/icinga/var/spool/checkresults


##生成Apache配置文件
cat <<EOF > /etc/httpd/conf.d/nagiosql.conf
Alias /nagiosql "/var/www/html/nagiosql"

<Directory "/var/www/html/nagiosql">
    AllowOverride None
    Order allow,deny
    Allow from all
    #
    # Use the same value as defined in nagios.conf
    #
    AuthName "Icinga Access"
    AuthType Basic
    AuthUserFile /usr/local/icinga/etc/htpasswd.users
    Require valid-user
</Directory>

EOF

##重载Apache
service httpd reload


##网站安装NagiosQL
#访问http://服务器IP/nagiosql


2、 选择语言。如果这里选了英文,以后也不能改为拥吻
31144444-2ca0360be55642f8b4a3de6da3e13f52.jpg

3、检查前置条件
31144444-36fa7d5629b24f01b69743b66070f495.jpg


4、指定数据库环境参数和Nagios配置文件目录
31144445-be197fc3365f4899b146ec127568383d.png


5、完成安装
31144446-4c961ddaf19b466ba129c7f21ed9ed76.jpg


二、NagiosQL基本环境配置
1、登陆NagiosQL
这里是2层安全认证:apache的基本认证和NagiosQL程序认证
31144446-6801cf14a65b4b85bf5c14e9fde8e088.jpg
2、禁用在线版本检查,这个功能有可能会造成程序假死
31144447-eaded6df42414bd18a9cd3605af8780d.jpg


3、修改Configuration target中localhost的配置
31144447-ccf6bdb6e14145dd80ac2fbf0c949383.png

根据实际的Icinga/Nagios文件位置填写相关路径
/usr/local/icinga/var/rw/icinga.cmd
/usr/local/icinga/bin/icinga
/usr/local/icinga/var/icinga.lock
/usr/local/icinga/etc/icinga.cfg
31144447-1de0d9a340794efe93c56012ac43bda3.png

设置完成后检查Support中的Config domain checks是否全部OK
31144448-55de92a3fa554f2388d0e7b0f6584fec.png



三、迁移导入现有Icinga/Nagios配置文件
1、 在服务器终端运行以下命令:
##备份现有Icinga配置文件,准备导入
\cp -R `grep "^cfg_dir" /usr/local/icinga/etc/icinga.cfg | grep -v "modules" | awk -F= '{print $2}' | xargs` /etc/nagiosql/import


\cp `grep "^cfg_file" /usr/local/icinga/etc/icinga.cfg | awk -F= '{print $2}' | xargs` /etc/nagiosql/import

#在http://服务器IP/nagiosql/admin/import.php,导入/etc/nagiosql/import中所有的cfg文件
#在http://服务器IP/nagiosql/admin/verify.php中写入检测数据和其他数据

2、在导入配置中选择导入/etc/nagiosql/import中所有的cfg文件
31144449-8ba82d7cbf9d45eb9bbdcae810c4cb50.png


31144449-085034ef5ebc4857bb709988fd73eab9.png

3、在Nagios控制中执行2个写入
31144450-f46628287efc42c28917f4edcc5586b5.jpg

31144450-b021e4f57646427f82e2f5a58728e9d3.jpg

4、 在服务器终端运行以下命令:
##修改配置文件icinga.cfg
#注释现有的cfg_file和非模块cfg_dir,使用4个井号#
sed -i -e 's/^\(cfg_file=.*\)$/####\1/' \
-e 's/^cfg_dir=\(.*modules\)$/@@@\1/;s/^\(cfg_dir=.*\)$/####\1/;s/^@@@\(.*\)$/cfg_dir=\1/' \
/usr/local/icinga/etc/icinga.cfg

#增加NagiosQL配置文件
grep -q "NagiosQL Configuration Files" /usr/local/icinga/etc/icinga.cfg || \
cat <<EOF >> /usr/local/icinga/etc/icinga.cfg

# NagiosQL Configuration Files
cfg_dir=/etc/nagiosql/hosts/
cfg_dir=/etc/nagiosql/services/
cfg_file=/etc/nagiosql/commands.cfg
cfg_file=/etc/nagiosql/contactgroups.cfg
cfg_file=/etc/nagiosql/contacts.cfg
cfg_file=/etc/nagiosql/contacttemplates.cfg
cfg_file=/etc/nagiosql/hostdependencies.cfg
cfg_file=/etc/nagiosql/hostescalations.cfg
cfg_file=/etc/nagiosql/hostextinfo.cfg
cfg_file=/etc/nagiosql/hostgroups.cfg
cfg_file=/etc/nagiosql/hosttemplates.cfg
cfg_file=/etc/nagiosql/servicedependencies.cfg
cfg_file=/etc/nagiosql/serviceescalations.cfg
cfg_file=/etc/nagiosql/serviceextinfo.cfg
cfg_file=/etc/nagiosql/servicegroups.cfg
cfg_file=/etc/nagiosql/servicetemplates.cfg
cfg_file=/etc/nagiosql/timeperiods.cfg
EOF


##检查配置文件icinga.cfg 
icinga -v /usr/local/icinga/etc/icinga.cfg


##重载Icinga
service icinga reload

5、查看Support中查看配置文件是否都OK。
忽略“cfg_dir=/usr/local/icinga/etc/modules”,idoutils或NDOUtils的配置文件在在这个目录下
31144451-df5d11dec01b4f60a555f943f8609009.png

参考文档:
1、安装nagios的WEB管理工具nagiosQL  http://cshbk.blog.51cto.com/5685776/1288846




转载于:https://www.cnblogs.com/han1988/p/3399233.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值