Menu

scripting documentation

2025-04-08
2025-04-20
  • Feathers164

    Feathers164 - 2025-04-08

    Hi - is there any documentation on how the scripting API works?

    Does the code need to be run as a specific user?

    I can run with no operands;

    myhost:/$ sudo -u www-data /var/www/nagiosql/scripts/do_config.php
    Usage: /var/www/nagiosql/scripts/do_config.php function domain [object]
    function = write/check/restart/import
    domain = domain name like 'localhost'
    object = object name, see below:
    import: object = file name like 'hostgroups.cfg' or 'localhost.cfg'
    write: object = table name like 'tbl_contact' or simplier 'contact' without 'tbl_'
    Attention: import function replaces existing data!
    Note that the new backup and configuration files becomes the UID/GID
    from the calling user and probably can't be deleted via web GUI anymore!

    Putting in operands breaks;

    myhost:/$ sudo -u www-data /var/www/nagiosql/scripts/do_config.php check localhost
    PHP Fatal error: Uncaught TypeError: functions\NagConfigClass::getConfigData(): Argument #3 ($strValue) must be of type string, null given, called in /var/www/nagiosql/scripts/do_config.php on line 87 and defined in /var/www/nagiosql/functions/NagConfigClass.php:612
    Stack trace:

    0 /var/www/nagiosql/scripts/do_config.php(87): functions\NagConfigClass->getConfigData()

    1 {main}

    thrown in /var/www/nagiosql/functions/NagConfigClass.php on line 612

     
  • Feathers164

    Feathers164 - 2025-04-10

    Fixed by declaring variables first;
    if ($argFunction === 'check') {
    ** $strBinary = '';
    $strBaseDir = '';
    $strNagiosBaseDir = '';
    $strConffile = '';

    Would be great if there was a mechansim in the import process to replace existing objects...You can only import new import new objects atm - not replace or delete existing objects.
    
     
  • Martin

    Martin - 2025-04-20

    The help output is not optimal - "object" is mandatory.

    Since there was almost never any feedback on the scripting function, I assumed that it was neither desired nor used. So there was no further development here either.

    Generally, today this would also be implemented via a JSON API.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.