Skip to content

Instantly share code, notes, and snippets.

@mohierf
Created March 2, 2017 11:23
Show Gist options
  • Save mohierf/c9809bbea5b40a74f9238b63c16fd02e to your computer and use it in GitHub Desktop.
Save mohierf/c9809bbea5b40a74f9238b63c16fd02e to your computer and use it in GitHub Desktop.
Using the duplicate_foreach property of a service definition
**Service definition duplicate_foreach**
This is used to generate serveral service with only one service declaration.
Alignak understands this statement as : “Create a service for each key in the variable”.
Usually, this statement come with a “$KEY$” string in the service_description (to have a different name) and
in the check_command (you also want a different check).
Moreover, one or several variables can be associated to each key.
Then, values can be used in the service definition with $VALUE$ or $VALUEn$ macros.
define host {
host_name linux-server
...
_partitions var $(/var)$, root $(/)$
_openvpns vpn1 $(tun1)$$(10.8.0.1)$, vpn2 $(tun2)$$(192.168.3.254)$
...
}
define service{
host_name linux-server
service_description disk-$KEY$
check_command check_disk!$VALUE$
...
duplicate_foreach _partitions
}
define service{
host_name linux-server
service_description openvpn-$KEY$-check-interface
check_command check_int!$VALUE1$
...
duplicate_foreach _openvpns
}
define service{
host_name linux-server
service_description openvpn-$KEY$-check-gateway
check_command check_ping!$VALUE2$
...
duplicate_foreach _openvpns
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment