How to add client or node to custom hostgroup

(Siddhant pardeshi) #1

Hello Friends,

I have just setup icinga2 server …added one host for monitoring and i have applied some services like http,load,ping4 everything working fine . but becouse of one thing i am little bit confused that , when i hit
sudo stress --cpu 8 command on host machine at the same time icinga is not showing its condition like warning , critical or like that but when i hit stress command on icinga server it makes changes on both machine i mean on icinga server and as well as on host machine

2 i have just created new custom hostgroup by below api call
[ curl -k -s -u root:password -H ‘Accept: application/json’ -X PUT -k “https://IPADDR:5665/v1/objects/hostgroups/BW_group” -d ‘{ “attrs”: { “display_name”: “api_dummy_hostgroup” } }’ | python -m json.tool ]
so how can change existing host’s hostgroup by api call or mannually please help me for this


First, please change your API password now as your icinga is publicly reachable, I was able to get a list of your hosts - someone else might do worse.

About your first issue, you probably did not set command_endpoint correctly or, if using zones for distributing config, did not put the Host in the correct Zone.
About your question. Groups are most often created using apply rules, which do not work over the API, but you can update the Host and add the group there.

(Siddhant pardeshi) #3

Sir ,
first of all thank you so much for notifying that mistake. which i made …
I really don’t understand your answer because , lack of knowledge capability about icinga server
the following steps i have done :

steps 1 :- configured icinga and icingaweb2

(note -now icinga is configured , and server is monitoring its own resources

step 2 i add the node by api call command is

 curl -k -s -u root:password -H 'Accept: application/json' -X PUT "https://ipaddres:5665/v1/objects/hosts/uae-server" -d ' { "templates": [ "generic-host" ], "attrs": { "address": "x.x.x.x", "check_command": "hostalive", "vars.os" : "Linux", "enable_notifications": true} }'

###result i got like this at path

 /var/lib/icinga2/api/packages/_api/ 96fe32d1-5cbc-4f49-ad00-f16f649bb10b/conf.d/hosts 
object Host "uae-server" {
        import "generic-host"

        address = "x.x.x.x"
        check_command = "hostalive"
        enable_notifications = true
        vars["os"] = "Linux"
        version = 1543564073.437501
        zone = "icinga2"

##step 3 applied load service by api call with following command :

curl -k -s -u root:password -H 'Accept: application/json' -X PUT 'https://ipof server:5665/v1/objects/services/uae-server!realtime-load' -d '{ "templates": [ "generic-service" ], "attrs": { "check_command": "load", "check_interval": 1,"retry_interval": 1 } }'

###result i got like at the path


object Service "realtime-load" {
        import "generic-service"

        check_command = "load"
        check_interval = 1.000000
        host_name = "uae-server"
        retry_interval = 1.000000
        version = 1543919532.766903
        zone = "icinga2"

now please tell me where should i specify command_endpoint

(Siddhant pardeshi) #4

sir could you please reply for that question


Stop calling me ‘sir’ please. The Queen of England and I are not that close.

A command_endpoint can be assigned like any other attribute, its value needs to be the name of the Endpoint object in question. This chapter might be of interest to you.

(Siddhant pardeshi) #6

Good morning ,
sorry for that calling you sir actually i am from india , here culture is very different if someone guide us we call
that person with very respect …and one more thing that i have confiugred icinga 2 on ubuntu 16.04

(Michael Friedrich) #7

Modify your PUT-Request in the way, that attrs contains the command_endpoint attribute, pointing to the host’s endpoint you’ve configured already. The documentation linked above should help clarify its meaning.

(Siddhant pardeshi) #8

sir i have just created one topic where i am unable to solve that problem could you please help me

(Michael Friedrich) #9

I have no idea what you’re talking about.

My impression is that you want to create a host via runtime API call, whose checks are executed on the remote client side. One method to get things going is to use a command endpoint bridge as configuration mode.

(Siddhant pardeshi) #10

latest topic i have created on this portal How to add additional contact groups to host for this i need help