[icinga-users] Question about icinga2 api dynamically added hosts and hostgroups

Madhusmita Gochhait mgochhait at juniper.net
Fri Nov 13 23:02:35 CET 2015


After restart of icinga process , Icinga unable to query the hosts/groups objects through api . Icinga http returns object does not exist

Here are the steps to simulate the issue (Single Node)

Step 1:   curl -k -s -u icingaadmin:icinga 'https://localhost:5665/v1/objects/hosts/10.102.58.77'  -H "Accept: application/json" -X PUT -d '{ "templates": [ "generic-host" ], "attrs": { "address": "10.102.58.77”}}
                {"results":[{"code":200.0,"status":"Object was created"}]}
Step 2 :  query to icinga - curl -k -s -u icingaadmin:icinga 'https://localhost:5665/v1/objects/hosts/10.102.58.77'  will result with detailed host output

Step 3: Restart Icinga
               service icinga2 reload

Step 4: Host Query as detailed in Step 2
curl -k -s -u icingaadmin:icinga 'https://localhost:5665/v1/objects/hosts/10.102.58.77'
Error: Object does not exist


Similar behavior with host groups also .

Thanks,
mgochhait




From: Madhusmita Gochhait <mgochhait at juniper.net<mailto:mgochhait at juniper.net>>
Date: Tuesday, November 10, 2015 at 3:21 PM
To: "icinga-users at lists.icinga.org<mailto:icinga-users at lists.icinga.org>" <icinga-users at lists.icinga.org<mailto:icinga-users at lists.icinga.org>>
Subject: Question about icinga2 api dynamically added hosts and hostgroups


I am using the snapshot version of icinga2 for the api feature . Dynamically add hosts and host groups.

Here is what i am doing :

To add hostgroup : curl -k -s -u icingaadmin:icinga 'https://localhost:5665/v1/objects/hostgroups/testgrp' -X PUT -d '{ "attrs": { "name" : "testgrp" ,"display_name" : "testgrp" , "state_loaded" :true }}'

To add host :

curl -k -s -u icingaadmin:icinga 'https://localhost:5665/v1/objects/hosts/<https://localhost:5665/v1/objects/hosts/8.8.8.8>testhost' -X PUT -d '{ "templates": [ "generic-host" ], "attrs": { "address": "8.8.8.8" , "groups" : [ "testgrp" ]} }'

It gets successfully added  and I am also able to  query them through the api .

But in UI , I am seeing only the host and no hostgroup .

The host group gets displayed once I restart/reload icinga .

Since , we have a large setup (>1000 hosts ) , we don’t want to reload /restart everytime we add hostgroups .

Is there any way it can be done in same way as the host , so that both host and host groups shows in UI without restart everytime ?


Thanks,

mgochhait


<http://stackoverflow.com/questions/tagged/icinga>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.icinga.org/pipermail/icinga-users/attachments/20151113/ceff5111/attachment.html>


More information about the icinga-users mailing list