Menu

do_config.php

2020-11-20
2020-11-26
  • Paul Clayton

    Paul Clayton - 2020-11-20

    Hi ,
    I am in the process of rewriting a bunch of scripts that do automatic configuration on server deployment from NCONF to NAGIOSQL.
    So I have few questions.
    What does the actual "write" function do when running do_config.php. It says it writes out a configuration, but I never see anything appear, and strace does not give sufficient information to trace what it is doing.
    In the gui what function would run the "Write all config files" , and is there a script to do this.

    regards

     
  • Martin

    Martin - 2020-11-20

    The do_config.php script has some low level functions like:
    - write config files
    - import config files
    - check configuration
    - restart nagios

    As example - write contact data:
    do_config.php write localhost contact
    (localhost means the data domain "localhost" - not the target system - although it can end up in the same way)

    Important: There is an "exit" at the beginning in do_config.php that has to be comment out to work

    "Write all config files" can be found below the host and service table. This is because each host and service in NagiosQL uses its own file, whereas e.g. all contacts are together in one file.

    So this command will write all host or service files - no matter if something changes in a file or not.

    The script can do this in the same way using:
    do_config.php write localhost host
    do_config.php write localhost service

     
  • Paul Clayton

    Paul Clayton - 2020-11-20

    Thanx for the feedback. I must a permissions issue that is not showing up.

     
  • Paul Clayton

    Paul Clayton - 2020-11-24

    Hi,
    Can anyone please explain exactly what the "write" option does in the do_config.php.
    I never get a failure when running it, but it does not seem to write anything out.
    I can import a file using the command, but the "write" function has me confused.

    Examples
    php doconfig.php write localhost hosts
    Write hosts.cfg ...
    Configuration file hosts.cfg successfully written!

    Nothing written anywhere

     
  • Martin

    Martin - 2020-11-26

    Hello

    Look at this examples on my test system:

    nagiosqltest:/appl/web/nagiosql/scripts # ll /etc/nagiosql/timeperiods.cfg
    -rw-r--r-- 1 wwwrun www 2629 Oct 25 14:30 /etc/nagiosql/timeperiods.cfg
    nagiosqltest:/appl/web/nagiosql/scripts # ./do_config.php write localhost timeperiod
    Write timeperiod.cfg ...
    Configuration file timeperiod.cfg successfully written!
    nagiosqltest:/appl/web/nagiosql/scripts # ll /etc/nagiosql/timeperiods.cfg
    -rw-r--r-- 1 root root 2629 Nov 26 11:08 /etc/nagiosql/timeperiods.cfg
    
    nagiosqltest:/appl/web/nagiosql/scripts # ll /etc/nagiosql/hosts/
    total 56
    -rw-r--r-- 1 wwwrun www 980 Oct 26 11:19 hpmfplaser.mydomain.cfg
    -rw-r--r-- 1 wwwrun www 866 Oct 26 11:19 nagiosqltest.mydomain.cfg
    nagiosqltest:/appl/web/nagiosql/scripts # ./do_config.php write localhost host
    Write host configurations  ...
    Host configuration files successfully written!
    nagiosqltest:/appl/web/nagiosql/scripts # ll /etc/nagiosql/hosts/
    total 56
    -rw-r--r-- 1 root root 980 Nov 26 11:09 hpmfplaser.mydomain.cfg
    -rw-r--r-- 1 root root 866 Nov 26 11:09 nagiosqltest.mydomain.cfg
    nagiosqltest:/appl/web/nagiosql/scripts # 
    

    This files are updated.

     
  • Martin

    Martin - 2020-11-26

    I think the error is using "hosts" insteed of "host"

     
  • John  Koffler

    John Koffler - 2023-11-29
    Post awaiting moderation.
  • John  Koffler

    John Koffler - 2023-11-29
    Post awaiting moderation.

Log in to post a comment.