CentOS 6.2 上基本 Nagios 服务器的 nconf deploy.ini 配置

CentOS 6.2 上基本 Nagios 服务器的 nconf deploy.ini 配置

我已经设置了 nconf 和 Nagios,但我无法弄清楚如何配置deployment.ini以将生成的配置正确部署到/usr/local/nagios/etc

以下是感兴趣的目录列表:

[jshin@nag0 tmp]$ ls
Default_collector  global

[jshin@nag0 tmp]$ cd Default_collector/
[jshin@nag0 Default_collector]$ ls
advanced_services.cfg  hostgroups.cfg  service_dependencies.cfg  services.cfg
host_dependencies.cfg  hosts.cfg       servicegroups.cfg

[jshin@nag0 Default_collector]$ cd ..
[jshin@nag0 tmp]$ cd global/
[jshin@nag0 global]$ ls
checkcommands.cfg  contacts.cfg        misccommands.cfg       timeperiods.cfg
contactgroups.cfg  host_templates.cfg  service_templates.cfg

[jshin@nag0 global]$ cd ..
[jshin@nag0 tmp]$ cd /usr/local/nagios/etc/
[jshin@nag0 etc]$ ls
cgi.cfg  htpasswd.users  nagios.cfg  objects  resource.cfg

[jshin@nag0 etc]$ cd objects/
[jshin@nag0 objects]$ ls
commands.cfg  localhost.cfg  switch.cfg     timeperiods.cfg
contacts.cfg  printer.cfg    templates.cfg  windows.cfg

这是我的deployment.ini(几乎是默认设置)

;; LOCAL deployment ;;

[extract config]
type        = local
source_file = "/var/www/html/nconf/output/NagiosConfig.tgz"
target_file = "/tmp/"
action      = extract

[copy collector config]
type        = local
source_file = "/tmp/Default_collector/"
target_file = "/usr/local/nagios/etc/Default_collector/"
action      = copy

[copy global config]
type        = local
source_file = "/tmp/global/"
target_file = "/usr/local/nagios/etc/global"
action      = copy
reload_command = "service nagios restart"

deployment.ini我想知道的是为什么默认显示的目录结构(带有Default_collectorglobal)与 Nagios 默认的目录结构不同,后者只有一个名为 的文件夹objects。我错过了什么?

deployment.ini或者更重要的是,你看起来怎么样?

答案1

但我不知道如何配置deployment.ini才能将生成的配置正确部署到/usr/local/nagios/etc

生成Nagios配置后,只需使用一些命令如:gunzip,,,, ... 即可复制到Nagios 配置目录。tarscprsync

使用上述配置,进入 Web UI,点击生成 Nagios 配置链接,然后点击部署按钮,它会告诉你哪个步骤失败了。单击加号 (+) 查看详细信息:

copy global config  FAILED

PHP mkdir:  OK  
Create target directory (/usr/local/nagios/etc/global)
PHP copy:   OK  
recursive copy(/tmp/global/, /usr/local/nagios/etc/global)
system call     FAILED  
service nagios restart
sh: service: command not found

从上面的错误可以看出,你漏掉了target_file。此外,你需要确保apache能够重新加载 Nagios无需输入密码。

编辑[复制全局配置]如下:

[copy global config]
type        = local
source_file = "/tmp/global/"
target_file = "/usr/local/nagios/etc/global/"
action      = copy
reload_command = "sudo /etc/init.d/nagios reload"

(你可以/sbin/service根据需要使用)

它会按您预期的那样工作。

但是,等等...为什么不直接将文件提取到/usr/local/nagios/etc/

[extract config]
type        = local
source_file = "/var/www/html/nconf/output/NagiosConfig.tgz"
target_file = "/usr/local/nagios/etc/"
action      = extract
reload_command = "sudo /etc/init.d/nagios reload"

deployment.ini我想知道的是为什么默认显示的目录结构( 带有Default_collectorglobal)与 Nagios 默认的目录结构不同,后者只有一个名为 的文件夹objects。我错过了什么?

没关系。你可以把配置文件放在你想要的任何文件夹中,但不要忘记在主配置文件中告诉 Nagiosnagios配置文件

相关内容