Skip to content

ugurengin/icinga2-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

icinga2-api

Add and remove host object

Installation:
Access to icinga2 server, then execute following commands

mkdir /var/www/html/
cd /var/www/html/
git clone https://github.com/ugurengin/icinga2-api.git
mv icinga2-api api

After this create a generic host template as specify before sending http request to create host object.

template Host "generic-api-host" {
   max_check_attempts = 3
   check_interval = 1m
   retry_interval = 30s

   enable_perfdata = true
}

In simply to add a new host object using http request on any remote machine, you can either use curl or base UI php page.

With Curl:

curl -X GET -s "http://icinga2-url/api/add_host.php?hostname=ugurengin.com&displayname=ugur-web-site&hostaddr=ugurengin.com&product=hede&os=Linux&Add=Submit"

After execute command above,so you may see that created a file which contains configuration parameteres in repository.d/hosts folder of icinga2.

object Host "ugurengin.com" {
import "generic-api-host" 
address = "ugurengin.com" 
check_command = "hostalive"
display_name = "ugur-web-site"
vars.os = "Linux" 
vars.product = "hede"
} 

To get it if really host is added as properly after curl execution, run command below or look at the icinga2 UI.

icinga2 repository host list|grep ugur
Host 'ugurengin.com'

Special note that if you correlate all base services with "vars.os=Linux" tag, so related services will be integrated with added host.

Tesekkurler, Thanks, Spasiba, Dekuji

About

add a new host object via http request

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages