HowTo: Connect OTRS with Icinga2 – Part 1

Robert Ullrich07. Mar 2018 | Best PracticesConsultingDevelopmentUse cases

Disclaimer:

The practical examples presented in our technical blog (blog.otrs.com) and now in the expert category in our FAQ blog section serve as a source of ideas and documentation to show what is theoretically possible with OTRS in concrete scenarios or sometimes even for more exotic configurations. All configurations presented here were developed under laboratory conditions as a proof of concept. 

We can only guarantee testing and implementation of these concepts to be error-free and productive if implemented in a workshop with one of our OTRS consultants. Without this, the responsibility lies with the customer himself. Please note that configurations from older OTRS versions may not work in the newer ones.

I think this might be an interesting use case for you if you have established a Release & Deployment management process in your OTRS system and if you want to create automatical a new host in your Icinga2 monitoring system. 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”.

Like in former blog posts, there are several requirements for this HowTo:

  • running OTRS 6.0.x system
  • running Icinga2 system with enabled API & user credentials

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

The following dynamic fields should be added because they’re required for this integration.

  • “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

Web service

In addition, the CMDBConnector might be useful, if you want to store the deployed item in the OTRS CMDB. You’ll find this blog article here.

Configuring the Icinga2Connector in OTRS

After you satisfied the pre-requirements, you’re ready to create a new web service within OTRS. The name of the new web service is “Icinga2Connector”. Afterward, you have to set up the needed invokers.

Icinga2Connector general config

Configuring the Invoker “CreateHost”

Now you’re ready to start the configuration of our Invokers. To be able to create a new host in Icinga2, you have to set up an Invoker called “CreateHost”.  Select all the needed data for your outgoing requests and use “XSLT” as mapping for your outgoing data.

Icinga2Connector invoker config

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”)

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

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

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

Icinga2Connector debugger

In Icinga2 a new host is added:

Icinga2Connector icinga2 result

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 *