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

Gunnar Beutner Gunnar.Beutner at netways.de
Sun Nov 15 23:13:30 CET 2015






On 15/11/15 23:10, "icinga-users on behalf of Madhusmita Gochhait" <icinga-users-bounces at lists.icinga.org on behalf of mgochhait at juniper.net> wrote:

>
>Here is the output of the config file :
>
>3) root at icinga-cluster-2:~# ls -ltr /usr/local/var/lib/icinga2/api/packages/_api/conf.d/hosts/10.102.58.77.conf
>-rw-r--r-- 1 icinga icinga 110 Nov 15 14:03 /usr/local/var/lib/icinga2/api/packages/_api/conf.d/hosts/10.102.58.77.conf

Sorry, that’s not what I asked for.

>
>4 ) root at icinga-cluster-2:~# cat /usr/local/var/lib/icinga2/api/packages/_api/conf.d/hosts/10.102.58.77.conf
>object Host "10.102.58.77" {
>import "generic-host"
>
>address = "10.102.58.77"
>version = 1447625037.471167
>}
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Sun, 15 Nov 2015 19:04:51 +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: <3C55C63C-E863-4C92-8796-7E86E8D777DE at netways.de>
>Content-Type: text/plain; charset="utf-8"
>
>Can you attach the output of ?ls -lR /usr/local/var/lib/icinga2/api/packages? and the contents of that config file?
>
>FWIW the path is somewhat odd, it _should_ be /usr/local/var/lib/icinga2/api/packages/_api/<unique-id>/conf.d/hosts/.
>
>
>
>
>On 15/11/15 19:44, "icinga-users on behalf of Madhusmita Gochhait" <icinga-users-bounces at lists.icinga.org on behalf of 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
>>
>>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 icinag2 .
>>
>>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
>
>--?
>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 **
>
>------------------------------
>
>Message: 2
>Date: Sun, 15 Nov 2015 19:06:43 +0000
>From: Michael Friedrich <Michael.Friedrich 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: <8D2CC12D-491A-4CA3-A452-56A2DFE5BAD1 at netways.de>
>Content-Type: text/plain; charset="utf-8"
>
>
>> 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 **
>
>------------------------------
>
>Message: 3
>Date: Sun, 15 Nov 2015 22:02:03 +0000
>From: Madhusmita Gochhait <mgochhait at juniper.net>
>To: "icinga-users at lists.icinga.org" <icinga-users at lists.icinga.org>
>Subject: Re: [icinga-users] icinga-users Digest, Vol 23, Issue 25
>Message-ID:
>        <BN3PR0501MB1283807A1A4E4DF5C8F6338EAE1F0 at BN3PR0501MB1283.namprd05.prod.outlook.com>
>
>Content-Type: text/plain; charset="iso-8859-1"
>
>I am using latest snapshot build ( compiled from the master branch in github) .
>
>
>root at icinga-cluster-2:~# icinga2 --version
>icinga2 - The Icinga 2 network monitoring daemon (version: r2.4.0-1)
>
>Copyright (c) 2012-2015 Icinga Development Team (https://www.icinga.org)
>License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>
>This is free software: you are free to change and redistribute it.
>There is NO WARRANTY, to the extent permitted by law.
>
>Application information:
>  Installation root: /usr/local
>  Sysconf directory: /usr/local/etc
>  Run directory: /usr/local/var/run
>  Local state directory: /usr/local/var
>  Package data directory: /usr/local/share/icinga2
>  State path: /usr/local/var/lib/icinga2/icinga2.state
>  Modified attributes path: /usr/local/var/lib/icinga2/modified-attributes.conf
>  Objects path: /usr/local/var/cache/icinga2/icinga2.debug
>  Vars path: /usr/local/var/cache/icinga2/icinga2.vars
>  PID path: /usr/local/var/run/icinga2/icinga2.pid
>
>System information:
>  Operating system: Linux
>  Operating system version: 3.13.0-32-generic
>  Architecture: x86_64
>  Distribution: Ubuntu 14.04.1 LTS
>
>-----------------------------
>
>Message: 1
>Date: Sun, 15 Nov 2015 11:39:36 +0000
>From: Michael Friedrich <Michael.Friedrich 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: <242C9A5C-194F-4616-A0A9-614D2011B017 at netways.de>
>Content-Type: text/plain; charset="utf-8"
>
>
>> On 13 Nov 2015, at 23:02, Madhusmita Gochhait <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
>>
>> 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
>
>I?m also unable to reproduce this here.
>
>michi at mbmif ~ $ icinga2 --version
>icinga2 - The Icinga 2 network monitoring daemon (version: v2.3.11-854-ge9db4bc; debug)
>
>Copyright (c) 2012-2015 Icinga Development Team (https://www.icinga.org)
>License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl2.html>
>This is free software: you are free to change and redistribute it.
>There is NO WARRANTY, to the extent permitted by law.
>
>Application information:
>  Installation root: /usr/local/icinga2
>  Sysconf directory: /usr/local/icinga2/etc
>  Run directory: /usr/local/icinga2/var/run
>  Local state directory: /usr/local/icinga2/var
>  Package data directory: /usr/local/icinga2/share/icinga2
>  State path: /usr/local/icinga2/var/lib/icinga2/icinga2.state
>  Modified attributes path: /usr/local/icinga2/var/lib/icinga2/modified-attributes.conf
>  Objects path: /usr/local/icinga2/var/cache/icinga2/icinga2.debug
>  Vars path: /usr/local/icinga2/var/cache/icinga2/icinga2.vars
>  PID path: /usr/local/icinga2/var/run/icinga2/icinga2.pid
>
>System information:
>  Operating system: Darwin
>  Operating system version: 15.0.0
>  Architecture: x86_64
>
>
>michi at mbmif ~ $ curl -k -s -u root:icinga -H 'Accept: application/json' -X PUT -d '{ "attrs": { "check_command": "hostalive", "address": "192.168.2.123" } }' 'https://localhost:5665/v1/objects/hosts/michiathome1'
>{"results":[{"code":200.0,"status":"Object was created"}]}
>
>[2015-11-15 12:32:31 +0100] information/ApiListener: New client connection (no client certificate)
>[2015-11-15 12:32:31 +0100] information/HttpServerConnection: Request: PUT /v1/objects/hosts/michiathome1 (root)
>[2015-11-15 12:32:31 +0100] information/ConfigCompiler: Compiling config file: /usr/local/icinga2/var/lib/icinga2/api/packages/_api/mbmif.int.netways.de-1442309540-1/conf.d/hosts/michiathome1.conf
>[2015-11-15 12:32:31 +0100] information/ConfigItem: Committing config items
>
>michi at mbmif ~ $ curl -k -s -u root:icinga 'https://localhost:5665/v1/objects/hosts/michiathome1'
>{"results":[{"attrs":{"__name":"michiathome1","acknowledgement":0.0,"acknowledgement_expiry":0.0,"action_url":"","active":true,"address":"192.168.2.123","address6":"","check_attempt":1.0,"check_command":"hostalive","check_interval":300.0,"display_name":"michiathome1","enable_active_checks":true,"enable_event_handler":true,"enable_flapping":false,"enable_notifications":true,"enable_passive_checks":true,"enable_perfdata":true,"flapping":false,"flapping_last_change":0.0,"flapping_negative":0.0,"flapping_positive":0.0,"flapping_threshold":30.0,"force_next_check":false,"force_next_notification":false,"groups":[],"ha_mode":0.0,"icon_image":"","icon_image_alt":"","last_check":-1.0,"last_check_result":null,"last_hard_state":1.0,"last_hard_state_change":1447587016.4019169807,"last_in_downtime":false,"last_reachable":true,"last_state":1.0,"last_state_change":1447587016.4019169807,"last_state_down":0.0,"last_state_type":0.0,"last_state_unreachable":0.0,"last_state_up":0.0,"max_check_attempts":3
> .0,"name":"michiathome1","next_check":1447587300.0599999428,"notes":"","notes_url":"","original_attributes":null,"package":"_api","paused":false,"retry_interval":60.0,"state":1.0,"state_type":0.0,"templates":["michiathome1"],"type":"Host","vars":null,"version":1447587151.0631680489,"volatile":false,"zone":""},"joins":{},"meta":{},"name":"michiathome1","type":"Host"}]}
>
>michi at mbmif ~ $ sudo cat /usr/local/icinga2/var/lib/icinga2/api/packages/_api/mbmif.int.netways.de-1442309540-1/conf.d/hosts/michiathome1.conf
>object Host "michiathome1" {
>address = "192.168.2.123"
>check_command = "hostalive"
>version = 1447587151.063168
>}
>
>michi at mbmif ~ $ sudo kill -HUP $(pidof icinga2)
>
>michi at mbmif ~ $ sudo cat /usr/local/icinga2/var/lib/icinga2/api/packages/_api/mbmif.int.netways.de-1442309540-1/conf.d/hosts/michiathome1.conf
>object Host "michiathome1" {
>address = "192.168.2.123"
>check_command = "hostalive"
>version = 1447587151.063168
>}
>
>michi at mbmif ~ $ curl -k -s -u root:icinga 'https://localhost:5665/v1/objects/hosts/michiathome1'
>{"results":[{"attrs":{"__name":"michiathome1","acknowledgement":0.0,"acknowledgement_expiry":0.0,"action_url":"","active":true,"address":"192.168.2.123","address6":"","check_attempt":1.0,"check_command":"hostalive","check_interval":300.0,"display_name":"michiathome1","enable_active_checks":true,"enable_event_handler":true,"enable_flapping":false,"enable_notifications":true,"enable_passive_checks":true,"enable_perfdata":true,"flapping":false,"flapping_last_change":1447587315.097356081,"flapping_negative":0.0,"flapping_positive":1447587315.0,"flapping_threshold":30.0,"force_next_check":false,"force_next_notification":false,"groups":[],"ha_mode":0.0,"icon_image":"","icon_image_alt":"","last_check":1447587315.096987009,"last_check_result":{"active":true,"check_source":"mbmif.int.netways.de","command":["/usr/local/sbin/check_ping","-H","192.168.2.123","-c","5000,100%","-w","3000,80%"],"execution_end":1447587315.0968000889,"execution_start":1447587300.0619831085,"exit_status":2.0,"output":
> "PING CRITICAL - Packet loss = 100%","performance_data":["rta=5000.000000ms;3000.000000;5000.000000;0.000000","pl=100%;80;100;0"],"schedule_end":1447587315.096987009,"schedule_start":1447587600.0599999428,"state":2.0,"type":"CheckResult","vars_after":{"attempt":1.0,"reachable":true,"state":2.0,"state_type":1.0},"vars_before":null},"last_hard_state":1.0,"last_hard_state_change":1447587315.096987009,"last_in_downtime":false,"last_reachable":true,"last_state":1.0,"last_state_change":1447587315.096987009,"last_state_down":0.0,"last_state_type":0.0,"last_state_unreachable":0.0,"last_state_up":0.0,"max_check_attempts":3.0,"name":"michiathome1","next_check":1447587599.129999876,"notes":"","notes_url":"","original_attributes":null,"package":"_api","paused":false,"retry_interval":60.0,"state":1.0,"state_type":1.0,"templates":["michiathome1"],"type":"Host","vars":null,"version":1447587151.0631680489,"volatile":false,"zone":""},"joins":{},"meta":{},"name":"michiathome1","type":"Host"}]}
>
>
>michi at mbmif ~ $ sudo mysql icinga -p -e 'select * from icinga_hoststatus hs join icinga_objects ohs on hs.host_object_id=ohs.object_id where ohs.name1="michiathome1" and ohs.is_active=1\G'
>Enter password:
>*************************** 1. row ***************************
>                hoststatus_id: 643
>                  instance_id: 1
>               host_object_id: 8940
>           status_update_time: 2015-11-15 12:35:58
>                       output: PING CRITICAL - Packet loss = 100%
>                  long_output:
>                     perfdata: rta=5000.000000ms;3000.000000;5000.000000;0.000000 pl=100%;80;100;0
>                 check_source: mbmif.int.netways.de
>                current_state: 1
>             has_been_checked: 1
>          should_be_scheduled: 1
>        current_check_attempt: 1
>           max_check_attempts: 3
>                   last_check: 2015-11-15 12:35:15
>                   next_check: 2015-11-15 12:39:59
>                   check_type: 0
>            last_state_change: 2015-11-15 12:35:15
>       last_hard_state_change: 2015-11-15 12:35:15
>              last_hard_state: 1
>                 last_time_up: 0000-00-00 00:00:00
>               last_time_down: 0000-00-00 00:00:00
>        last_time_unreachable: 0000-00-00 00:00:00
>                   state_type: 1
>            last_notification: 0000-00-00 00:00:00
>            next_notification: 0000-00-00 00:00:00
>        no_more_notifications: 0
>        notifications_enabled: 1
>problem_has_been_acknowledged: 0
>         acknowledgement_type: 0
>  current_notification_number: 0
>       passive_checks_enabled: 1
>        active_checks_enabled: 1
>        event_handler_enabled: 1
>       flap_detection_enabled: 0
>                  is_flapping: 0
>         percent_state_change: 0
>                      latency: 0
>               execution_time: 15.034816980361938
>     scheduled_downtime_depth: 0
>   failure_prediction_enabled: 0
>     process_performance_data: 1
>             obsess_over_host: 0
>     modified_host_attributes: 0
>                event_handler:
>                check_command: hostalive
>        normal_check_interval: 5
>         retry_check_interval: 1
>   check_timeperiod_object_id: 0
>                 is_reachable: 1
>           endpoint_object_id: 1
>          original_attributes: null
>                    object_id: 8940
>                  instance_id: 1
>                objecttype_id: 1
>                        name1: michiathome1
>                        name2: NULL
>                    is_active: 1
>
>
>>
>>
>> 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/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
>>
>> _______________________________________________
>> 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 **
>
>------------------------------
>
>Message: 2
>Date: Sun, 15 Nov 2015 11:48:58 +0000
>From: Michael Friedrich <Michael.Friedrich at netways.de>
>To: "icinga-users at lists.icinga.org" <icinga-users at lists.icinga.org>
>Subject: Re: [icinga-users] Overriding Ping4 thresholds
>Message-ID: <9F8B16E5-EEBB-483A-88A7-CBCC48006A00 at netways.de>
>Content-Type: text/plain; charset="utf-8"
>
>
>> On 12 Nov 2015, at 21:14, Lance Reed <reed.r.lance at gmail.com> wrote:
>>
>> I suspect my question has been answered multiple times in the past,
>> but I am not easily finding answers so here goes.
>>
>> I have multiple remote locations that use VPNs, so ping latency can
>> often go failure high and I get alerts on hosts and ping4 checks (the
>> default checks).
>>
>> We use multiple custom vars for things like location, and environment etc.
>> Because of this it was easy to setup in each hosts file created via
>> puppet to override hostalive.
>>
>> e.g.
>>
>> object Host "somehost.abcd.com" {
>>      import "generic-host"
>> ...
>>  vars.ping_wrta = "500"
>>  vars.environment = "abcd"
>>  vars.customer_monitored = "true"
>>  vars.customer = "abcd"
>>  vars.ping_cpl = "30"
>> }
>>
>>
>> That works well.  However the default service checks are using default
>> attributes for ping4 which are not modified.
>>
>> I am wondering what people use to override default values for existing
>> service checks that get applied.
>> Or do I have to modify what type of check gets used in my host object
>> and make sure the correct one is used much like hostalive.  I'd prefer
>> not to have any more Custom Vars added to each host object if
>> possible.
>
>I?d personally set these thresholds inside the service apply rules, and use the assign where/ignore where expressions to selectively apply certain services with different thresholds. Similar to what Thomas already posted.
>
>A different approach might also be to add conditionals inside your service apply rules, for example:
>
>apply Service ?ping4? {
>  check_command = ?ping4?
>
>  if (host.vars.customer == ?abcd?) {
>    vars.ping_cpl = 50
>  } else if (host.vars.customer == ?efgh?) {
>    vars.ping_cl = 30
>  } else { //default
>    vars.ping_cpl = 40
>  }
>
>  assign where host.address
>}
>
>Service apply rules may access all host configuration attributes, so you?re not bound to custom variables here. One could also match against the host name, or its display_name.
>
>Kind regards,
>Michael
>
>
>--?
>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 **
>
>------------------------------
>
>Message: 3
>Date: Sun, 15 Nov 2015 18:44:55 +0000
>From: Madhusmita Gochhait <mgochhait at juniper.net>
>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:
>        <BN3PR0501MB1283DCD485CBE5FA7815D74FAE1F0 at BN3PR0501MB1283.namprd05.prod.outlook.com>
>
>Content-Type: text/plain; charset="iso-8859-1"
>
>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
>
>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 icinag2 .
>
>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
>********************************************
>
>
>------------------------------
>
>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 25
>********************************************
>
>
>------------------------------
>
>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 26
>********************************************
>_______________________________________________
>icinga-users mailing list
>icinga-users at lists.icinga.org
>https://lists.icinga.org/mailman/listinfo/icinga-users
>

-- 
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 **


More information about the icinga-users mailing list