HowTo: Connect OTRS with Icinga2 – Part 2

Robert Ullrich15. Mar 2018 | Best PracticesConsultingMiscellaneousUse cases

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 modify hosts. 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

OTRS Framework

  • at least OTRS 6.0.x

OTRS Packages

You need the following Freely selectable Features of the OTRS Business Solution6 :

  • OTRSTicketInvoker
(Adds new invoker for TicketCreate and TicketUpdate in the GenericInterface.)

Third Party Software

You need this third-party software:

  • XML::Simple
  • XML::LibXML
  • XML::LibXSLT

DynamicFields

  • “Icinga2Hostname” of type “TEXT” to specify the name of the new Icinga2 host
  • “Icinga2Address” of type “TEXT” to specify the login of the new user
  • “Icinga2Command” of type “Dropdown” to specify the check command in Icinga2. Please use the following values:
    • hostalive: hostalive
    • http: http
    • ping4: ping4
  • “Icinga2OS” of type “Dropdown” to specify the Host OS. Use the following values:
    • Linux: Linux
    • Windows: Windows

Web service

In addition, part 1 of the Icinga2Connector might be useful. You’ll find the first blog article here.

Configuring the Invoker “UpdateHost”

Now we’re ready to start the configuration of our next Invoker. Create a new Invoker called “UpdateHost”.  Select all the needed data for your outgoing requests and use “XSLT” as mapping for your outgoing data.

Icinga2Connector_UpdateHost_InvokerConfig1Icinga2Connector_UpdateHost_InvokerConfig2

For our XSLT mapping we need the following elements:

  • the hostname, which should be displayed in Icinga2 (dynamic field “Icinga2Hostname”)
  • the IP address of the new host (dynamic field “Icinga2Address”)
  • the used Icinga check (dynamic field “Icinga2Command”)
  • the OS of the Host (dynamic field “Icinga2OS”)

Now you can configure your outgoing XSLT-mapping. If you need a working XSLT-mapping, you can use the following example:

Icinga2Connector UpdateHost XSLT mapping

The used “Event trigger” is the last point for this invoker. Just select one and you’re done with the Invoker.

 

Configuring the Icinga2Connector “Network Transport”

Requester configuration

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:

Icinga2Connector_UpdateHost Transport Config

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 “UpdateHost” invoker.

As result you should see something similar in the OTRS Debugger:

Icinga2Connector UpdateHost Debugger

In Icinga2 a the host is updated:

Icinga2Connector UpdateHost Icinga2GUI

Stay tuned…

Next time I’ll show you other useful examples how you could integrate OTRS with Icinga2.

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/

Your email address will not be published. Required fields are marked *

This site uses cookies. By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close