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:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
Fixed by declaring variables first;
if ($argFunction === 'check') {
** $strBinary = '';
$strBaseDir = '';
$strNagiosBaseDir = '';
$strConffile = '';
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.