/*
 * Service apply rules.
 *
 * The CheckCommand objects `ping4`, `ping6`, etc
 * are provided by the plugin check command templates.
 * Check the documentation for details.
 *
 * Tip: Use `icinga2 object list --type Service` to
 * list all service objects after running
 * configuration validation (`icinga2 daemon -C`).
 */

/*
 * A template for ntopng-based services.
 * max_check_attempts is equal to 1 as
 * it is necessary to change (and notify) as soon
 * has the host has an alert.
 * In other words, it no SOFT state is used for services
 * which inherits from this.
*/
template Service "ntopng-service" {
  check_interval = 1m
  retry_interval = 1m
  max_check_attempts = 1
}

/*
 * This service checks for host engaged alerts.
*/
apply Service "ntopng-icinga-host-health" {
  import "ntopng-service"

  check_command = "ntopng"
  vars.ntopng_check_type = "host-alerts"

  assign where host.address
}

/*
 * This service checks for host flow alerts.
 * As flow alert are stateless, it is necessary to
 * grab the performance data and pass it to the check.
 * The check, using performance data, will be able to
 * reliably determine if new flow alerts have appeared
 * across two consecutive checks.
*/
apply Service "ntopng-icinga-host-flows-health" {
  import "ntopng-service"

  check_command = "ntopng"
  vars.ntopng_check_type = "flow-alerts"

  assign where host.address
}
