Each plugin requires a command definition which defines the command line parameters and arguments passed from service checks.
- Icinga 2 integration
- Icinga 1.x/Naemon/Nagios integration
The Icinga 2 Template Library (ITL) already provides many CheckCommand definitions out of the box. This enables you to just use the CheckCommand object and focus on your service apply rules.
Best practice is to store the credentials in a separate constant:
vim /etc/icinga2/constants.conf
const ManubulonSnmpCommunity = "icingasnmpro"
Define a generic SNMP service template and set common attributes.
template Service "snmp-template" {
vars.snmp_community = ManubulonSnmpCommunity
}
Define service apply rules like this:
apply Service "snmp-memory" {
import "snmp-template"
check_command = "snmp-memory"
vars.snmp_warn = "50,0"
vars.snmp_crit = "80,0"
assign where "snmp" in host.groups
}
apply Service "snmp-storage /var" {
import "snmp-template"
check_command = "snmp-storage"
vars.snmp_warn = "50"
vars.snmp_crit = "80"
vars.snmp_storage_name = "/var"
assign where "snmp" in host.groups
}
apply Service "snmp-storage" {
import "snmp-template"
check_command = "snmp-storage"
vars.snmp_warn = "50"
vars.snmp_crit = "80"
assign where "snmp" in host.groups
}
A more complex example using apply for rules is to store the monitored storage disks on the host. This allows to generate service objects in a more efficient way.
object Host "snmp-host" {
check_command = "hostalive"
vars.snmp_storage["/"] = {
snmp_warn = "80"
snmp_crit = "90"
}
vars.snmp_storage["/var"] = {
snmp_warn = "60"
snmp_crit = "90"
}
}
apply Service "snmp-storage-" for (storage_name => config in host.vars.snmp_storage) {
import "snmp-template"
display_name = "Storage: " + storage_name
vars += config
vars.snmp_storage_name = storage_name
}
You need to write a check command definition and use that in your service definitions. Please refer to this documentation.