设为首页 收藏本站
查看: 1081|回复: 0

[经验分享] 开源监控解决方案Nagios+Cacti+PNP4Nagios+NConf+NDOUtils+Nagvis(八)nconf安装

[复制链接]

尚未签到

发表于 2019-1-9 12:45:57 | 显示全部楼层 |阅读模式
  nconf提供WEB界面,管理nagios配置,其将nagios配置文件放入数据库,用户做相应修改后点击生成配置文件,Nconf会从数据库中将配置写入配置文件。所以最后nagios的配置还是以文件的形式存在,这是相对与nagioSQL本人比较喜欢Nconf的原因,其次Nconf还提供了静态文件的修改页面。

  

  一、初始化数据库
mysql> create database nconf default character set utf8;
mysql> grant all privileges on nconf.* to 'nconf'@'localhost' identified by 'XXXX' with grant option;
mysql> grant all privileges on nconf.* to 'nconf'@'%' identified by 'XXXX' with grant option;
mysql> flush privileges;

二、安装Nconf
#tar -zxvf  nconf-1.3.0-0.tgz -C /var/www/html/
#chown -R apache:apache /var/www/html/nconf

三、初始化Nconf
  

  第二步骤需要建立软连接,并且注意原文件的权限最好修改为777
#chmod 777 /usr/local/nagios/bin/nagios
#ln -s /usr/local/nagios/bin/nagios /var/www/html/nconf/bin/


  #第四步结束后删除临时文件
#rm -rf /var/www/html/nconf/{INSTALL,INSTALL.php,UPDATE,UPDATE.php}
  

  三、配置Nconf sudo权限和自动生成配置文件
  #visudo
  apache    ALL=(ALL)       NOPASSWD:/etc/init.d/nagios

//修改nconf配置文件
#cat /var/www/html/nconf/config/deployment.ini
[extract config]
type        = local
source_file = "/var/www/html/nconf/output/NagiosConfig.tgz"
target_file = "/var/www/html/nconf/temp/"
action      = extract

[copy collector config]
type        = local
source_file = "/var/www/html/nconf/temp/Default_collector/"
target_file = "/usr/local/nagios/etc/Default_collector/"
action      = copy

[copy global config]
type        = local
source_file = "/var/www/html/nconf/temp/global/"
target_file = "/usr/local/nagios/etc/global/"
action      = copy
reload_command = "sudo /etc/rc.d/init.d/nagios reload"
  

  四、nconf生成配置文件的流程

  点击 Generate Nagios config 后会检测Nagios配置文件是否有问题
  


  无问题后点击 Deploy ,就会安装下面的流程和上面配置文件中配置的路径去执行相关操作。


  (1)在 [extract config] 配置的source_file下生成压缩文件同时备份之前的压缩文件,之后解压到target_file下面

  

  (2)按照[copy collector config][copy global config] 的配置,将source_file 的文件复制到target_file 下。

(3)执行 sudo /etc/init.d/nagios reload
  
五、将现有配置导入Nconf中

  (1)注意事项
按以下方式导入可避免配置文件之间的冲突:
1. timeperiods
2. misccommands & check_commands
3. contacts
4. contactgroups (considering that some contactgroups might be linked to others)
5. host-templates
6. parent-hosts, then remaining hosts
7. hostgroups (considering that some hostgroups might be linked to others)
8. host-dependencies(主机依赖)
9. service-templates
10. services
11. advanced-services
12. servicegroups (considering that some servicegroups might be linked to others)
13. service-dependencies

现有配置文件按属性做更精细的分离,确保每个配置文件里面只有对应的配置属性

(2)语法
Usage:
/var/www/html/nconf/bin/add_items_from_nagios.pl -c class -f /path/to/file [-x (1-5)] [-s]

Help:

  required

  -c  Specify the class of items that you wish to import. Must correspond to an NConf class
      (e.g. "host", "service, "hostgroup", "checkcommand", "contact", "timeperiod"...)

  -f  The path to the file which is to be imported. CAUTION: Make sure you have
      only items of one class in the same file (e.g. "hosts.cfg", "services.cfg"...)
      Also make sure you import host- or service-templates separately ("host" or
      "service" items containing a "name" attribute)

  optional

  -x  Set a custom loglevel (1 = lowest, 5 = most verbose)

  -s  Simulate only. Do not make any actual modifications to the database.
  
  #-s为测试模式,不会往数据库插入任何数据
  /var/www/html/nconf/bin/add_items_from_nagios.pl -c timeperiod -f /usr/local/nagios/etc/objects/timeperiods.cfg -s
  
  (3)实战
/var/www/html/nconf/bin/add_items_from_nagios.pl -c timeperiod -f /usr/local/nagios/etc/objects/timeperiods.cfg -s
/var/www/html/nconf/bin/add_items_from_nagios.pl -c misccommand  -f /usr/local/nagios/etc/objects/misccommands.cfg -s
/var/www/html/nconf/bin/add_items_from_nagios.pl -c checkcommand -f /usr/local/nagios/etc/objects/checkcommands.cfg -s
/var/www/html/nconf/bin/add_items_from_nagios.pl -c contact -f /usr/local/nagios/etc/objects/contacts.cfg -s
/var/www/html/nconf/bin/add_items_from_nagios.pl -c contactgroup -f /usr/local/nagios/etc/objects/contactgroup.cfg -s
/var/www/html/nconf/bin/add_items_from_nagios.pl -c host-template -f /usr/local/nagios/etc/objects/host-template.cfg -s
/var/www/html/nconf/bin/add_items_from_nagios.pl -c host -f /usr/local/nagios/etc/objects/hosts.cfg -s
/var/www/html/nconf/bin/add_items_from_nagios.pl -c service-template -f /usr/local/nagios/etc/objects/service-template.cfg -s
/var/www/html/nconf/bin/add_items_from_nagios.pl -c service -f /usr/local/nagios/etc/objects/services.cfg -s
/var/www/html/nconf/bin/add_items_from_nagios.pl -c service -f /usr/local/nagios/etc/objects/localhost.cfg -s

  

  六、静态文件修改功能
  static_cfg默认路径为/var/www/html/nconf/static_cfg
  //创建一个测试文件
  #echo "您好kjklsj111" >>/var/www/html/nconf/static_cfg/test.txt
  

  页面点击Administration->Edit static config files,你会发现有保存和下载按钮,直接编辑文件后点击保存就可

  http://s2.运维网.com/wyfs02/M01/7C/7C/wKiom1bRVsqiFsVPAAExRD9GDpM237.png
  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-661249-1-1.html 上篇帖子: 开源监控解决方案Nagios+Cacti+PNP4Nagios+NConf+NDOUtils+Nagvis(七)nagios+cacti整合 下篇帖子: 开源监控解决方案Nagios+Cacti+PNP4Nagios+NConf+NDOUtils+Nagvis(九)NagVis安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表