Icinga2 Forwarder

Add the forwarder to your project with:

SAKULI_LICENSE_KEY=<PERSONAL_NPM_ACCESS_TOKEN> npm i @sakuli/forwarder-icinga2

To register the forwarder in your project you have edit the package.json file and add the preset to the Sakuli configuration key:

{
    "sakuli": {
        "presetProvider": [
            "@sakuli/legacy",
            "@sakuli/forwarder-icinga2"
        ]
    }
}

Enable the Icinga2 API

The steps to enable the Icinga2 API are described in the REST API documentation.

Create a Icinga2 service

Create a check_command, which will be executed only if Icinga did not receive a Sakuli result within a certain time. This ensures that you get a notification even if no passive check results arrive in Icinga at all:

/etc/icinga2/conf.d/commands.conf

object CheckCommand "check_dummy" {
   import "plugin-check-command"
   command = [
     PluginDir + "/check_dummy","$dummy_state$","$dummy_text$"
   ]
   vars.dummy_state = 0
   vars.dummy_text = "Check was successful."
}

object CheckCommand "check_sakuli" {
   import "check_dummy"
   vars.dummy_state = 3
   vars.dummy_text = "No passive Sakuli check result received."
}

/etc/incinga2/conf.d/hosts.conf

object Host "sakuliclient01" {
   import "generic-host"
   address = "<IP>"
}

Create the following service object for the first test case. The freshness_threshold should be slightly higher than the interval Sakuli tests are planned.

object Service "sakuli_demo" {
  import "generic-service"
  host_name = "sakuliclient01"
  check_command = "check_sakuli"
  enable_active_checks = 0
  enable_passive_checks = 1
  enable_flapping = 0
  volatile = 1
  enable_perfdata = 1
}

Reload Icinga2:

service icinga2 reload

Now open Icingaweb2, you should see the Sakuli host with the service “sakuli_demo” attached.

The check is waiting now for check results from a Sakuli client.

Sakuli Client Configuration

You must set the global properties for the Icinga2 receiver on the Sakuli client by editing the sakuli.properties. You can find them in the folder containing the test suites:

Property Default Effect
sakuli.forwarder.icinga2.enabled false Enables result forwarding to Icinga2
sakuli.forwarder.icinga2.api.host The hostname or ip of the Icinga2 API-Endpoints
sakuli.forwarder.icinga2.api.port 5665 The port or ip of the Icinga2 API-Endpoints
sakuli.forwarder.icinga2.api.username API user name
sakuli.forwarder.icinga2.api.password API user password
sakuli.forwarder.icinga2.hostname The name of the host object configured in Icinga2
sakuli.forwarder.icinga2.service_description ${testsuite.id} The name of the service in icinga2
sakuli.forwarder.icinga2.allow_insecure_connection false Disable SSL checks. Never use this in production environments!