Adding new Hosts or Services found by check


I’m new to Icinga2 and right now i got my test instance running properly, with Icingaweb2.
Also, I already wrote a small check by myself for testing.

But I got a question about creating checks that creates hosts and services.
As I understood I have to create hosts first, or services and then put them together.
What means, I have to put in settings for every service, I want to add to manually.

For instance, in my lab environment I created a small test check. The check is running on a Host with an agent on it. It checks the network for hosts with a specific Port open, gather them and check if there are online or not.

But they are all shown in one service, of the host, where the agent is installed ofc.
I would like to have some kind of automation, so that Icinga creates an own service for each Host found in the Network, or even create a new host.

Is this doable, maybe with some command within my check, or with the director?
Hopefully it is understandable, what i want to do, even it’s just a test scenario.

Thank you!

Hello @Katchy,
Welcome to the Icinga community. I hope I can answer some of your questions.

Your post has many question in it (But missing the ? mark :slight_smile: ). Starting with the basics, you need to define a host object (Server01). If you want to monitor if Server01 is online. Define a host object for Server 1. This host object will include a check command to ping if the server is up. If the Server1 is down the ping check command will fail and you will receive a monitoring alert.

Now a Service object is dependent on a Host object. On Server1, if you want to monitor the percentage of CPU that is used. You will add a service object to check the status of the CPU on Server1.

Please review the online documentation about configuring Host and Service objects.

You do not need to apply services to every host manually. You want configure apply rules to automatically apply service object to host object. Please review how to configure a apply rules in the online documentation.

I hope this post help you get started.

Hello @aclark6996,

thank you for replying, but I think you missunderstood my question.

I understand the first part of your answer.

However, I would like to automate the actual creation of the host objects part. So that, as my Icinga indentifies a host in the network that runs specific serviecs.

For example:

Lets say i want to create a host object for every maschine which has a SSH on port 22 running.

Icinga should then run a check against all IPs in the network range and search for hosts with the port specified open.

The next step would be to create a host object for each host that was found. After this the apply rule would trigger, ofcourse. I hope I made my intentions more clear.

Thank you in advance.

Hello Katchy,

I do not believe it is possible with Icinga2 to do what you asking about here. Icinga can monitor the host once they are added to the Icinga application. Maybe another member of the Icinga community has configured their Icinga application to scan their network and automate the addition of new host once found.

If you had a way (by script or another program) to scan your network and find these new host, you could automate adding the new host by using the API commands.

I hope that helps.