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

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jaimie.livingston
Posts: 59
Joined: Wed Nov 23, 2016 10:41 am

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

Post 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."
}
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

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

Post 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?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
jaimie.livingston
Posts: 59
Joined: Wed Nov 23, 2016 10:41 am

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

Post by jaimie.livingston »

There was not. Even so, I'm not sure that should matter when using the "overwrite=1" option.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

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

Post 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.
jaimie.livingston
Posts: 59
Joined: Wed Nov 23, 2016 10:41 am

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

Post 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.
npolovenko
Support Tech
Posts: 3457
Joined: Mon May 15, 2017 5:00 pm

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

Post by npolovenko »

@jaimie.livingston, That is strange. Thanks for updating us. Next time try restarting ndo2db only.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Locked