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

Michael Friedrich Michael.Friedrich at netways.de
Sun Nov 15 20:06:43 CET 2015


> On 15 Nov 2015, at 19:44, Madhusmita Gochhait <mgochhait at juniper.net> wrote:
>
> The host config file was created .
>
> ls -ltr /usr/local/var/lib/icinga2/api/packages/_api/conf.d/hosts/
> total 4
> -rw-r--r-- 1 icinga icinga 110 Nov 15 10:29 10.102.58.77.conf

That path is not coming from the package repositories, what kind of build is that?

>
> But not able to query , after restart of icinga process.
>
> curl -k -s -u icingaadmin:icinga 'https://localhost:5665/v1/objects/hosts/10.102.58.77'
> Error: Object does not exist.
>
> Please note that i am using the latest snapshot build of icing .

Please post the output of

icinga2 --version

Kind regards,
Michael

>
> Regards,
> mgochhait
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 15 Nov 2015 08:55:40 +0000
> From: Gunnar Beutner <Gunnar.Beutner at netways.de>
> To: "icinga-users at lists.icinga.org" <icinga-users at lists.icinga.org>
> Subject: Re: [icinga-users] Question about icinga2 api dynamically
>        added hosts and hostgroups
> Message-ID: <988042E7-141F-4BF4-BD5A-5A9F46BA56C5 at netways.de>
> Content-Type: text/plain; charset="utf-8"
>
>
>
>
>
>
> On 13/11/15 23:02, "icinga-users on behalf of Madhusmita Gochhait" <icinga-users-bounces at lists.icinga.org on behalf of mgochhait at juniper.net> wrote:
>
>> 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
>
> Works for me. Can you check whether the host?s config file was created?:
>
> acheron:icinga2 gunnar$ ls -l ../i2/var/lib/icinga2/api/packages/_api/acheron-1445924979-1/conf.d/hosts/
> total 8
> -rw-r--r--  1 gunnar  staff  110 Nov 15 09:53 10.102.58.77.conf
> acheron:icinga2 gunnar$ cat ../i2/var/lib/icinga2/api/packages/_api/acheron-1445924979-1/conf.d/hosts/10.102.58.77.conf
> object Host "10.102.58.77" {
> import "generic-host"
>
>
> address = "10.102.58.77"
> version = 1447577614.982893
> }
> acheron:icinga2 gunnar$
>
>
>
>>
>>
>> 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>
>> Date: Tuesday, November 10, 2015 at 3:21 PM
>> To: "icinga-users at lists.icinga.org" <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>
>>
>>
>>
>>
>
> --?
> Gunnar Beutner
> Senior Developer
>
> NETWAYS GmbH | Deutschherrnstr. 15-19 | D-90429 Nuernberg
> Tel: +49 911 92885-0 | Fax: +49 911 92885-77
> GF: Julian Hein, Bernd Erk | AG Nuernberg HRB18461
> http://www.netways.de | Gunnar.Beutner at netways.de
>
> ** OSMC 2015 - November - netways.de/osmc **
> ** OSDC 2016 - April ? netways.de/osdc **
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> icinga-users mailing list
> icinga-users at lists.icinga.org
> https://lists.icinga.org/mailman/listinfo/icinga-users
>
>
> ------------------------------
>
> End of icinga-users Digest, Vol 23, Issue 24
> ********************************************
> _______________________________________________
> icinga-users mailing list
> icinga-users at lists.icinga.org
> https://lists.icinga.org/mailman/listinfo/icinga-users


-- 
Michael Friedrich, DI (FH)
Senior Developer

NETWAYS GmbH | Deutschherrnstr. 15-19 | D-90429 Nuernberg
Tel: +49 911 92885-0 | Fax: +49 911 92885-77
GF: Julian Hein, Bernd Erk | AG Nuernberg HRB18461
http://www.netways.de | Michael.Friedrich at netways.de

** OSMC 2015 - November - netways.de/osmc **
** OSDC 2016 - April – netways.de/osdc **


More information about the icinga-users mailing list