Page 1 of 1

5.6.x config/import api failure/formatting question...

Posted: Thu May 02, 2019 1:10 pm
by jaimie.livingston
Can anyone explain why importing the config below via the config/import API fails?
The same config imports without error using the CCM Import Config wizard.

Code: Select all

curl -XPOST "http://rdcengnag02.rdc.l/nagiosxi/api/v1/config/import/?apikey=MYAPIKEYISREALLYREALLYLONG&pretty=1&overwrite=1" -d '
define host {
    host_name                 XTEST rdctsthst05 172.16.0.5 dc-natest lnx-t
    use                       a-x--xtest-integration-testing
    display_name              testhost.natest.l
    address                   172.16.0.5
    hostgroups                +ALL Servers - Windows,Test Servers [T ---tsthst--]
    active_checks_enabled     0
    passive_checks_enabled    1
    contacts                  testing.contact
    contact_groups            x-blackhole-devnull-grp
    notification_period       24x7
    notification_options      d,u,r,f,s,
    notifications_enabled     1
    stalking_options          o,d,u,
    _WORKER                   hostgroup_WORKERQ-RDC
    register                  1
} '
{
    "error": "Import failed. Configuration passed may not be formatted properly."
}

Re: 5.6.x config/import api failure/formatting question...

Posted: Thu May 02, 2019 3:12 pm
by npolovenko
Hello, @jaimie.livingston. I imported a similar configuration via API command and it completed successfully.
I noticed if I try to import the same configuration multiple times, it will result in a similar error to what you're seeing:
"error": "Import failed. Configuration passed may not be formatted properly."
Can you check if there is already a host with the same name in the Core Configurations Manager by chance?

Re: 5.6.x config/import api failure/formatting question...

Posted: Thu May 02, 2019 8:17 pm
by jaimie.livingston
There was not. Even so, I'm not sure that should matter when using the "overwrite=1" option.

Re: 5.6.x config/import api failure/formatting question...

Posted: Fri May 03, 2019 12:43 pm
by ssax
I copy/pasted your exact command from here into my system and it worked perfectly as well.

You may have some unprintable characters in there, try copy/pasting from here and modifying that command.

Please run this command (and leave it running):

Code: Select all

tail -Fn0 /var/log/httpd/error_log /var/log/httpd/ssl_error_log
Then run the curl request again and send me the full output of the tail command above once it's failed so that I can review the data.

Re: 5.6.x config/import api failure/formatting question...

Posted: Wed May 08, 2019 3:51 pm
by jaimie.livingston
I "resolved" this with a complete system reboot during my last maintenance window.
I still have no idea what went sideways, but I'm not going to worry about it until it happens again.

Thanks for the replys.

Re: 5.6.x config/import api failure/formatting question...

Posted: Wed May 08, 2019 4:01 pm
by npolovenko
@jaimie.livingston, That is strange. Thanks for updating us. Next time try restarting ndo2db only.