Implement support for default templates

fixes #12575
This commit is contained in:
Gunnar Beutner 2016-08-28 10:27:43 +02:00
parent 0e8edfa2c7
commit 78cd56e277
41 changed files with 158 additions and 203 deletions

View File

@ -27,24 +27,32 @@ Command template for check plugins executed by Icinga 2.
The `plugin-check-command` command does not support any vars. The `plugin-check-command` command does not support any vars.
By default this template is automatically imported into all CheckCommand definitions.
### <a id="itl-plugin-notification-command"></a> plugin-notification-command ### <a id="itl-plugin-notification-command"></a> plugin-notification-command
Command template for notification scripts executed by Icinga 2. Command template for notification scripts executed by Icinga 2.
The `plugin-notification-command` command does not support any vars. The `plugin-notification-command` command does not support any vars.
By default this template is automatically imported into all CheckCommand definitions.
### <a id="itl-plugin-event-command"></a> plugin-event-command ### <a id="itl-plugin-event-command"></a> plugin-event-command
Command template for event handler scripts executed by Icinga 2. Command template for event handler scripts executed by Icinga 2.
The `plugin-event-command` command does not support any vars. The `plugin-event-command` command does not support any vars.
By default this template is automatically imported into all CheckCommand definitions.
### <a id="itl-legacy-timeperiod"></a> legacy-timeperiod ### <a id="itl-legacy-timeperiod"></a> legacy-timeperiod
Timeperiod template for [Timeperiod objects](9-object-types.md#objecttype-timeperiod). Timeperiod template for [Timeperiod objects](9-object-types.md#objecttype-timeperiod).
The `legacy-timeperiod` timeperiod does not support any vars. The `legacy-timeperiod` timeperiod does not support any vars.
By default this template is automatically imported into all CheckCommand definitions.
## <a id="itl-check-commands"></a> Check Commands ## <a id="itl-check-commands"></a> Check Commands
These check commands are embedded into Icinga 2 and do not require any external These check commands are embedded into Icinga 2 and do not require any external

View File

@ -344,6 +344,19 @@ custom attributes and the custom attribute `colour` has the value `"blue"`.
Parent objects are resolved in the order they're specified using the Parent objects are resolved in the order they're specified using the
`import` keyword. `import` keyword.
Default templates which are automatically imported into all object definitions
can be specified using the `default` keyword:
template CheckCommand "plugin-check-command" default {
// ...
}
Default templates are imported before any other user-specified statement in an
object definition is evaluated.
If there are multiple default templates the order in which they are imported
is unspecified.
## <a id="constants"></a> Constants ## <a id="constants"></a> Constants
Global constants can be set using the `const` keyword: Global constants can be set using the `const` keyword:

View File

@ -153,8 +153,6 @@ are referenced as `$ARGn$` where `n` is the argument counter.
While you could manually migrate this like (please note the new generic command arguments and default argument values!): While you could manually migrate this like (please note the new generic command arguments and default argument values!):
object CheckCommand "my-ping-check" { object CheckCommand "my-ping-check" {
import "plugin-check-command"
command = [ command = [
PluginDir + "/check_ping", "-4" PluginDir + "/check_ping", "-4"
] ]
@ -233,7 +231,6 @@ Custom variables from Icinga 1.x are available as Icinga 2 custom attributes.
Can be written as the following in Icinga 2: Can be written as the following in Icinga 2:
object CheckCommand "test_customvar" { object CheckCommand "test_customvar" {
import "plugin-check-command"
command = "echo "Host CV: $host.vars.CVTEST$ Service CV: $service.vars.CVTEST$\n"" command = "echo "Host CV: $host.vars.CVTEST$ Service CV: $service.vars.CVTEST$\n""
} }

View File

@ -163,8 +163,6 @@ The special case here is that whenever Icinga 2 needs the value for such a custo
the function and uses whatever value the function returns: the function and uses whatever value the function returns:
object CheckCommand "random-value" { object CheckCommand "random-value" {
import "plugin-check-command"
command = [ PluginDir + "/check_dummy", "0", "$text$" ] command = [ PluginDir + "/check_dummy", "0", "$text$" ]
vars.text = {{ Math.random() * 100 }} vars.text = {{ Math.random() * 100 }}
@ -229,8 +227,6 @@ are used in command definitions to figure out which IP address a check should be
run against: run against:
object CheckCommand "my-ping" { object CheckCommand "my-ping" {
import "plugin-check-command"
command = [ PluginDir + "/check_ping", "-H", "$ping_address$" ] command = [ PluginDir + "/check_ping", "-H", "$ping_address$" ]
arguments = { arguments = {
@ -1238,9 +1234,6 @@ using the `check_command` attribute.
#### <a id="command-plugin-integration"></a> Integrate the Plugin with a CheckCommand Definition #### <a id="command-plugin-integration"></a> Integrate the Plugin with a CheckCommand Definition
[CheckCommand](9-object-types.md#objecttype-checkcommand) objects require the [ITL template](10-icinga-template-library.md#itl-plugin-check-command)
`plugin-check-command` to support native plugin based check methods.
Unless you have done so already, download your check plugin and put it Unless you have done so already, download your check plugin and put it
into the [PluginDir](4-configuring-icinga-2.md#constants-conf) directory. The following example uses the into the [PluginDir](4-configuring-icinga-2.md#constants-conf) directory. The following example uses the
`check_mysql` plugin contained in the Monitoring Plugins package. `check_mysql` plugin contained in the Monitoring Plugins package.
@ -1299,8 +1292,6 @@ can also be inherited from a parent template using additive inheritance (`+=`).
# vim /etc/icinga2/conf.d/commands.conf # vim /etc/icinga2/conf.d/commands.conf
object CheckCommand "my-mysql" { object CheckCommand "my-mysql" {
import "plugin-check-command"
command = [ PluginDir + "/check_mysql" ] //constants.conf -> const PluginDir command = [ PluginDir + "/check_mysql" ] //constants.conf -> const PluginDir
arguments = { arguments = {
@ -1426,8 +1417,6 @@ at command execution. Or making arguments optional -- only set if the
macro value can be resolved by Icinga 2. macro value can be resolved by Icinga 2.
object CheckCommand "check_http" { object CheckCommand "check_http" {
import "plugin-check-command"
command = [ PluginDir + "/check_http" ] command = [ PluginDir + "/check_http" ]
arguments = { arguments = {
@ -1490,8 +1479,6 @@ This is useful for example for hiding sensitive information on the command line
when passing credentials to database checks: when passing credentials to database checks:
object CheckCommand "mysql-health" { object CheckCommand "mysql-health" {
import "plugin-check-command"
command = [ command = [
PluginDir + "/check_mysql" PluginDir + "/check_mysql"
] ]
@ -1520,9 +1507,6 @@ interfaces (email, XMPP, IRC, Twitter, etc.).
[NotificationCommand](9-object-types.md#objecttype-notificationcommand) objects are referenced by [NotificationCommand](9-object-types.md#objecttype-notificationcommand) objects are referenced by
[Notification](9-object-types.md#objecttype-notification) objects using the `command` attribute. [Notification](9-object-types.md#objecttype-notification) objects using the `command` attribute.
`NotificationCommand` objects require the [ITL template](10-icinga-template-library.md#itl-plugin-notification-command)
`plugin-notification-command` to support native plugin-based notifications.
> **Note** > **Note**
> >
> Make sure that the [notification](11-cli-commands.md#enable-features) feature is enabled > Make sure that the [notification](11-cli-commands.md#enable-features) feature is enabled
@ -1536,8 +1520,6 @@ If you want to specify default values for some of the custom attribute definitio
you can add a `vars` dictionary as shown for the `CheckCommand` object. you can add a `vars` dictionary as shown for the `CheckCommand` object.
object NotificationCommand "mail-service-notification" { object NotificationCommand "mail-service-notification" {
import "plugin-notification-command"
command = [ SysconfDir + "/icinga2/scripts/mail-notification.sh" ] command = [ SysconfDir + "/icinga2/scripts/mail-notification.sh" ]
env = { env = {
@ -1618,9 +1600,6 @@ Common use case scenarios are a failing HTTP check requiring an immediate
restart via event command, or if an application is locked and requires restart via event command, or if an application is locked and requires
a restart upon detection. a restart upon detection.
`EventCommand` objects require the ITL template `plugin-event-command`
to support native plugin based checks.
#### <a id="event-command-restart-service-daemon"></a> Use Event Commands to Restart Service Daemon #### <a id="event-command-restart-service-daemon"></a> Use Event Commands to Restart Service Daemon
The following example will trigger a restart of the `httpd` daemon The following example will trigger a restart of the `httpd` daemon
@ -1647,8 +1626,6 @@ which can be used for all event commands triggered using ssh:
/* pass event commands through ssh */ /* pass event commands through ssh */
object EventCommand "event_by_ssh" { object EventCommand "event_by_ssh" {
import "plugin-event-command"
command = [ PluginDir + "/check_by_ssh" ] command = [ PluginDir + "/check_by_ssh" ]
arguments = { arguments = {

View File

@ -58,7 +58,6 @@ into your host and service objects.
Please make sure to follow these conventions when adding a new command object definition: Please make sure to follow these conventions when adding a new command object definition:
* Always import the `plugin-check-command` template.
* Use [command arguments](3-monitoring-basics.md#command-arguments) whenever possible. The `command` attribute * Use [command arguments](3-monitoring-basics.md#command-arguments) whenever possible. The `command` attribute
must be an array in `[ ... ]` for shell escaping. must be an array in `[ ... ]` for shell escaping.
* Define a unique `prefix` for the command's specific arguments. That way you can safely * Define a unique `prefix` for the command's specific arguments. That way you can safely
@ -69,8 +68,6 @@ set them on host/service level and you'll always know which command they control
This is an example for a custom `my-snmp-int` check command: This is an example for a custom `my-snmp-int` check command:
object CheckCommand "my-snmp-int" { object CheckCommand "my-snmp-int" {
import "plugin-check-command"
command = [ CustomPluginDir + "/check_snmp_int.pl" ] command = [ CustomPluginDir + "/check_snmp_int.pl" ]
arguments = { arguments = {

View File

@ -658,8 +658,6 @@ If you have your own custom `CheckCommand` definition, add it to the global zone
[root@icinga2-master1.localdomain /]# vim /etc/icinga2/zones.d/global-templates/commands.conf [root@icinga2-master1.localdomain /]# vim /etc/icinga2/zones.d/global-templates/commands.conf
object CheckCommand "my-cmd" { object CheckCommand "my-cmd" {
import "plugin-check-command"
//... //...
} }
@ -1565,8 +1563,6 @@ Next, add a new check command, for example:
[root@icinga2-master1.localdomain /]# vim /etc/icinga2/zones.d/global-templates/commands.conf [root@icinga2-master1.localdomain /]# vim /etc/icinga2/zones.d/global-templates/commands.conf
object CheckCommand "my-cmd" { object CheckCommand "my-cmd" {
import "plugin-check-command"
//... //...
} }

View File

@ -211,8 +211,6 @@ match your Icinga convention.
Add an `EventCommand` configuration object for the passive service auto reset event. Add an `EventCommand` configuration object for the passive service auto reset event.
object EventCommand "coldstart-reset-event" { object EventCommand "coldstart-reset-event" {
import "plugin-event-command"
command = [ SysconfDir + "/icinga2/conf.d/custom/scripts/coldstart_reset_event.sh" ] command = [ SysconfDir + "/icinga2/conf.d/custom/scripts/coldstart_reset_event.sh" ]
arguments = { arguments = {

View File

@ -323,7 +323,6 @@ and evaluating the host custom attribute `compellent` containing the `disks` thi
solved like this: solved like this:
object CheckCommand "check_compellent" { object CheckCommand "check_compellent" {
import "plugin-check-command"
command = [ "/usr/bin/check_compellent" ] command = [ "/usr/bin/check_compellent" ]
arguments = { arguments = {
"--disks" = { "--disks" = {
@ -410,7 +409,6 @@ returned.
You can omit the `log()` calls, they only help debugging. You can omit the `log()` calls, they only help debugging.
object NotificationCommand "mail-host-notification-test" { object NotificationCommand "mail-host-notification-test" {
import "plugin-notification-command"
command = {{ command = {{
log("command as function") log("command as function")
var mailscript = "mail-host-notification-long.sh" var mailscript = "mail-host-notification-long.sh"

View File

@ -84,8 +84,6 @@ defined here.
Example: Example:
object CheckCommand "check_http" { object CheckCommand "check_http" {
import "plugin-check-command"
command = [ PluginDir + "/check_http" ] command = [ PluginDir + "/check_http" ]
arguments = { arguments = {
@ -122,7 +120,7 @@ Configuration Attributes:
Name |Description Name |Description
----------------|---------------- ----------------|----------------
execute |**Required.** The "execute" script method takes care of executing the check. In virtually all cases you should import the "plugin-check-command" template to take care of this setting. execute |**Required.** The "execute" script method takes care of executing the check. The default template "plugin-check-command" which is imported into all CheckCommand objects takes care of this setting.
command |**Required.** The command. This can either be an array of individual command arguments. Alternatively a string can be specified in which case the shell interpreter (usually /bin/sh) takes care of parsing the command. When using the "arguments" attribute this must be an array. Can be specified as function for advanced implementations. command |**Required.** The command. This can either be an array of individual command arguments. Alternatively a string can be specified in which case the shell interpreter (usually /bin/sh) takes care of parsing the command. When using the "arguments" attribute this must be an array. Can be specified as function for advanced implementations.
env |**Optional.** A dictionary of macros which should be exported as environment variables prior to executing the command. env |**Optional.** A dictionary of macros which should be exported as environment variables prior to executing the command.
vars |**Optional.** A dictionary containing custom attributes that are specific to this command. vars |**Optional.** A dictionary containing custom attributes that are specific to this command.
@ -441,8 +439,6 @@ An event command definition.
Example: Example:
object EventCommand "restart-httpd-event" { object EventCommand "restart-httpd-event" {
import "plugin-event-command"
command = "/opt/bin/restart-httpd.sh" command = "/opt/bin/restart-httpd.sh"
} }
@ -451,7 +447,7 @@ Configuration Attributes:
Name |Description Name |Description
----------------|---------------- ----------------|----------------
execute |**Required.** The "execute" script method takes care of executing the event handler. In virtually all cases you should import the "plugin-event-command" template to take care of this setting. execute |**Required.** The "execute" script method takes care of executing the event handler. The default template "plugin-event-command" which is imported into all CheckCommand objects takes care of this setting.
command |**Required.** The command. This can either be an array of individual command arguments. Alternatively a string can be specified in which case the shell interpreter (usually /bin/sh) takes care of parsing the command. command |**Required.** The command. This can either be an array of individual command arguments. Alternatively a string can be specified in which case the shell interpreter (usually /bin/sh) takes care of parsing the command.
env |**Optional.** A dictionary of macros which should be exported as environment variables prior to executing the command. env |**Optional.** A dictionary of macros which should be exported as environment variables prior to executing the command.
vars |**Optional.** A dictionary containing custom attributes that are specific to this command. vars |**Optional.** A dictionary containing custom attributes that are specific to this command.
@ -1087,8 +1083,6 @@ A notification command definition.
Example: Example:
object NotificationCommand "mail-service-notification" { object NotificationCommand "mail-service-notification" {
import "plugin-notification-command"
command = [ command = [
SysconfDir + "/icinga2/scripts/mail-notification.sh" SysconfDir + "/icinga2/scripts/mail-notification.sh"
] ]
@ -1113,7 +1107,7 @@ Configuration Attributes:
Name |Description Name |Description
----------------|---------------- ----------------|----------------
execute |**Required.** The "execute" script method takes care of executing the notification. In virtually all cases you should import the "plugin-notification-command" template to take care of this setting. execute |**Required.** The "execute" script method takes care of executing the notification. The default template "plugin-notification-command" which is imported into all CheckCommand objects takes care of this setting.
command |**Required.** The command. This can either be an array of individual command arguments. Alternatively a string can be specified in which case the shell interpreter (usually /bin/sh) takes care of parsing the command. command |**Required.** The command. This can either be an array of individual command arguments. Alternatively a string can be specified in which case the shell interpreter (usually /bin/sh) takes care of parsing the command.
env |**Optional.** A dictionary of macros which should be exported as environment variables prior to executing the command. env |**Optional.** A dictionary of macros which should be exported as environment variables prior to executing the command.
vars |**Optional.** A dictionary containing custom attributes that are specific to this command. vars |**Optional.** A dictionary containing custom attributes that are specific to this command.

View File

@ -1,8 +1,6 @@
/* Command objects */ /* Command objects */
object NotificationCommand "mail-host-notification" { object NotificationCommand "mail-host-notification" {
import "plugin-notification-command"
command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ] command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ]
env = { env = {
@ -20,8 +18,6 @@ object NotificationCommand "mail-host-notification" {
} }
object NotificationCommand "mail-service-notification" { object NotificationCommand "mail-service-notification" {
import "plugin-notification-command"
command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ] command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]
env = { env = {

View File

@ -22,8 +22,6 @@ if (!globals.contains("NscpPath")) {
} }
object CheckCommand "nscp-local" { object CheckCommand "nscp-local" {
import "plugin-check-command"
command = [ NscpPath + "\\nscp.exe", "client" ] command = [ NscpPath + "\\nscp.exe", "client" ]
arguments = { arguments = {

View File

@ -22,7 +22,6 @@
*/ */
template CheckCommand "snmp-manubulon-command" { template CheckCommand "snmp-manubulon-command" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
arguments = { arguments = {

View File

@ -18,8 +18,6 @@
******************************************************************************/ ******************************************************************************/
object CheckCommand "disk-windows" { object CheckCommand "disk-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_disk.exe" ] command = [ PluginDir + "/check_disk.exe" ]
arguments = { arguments = {
@ -51,8 +49,6 @@ object CheckCommand "disk-windows" {
} }
object CheckCommand "load-windows" { object CheckCommand "load-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_load.exe" ] command = [ PluginDir + "/check_load.exe" ]
arguments = { arguments = {
@ -68,8 +64,6 @@ object CheckCommand "load-windows" {
} }
object CheckCommand "memory-windows" { object CheckCommand "memory-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_memory.exe" ] command = [ PluginDir + "/check_memory.exe" ]
arguments = { arguments = {
@ -91,8 +85,6 @@ object CheckCommand "memory-windows" {
} }
object CheckCommand "network-windows" { object CheckCommand "network-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_network.exe" ] command = [ PluginDir + "/check_network.exe" ]
arguments = { arguments = {
@ -108,8 +100,6 @@ object CheckCommand "network-windows" {
} }
object CheckCommand "perfmon-windows" { object CheckCommand "perfmon-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_perfmon.exe" ] command = [ PluginDir + "/check_perfmon.exe" ]
arguments = { arguments = {
@ -143,8 +133,6 @@ object CheckCommand "perfmon-windows" {
template CheckCommand "ping-common-windows" { template CheckCommand "ping-common-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_ping.exe" ] command = [ PluginDir + "/check_ping.exe" ]
arguments = { arguments = {
@ -200,8 +188,6 @@ object CheckCommand "ping6-windows" {
} }
object CheckCommand "procs-windows" { object CheckCommand "procs-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_procs.exe" ] command = [ PluginDir + "/check_procs.exe" ]
arguments = { arguments = {
@ -221,8 +207,6 @@ object CheckCommand "procs-windows" {
} }
object CheckCommand "service-windows" { object CheckCommand "service-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_service.exe" ] command = [ PluginDir + "/check_service.exe" ]
arguments = { arguments = {
@ -239,8 +223,6 @@ object CheckCommand "service-windows" {
} }
object CheckCommand "swap-windows" { object CheckCommand "swap-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_swap.exe" ] command = [ PluginDir + "/check_swap.exe" ]
arguments = { arguments = {
@ -263,8 +245,6 @@ object CheckCommand "swap-windows" {
} }
object CheckCommand "update-windows" { object CheckCommand "update-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_update.exe" ] command = [ PluginDir + "/check_update.exe" ]
arguments = { arguments = {
@ -286,8 +266,6 @@ object CheckCommand "update-windows" {
} }
object CheckCommand "uptime-windows" { object CheckCommand "uptime-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_uptime.exe" ] command = [ PluginDir + "/check_uptime.exe" ]
arguments = { arguments = {
@ -310,8 +288,6 @@ object CheckCommand "uptime-windows" {
} }
object CheckCommand "users-windows" { object CheckCommand "users-windows" {
import "plugin-check-command"
command = [ PluginDir + "/check_users.exe" ] command = [ PluginDir + "/check_users.exe" ]
arguments = { arguments = {

View File

@ -34,8 +34,6 @@ template CheckCommand "ipv4-or-ipv6" {
} }
template CheckCommand "ping-common" { template CheckCommand "ping-common" {
import "plugin-check-command"
command = [ PluginDir + "/check_ping" ] command = [ PluginDir + "/check_ping" ]
arguments = { arguments = {
@ -99,8 +97,6 @@ object CheckCommand "hostalive6" {
} }
template CheckCommand "fping-common" { template CheckCommand "fping-common" {
import "plugin-check-command"
command = [ command = [
PluginDir + "/check_fping", PluginDir + "/check_fping",
"$fping_address$" "$fping_address$"
@ -142,8 +138,6 @@ object CheckCommand "fping6" {
} }
object CheckCommand "dummy" { object CheckCommand "dummy" {
import "plugin-check-command"
command = [ command = [
PluginDir + "/check_dummy", PluginDir + "/check_dummy",
"$dummy_state$", "$dummy_state$",
@ -162,7 +156,6 @@ object CheckCommand "passive" {
} }
object CheckCommand "tcp" { object CheckCommand "tcp" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_tcp" ] command = [ PluginDir + "/check_tcp" ]
@ -266,7 +259,6 @@ object CheckCommand "tcp" {
} }
object CheckCommand "ssl" { object CheckCommand "ssl" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_tcp" ] command = [ PluginDir + "/check_tcp" ]
@ -283,7 +275,6 @@ object CheckCommand "ssl" {
} }
object CheckCommand "udp" { object CheckCommand "udp" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ command = [
@ -318,7 +309,6 @@ object CheckCommand "udp" {
} }
object CheckCommand "http" { object CheckCommand "http" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_http" ] command = [ PluginDir + "/check_http" ]
@ -477,7 +467,6 @@ object CheckCommand "http" {
} }
object CheckCommand "ftp" { object CheckCommand "ftp" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_ftp" ] command = [ PluginDir + "/check_ftp" ]
@ -581,7 +570,6 @@ object CheckCommand "ftp" {
} }
object CheckCommand "smtp" { object CheckCommand "smtp" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_smtp" ] command = [ PluginDir + "/check_smtp" ]
@ -622,7 +610,6 @@ object CheckCommand "smtp" {
} }
object CheckCommand "ssmtp" { object CheckCommand "ssmtp" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_ssmtp" ] command = [ PluginDir + "/check_ssmtp" ]
@ -670,7 +657,6 @@ object CheckCommand "ssmtp" {
} }
object CheckCommand "imap" { object CheckCommand "imap" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_imap" ] command = [ PluginDir + "/check_imap" ]
@ -718,7 +704,6 @@ object CheckCommand "imap" {
} }
object CheckCommand "simap" { object CheckCommand "simap" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_simap" ] command = [ PluginDir + "/check_simap" ]
@ -766,7 +751,6 @@ object CheckCommand "simap" {
} }
object CheckCommand "pop" { object CheckCommand "pop" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_pop" ] command = [ PluginDir + "/check_pop" ]
@ -814,7 +798,6 @@ object CheckCommand "pop" {
} }
object CheckCommand "spop" { object CheckCommand "spop" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_spop" ] command = [ PluginDir + "/check_spop" ]
@ -862,7 +845,6 @@ object CheckCommand "spop" {
} }
object CheckCommand "ntp_time" { object CheckCommand "ntp_time" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_ntp_time" ] command = [ PluginDir + "/check_ntp_time" ]
@ -894,7 +876,6 @@ object CheckCommand "ntp_time" {
} }
object CheckCommand "ntp_peer" { object CheckCommand "ntp_peer" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_ntp_peer" ] command = [ PluginDir + "/check_ntp_peer" ]
@ -927,7 +908,6 @@ object CheckCommand "ntp_peer" {
} }
object CheckCommand "ssh" { object CheckCommand "ssh" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_ssh" ] command = [ PluginDir + "/check_ssh" ]
@ -956,8 +936,6 @@ object CheckCommand "ssh" {
} }
object CheckCommand "disk" { object CheckCommand "disk" {
import "plugin-check-command"
command = [ PluginDir + "/check_disk" ] command = [ PluginDir + "/check_disk" ]
arguments = { arguments = {
@ -1115,8 +1093,6 @@ object CheckCommand "disk" {
} }
object CheckCommand "disk_smb" { object CheckCommand "disk_smb" {
import "plugin-check-command"
command = [ PluginDir + "/check_disk_smb" ] command = [ PluginDir + "/check_disk_smb" ]
arguments = { arguments = {
@ -1163,8 +1139,6 @@ object CheckCommand "disk_smb" {
} }
object CheckCommand "users" { object CheckCommand "users" {
import "plugin-check-command"
command = [ PluginDir + "/check_users" ] command = [ PluginDir + "/check_users" ]
arguments = { arguments = {
@ -1177,8 +1151,6 @@ object CheckCommand "users" {
} }
object CheckCommand "procs" { object CheckCommand "procs" {
import "plugin-check-command"
command = [ PluginDir + "/check_procs" ] command = [ PluginDir + "/check_procs" ]
arguments = { arguments = {
@ -1251,8 +1223,6 @@ object CheckCommand "procs" {
} }
object CheckCommand "swap" { object CheckCommand "swap" {
import "plugin-check-command"
command = [ PluginDir + "/check_swap" ] command = [ PluginDir + "/check_swap" ]
arguments = { arguments = {
@ -1287,8 +1257,6 @@ object CheckCommand "swap" {
} }
object CheckCommand "load" { object CheckCommand "load" {
import "plugin-check-command"
command = [ PluginDir + "/check_load" ] command = [ PluginDir + "/check_load" ]
arguments = { arguments = {
@ -1318,8 +1286,6 @@ object CheckCommand "load" {
} }
object CheckCommand "snmp" { object CheckCommand "snmp" {
import "plugin-check-command"
command = [ PluginDir + "/check_snmp" ] command = [ PluginDir + "/check_snmp" ]
arguments = { arguments = {
@ -1370,7 +1336,6 @@ object CheckCommand "snmp" {
} }
object CheckCommand "snmpv3" { object CheckCommand "snmpv3" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_snmp" ] command = [ PluginDir + "/check_snmp" ]
@ -1467,8 +1432,6 @@ object CheckCommand "snmp-uptime" {
} }
object CheckCommand "apt" { object CheckCommand "apt" {
import "plugin-check-command"
command = [ PluginDir + "/check_apt" ] command = [ PluginDir + "/check_apt" ]
arguments = { arguments = {
@ -1506,8 +1469,6 @@ object CheckCommand "apt" {
} }
object CheckCommand "dhcp" { object CheckCommand "dhcp" {
import "plugin-check-command"
command = [ PluginDir + "/check_dhcp" ] command = [ PluginDir + "/check_dhcp" ]
arguments = { arguments = {
@ -1525,7 +1486,6 @@ object CheckCommand "dhcp" {
} }
object CheckCommand "dns" { object CheckCommand "dns" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_dns" ] command = [ PluginDir + "/check_dns" ]
@ -1570,7 +1530,6 @@ object CheckCommand "dns" {
} }
object CheckCommand "dig" { object CheckCommand "dig" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_dig" ] command = [ PluginDir + "/check_dig" ]
@ -1605,7 +1564,6 @@ object CheckCommand "dig" {
} }
object CheckCommand "nscp" { object CheckCommand "nscp" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_nt" ] command = [ PluginDir + "/check_nt" ]
@ -1638,7 +1596,6 @@ object CheckCommand "nscp" {
} }
object CheckCommand "by_ssh" { object CheckCommand "by_ssh" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_by_ssh" ] command = [ PluginDir + "/check_by_ssh" ]
@ -1689,7 +1646,6 @@ object CheckCommand "by_ssh" {
} }
object CheckCommand "ups" { object CheckCommand "ups" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_ups" ] command = [ PluginDir + "/check_ups" ]
@ -1736,7 +1692,6 @@ object CheckCommand "ups" {
} }
object CheckCommand "nrpe" { object CheckCommand "nrpe" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_nrpe" ] command = [ PluginDir + "/check_nrpe" ]
@ -1779,7 +1734,6 @@ object CheckCommand "nrpe" {
} }
object CheckCommand "hpjd" { object CheckCommand "hpjd" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_hpjd" ] command = [ PluginDir + "/check_hpjd" ]
@ -1794,8 +1748,6 @@ object CheckCommand "hpjd" {
} }
object CheckCommand "icmp" { object CheckCommand "icmp" {
import "plugin-check-command"
command = [ PluginDir + "/check_icmp" ] command = [ PluginDir + "/check_icmp" ]
arguments = { arguments = {
@ -1823,7 +1775,6 @@ object CheckCommand "icmp" {
} }
object CheckCommand "ldap" { object CheckCommand "ldap" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_ldap" ] command = [ PluginDir + "/check_ldap" ]
@ -1896,8 +1847,6 @@ object CheckCommand "ldap" {
} }
object CheckCommand "clamd" { object CheckCommand "clamd" {
import "plugin-check-command"
command = [ PluginDir + "/check_clamd" ] command = [ PluginDir + "/check_clamd" ]
arguments = { arguments = {
@ -2000,8 +1949,6 @@ object CheckCommand "clamd" {
} }
object CheckCommand "mailq" { object CheckCommand "mailq" {
import "plugin-check-command"
command = [ PluginDir + "/check_mailq" ] command = [ PluginDir + "/check_mailq" ]
arguments = { arguments = {
@ -2035,7 +1982,6 @@ object CheckCommand "mailq" {
} }
object CheckCommand "pgsql" { object CheckCommand "pgsql" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_pgsql" ] command = [ PluginDir + "/check_pgsql" ]
@ -2059,7 +2005,6 @@ object CheckCommand "pgsql" {
} }
object CheckCommand "mysql" { object CheckCommand "mysql" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_mysql" ] command = [ PluginDir + "/check_mysql" ]
@ -2095,8 +2040,6 @@ object CheckCommand "mysql" {
} }
object CheckCommand "negate" { object CheckCommand "negate" {
import "plugin-check-command"
command = [ PluginDir + "/negate" ] command = [ PluginDir + "/negate" ]
arguments = { arguments = {
@ -2132,8 +2075,6 @@ object CheckCommand "negate" {
} }
object CheckCommand "file_age" { object CheckCommand "file_age" {
import "plugin-check-command"
command = [ PluginDir + "/check_file_age" ] command = [ PluginDir + "/check_file_age" ]
arguments = { arguments = {
@ -2167,8 +2108,6 @@ object CheckCommand "file_age" {
} }
object CheckCommand "smart" { object CheckCommand "smart" {
import "plugin-check-command"
command = [ PluginDir + "/check_ide_smart" ] command = [ PluginDir + "/check_ide_smart" ]
arguments = { arguments = {
@ -2181,7 +2120,6 @@ object CheckCommand "smart" {
} }
object CheckCommand "breeze" { object CheckCommand "breeze" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_breeze" ] command = [ PluginDir + "/check_breeze" ]
@ -2214,8 +2152,6 @@ object CheckCommand "breeze" {
} }
object CheckCommand "flexlm" { object CheckCommand "flexlm" {
import "plugin-check-command"
command = [ PluginDir + "/check_flexlm" ] command = [ PluginDir + "/check_flexlm" ]
arguments = { arguments = {
@ -2232,7 +2168,6 @@ object CheckCommand "flexlm" {
} }
object CheckCommand "game" { object CheckCommand "game" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_game" ] command = [ PluginDir + "/check_game" ]
@ -2282,7 +2217,6 @@ object CheckCommand "game" {
} }
object CheckCommand "mysql_query" { object CheckCommand "mysql_query" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginDir + "/check_mysql_query" ] command = [ PluginDir + "/check_mysql_query" ]

View File

@ -18,8 +18,6 @@
******************************************************************************/ ******************************************************************************/
object CheckCommand "mssql_health" { object CheckCommand "mssql_health" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_mssql_health" ] command = [ PluginContribDir + "/check_mssql_health" ]
arguments = { arguments = {
@ -95,7 +93,6 @@ object CheckCommand "mssql_health" {
} }
object CheckCommand "mysql_health" { object CheckCommand "mysql_health" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginContribDir + "/check_mysql_health" ] command = [ PluginContribDir + "/check_mysql_health" ]
@ -247,8 +244,6 @@ object CheckCommand "mysql_health" {
} }
object CheckCommand "db2_health" { object CheckCommand "db2_health" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_db2_health" ] command = [ PluginContribDir + "/check_db2_health" ]
arguments = { arguments = {
@ -338,8 +333,6 @@ object CheckCommand "db2_health" {
} }
object CheckCommand "oracle_health" { object CheckCommand "oracle_health" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_oracle_health" ] command = [ PluginContribDir + "/check_oracle_health" ]
arguments = { arguments = {
@ -416,7 +409,6 @@ object CheckCommand "oracle_health" {
} }
object CheckCommand "postgres" { object CheckCommand "postgres" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginContribDir + "/check_postgres.pl" ] command = [ PluginContribDir + "/check_postgres.pl" ]
@ -504,8 +496,6 @@ object CheckCommand "postgres" {
} }
object CheckCommand "mongodb" { object CheckCommand "mongodb" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_mongodb.py" ] command = [ PluginContribDir + "/check_mongodb.py" ]
arguments = { arguments = {
@ -585,8 +575,6 @@ object CheckCommand "mongodb" {
} }
object CheckCommand "elasticsearch" { object CheckCommand "elasticsearch" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_elasticsearch" ] command = [ PluginContribDir + "/check_elasticsearch" ]
arguments = { arguments = {
@ -621,8 +609,6 @@ object CheckCommand "elasticsearch" {
} }
object CheckCommand "redis" { object CheckCommand "redis" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_redis.pl" ] command = [ PluginContribDir + "/check_redis.pl" ]
arguments = { arguments = {

View File

@ -18,7 +18,6 @@
******************************************************************************/ ******************************************************************************/
object CheckCommand "hpasm" { object CheckCommand "hpasm" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginContribDir + "/check_hpasm" ] command = [ PluginContribDir + "/check_hpasm" ]

View File

@ -18,8 +18,6 @@
******************************************************************************/ ******************************************************************************/
template CheckCommand "icingacli" { template CheckCommand "icingacli" {
import "plugin-check-command"
command = [ PrefixDir + "/bin/icingacli" ] command = [ PrefixDir + "/bin/icingacli" ]
} }

View File

@ -18,7 +18,6 @@
******************************************************************************/ ******************************************************************************/
object CheckCommand "ipmi-sensor" { object CheckCommand "ipmi-sensor" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginContribDir + "/check_ipmi_sensor" ] command = [ PluginContribDir + "/check_ipmi_sensor" ]

View File

@ -18,8 +18,6 @@
******************************************************************************/ ******************************************************************************/
object CheckCommand "graphite" { object CheckCommand "graphite" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_graphite" ] command = [ PluginContribDir + "/check_graphite" ]
arguments = { arguments = {

View File

@ -18,8 +18,6 @@
******************************************************************************/ ******************************************************************************/
object CheckCommand "interfacetable" { object CheckCommand "interfacetable" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_interface_table_v3t" ] command = [ PluginContribDir + "/check_interface_table_v3t" ]
arguments = { arguments = {
@ -302,7 +300,6 @@ object CheckCommand "interfacetable" {
} }
object CheckCommand "iftraffic" { object CheckCommand "iftraffic" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginContribDir + "/check_iftraffic.pl"] command = [ PluginContribDir + "/check_iftraffic.pl"]
@ -351,7 +348,6 @@ object CheckCommand "iftraffic" {
} }
object CheckCommand "iftraffic64" { object CheckCommand "iftraffic64" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginContribDir + "/check_iftraffic64.pl"] command = [ PluginContribDir + "/check_iftraffic64.pl"]
@ -400,7 +396,6 @@ object CheckCommand "iftraffic64" {
} }
object CheckCommand "interfaces" { object CheckCommand "interfaces" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginContribDir + "/check_interfaces" ] command = [ PluginContribDir + "/check_interfaces" ]
@ -503,7 +498,6 @@ object CheckCommand "interfaces" {
} }
object CheckCommand "nwc_health" { object CheckCommand "nwc_health" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginContribDir + "/check_nwc_health" ] command = [ PluginContribDir + "/check_nwc_health" ]

View File

@ -18,7 +18,6 @@
******************************************************************************/ ******************************************************************************/
object CheckCommand "kdc" { object CheckCommand "kdc" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginContribDir + "/check_kdc" ] command = [ PluginContribDir + "/check_kdc" ]
@ -48,7 +47,6 @@ object CheckCommand "kdc" {
} }
object CheckCommand "rbl" { object CheckCommand "rbl" {
import "plugin-check-command"
import "ipv4-or-ipv6" import "ipv4-or-ipv6"
command = [ PluginContribDir + "/check_rbl" ] command = [ PluginContribDir + "/check_rbl" ]

View File

@ -18,8 +18,6 @@
******************************************************************************/ ******************************************************************************/
object CheckCommand "mem" { object CheckCommand "mem" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_mem.pl" ] command = [ PluginContribDir + "/check_mem.pl" ]
arguments = { arguments = {
@ -51,8 +49,6 @@ object CheckCommand "mem" {
} }
object CheckCommand "running_kernel" { object CheckCommand "running_kernel" {
import "plugin-check-command"
command = {{ command = {{
var use_sudo = macro("$running_kernel_use_sudo$") var use_sudo = macro("$running_kernel_use_sudo$")
@ -75,8 +71,6 @@ object CheckCommand "running_kernel" {
} }
object CheckCommand "yum" { object CheckCommand "yum" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_yum" ] command = [ PluginContribDir + "/check_yum" ]
arguments = { arguments = {
@ -128,8 +122,6 @@ object CheckCommand "yum" {
} }
object CheckCommand "iostat" { object CheckCommand "iostat" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_iostat" ] command = [ PluginContribDir + "/check_iostat" ]
arguments = { arguments = {

View File

@ -18,8 +18,6 @@
******************************************************************************/ ******************************************************************************/
object CheckCommand "esxi_hardware" { object CheckCommand "esxi_hardware" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_esxi_hardware.py" ] command = [ PluginContribDir + "/check_esxi_hardware.py" ]
arguments = { arguments = {

View File

@ -22,8 +22,6 @@
*/ */
template CheckCommand "vmware-esx-command" { template CheckCommand "vmware-esx-command" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_vmware_esx" ] command = [ PluginContribDir + "/check_vmware_esx" ]
arguments = { arguments = {

View File

@ -18,8 +18,6 @@
******************************************************************************/ ******************************************************************************/
object CheckCommand "webinject" { object CheckCommand "webinject" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_webinject" ] command = [ PluginContribDir + "/check_webinject" ]
arguments = { arguments = {
@ -63,8 +61,6 @@ object CheckCommand "webinject" {
} }
object CheckCommand "jmx4perl" { object CheckCommand "jmx4perl" {
import "plugin-check-command"
command = [ PluginContribDir + "/check_jmx4perl" ] command = [ PluginContribDir + "/check_jmx4perl" ]
arguments = { arguments = {

View File

@ -243,6 +243,7 @@ const std::vector<String>& ConfigWriter::GetKeywords(void)
keywords.push_back("locals"); keywords.push_back("locals");
keywords.push_back("use"); keywords.push_back("use");
keywords.push_back("__using"); keywords.push_back("__using");
keywords.push_back("default");
keywords.push_back("ignore_on_error"); keywords.push_back("ignore_on_error");
keywords.push_back("current_filename"); keywords.push_back("current_filename");
keywords.push_back("current_line"); keywords.push_back("current_line");

View File

@ -182,6 +182,7 @@ locals return T_LOCALS;
use return T_USE; use return T_USE;
__using return T_USING; __using return T_USING;
apply return T_APPLY; apply return T_APPLY;
default return T_DEFAULT;
to return T_TO; to return T_TO;
where return T_WHERE; where return T_WHERE;
import return T_IMPORT; import return T_IMPORT;

View File

@ -144,6 +144,7 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
%token T_GLOBALS "globals (T_GLOBALS)" %token T_GLOBALS "globals (T_GLOBALS)"
%token T_LOCALS "locals (T_LOCALS)" %token T_LOCALS "locals (T_LOCALS)"
%token T_CONST "const (T_CONST)" %token T_CONST "const (T_CONST)"
%token T_DEFAULT "default (T_DEFAULT)"
%token T_IGNORE_ON_ERROR "ignore_on_error (T_IGNORE_ON_ERROR)" %token T_IGNORE_ON_ERROR "ignore_on_error (T_IGNORE_ON_ERROR)"
%token T_CURRENT_FILENAME "current_filename (T_CURRENT_FILENAME)" %token T_CURRENT_FILENAME "current_filename (T_CURRENT_FILENAME)"
%token T_CURRENT_LINE "current_line (T_CURRENT_LINE)" %token T_CURRENT_LINE "current_line (T_CURRENT_LINE)"
@ -199,6 +200,7 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
%type <expr> apply %type <expr> apply
%type <expr> optional_rterm %type <expr> optional_rterm
%type <text> target_type_specifier %type <text> target_type_specifier
%type <boolean> default_specifier
%type <boolean> ignore_specifier %type <boolean> ignore_specifier
%type <cvlist> use_specifier %type <cvlist> use_specifier
%type <cvlist> use_specifier_items %type <cvlist> use_specifier_items
@ -370,7 +372,7 @@ object:
context->m_Assign.push(0); context->m_Assign.push(0);
context->m_Ignore.push(0); context->m_Ignore.push(0);
} }
object_declaration identifier optional_rterm use_specifier ignore_specifier object_declaration identifier optional_rterm use_specifier default_specifier ignore_specifier
{ {
BeginFlowControlBlock(context, FlowControlReturn, false); BeginFlowControlBlock(context, FlowControlReturn, false);
} }
@ -381,6 +383,10 @@ object:
context->m_ObjectAssign.pop(); context->m_ObjectAssign.pop();
bool abstract = $2; bool abstract = $2;
bool defaultTmpl = $6;
if (!abstract && defaultTmpl)
BOOST_THROW_EXCEPTION(ScriptError("'default' keyword is invalid for object definitions", DebugInfoRange(@2, @4)));
String type = *$3; String type = *$3;
delete $3; delete $3;
@ -416,7 +422,7 @@ object:
BOOST_THROW_EXCEPTION(ScriptError("object rule 'ignore' is missing 'assign' for type '" + type + "'", DebugInfoRange(@2, @4))); BOOST_THROW_EXCEPTION(ScriptError("object rule 'ignore' is missing 'assign' for type '" + type + "'", DebugInfoRange(@2, @4)));
} }
$$ = new ObjectExpression(abstract, type, $4, filter, context->GetZone(), context->GetPackage(), $5, $6, $8, DebugInfoRange(@2, @6)); $$ = new ObjectExpression(abstract, type, $4, filter, context->GetZone(), context->GetPackage(), $5, $6, $7, $9, DebugInfoRange(@2, @7));
} }
; ;
@ -1044,6 +1050,16 @@ target_type_specifier: /* empty */
} }
; ;
default_specifier: /* empty */
{
$$ = false;
}
| T_DEFAULT
{
$$ = true;
}
;
ignore_specifier: /* empty */ ignore_specifier: /* empty */
{ {
$$ = false; $$ = false;

View File

@ -59,11 +59,12 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, run_with_activation_context, &ConfigItem::R
*/ */
ConfigItem::ConfigItem(const String& type, const String& name, ConfigItem::ConfigItem(const String& type, const String& name,
bool abstract, const boost::shared_ptr<Expression>& exprl, bool abstract, const boost::shared_ptr<Expression>& exprl,
const boost::shared_ptr<Expression>& filter, bool ignoreOnError, const boost::shared_ptr<Expression>& filter, bool defaultTmpl, bool ignoreOnError,
const DebugInfo& debuginfo, const Dictionary::Ptr& scope, const DebugInfo& debuginfo, const Dictionary::Ptr& scope,
const String& zone, const String& package) const String& zone, const String& package)
: m_Type(type), m_Name(name), m_Abstract(abstract), : m_Type(type), m_Name(name), m_Abstract(abstract),
m_Expression(exprl), m_Filter(filter), m_IgnoreOnError(ignoreOnError), m_Expression(exprl), m_Filter(filter),
m_DefaultTmpl(defaultTmpl), m_IgnoreOnError(ignoreOnError),
m_DebugInfo(debuginfo), m_Scope(scope), m_Zone(zone), m_DebugInfo(debuginfo), m_Scope(scope), m_Zone(zone),
m_Package(package) m_Package(package)
{ {
@ -99,6 +100,16 @@ bool ConfigItem::IsAbstract(void) const
return m_Abstract; return m_Abstract;
} }
bool ConfigItem::IsDefaultTemplate(void) const
{
return m_DefaultTmpl;
}
bool ConfigItem::IsIgnoreOnError(void) const
{
return m_IgnoreOnError;
}
/** /**
* Retrieves the debug information for the configuration item. * Retrieves the debug information for the configuration item.
* *
@ -649,6 +660,26 @@ std::vector<ConfigItem::Ptr> ConfigItem::GetItems(const String& type)
return items; return items;
} }
std::vector<ConfigItem::Ptr> ConfigItem::GetDefaultTemplates(const String& type)
{
std::vector<ConfigItem::Ptr> items;
boost::mutex::scoped_lock lock(m_Mutex);
auto it = m_Items.find(type);
if (it == m_Items.end())
return items;
for (const ItemMap::value_type& kv : it->second)
{
if (kv.second->IsDefaultTemplate())
items.push_back(kv.second);
}
return items;
}
void ConfigItem::RemoveIgnoredItems(const String& allowedConfigPath) void ConfigItem::RemoveIgnoredItems(const String& allowedConfigPath)
{ {
boost::mutex::scoped_lock lock(m_Mutex); boost::mutex::scoped_lock lock(m_Mutex);

View File

@ -43,14 +43,15 @@ public:
ConfigItem(const String& type, const String& name, bool abstract, ConfigItem(const String& type, const String& name, bool abstract,
const boost::shared_ptr<Expression>& exprl, const boost::shared_ptr<Expression>& exprl,
const boost::shared_ptr<Expression>& filter, const boost::shared_ptr<Expression>& filter,
bool ignoreOnError, const DebugInfo& debuginfo, bool defaultTmpl, bool ignoreOnError, const DebugInfo& debuginfo,
const Dictionary::Ptr& scope, const String& zone, const Dictionary::Ptr& scope, const String& zone,
const String& package); const String& package);
String GetType(void) const; String GetType(void) const;
String GetName(void) const; String GetName(void) const;
bool IsAbstract(void) const; bool IsAbstract(void) const;
bool GetIgnoreOnError(void) const; bool IsDefaultTemplate(void) const;
bool IsIgnoreOnError(void) const;
std::vector<ConfigItem::Ptr> GetParents(void) const; std::vector<ConfigItem::Ptr> GetParents(void) const;
@ -74,6 +75,7 @@ public:
static bool RunWithActivationContext(const Function::Ptr& function); static bool RunWithActivationContext(const Function::Ptr& function);
static std::vector<ConfigItem::Ptr> GetItems(const String& type); static std::vector<ConfigItem::Ptr> GetItems(const String& type);
static std::vector<ConfigItem::Ptr> GetDefaultTemplates(const String& type);
static void RemoveIgnoredItems(const String& allowedConfigPath); static void RemoveIgnoredItems(const String& allowedConfigPath);
@ -84,6 +86,7 @@ private:
boost::shared_ptr<Expression> m_Expression; boost::shared_ptr<Expression> m_Expression;
boost::shared_ptr<Expression> m_Filter; boost::shared_ptr<Expression> m_Filter;
bool m_DefaultTmpl;
bool m_IgnoreOnError; bool m_IgnoreOnError;
DebugInfo m_DebugInfo; /**< Debug information. */ DebugInfo m_DebugInfo; /**< Debug information. */
Dictionary::Ptr m_Scope; /**< variable scope. */ Dictionary::Ptr m_Scope; /**< variable scope. */

View File

@ -79,6 +79,11 @@ void ConfigItemBuilder::SetFilter(const boost::shared_ptr<Expression>& filter)
m_Filter = filter; m_Filter = filter;
} }
void ConfigItemBuilder::SetDefaultTemplate(bool defaultTmpl)
{
m_DefaultTmpl = defaultTmpl;
}
void ConfigItemBuilder::SetIgnoreOnError(bool ignoreOnError) void ConfigItemBuilder::SetIgnoreOnError(bool ignoreOnError)
{ {
m_IgnoreOnError = ignoreOnError; m_IgnoreOnError = ignoreOnError;
@ -119,10 +124,25 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
dexpr->MakeInline(); dexpr->MakeInline();
exprs.push_back(dexpr); exprs.push_back(dexpr);
#ifdef I2_DEBUG
if (!m_Abstract) {
bool foundDefaultImport = false;
for (Expression *expr : m_Expressions) {
if (dynamic_cast<ImportDefaultTemplatesExpression *>(expr)) {
foundDefaultImport = true;
break;
}
}
ASSERT(foundDefaultImport);
}
#endif /* I2_DEBUG */
boost::shared_ptr<DictExpression> exprl = boost::make_shared<DictExpression>(exprs, m_DebugInfo); boost::shared_ptr<DictExpression> exprl = boost::make_shared<DictExpression>(exprs, m_DebugInfo);
exprl->MakeInline(); exprl->MakeInline();
return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter, return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter,
m_IgnoreOnError, m_DebugInfo, m_Scope, m_Zone, m_Package); m_DefaultTmpl, m_IgnoreOnError, m_DebugInfo, m_Scope, m_Zone, m_Package);
} }

View File

@ -48,6 +48,7 @@ public:
void SetScope(const Dictionary::Ptr& scope); void SetScope(const Dictionary::Ptr& scope);
void SetZone(const String& zone); void SetZone(const String& zone);
void SetPackage(const String& package); void SetPackage(const String& package);
void SetDefaultTemplate(bool defaultTmpl);
void SetIgnoreOnError(bool ignoreOnError); void SetIgnoreOnError(bool ignoreOnError);
void AddExpression(Expression *expr); void AddExpression(Expression *expr);
@ -65,6 +66,7 @@ private:
Dictionary::Ptr m_Scope; /**< variable scope. */ Dictionary::Ptr m_Scope; /**< variable scope. */
String m_Zone; /**< The zone. */ String m_Zone; /**< The zone. */
String m_Package; /**< The package name. */ String m_Package; /**< The package name. */
bool m_DefaultTmpl;
bool m_IgnoreOnError; /**< Whether the object should be ignored when an error occurs in one of the expressions. */ bool m_IgnoreOnError; /**< Whether the object should be ignored when an error occurs in one of the expressions. */
}; };

View File

@ -761,6 +761,26 @@ ExpressionResult ImportExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhi
return Empty; return Empty;
} }
ExpressionResult ImportDefaultTemplatesExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{
if (frame.Sandboxed)
BOOST_THROW_EXCEPTION(ScriptError("Imports are not allowed in sandbox mode.", m_DebugInfo));
String type = VMOps::GetField(frame.Self, "type", frame.Sandboxed, m_DebugInfo);
for (const ConfigItem::Ptr& item : ConfigItem::GetDefaultTemplates(type)) {
Dictionary::Ptr scope = item->GetScope();
if (scope)
scope->CopyTo(frame.Locals);
ExpressionResult result = item->GetExpression()->Evaluate(frame, dhint);
CHECK_RESULT(result);
}
return Empty;
}
ExpressionResult FunctionExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const ExpressionResult FunctionExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const
{ {
return VMOps::NewFunction(frame, m_Name, m_Args, m_ClosedVars, m_Expression); return VMOps::NewFunction(frame, m_Name, m_Args, m_ClosedVars, m_Expression);
@ -793,7 +813,7 @@ ExpressionResult ObjectExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhi
} }
return VMOps::NewObject(frame, m_Abstract, m_Type, name, m_Filter, m_Zone, return VMOps::NewObject(frame, m_Abstract, m_Type, name, m_Filter, m_Zone,
m_Package, m_IgnoreOnError, m_ClosedVars, m_Expression, m_DebugInfo); m_Package, m_DefaultTmpl, m_IgnoreOnError, m_ClosedVars, m_Expression, m_DebugInfo);
} }
ExpressionResult ForExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const ExpressionResult ForExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const

View File

@ -800,6 +800,17 @@ private:
Expression *m_Name; Expression *m_Name;
}; };
class I2_CONFIG_API ImportDefaultTemplatesExpression : public DebuggableExpression
{
public:
ImportDefaultTemplatesExpression(const DebugInfo& debugInfo = DebugInfo())
: DebuggableExpression(debugInfo)
{ }
protected:
virtual ExpressionResult DoEvaluate(ScriptFrame& frame, DebugHint *dhint) const override;
};
class I2_CONFIG_API FunctionExpression : public DebuggableExpression class I2_CONFIG_API FunctionExpression : public DebuggableExpression
{ {
public: public:
@ -879,9 +890,9 @@ class I2_CONFIG_API ObjectExpression : public DebuggableExpression
public: public:
ObjectExpression(bool abstract, const String& type, Expression *name, Expression *filter, ObjectExpression(bool abstract, const String& type, Expression *name, Expression *filter,
const String& zone, const String& package, std::map<String, Expression *> *closedVars, const String& zone, const String& package, std::map<String, Expression *> *closedVars,
bool ignoreOnError, Expression *expression, const DebugInfo& debugInfo = DebugInfo()) bool defaultTmpl, bool ignoreOnError, Expression *expression, const DebugInfo& debugInfo = DebugInfo())
: DebuggableExpression(debugInfo), m_Abstract(abstract), m_Type(type), : DebuggableExpression(debugInfo), m_Abstract(abstract), m_Type(type),
m_Name(name), m_Filter(filter), m_Zone(zone), m_Package(package), m_Name(name), m_Filter(filter), m_Zone(zone), m_Package(package), m_DefaultTmpl(defaultTmpl),
m_IgnoreOnError(ignoreOnError), m_ClosedVars(closedVars), m_Expression(expression) m_IgnoreOnError(ignoreOnError), m_ClosedVars(closedVars), m_Expression(expression)
{ } { }
@ -909,6 +920,7 @@ private:
boost::shared_ptr<Expression> m_Filter; boost::shared_ptr<Expression> m_Filter;
String m_Zone; String m_Zone;
String m_Package; String m_Package;
bool m_DefaultTmpl;
bool m_IgnoreOnError; bool m_IgnoreOnError;
std::map<String, Expression *> *m_ClosedVars; std::map<String, Expression *> *m_ClosedVars;
boost::shared_ptr<Expression> m_Expression; boost::shared_ptr<Expression> m_Expression;

View File

@ -129,7 +129,7 @@ public:
} }
static inline Value NewObject(ScriptFrame& frame, bool abstract, const String& type, const String& name, const boost::shared_ptr<Expression>& filter, static inline Value NewObject(ScriptFrame& frame, bool abstract, const String& type, const String& name, const boost::shared_ptr<Expression>& filter,
const String& zone, const String& package, bool ignoreOnError, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo()) const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
{ {
ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo); ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo);
@ -157,12 +157,16 @@ public:
item->SetType(type); item->SetType(type);
item->SetName(name); item->SetName(name);
if (!abstract)
item->AddExpression(new ImportDefaultTemplatesExpression());
item->AddExpression(new OwnedExpression(expression)); item->AddExpression(new OwnedExpression(expression));
item->SetAbstract(abstract); item->SetAbstract(abstract);
item->SetScope(EvaluateClosedVars(frame, closedVars)); item->SetScope(EvaluateClosedVars(frame, closedVars));
item->SetZone(zone); item->SetZone(zone);
item->SetPackage(package); item->SetPackage(package);
item->SetFilter(filter); item->SetFilter(filter);
item->SetDefaultTemplate(defaultTmpl);
item->SetIgnoreOnError(ignoreOnError); item->SetIgnoreOnError(ignoreOnError);
item->Compile()->Register(); item->Compile()->Register();

View File

@ -71,7 +71,9 @@ bool Dependency::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, cons
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di)); builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "zone"), OpSetLiteral, MakeLiteral(zone), di));
builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di)); builder->AddExpression(new SetExpression(MakeIndexer(ScopeThis, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
builder->AddExpression(new ImportDefaultTemplatesExpression());
builder->AddExpression(new OwnedExpression(rule.GetExpression())); builder->AddExpression(new OwnedExpression(rule.GetExpression()));
ConfigItem::Ptr dependencyItem = builder->Compile(); ConfigItem::Ptr dependencyItem = builder->Compile();

View File

@ -20,7 +20,7 @@
System.assert(Internal.run_with_activation_context(function() { System.assert(Internal.run_with_activation_context(function() {
var _Internal = Internal.clone() var _Internal = Internal.clone()
template TimePeriod "legacy-timeperiod" use (_Internal) { template TimePeriod "legacy-timeperiod" use (_Internal) default {
update = _Internal.LegacyTimePeriod update = _Internal.LegacyTimePeriod
} }
})) }))

View File

@ -73,6 +73,8 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co
builder->AddExpression(new OwnedExpression(rule.GetExpression())); builder->AddExpression(new OwnedExpression(rule.GetExpression()));
builder->AddExpression(new ImportDefaultTemplatesExpression());
ConfigItem::Ptr notificationItem = builder->Compile(); ConfigItem::Ptr notificationItem = builder->Compile();
notificationItem->Register(); notificationItem->Register();

View File

@ -72,6 +72,8 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl
builder->AddExpression(new OwnedExpression(rule.GetExpression())); builder->AddExpression(new OwnedExpression(rule.GetExpression()));
builder->AddExpression(new ImportDefaultTemplatesExpression());
ConfigItem::Ptr downtimeItem = builder->Compile(); ConfigItem::Ptr downtimeItem = builder->Compile();
downtimeItem->Register(); downtimeItem->Register();

View File

@ -66,6 +66,8 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam
builder->AddExpression(new OwnedExpression(rule.GetExpression())); builder->AddExpression(new OwnedExpression(rule.GetExpression()));
builder->AddExpression(new ImportDefaultTemplatesExpression());
ConfigItem::Ptr serviceItem = builder->Compile(); ConfigItem::Ptr serviceItem = builder->Compile();
serviceItem->Register(); serviceItem->Register();

View File

@ -32,7 +32,7 @@ System.assert(Internal.run_with_activation_context(function() {
execute = _Internal.ClusterZoneCheck execute = _Internal.ClusterZoneCheck
} }
template CheckCommand "plugin-check-command" use (_Internal) { template CheckCommand "plugin-check-command" use (_Internal) default {
execute = _Internal.PluginCheck execute = _Internal.PluginCheck
} }
@ -44,11 +44,11 @@ System.assert(Internal.run_with_activation_context(function() {
} }
} }
template NotificationCommand "plugin-notification-command" use (_Internal) { template NotificationCommand "plugin-notification-command" use (_Internal) default {
execute = _Internal.PluginNotification execute = _Internal.PluginNotification
} }
template EventCommand "plugin-event-command" use (_Internal) { template EventCommand "plugin-event-command" use (_Internal) default {
execute = _Internal.PluginEvent execute = _Internal.PluginEvent
} }