HowTo: Connect OTRS with Icinga2 – Part 3
Let’s continue with our Icinga2Connector. Last time I showed you how to create a new host in Icinga2 via API. Today I will show you how to delete hosts, if they’re retired. To complete this how-to, you need at first a running OTRS and an Icinga2 system.
Use case for this connector
If you have a Release & Deployment management process in your OTRS system and you want to transmit information automatical to Icinga2. In this small blog article, I’ll show you, how to create a web service between OTRS and Icinga2. I’ll call this integration “Icinga2Connector”.
OTRS Requirements for this HowTo
- at least OTRS 6.0.x
You need the following Feature Add-Ons :
(Adds new invoker for TicketCreate and TicketUpdate in the GenericInterface.)
Third Party Software
You need this third-party software:
- “Icinga2Hostname” of type “TEXT” to specify the name of the new Icinga2 host
- “Icinga2DeleteHost” of type “Dropdown” to make a decision
Configuring the Invoker “DeleteHost”
Now we’re ready to start the configuration of our next Invoker. Create a new Invoker called “DeleteHost”. Select all the needed data for your outgoing requests and use “XSLT” as mapping for your outgoing data.
For our XSLT mapping we need the following elements:
- the hostname, which should be deleted in Icinga2 (dynamic field “Icinga2Hostname”)
Now you can configure your outgoing XSLT-mapping. If you need a working XSLT-mapping, you can use the following example:
The used “Event trigger” is the last point for this invoker. Just select one and you’re done with the Invoker configuration.
Configuring the Icinga2Connector “Network Transport”
It’s necessary to configure the network transport for the invoker because we’ve to use the right requests commands towards Icinga2. Otherwise, we’ll receive errors. It’s quite easy as you can see:
As authentication module please use HTTP basic auth and fill in the user credentials of the Icinga2 API user. Afterward just click on “Save and finish”.
Testing the Icinga2Connector
Testing the Requester
Create or take an already existing ticket and trigger the “DeleteHost” invoker. In the Icinga2 WebGUI, the host disappears. ;-)
More information about the Icinga2 API
You can also use other resources which are provided by the Icinga2 API.
Please go to the following website, if you need more information: https://www.icinga.com/docs/icinga2/latest/doc/12-icinga2-api/