/**
* Although in theory you could define all your objects in this file
* the preferred way is to create separate directories and files in the conf.d
- * directory.
+ * directory. Each of these files must have the file extension ".conf".
*/
- include_recursive "conf.d" "*.conf"
+ include_recursive "conf.d"
You can put your own configuration files in the `conf.d` directory. This
directive makes sure that all of your own configuration files are included.
* files in this directory are included.
*/
object Host "localhost" {
- import "linux-server",
+ import "linux-server"
- macros.address = "127.0.0.1",
+ macros.address = "127.0.0.1"
macros.address6 = "::1"
}
Library require an `address` macro.
apply Service "icinga" {
- import "generic-service",
+ import "generic-service"
- check_command = "icinga",
+ check_command = "icinga"
assign where host.name == "localhost"
}
apply Service "http" {
- import "generic-service",
+ import "generic-service"
- check_command = "http_ip",
+ check_command = "http_ip"
assign where host.name == "localhost"
}
apply Service "ssh" {
- import "generic-service",
+ import "generic-service"
- check_command = "ssh",
+ check_command = "ssh"
assign where host.name == "localhost"
}
apply Service "load" {
- import "generic-service",
+ import "generic-service"
- check_command = "load",
+ check_command = "load"
assign where host.name == "localhost"
}
apply ScheduledDowntime "backup-downtime" {
- import "backup-downtime",
+ import "backup-downtime"
assign where service.host == "localhost" && service.short_name == "load"
}
apply Service "processes" {
- import "generic-service",
+ import "generic-service"
- check_command = "processes",
+ check_command = "processes"
assign where host.name == "localhost"
}
apply Service "users" {
- import "generic-service",
+ import "generic-service"
- check_command = "users",
+ check_command = "users"
assign where host.name == "localhost"
}
apply Service "disk" {
- import "generic-service",
+ import "generic-service"
- check_command = "disk",
+ check_command = "disk"
assign where host.name == "localhost"
}
Here is an example of a host object which defines two child services:
object Host "my-server1" {
- macros.address = "10.0.0.1",
+ macros.address = "10.0.0.1"
check = "ping4"
}
> be inherited from a parent template using additive inheritance (`+=`).
object CheckCommand "disk" {
- import "plugin-check-command",
+ import "plugin-check-command"
command = [
PluginDir + "/check_disk",
"-c", "$cfree$%"
],
- macros.wfree = 20,
+ macros.wfree = 20
macros.cfree = 10
}
space).
object Host "localhost" {
- import "generic-host",
+ import "generic-host"
- macros.address = "127.0.0.1",
+ macros.address = "127.0.0.1"
macros.address6 = "::1"
}
apply Service "disk" {
- import "generic-service",
+ import "generic-service"
- check_command = "disk",
+ check_command = "disk"
- macros.wfree = 10,
+ macros.wfree = 10
macros.cfree = 5
}
`CheckCommand` object.
object NotificationCommand "mail-service-notification" {
- import "plugin-notification-command",
+ import "plugin-notification-command"
- command = [ IcingaSysconfDir + "/icinga2/scripts/mail-notification.sh" ],
+ command = [ IcingaSysconfDir + "/icinga2/scripts/mail-notification.sh" ]
export_macros = [
"NOTIFICATIONTYPE",
information in the check output (`-o`).
object EventCommand "plugin-event-process-check-result" {
- import "plugin-event-command",
+ import "plugin-event-command"
command = [
PluginDir + "/process_check_result",
- "-H",
- "$HOSTNAME$",
- "-S",
- "$SERVICEDESC$",
- "-c",
- "/var/run/icinga2/cmd/icinga2.cmd",
- "-r",
- "0",
- "-o",
- "Event Handler triggered in state '$SERVICESTATE$' with output '$SERVICEOUTPUT$'."
+ "-H", "$HOSTNAME$",
+ "-S", "$SERVICEDESC$",
+ "-c", "/var/run/icinga2/cmd/icinga2.cmd",
+ "-r", "0",
+ "-o", "Event Handler triggered in state '$SERVICESTATE$' with output '$SERVICEOUTPUT$'."
]
}
Here is an example of a command definition which uses user-defined macros:
object CheckCommand "my-ping" {
- import "plugin-check-command",
+ import "plugin-check-command"
command = [
PluginDir + "/check_ping",
],
macros = {
- wrta = 100,
- wpl = 5,
+ wrta = 100
+ wpl = 5
- crta = 200,
- cpl = 15,
+ crta = 200
+ cpl = 15
- packets = 5,
+ packets = 5
timeout = 0
}
}
in the service definition like this:
apply Service "ping" {
- check_command = "my-ping",
+ check_command = "my-ping"
macros.packets = 10 // Overrides the default value of 5 given in the command
`CRITICAL` states and `problem` and `recovery` notification types.
object User "icingaadmin" {
- display_name = "Icinga 2 Admin",
- enable_notifications = 1,
- notification_state_filter = StateFilterOK |
+ display_name = "Icinga 2 Admin"
+ enable_notifications = 1
+ notification_state_filter = (StateFilterOK |
StateFilterWarning |
- StateFilterCritical,
- notification_type_filter = NotificationFilterProblem |
- NotificationFilterRecovery,
+ StateFilterCritical)
+ notification_type_filter = (NotificationFilterProblem |
+ NotificationFilterRecovery)
macros = {
- "email" = "icinga@localhost",
+ "email" = "icinga@localhost"
"pager" = "+49123456789"
}
}
The example below may or may not fit your needs.
object NotificationCommand "mail-service-notification" {
- import "plugin-notification-command",
+ import "plugin-notification-command"
- command = [ IcingaSysconfDir + "/icinga2/scripts/mail-notification.sh" ],
+ command = [ IcingaSysconfDir + "/icinga2/scripts/mail-notification.sh" ]
export_macros = [
"NOTIFICATIONTYPE",
`Notification` object. Attributes can be overridden locally.
template Notification "generic-notification" {
- notification_interval = 15m,
+ notification_interval = 15m
- notification_command = "mail-service-notification",
+ notification_command = "mail-service-notification"
- notification_state_filter = StateFilterWarning |
+ notification_state_filter = (StateFilterWarning |
StateFilterCritical |
- StateFilterUnknown,
- notification_type_filter = NotificationFilterProblem |
+ StateFilterUnknown)
+ notification_type_filter = (NotificationFilterProblem |
NotificationFilterAcknowledgement |
NotificationFilterRecovery |
NotificationFilterCustom |
NotificationFilterFlappingEnd |
NotificationFilterDowntimeStart |
NotificationFilterDowntimeEnd |
- NotificationFilterDowntimeRemoved,
+ NotificationFilterDowntimeRemoved)
notification_period = "24x7"
}
Use the `apply` keyword to create `Notification` objects for your services:
apply Notification "mail" {
- import "generic-notification",
+ import "generic-notification"
- notification_command = "mail-notification",
- users = [ "icingaadmin" ],
+ notification_command = "mail-notification"
+ users = [ "icingaadmin" ]
assign where service.short_name == "ping4"
}
> are not set in this example.
object User "icinga-oncall-2nd-level" {
- display_name = "Icinga 2nd Level",
- enable_notifications = true,
+ display_name = "Icinga 2nd Level"
+ enable_notifications = true
macros = {
"mobile" = "+49123456781"
}
object User "icinga-oncall-1st-level" {
- display_name = "Icinga 1st Level",
- enable_notifications = true,
+ display_name = "Icinga 1st Level"
+ enable_notifications = true
macros.mobile = "+49123456782"
}
notified, but only for one hour (`2h` as `end` key for the `times` dictionary).
apply Notification "mail" {
- import "generic-notification",
- notification_command = "mail-notification",
- users = [ "icingaadmin" ],
+ import "generic-notification"
+ notification_command = "mail-notification"
+ users = [ "icingaadmin" ]
assign where service.short_name == "ping4"
}
apply Notification "escalation-sms-2nd-level" {
- import "generic-notification",
- notification_command = "sms-notification",
- users = [ "icinga-oncall-2nd-level" ],
+ import "generic-notification"
+ notification_command = "sms-notification"
+ users = [ "icinga-oncall-2nd-level" ]
times = {
- begin = 30m,
+ begin = 30m
end = 1h
}
}
apply Notification "escalation-sms-1st-level" {
- import "generic-notification",
- notification_command = "sms-notification",
- users = [ "icinga-oncall-1st-level" ],
+ import "generic-notification"
+ notification_command = "sms-notification"
+ users = [ "icinga-oncall-1st-level" ]
times = {
- begin = 1h,
+ begin = 1h
end = 2h
}
}
end time for this notification.
apply Notification "mail" {
- import "generic-notification",
- notification_command = "mail-notification",
- users = [ "icingaadmin" ],
+ import "generic-notification"
+ notification_command = "mail-notification"
+ users = [ "icingaadmin" ]
times.begin = 15m // delay first notification
}
template Notification "generic-notification" {
- notification_state_filter = StateFilterWarning |
+ notification_state_filter = (StateFilterWarning |
StateFilterCritical |
- StateFilterUnknown,
- notification_type_filter = NotificationFilterProblem |
+ StateFilterUnknown)
+ notification_type_filter = (NotificationFilterProblem |
NotificationFilterAcknowledgement |
NotificationFilterRecovery |
NotificationFilterCustom |
NotificationFilterFlappingEnd |
NotificationFilterDowntimeStart |
NotificationFilterDowntimeEnd |
- NotificationFilterDowntimeRemoved,
+ NotificationFilterDowntimeRemoved)
}
> **Note**
configuration:
template Service "generic-service" {
- max_check_attempts = 3,
- check_interval = 5m,
- retry_interval = 1m,
+ max_check_attempts = 3
+ check_interval = 5m
+ retry_interval = 1m
enable_perfdata = true
}
apply Service "ping4" {
- import "generic-service",
- check_command = "ping4",
+ import "generic-service"
+ check_command = "ping4"
assign where host.macros.address
}
apply Service "ping6" {
- import "generic-service",
- check_command = "ping6",
+ import "generic-service"
+ check_command = "ping6"
assign where host.macros.address6
}
Then add your hosts to this hostgroup
object Host "mssql-srv1" {
- groups = [ "windows" ],
- macros = {
- "mssql_port" = 1433
- }
+ groups = [ "windows" ]
+ macros.mssql_port = 1433
}
object Host "mssql-srv2" {
- groups = [ "windows" ],
- macros = {
- "mssql_port" = 1433
+ groups = [ "windows" ]
+ macros.mssql_port = 1433
}
}
> You can also define multiple group memberships.
template Host "windows-mssql-template" {
- groups = [ "windows" ],
+ groups = [ "windows" ]
macros.mssql_port = 1433
}
}
}
object User "win-mssql-noc" {
- import "generic-windows-mssql-users",
+ import "generic-windows-mssql-users"
macros.email = "noc@example.com"
}
object User "win-mssql-ops" {
- import "generic-windows-mssql-users",
+ import "generic-windows-mssql-users"
macros.email = "ops@example.com"
}
apply Service "ping4" {
- import "generic-notification",
- notification_command = "mail-notification",
- user_groups = [ "windows-admins" ],
+ import "generic-notification"
+ notification_command = "mail-notification"
+ user_groups = [ "windows-admins" ]
}
as shown below.
object TimePeriod "24x7" {
- import "legacy-timeperiod",
+ import "legacy-timeperiod"
- display_name = "Icinga 2 24x7 TimePeriod",
+ display_name = "Icinga 2 24x7 TimePeriod"
ranges = {
- "monday" = "00:00-24:00",
- "tuesday" = "00:00-24:00",
- "wednesday" = "00:00-24:00",
- "thursday" = "00:00-24:00",
- "friday" = "00:00-24:00",
- "saturday" = "00:00-24:00",
- "sunday" = "00:00-24:00",
+ "monday" = "00:00-24:00"
+ "tuesday" = "00:00-24:00"
+ "wednesday" = "00:00-24:00"
+ "thursday" = "00:00-24:00"
+ "friday" = "00:00-24:00"
+ "saturday" = "00:00-24:00"
+ "sunday" = "00:00-24:00"
}
}
09:00 to 17:00.
object TimePeriod "workhours" {
- import "legacy-timeperiod",
+ import "legacy-timeperiod"
- display_name = "Icinga 2 8x5 TimePeriod",
+ display_name = "Icinga 2 8x5 TimePeriod"
ranges = {
- "monday" = "09:00-17:00",
- "tuesday" = "09:00-17:00",
- "wednesday" = "09:00-17:00",
- "thursday" = "09:00-17:00",
- "friday" = "09:00-17:00",
+ "monday" = "09:00-17:00"
+ "tuesday" = "09:00-17:00"
+ "wednesday" = "09:00-17:00"
+ "thursday" = "09:00-17:00"
+ "friday" = "09:00-17:00"
}
}
object then.
apply Notification "mail" {
- import "generic-notification",
+ import "generic-notification"
- notification_command = "mail-notification",
- users = [ "icingaadmin" ],
+ notification_command = "mail-notification"
+ users = [ "icingaadmin" ]
notification_period = "workhours"
assign where host.name == "localhost"
Therefore the Icinga 2 `PerfdataWriter` object allows you to define
the output template format backed with Icinga 2 runtime macros.
- format_template = "DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$",
+ format_template = "DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$"
The default template is already provided with the Icinga 2 feature configuration
which can be enabled using
have the `community` macro set.
apply Service "uptime" {
- import "generic-service",
+ import "generic-service"
- templates = [ "generic-service" ],
- check_command = "snmp",
- macros.oid = "1.3.6.1.2.1.1.3.0",
+ templates = [ "generic-service" ]
+ check_command = "snmp"
+ macros.oid = "1.3.6.1.2.1.1.3.0"
assign where host.macros.community
}
its return code and output. `check_by_ssh` is available in the [Monitoring Plugins package](#setting-up-check-plugins).
object CheckCommand "check_by_ssh_swap" {
- import "plugin-check-command",
+ import "plugin-check-command"
command = [ PluginDir + "/check_by_ssh",
"-l", "remoteuser",
}
apply Service "swap" {
- import "generic-service",
- check_command = "check_by_ssh_swap",
+ import "generic-service"
+ check_command = "check_by_ssh_swap"
macros = {
- "warn" = "50%",
+ "warn" = "50%"
"crit" = "75%"
}
Example:
object CheckCommand "check_nrpe" {
- import "plugin-check-command",
+ import "plugin-check-command"
- command = [ PluginDir + "/check_nrpe",
- "-H", "$address$",
- "-c", "$remote_nrpe_command$",
- ],
+ command = [
+ PluginDir + "/check_nrpe",
+ "-H", "$address$",
+ "-c", "$remote_nrpe_command$",
+ ]
}
apply Service "users" {
- import "generic-service",
+ import "generic-service"
- check_command = "check_nrpe",
- macros.remote_nrpe_command = "check_users",
+ check_command = "check_nrpe"
+ macros.remote_nrpe_command = "check_users"
assign where host.name == "remote-nrpe-host"
}
Example:
object CheckCommand "check_nscp" {
- import "plugin-check-command",
+ import "plugin-check-command"
+
+ command = [
+ PluginDir + "/check_nt",
+ "-H", "$address$",
+ "-p", "$port$",
+ "-v", "$remote_nscp_command$",
+ "-l", "$partition$",
+ "-w", "$warn$",
+ "-c", "$crit$",
+ "-s", "$pass$"
+ ]
- command = [ PluginDir + "/check_nt",
- "-H", "$address$",
- "-p", "$port$",
- "-v", "$remote_nscp_command$",
- "-l", "$partition$",
- "-w", "$warn$",
- "-c", "$crit$",
- "-s", "$pass$"
- ],
macros = {
- "port" = "12489",
+ "port" = "12489"
"pass" = "supersecret"
}
}
apply Service "users" {
- import "generic-service",
+ import "generic-service"
- check_command = "check_nscp",
+ check_command = "check_nscp"
+
macros += {
- "remote_nscp_command" = "USEDDISKSPACE",
- "partition" = "c",
- "warn" = "70",
- "crit" = "80"
+ remote_nscp_command = "USEDDISKSPACE"
+ partition = "c"
+ warn = "70"
+ crit = "80"
}
assign where host.name == "remote-windows-host"
objects using the `object` keyword:
object Host "host1.example.org" {
- display_name = "host1",
+ display_name = "host1"
macros = {
address = "192.168.0.1"
+ address6 = "::1"
}
}
-> **Note**
->
-> The Icinga 2 configuration format is agnostic to white space characters and
-> new-lines.
+In general you need to write each statement on a new line. Expressions started
+with `{`, `(` and `[` extend until the matching closing brace and can be broken
+up into multiple lines.
+
+Alternatively you can write multiple statements in a single line by separating
+them with a semi-colon:
+
+ object Host "host1.example.org" {
+ display_name = "host1"
+
+ macros = { address = "192.168.0.1"; address6 = "::1"; }
+ }
+
+The semi-colon after the last element (i.e. `address6`) may be omitted.
> **Note**
>
Example:
{
- address = "192.168.0.1",
+ address = "192.168.0.1"
port = 443
}
The += operator is a shortcut. The following expression:
{
- a = [ "hello" ],
+ a = [ "hello" ]
a += [ "world" ]
}
is equivalent to:
{
- a = [ "hello" ],
+ a = [ "hello" ]
a = a + [ "world" ]
}
The -= operator is a shortcut. The following expression:
{
- a = 10,
+ a = 10
a -= 5
}
is equivalent to:
{
- a = 10,
+ a = 10
a = a - 5
}
The *= operator is a shortcut. The following expression:
{
- a = 60,
+ a = 60
a *= 5
}
is equivalent to:
{
- a = 60,
+ a = 60
a = a * 5
}
The /= operator is a shortcut. The following expression:
{
- a = 300,
+ a = 300
a /= 5
}
is equivalent to:
{
- a = 300,
+ a = 300
a = a / 5
}
}
template Host "test-host" {
- import "default-host",
+ import "default-host"
macros.color = "blue"
}
object Host "localhost" {
- import "test-host",
+ import "test-host"
- macros.address = "127.0.0.1",
+ macros.address = "127.0.0.1"
macros.address6 = "::1"
}
another group of objects.
apply Service "ping" {
- import "generic-service",
+ import "generic-service"
- check_command = "ping4",
+ check_command = "ping4"
assign where host.name == "localhost"
}
This is a comment.
*/
object Host "localhost" {
- check_interval = 30, // this is also a comment.
+ check_interval = 30 // this is also a comment.
retry_interval = 15
}
Example:
- include_recursive "conf.d" "*.conf"
+ include_recursive "conf.d", "*.conf"
include_recursive "templates"
The first parameter specifies the directory from which files should be
Example:
object Host "localhost" {
- display_name = "The best host there is",
+ display_name = "The best host there is"
- groups = [ "all-hosts" ],
+ groups = [ "all-hosts" ]
check = "ping"
}
Example:
object HostGroup "my-hosts" {
- display_name = "My hosts",
+ display_name = "My hosts"
}
Attributes:
Example:
object Service "localhost-uptime" {
- host = "localhost",
- short_name = "uptime",
+ host = "localhost"
+ short_name = "uptime"
- display_name = "localhost Uptime",
+ display_name = "localhost Uptime"
- check_command = "check_snmp",
+ check_command = "check_snmp"
macros = {
- community = "public",
+ community = "public"
oid = "DISMAN-EVENT-MIB::sysUpTimeInstance"
}
- check_interval = 60s,
- retry_interval = 15s,
+ check_interval = 60s
+ retry_interval = 15s
- groups = [ "all-services", "snmp" ],
+ groups = [ "all-services", "snmp" ]
}
Attributes:
Example:
object ServiceGroup "snmp" {
- display_name = "SNMP services",
+ display_name = "SNMP services"
}
Attributes:
Example:
object Notification "localhost-ping-notification" {
- host = "localhost",
- service = "ping4",
+ host = "localhost"
+ service = "ping4"
- notification_command = "mail-notification",
+ notification_command = "mail-notification"
users = [ "user1", "user2" ]
}
Example:
object Dependency "webserver-internet" {
- child_host = "webserver",
- child_service = "ping4",
+ child_host = "webserver"
+ child_service = "ping4"
- parent_host = "internet",
- parent_service = "ping4",
+ parent_host = "internet"
+ parent_service = "ping4"
- state_filter = StateFilterOK,
+ state_filter = StateFilterOK
disable_checks = true
}
Example:
object User "icingaadmin" {
- display_name = "Icinga 2 Admin",
- groups = [ "icingaadmins" ],
+ display_name = "Icinga 2 Admin"
+ groups = [ "icingaadmins" ]
- enable_notifications = 1,
- notification_period = "24x7",
+ enable_notifications = 1
+ notification_period = "24x7"
- notification_state_filter = StateFilterOK |
+ notification_state_filter = (StateFilterOK |
StateFilterWarning |
StateFilterCritical |
- StateFilterUnknown,
- notification_type_filter = NotificationFilterProblem |
- NotificationFilterRecovery,
+ StateFilterUnknown)
+ notification_type_filter = (NotificationFilterProblem |
+ NotificationFilterRecovery)
+
macros = {
- "name" = "Icinga 2 Admin",
- "email" = "icinga@localhost",
- "pager" = "icingaadmin@localhost.localdomain"
- },
+ name = "Icinga 2 Admin"
+ email = "icinga@localhost"
+ pager = "icingaadmin@localhost.localdomain"
+ }
custom = {
- notes = "This is the Icinga 2 Admin account.",
+ notes = "This is the Icinga 2 Admin account."
}
}
Example:
object TimePeriod "24x7" {
- import "legacy-timeperiod",
+ import "legacy-timeperiod"
+
+ display_name = "Icinga 2 24x7 TimePeriod"
- display_name = "Icinga 2 24x7 TimePeriod",
ranges = {
- "monday" = "00:00-24:00",
- "tuesday" = "00:00-24:00",
- "wednesday" = "00:00-24:00",
- "thursday" = "00:00-24:00",
- "friday" = "00:00-24:00",
- "saturday" = "00:00-24:00",
- "sunday" = "00:00-24:00",
+ monday = "00:00-24:00"
+ tuesday = "00:00-24:00"
+ wednesday = "00:00-24:00"
+ thursday = "00:00-24:00"
+ friday = "00:00-24:00"
+ saturday = "00:00-24:00"
+ sunday = "00:00-24:00"
}
}
Example:
object ScheduledDowntime "some-downtime" {
- host = "localhost",
- service = "ping4",
+ host = "localhost"
+ service = "ping4"
- author = "icingaadmin",
- comment = "Some comment",
+ author = "icingaadmin"
+ comment = "Some comment"
- fixed = false,
- duration = 30m,
+ fixed = false
+ duration = 30m
ranges = {
"sunday" = "02:00-03:00"
Example:
object FileLogger "my-debug-file" {
- severity = "debug",
+ severity = "debug"
path = "/var/log/icinga2/icinga2-debug.log"
}
Example:
object CheckCommand "check_snmp" {
- import "plugin-check-command",
+ import "plugin-check-command"
command = [
PluginDir + "/check_snmp",
"-H", "$address$",
"-C", "$community$",
"-o", "$oid$"
- ],
+ ]
macros = {
- address = "127.0.0.1",
- community = "public",
+ address = "127.0.0.1"
+ community = "public"
}
}
Example:
object NotificationCommand "mail-service-notification" {
- import "plugin-notification-command",
+ import "plugin-notification-command"
command = [
IcingaSysconfDir + "/icinga2/scripts/mail-notification.sh"
- ],
+ ]
export_macros = [
"NOTIFICATIONTYPE",
Example:
object EventCommand "restart-httpd-event" {
- import "plugin-event-command",
+ import "plugin-event-command"
- command = "/opt/bin/restart-httpd.sh",
+ command = "/opt/bin/restart-httpd.sh"
}
library "perfdata"
object PerfdataWriter "pnp" {
- perfdata_path = "/var/spool/icinga2/perfdata/service-perfdata",
+ perfdata_path = "/var/spool/icinga2/perfdata/service-perfdata"
- format_template = "DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$",
+ format_template = "DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$"
- rotation_interval = 15s,
+ rotation_interval = 15s
}
Attributes:
library "perfdata"
object GraphiteWriter "graphite" {
- host = "127.0.0.1",
+ host = "127.0.0.1"
port = 2003
}
library "db_ido_mysql"
object IdoMysqlConnection "mysql-ido" {
- host = "127.0.0.1",
- port = 3306,
- user = "icinga",
- password = "icinga",
- database = "icinga",
- table_prefix = "icinga_",
- instance_name = "icinga2",
- instance_description = "icinga2 dev instance",
+ host = "127.0.0.1"
+ port = 3306
+ user = "icinga"
+ password = "icinga"
+ database = "icinga"
+ table_prefix = "icinga_"
+ instance_name = "icinga2"
+ instance_description = "icinga2 dev instance"
cleanup = {
- downtimehistory_age = 48h,
- logentries_age = 31d,
- },
+ downtimehistory_age = 48h
+ logentries_age = 31d
+ }
categories = DbCatConfig | DbCatState
}
library "db_ido_pgsql"
object IdoMysqlConnection "pgsql-ido" {
- host = "127.0.0.1",
- port = 5432,
- user = "icinga",
- password = "icinga",
- database = "icinga",
- table_prefix = "icinga_",
- instance_name = "icinga2",
- instance_description = "icinga2 dev instance",
+ host = "127.0.0.1"
+ port = 5432
+ user = "icinga"
+ password = "icinga"
+ database = "icinga"
+ table_prefix = "icinga_"
+ instance_name = "icinga2"
+ instance_description = "icinga2 dev instance"
cleanup = {
- downtimehistory_age = 48h,
- logentries_age = 31d,
- },
+ downtimehistory_age = 48h
+ logentries_age = 31d
+ }
categories = DbCatConfig | DbCatState
}
library "livestatus"
object LivestatusListener "livestatus-tcp" {
- socket_type = "tcp",
- bind_host = "127.0.0.1",
+ socket_type = "tcp"
+ bind_host = "127.0.0.1"
bind_port = "6558"
}
object LivestatusListener "livestatus-unix" {
- socket_type = "unix",
+ socket_type = "unix"
socket_path = "/var/run/icinga2/cmd/livestatus"
}
library "compat"
object StatusDataWriter "status" {
- status\_path = "/var/cache/icinga2/status.dat",
- objects\_path = "/var/cache/icinga2/objects.path",
+ status\_path = "/var/cache/icinga2/status.dat"
+ objects\_path = "/var/cache/icinga2/objects.path"
update\_interval = 30s
}
library "compat"
object CompatLogger "my-log" {
- log\_dir = "/var/log/icinga2/compat",
+ log\_dir = "/var/log/icinga2/compat"
rotation\_method = "HOURLY"
}
Example:
object IcingaStatusWriter "status" {
- status_path = IcingaLocalStateDir + "/cache/icinga2/status.json",
+ status_path = IcingaLocalStateDir + "/cache/icinga2/status.json"
update_interval = 15s
}
library "cluster"
object ClusterListener "cluster" {
- ca_path = "/etc/icinga2/ca/ca.crt",
- cert_path = "/etc/icinga2/ca/icinga-node-1.crt",
- key_path = "/etc/icinga2/ca/icinga-node-1.key",
+ ca_path = "/etc/icinga2/ca/ca.crt"
+ cert_path = "/etc/icinga2/ca/icinga-node-1.crt"
+ key_path = "/etc/icinga2/ca/icinga-node-1.key"
- bind_port = 8888,
+ bind_port = 8888
peers = [ "icinga-node-2" ]
}
library "cluster"
object Endpoint "icinga-c2" {
- host = "192.168.5.46",
- port = 7777,
+ host = "192.168.5.46"
+ port = 7777
- config_files = [ "/etc/icinga2/cluster.d/*" ],
+ config_files = [ "/etc/icinga2/cluster.d/*" ]
config_files_recursive = [
"/etc/icinga2/cluster2",
- { path = "/etc/icinga2/cluster3", pattern = "*.myconf" }
+ { path = "/etc/icinga2/cluster3"; pattern = "*.myconf" }
]
}
object Domain "dmz-1" {
acl = {
- node1 = DomainPrivCheckResult,
+ node1 = DomainPrivCheckResult
node2 = DomainPrivReadWrite
}
}
Example:
apply ScheduledDowntime "backup-downtime" {
- author = "icingaadmin",
- comment = "Scheduled downtime for backup",
+ author = "icingaadmin"
+ comment = "Scheduled downtime for backup"
ranges = {
- monday = "02:00-03:00",
- tuesday = "02:00-03:00",
- wednesday = "02:00-03:00",
- thursday = "02:00-03:00",
- friday = "02:00-03:00",
- saturday = "02:00-03:00",
+ monday = "02:00-03:00"
+ tuesday = "02:00-03:00"
+ wednesday = "02:00-03:00"
+ thursday = "02:00-03:00"
+ friday = "02:00-03:00"
+ saturday = "02:00-03:00"
sunday = "02:00-03:00"
}
library "cluster"
object ClusterListener "cluster" {
- ca_path = "/etc/icinga2/ca/ca.crt",
- cert_path = "/etc/icinga2/ca/icinga-node-1.crt",
- key_path = "/etc/icinga2/ca/icinga-node-1.key",
+ ca_path = "/etc/icinga2/ca/ca.crt"
+ cert_path = "/etc/icinga2/ca/icinga-node-1.crt"
+ key_path = "/etc/icinga2/ca/icinga-node-1.key"
- bind_port = 8888,
+ bind_port = 8888
peers = [ "icinga-node-2" ]
}
*/
object Endpoint "icinga-node-1" {
- host = "icinga-node-1.localdomain",
- port = 8888,
+ host = "icinga-node-1.localdomain"
+ port = 8888
config_files = ["/etc/icinga2/conf.d/*.conf"]
}
*/
object Endpoint "icinga-node-2" {
- host = "icinga-node-2.localdomain",
- port = 8888,
+ host = "icinga-node-2.localdomain"
+ port = 8888
accept_config = [ "icinga-node-1" ]
}
# vim cluster.conf
object Endpoint "icinga-node-1" {
- host = "icinga-node-1.localdomain",
+ host = "icinga-node-1.localdomain"
port = 8888
}
[ClusterListener](pbjecttype-clusterlistener) object.
object Endpoint "icinga-node-2" {
- host = "icinga-node-2.localdomain",
+ host = "icinga-node-2.localdomain"
port = 8888
}
object ClusterListener "cluster" {
- ca_path = "/etc/icinga2/ca/ca.crt",
- cert_path = "/etc/icinga2/ca/icinga-node-1.crt",
- key_path = "/etc/icinga2/ca/icinga-node-1.key",
+ ca_path = "/etc/icinga2/ca/ca.crt"
+ cert_path = "/etc/icinga2/ca/icinga-node-1.crt"
+ key_path = "/etc/icinga2/ca/icinga-node-1.key"
- bind_port = 8888,
+ bind_port = 8888
peers = [ "icinga-node-2" ]
}
attribute. Required Endpoints must be defined as array.
apply Service "dmz-oracledb" {
- import "generic-service",
+ import "generic-service"
- authorities = [ "icinga-node-1" ],
+ authorities = [ "icinga-node-1" ]
assign where "oracle" in host.groups
}
Example:
apply Service "cluster" {
- import "generic-service",
+ import "generic-service"
- check_interval = 1m,
- check_command = "cluster",
- authorities = [ "icinga2a" ],
+ check_interval = 1m
+ check_command = "cluster"
+ authorities = [ "icinga2a" ]
assign where host.name = "icinga2a"
}
The endpoint configuration on the `nuremberg` node would look like:
object Endpoint "nuremberg" {
- host = "nuremberg.icinga.org",
- port = 8888,
+ host = "nuremberg.icinga.org"
+ port = 8888
}
object Endpoint "berlin" {
- host = "berlin.icinga.org",
- port = 8888,
+ host = "berlin.icinga.org"
+ port = 8888
config_files_recursive = [ "/etc/icinga2/conf.d/templates",
"/etc/icinga2/conf.d/germany/berlin" ]
}
object Endpoint "vienna" {
- host = "vienna.icinga.org",
- port = 8888,
+ host = "vienna.icinga.org"
+ port = 8888
config_files_recursive = [ "/etc/icinga2/conf.d/templates",
"/etc/icinga2/conf.d/austria/vienna" ]
}
Example for the configuration on the `berlin` node:
object Endpoint "nuremberg" {
- host = "nuremberg.icinga.org",
- port = 8888,
+ host = "nuremberg.icinga.org"
+ port = 8888
}
object Endpoint "berlin" {
- host = "berlin.icinga.org",
- port = 8888,
+ host = "berlin.icinga.org"
+ port = 8888
accept_config = [ "nuremberg" ]
}
library "cluster"
object ClusterListener "berlin-cluster" {
- ca_path = "/etc/icinga2/ca/ca.crt",
- cert_path = "/etc/icinga2/ca/berlin.crt",
- key_path = "/etc/icinga2/ca/berlin.key",
- bind_port = 8888,
+ ca_path = "/etc/icinga2/ca/ca.crt"
+ cert_path = "/etc/icinga2/ca/berlin.crt"
+ key_path = "/etc/icinga2/ca/berlin.key"
+ bind_port = 8888
peers = [ "nuremberg" ]
}
library "cluster"
object ClusterListener "nuremberg-cluster" {
- ca_path = "/etc/icinga2/ca/ca.crt",
- cert_path = "/etc/icinga2/ca/nuremberg.crt",
- key_path = "/etc/icinga2/ca/nuremberg.key",
- bind_port = 8888,
+ ca_path = "/etc/icinga2/ca/ca.crt"
+ cert_path = "/etc/icinga2/ca/nuremberg.crt"
+ key_path = "/etc/icinga2/ca/nuremberg.key"
+ bind_port = 8888
peers = [ "berlin", "vienna" ]
}
Example on the `central` node:
object Endpoint "central" {
- host = "central.icinga.org",
- port = 8888,
+ host = "central.icinga.org"
+ port = 8888
}
object Endpoint "checker1" {
- host = "checker1.icinga.org",
- port = 8888,
+ host = "checker1.icinga.org"
+ port = 8888
config_files_recursive = [ "/etc/icinga2/conf.d" ]
}
object Endpoint "checker2" {
- host = "checker2.icinga.org",
- port = 8888,
+ host = "checker2.icinga.org"
+ port = 8888
config_files_recursive = [ "/etc/icinga2/conf.d" ]
}
object ClusterListener "central-cluster" {
- ca_path = "/etc/icinga2/ca/ca.crt",
- cert_path = "/etc/icinga2/ca/central.crt",
- key_path = "/etc/icinga2/ca/central.key",
- bind_port = 8888,
+ ca_path = "/etc/icinga2/ca/ca.crt"
+ cert_path = "/etc/icinga2/ca/central.crt"
+ key_path = "/etc/icinga2/ca/central.key"
+ bind_port = 8888
peers = [ "checker1", "checker2" ]
}
Example on `checker1` node:
object Endpoint "central" {
- host = "central.icinga.org",
- port = 8888,
+ host = "central.icinga.org"
+ port = 8888
}
object Endpoint "checker1" {
- host = "checker1.icinga.org",
- port = 8888,
+ host = "checker1.icinga.org"
+ port = 8888
accept_config = [ "central" ]
}
object Endpoint "checker2" {
- host = "checker2.icinga.org",
- port = 8888,
+ host = "checker2.icinga.org"
+ port = 8888
accept_config = [ "central" ]
}
object ClusterListener "checker1-cluster" {
- ca_path = "/etc/icinga2/ca/ca.crt",
- cert_path = "/etc/icinga2/ca/checker1.crt",
- key_path = "/etc/icinga2/ca/checker1.key",
+ ca_path = "/etc/icinga2/ca/ca.crt"
+ cert_path = "/etc/icinga2/ca/checker1.crt"
+ key_path = "/etc/icinga2/ca/checker1.key"
bind_port = 8888
}
from the `icinga-node-dmz-1` endpoint.
object Host "dmz-host1" {
- import "generic-host",
+ import "generic-host"
services["dmz-oracledb"] = {
- templates = [ "generic-service" ],
- domains = [ "dmz-db" ],
- authorities = [ "icinga-node-dmz-1", "icinga-node-dmz-2"],
+ templates = [ "generic-service" ]
+ domains = [ "dmz-db" ]
+ authorities = [ "icinga-node-dmz-1", "icinga-node-dmz-2"]
}
}
object Domain "dmz-db" {
acl = {
- icinga-node-dmz-1 = DomainPrivReadOnly,
+ icinga-node-dmz-1 = DomainPrivReadOnly
icinga-node-dmz-2 = DomainPrivReadWrite
}
}
}
object Host "google-dns" {
- macros.address = "8.8.8.8",
+ macros.address = "8.8.8.8"
}
apply Service "ping4" {
- import "generic-service",
+ import "generic-service"
check_command = "ping4"
}
apply Dependency "internet" {
- parent_host = "dsl-router",
+ parent_host = "dsl-router"
disable_checks = true
assign where host.name != "dsl-router"
Icinga 2 supports objects and (global) variables, but does not make a difference
if it's the main configuration file, or any included file.
- set IcingaEnableNotifications = 1,
+ const IcingaEnableNotifications = true
object Service "test" {
- enable_notifications = 0,
+ enable_notifications = 0
}
### <a id="differences-1x-2-sample-configuration-itl"></a> Sample Configuration and ITL
}
object Service "testservice" {
- import "tmpl1",
- import "tmpl2",
+ import "tmpl1"
+ import "tmpl2"
import "tmpl3"
}
}
object Service "test" {
- check_interval = 5m,
+ check_interval = 5m
}
> **Note**
or `Service` objects:
custom = {
- notes = "Icinga 2 is the best!",
- notes_url = "http://docs.icinga.org",
- action_url = "http://dev.icinga.org",
- icon_image = "../../images/logos/Stats2.png",
- icon_image_alt = "icinga2 alt icon text",
- "2d_coords" = "1,2",
- statusmap_image = "../../images/logos/icinga.gif",
+ notes = "Icinga 2 is the best!"
+ notes_url = "http://docs.icinga.org"
+ action_url = "http://dev.icinga.org"
+ icon_image = "../../images/logos/Stats2.png"
+ icon_image_alt = "icinga2 alt icon text"
+ "2d_coords" = "1,2"
+ statusmap_image = "../../images/logos/icinga.gif"
}
External interfaces will recognize and display these attributes accordingly.
In Icinga 2 these attributes must be added to the `custom`dictionary.
custom = {
- DN = "cn=icinga2-dev-host,ou=icinga,ou=main,ou=IcingaConfig,ou=LConf,dc=icinga,dc=org",
- CV = "my custom cmdb description",
+ DN = "cn=icinga2-dev-host,ou=icinga,ou=main,ou=IcingaConfig,ou=LConf,dc=icinga,dc=org"
+ CV = "my custom cmdb description"
}
> **Note**
With the freely definable macros in Icinga 2 it looks like this:
object CheckCommand "ping4" {
- command = PluginDir + "/check_ping -H $HOSTADDRESS$ -w $wrta$,$wpl%$ -c $crta$,$cpl%$",
+ command = PluginDir + "/check_ping -H $HOSTADDRESS$ -w $wrta$,$wpl%$ -c $crta$,$cpl%$"
}
object Service "PING" {
- check_command = "ping4",
+ check_command = "ping4"
macros = {
- wrta = 100,
- wpl = 20,
- crta = 500,
+ wrta = 100
+ wpl = 20
+ crta = 500
cpl = 60
}
}
The preferred way of assigning objects to groups is by using a template:
template Host "dev-host" {
- groups += [ "dev-hosts" ],
+ groups += [ "dev-hosts" ]
}
object Host "web-dev" {
keyword can be used:
apply Service "ping" {
- import "generic-service",
+ import "generic-service"
- check_command = "ping4",
+ check_command = "ping4"
assign where "group" in host.groups
}
*/
template ScheduledDowntime "backup-downtime" {
- author = "icingaadmin",
- comment = "Scheduled downtime for backup",
+ author = "icingaadmin"
+ comment = "Scheduled downtime for backup"
ranges = {
- monday = "02:00-03:00",
- tuesday = "02:00-03:00",
- wednesday = "02:00-03:00",
- thursday = "02:00-03:00",
- friday = "02:00-03:00",
- saturday = "02:00-03:00",
+ monday = "02:00-03:00"
+ tuesday = "02:00-03:00"
+ wednesday = "02:00-03:00"
+ thursday = "02:00-03:00"
+ friday = "02:00-03:00"
+ saturday = "02:00-03:00"
sunday = "02:00-03:00"
}
}
}
apply Service "ping4" {
- import "generic-service",
+ import "generic-service"
- check_command = "ping4",
+ check_command = "ping4"
- assign where "generic-host" in host.templates,
+ assign where "generic-host" in host.templates
ignore where !host.macros.address
}
apply Service "ping6" {
- import "generic-service",
+ import "generic-service"
- check_command = "ping6",
+ check_command = "ping6"
- assign where "generic-host" in host.templates,
+ assign where "generic-host" in host.templates
ignore where !host.macros.address6
}
template Host "linux-server" {
- import "generic-host",
+ import "generic-host"
- groups += [ "linux-servers" ],
+ groups += [ "linux-servers" ]
}
template Host "windows-server" {
- import "generic-host",
+ import "generic-host"
- groups += [ "windows-servers" ],
+ groups += [ "windows-servers" ]
}
template Host "generic-printer" {
- import "generic-host",
+ import "generic-host"
}
template Host "generic-switch" {
- import "generic-host",
+ import "generic-host"
}
* all services should import this template.
*/
template Service "generic-service" {
- max_check_attempts = 3,
- check_interval = 5m,
- retry_interval = 1m,
+ max_check_attempts = 3
+ check_interval = 5m
+ retry_interval = 1m
enable_perfdata = true
}
apply Notification "mail-icingaadmin" {
- import "mail-notification",
+ import "mail-notification"
- user_groups = [ "icingaadmins"],
+ user_groups = [ "icingaadmins"]
assign where "generic-service" in service.templates
}
* files in this directory are included.
*/
object Host "localhost" {
- import "linux-server",
+ import "linux-server"
- macros.address = "127.0.0.1",
+ macros.address = "127.0.0.1"
macros.address6 = "::1"
}
apply Service "icinga" {
- import "generic-service",
+ import "generic-service"
- check_command = "icinga",
+ check_command = "icinga"
assign where host.name == "localhost"
}
apply Service "http" {
- import "generic-service",
+ import "generic-service"
- check_command = "http_ip",
+ check_command = "http_ip"
assign where host.name == "localhost"
}
apply Service "ssh" {
- import "generic-service",
+ import "generic-service"
- check_command = "ssh",
+ check_command = "ssh"
assign where host.name == "localhost"
}
apply Service "load" {
- import "generic-service",
+ import "generic-service"
- check_command = "load",
+ check_command = "load"
assign where host.name == "localhost"
}
apply ScheduledDowntime "backup-downtime" {
- import "backup-downtime",
+ import "backup-downtime"
assign where service.host == "localhost" && service.short_name == "load"
}
apply Service "processes" {
- import "generic-service",
+ import "generic-service"
- check_command = "processes",
+ check_command = "processes"
assign where host.name == "localhost"
}
apply Service "users" {
- import "generic-service",
+ import "generic-service"
- check_command = "users",
+ check_command = "users"
assign where host.name == "localhost"
}
apply Service "disk" {
- import "generic-service",
+ import "generic-service"
- check_command = "disk",
+ check_command = "disk"
assign where host.name == "localhost"
}
*/
template Notification "mail-notification" {
- notification_command = "mail-service-notification",
+ notification_command = "mail-service-notification"
- notification_state_filter = StateFilterOK |
+ notification_state_filter = (StateFilterOK |
StateFilterWarning |
StateFilterCritical |
- StateFilterUnknown,
- notification_type_filter = NotificationFilterProblem |
+ StateFilterUnknown)
+ notification_type_filter = (NotificationFilterProblem |
NotificationFilterAcknowledgement |
NotificationFilterRecovery |
NotificationFilterCustom |
NotificationFilterFlappingEnd |
NotificationFilterDowntimeStart |
NotificationFilterDowntimeEnd |
- NotificationFilterDowntimeRemoved,
+ NotificationFilterDowntimeRemoved)
notification_period = "24x7"
}
object NotificationCommand "mail-service-notification" {
- import "plugin-notification-command",
+ import "plugin-notification-command"
- command = [ IcingaSysconfDir + "/icinga2/scripts/mail-notification.sh" ],
+ command = [ IcingaSysconfDir + "/icinga2/scripts/mail-notification.sh" ]
export_macros = [
"NOTIFICATIONTYPE",
*/
object TimePeriod "24x7" {
- import "legacy-timeperiod",
+ import "legacy-timeperiod"
- display_name = "Icinga 2 24x7 TimePeriod",
+ display_name = "Icinga 2 24x7 TimePeriod"
ranges = {
- "monday" = "00:00-24:00",
- "tuesday" = "00:00-24:00",
- "wednesday" = "00:00-24:00",
- "thursday" = "00:00-24:00",
- "friday" = "00:00-24:00",
- "saturday" = "00:00-24:00",
- "sunday" = "00:00-24:00",
+ "monday" = "00:00-24:00"
+ "tuesday" = "00:00-24:00"
+ "wednesday" = "00:00-24:00"
+ "thursday" = "00:00-24:00"
+ "friday" = "00:00-24:00"
+ "saturday" = "00:00-24:00"
+ "sunday" = "00:00-24:00"
}
}
object TimePeriod "9to5" {
- import "legacy-timeperiod",
+ import "legacy-timeperiod"
- display_name = "Icinga 2 9to5 TimePeriod",
+ display_name = "Icinga 2 9to5 TimePeriod"
ranges = {
- "monday" = "09:00-17:00",
- "tuesday" = "09:00-17:00",
- "wednesday" = "09:00-17:00",
- "thursday" = "09:00-17:00",
- "friday" = "09:00-17:00",
+ "monday" = "09:00-17:00"
+ "tuesday" = "09:00-17:00"
+ "wednesday" = "09:00-17:00"
+ "thursday" = "09:00-17:00"
+ "friday" = "09:00-17:00"
}
}
object TimePeriod "never" {
- import "legacy-timeperiod",
+ import "legacy-timeperiod"
- display_name = "Icinga 2 never TimePeriod",
+ display_name = "Icinga 2 never TimePeriod"
ranges = {
}
}
*/
object User "icingaadmin" {
- import "generic-user",
+ import "generic-user"
- display_name = "Icinga 2 Admin",
- groups = [ "icingaadmins" ],
+ display_name = "Icinga 2 Admin"
+ groups = [ "icingaadmins" ]
macros = {
- "name" = "Icinga 2 Admin",
- "email" = "icinga@localhost",
+ "name" = "Icinga 2 Admin"
+ "email" = "icinga@localhost"
"pager" = "icingaadmin@localhost.localdomain"
- },
+ }
custom = {
- notes = "This is the Icinga 2 Admin account.",
+ notes = "This is the Icinga 2 Admin account."
}
}
/**
* Although in theory you could define all your objects in this file
* the preferred way is to create separate directories and files in the conf.d
- * directory.
+ * directory. Each of these files must have the file extension ".conf".
*/
-include_recursive "conf.d" "*.conf"
+include_recursive "conf.d"
result = yyextra->ReadInput(buf, max_size); \
} while (0)
+extern int ignore_newlines;
+
struct lex_buf {
char *buf;
size_t size;
\/\/[^\n]* /* ignore C++-style comments */
-[ \t\r\n] /* ignore whitespace */
+[ \t] /* ignore whitespace */
<INITIAL>{
%type return T_TYPE;
\> { yylval->op = &AExpression::OpLessThan; return T_GREATER_THAN; }
}
+[\r\n]+ { if (!ignore_newlines) return T_NEWLINE; }
. return yytext[0];
%%
using namespace icinga;
+int ignore_newlines = 0;
+
static void MakeRBinaryOp(Value** result, AExpression::OpCallback& op, Value *left, Value *right, DebugInfo& diLeft, DebugInfo& diRight)
{
*result = new Value(make_shared<AExpression>(op, static_cast<AExpression::Ptr>(*left), static_cast<AExpression::Ptr>(*right), DebugInfoRange(diLeft, diRight)));
Array *array;
}
+%token T_NEWLINE "new-line"
%token <text> T_STRING
%token <text> T_STRING_ANGLE
%token <num> T_NUMBER
%left T_MULTIPLY T_DIVIDE_OP
%right '!' '~'
%left '.' '(' '['
+%right ':'
%{
int yylex(YYSTYPE *lvalp, YYLTYPE *llocp, void *scanner);
| statements statement
;
-statement: type | include | include_recursive | library | constant
+statement: type | include | include_recursive | library | constant | newlines
{ }
| lterm
{
}
;
-include: T_INCLUDE rterm
+include: T_INCLUDE rterm sep
{
AExpression::Ptr aexpr = static_cast<AExpression::Ptr>(*$2);
delete $2;
context->HandleIncludeRecursive(aexpr->Evaluate(m_ModuleScope), "*.conf", DebugInfoRange(@1, @2));
}
- | T_INCLUDE_RECURSIVE rterm rterm
+ | T_INCLUDE_RECURSIVE rterm ',' rterm
{
AExpression::Ptr aexpr1 = static_cast<AExpression::Ptr>(*$2);
delete $2;
- AExpression::Ptr aexpr2 = static_cast<AExpression::Ptr>(*$3);
- delete $3;
+ AExpression::Ptr aexpr2 = static_cast<AExpression::Ptr>(*$4);
+ delete $4;
- context->HandleIncludeRecursive(aexpr1->Evaluate(m_ModuleScope), aexpr2->Evaluate(m_ModuleScope), DebugInfoRange(@1, @3));
+ context->HandleIncludeRecursive(aexpr1->Evaluate(m_ModuleScope), aexpr2->Evaluate(m_ModuleScope), DebugInfoRange(@1, @4));
}
;
-library: T_LIBRARY T_STRING
+library: T_LIBRARY T_STRING sep
{
context->HandleLibrary($2);
free($2);
}
;
-constant: T_CONST identifier T_SET rterm
+constant: T_CONST identifier T_SET rterm sep
{
AExpression::Ptr aexpr = static_cast<AExpression::Ptr>(*$4);
delete $4;
m_Type->Register();
}
}
- type_inherits_specifier typerulelist
+ type_inherits_specifier typerulelist sep
{
TypeRuleList::Ptr ruleList = *$6;
m_Type->GetRuleList()->AddRules(ruleList);
;
typerules: typerules_inner
- | typerules_inner ','
+ | typerules_inner sep
typerules_inner: /* empty */
| typerule
- | typerules_inner ',' typerule
+ | typerules_inner sep typerule
;
typerule: T_REQUIRE T_STRING
{
m_Abstract = false;
}
- object_declaration identifier rterm rterm_scope
+ object_declaration identifier rterm rterm_scope sep
{
Array::Ptr args = make_shared<Array>();
}
;
-comma_or_semicolon: ',' | ';'
- ;
-
lterm_items: lterm_items_inner
{
$$ = $1;
}
- | lterm_items_inner comma_or_semicolon
+ | lterm_items_inner sep
{
$$ = $1;
}
$$->Add(*$1);
delete $1;
}
- | lterm_items_inner comma_or_semicolon lterm
+ | lterm_items_inner sep lterm
{
if ($1)
$$ = $1;
}
| rterm_items_inner ',' rterm
{
- if ($1)
- $$ = $1;
- else
- $$ = new Array();
-
+ $$ = $1;
$$->Add(*$3);
delete $3;
}
+ | rterm_items_inner ',' newlines rterm
+ {
+ $$ = $1;
+ $$->Add(*$4);
+ delete $4;
+ }
;
-rterm_scope: '{' lterm_items '}'
+rterm_scope: '{' newlines lterm_items newlines '}'
+ {
+ $$ = new Value(make_shared<AExpression>(&AExpression::OpDict, Array::Ptr($3), DebugInfoRange(@1, @5)));
+ }
+ | '{' newlines lterm_items '}'
+ {
+ $$ = new Value(make_shared<AExpression>(&AExpression::OpDict, Array::Ptr($3), DebugInfoRange(@1, @4)));
+ }
+ | '{' lterm_items newlines '}'
+ {
+ $$ = new Value(make_shared<AExpression>(&AExpression::OpDict, Array::Ptr($2), DebugInfoRange(@1, @4)));
+ }
+ | '{' lterm_items '}'
{
$$ = new Value(make_shared<AExpression>(&AExpression::OpDict, Array::Ptr($2), DebugInfoRange(@1, @3)));
}
delete $1;
free($3);
}
+ | '[' newlines rterm_items newlines ']'
+ {
+ $$ = new Value(make_shared<AExpression>(&AExpression::OpArray, Array::Ptr($3), DebugInfoRange(@1, @5)));
+ }
+ | '[' rterm_items newlines ']'
+ {
+ $$ = new Value(make_shared<AExpression>(&AExpression::OpArray, Array::Ptr($2), DebugInfoRange(@1, @4)));
+ }
+ | '[' newlines rterm_items ']'
+ {
+ $$ = new Value(make_shared<AExpression>(&AExpression::OpArray, Array::Ptr($3), DebugInfoRange(@1, @4)));
+ }
| '[' rterm_items ']'
{
$$ = new Value(make_shared<AExpression>(&AExpression::OpArray, Array::Ptr($2), DebugInfoRange(@1, @3)));
{
$$ = $1;
}
- | '(' rterm ')'
+ | '('
{
- $$ = $2;
+ ignore_newlines++;
+ }
+ rterm ')'
+ {
+ ignore_newlines--;
+ $$ = $3;
}
| rterm T_LOGICAL_OR rterm { MakeRBinaryOp(&$$, $2, $1, $3, @1, @3); }
| rterm T_LOGICAL_AND rterm { MakeRBinaryOp(&$$, $2, $1, $3, @1, @3); }
m_Assign.reset();
m_Ignore.reset();
}
+ ;
+
+newlines: T_NEWLINE
+ | newlines T_NEWLINE
+ ;
+
+/* required separator */
+sep: ',' newlines
+ | ','
+ | ';' newlines
+ | ';'
+ | newlines
+ ;
+
%%