nconf deployment.ini configuration for a basic Nagios server on CentOS 6.2

7,495

but I cannot figure out how to configure deployment.ini to properly deploy the generated configuration to /usr/local/nagios/etc.

After generating Nagios config, it simply uses some commands such as: gunzip, tar, scp, rsync, ... to copy to the Nagios config directory.

With the above config, go to the Web UI, hit the Generate Nagios config link and followed by click on the Deploy button, it will tell you which step has failed. Click the plus signs (+) to see the details info:

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

As you can see from the above error, you missed the trailing slash in target_file. Moreover, you need to make sure that apache can reload Nagios without prompting password.

Edit the [copy global config] as belows:

[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"

(you can use /sbin/service if you want)

it will work as you expected.

But, wait... why not extract the files direct to /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"

What I am wondering is why the directory structure that the default deployment.ini seems to suggest, with Default_collector and global, is different from the one that Nagios has by default, with only a folder called objects. What am I missing?

No matter. You can put the config files in the any folder which you want but don't forget to tell Nagios in the main config file nagios.cfg.

Share:
7,495

Related videos on Youtube

tacos_tacos_tacos
Author by

tacos_tacos_tacos

Updated on September 18, 2022

Comments

  • tacos_tacos_tacos
    tacos_tacos_tacos almost 2 years

    I have set up nconf and Nagios but I cannot figure out how to configure deployment.ini to properly deploy the generated configuration to /usr/local/nagios/etc.

    Here are the directory listings of interest:

    [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
    

    Here is my deployment.ini (pretty much the default setting)

    ;; 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"
    

    What I am wondering is why the directory structure that the default deployment.ini seems to suggest, with Default_collector and global, is different from the one that Nagios has by default, with only a folder called objects. What am I missing?

    Or more importantly, how does your deployment.ini look?