mirror of https://github.com/Icinga/icinga2.git
parent
0e8edfa2c7
commit
78cd56e277
|
@ -27,24 +27,32 @@ Command template for check plugins executed by Icinga 2.
|
|||
|
||||
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
|
||||
|
||||
Command template for notification scripts executed by Icinga 2.
|
||||
|
||||
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
|
||||
|
||||
Command template for event handler scripts executed by Icinga 2.
|
||||
|
||||
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
|
||||
|
||||
Timeperiod template for [Timeperiod objects](9-object-types.md#objecttype-timeperiod).
|
||||
|
||||
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
|
||||
|
||||
These check commands are embedded into Icinga 2 and do not require any external
|
||||
|
|
|
@ -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
|
||||
`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
|
||||
|
||||
Global constants can be set using the `const` keyword:
|
||||
|
|
|
@ -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!):
|
||||
|
||||
object CheckCommand "my-ping-check" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [
|
||||
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:
|
||||
|
||||
object CheckCommand "test_customvar" {
|
||||
import "plugin-check-command"
|
||||
command = "echo "Host CV: $host.vars.CVTEST$ Service CV: $service.vars.CVTEST$\n""
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
||||
object CheckCommand "random-value" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_dummy", "0", "$text$" ]
|
||||
|
||||
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:
|
||||
|
||||
object CheckCommand "my-ping" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_ping", "-H", "$ping_address$" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1238,9 +1234,6 @@ using the `check_command` attribute.
|
|||
|
||||
#### <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
|
||||
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.
|
||||
|
@ -1299,8 +1292,6 @@ can also be inherited from a parent template using additive inheritance (`+=`).
|
|||
# vim /etc/icinga2/conf.d/commands.conf
|
||||
|
||||
object CheckCommand "my-mysql" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_mysql" ] //constants.conf -> const PluginDir
|
||||
|
||||
arguments = {
|
||||
|
@ -1426,8 +1417,6 @@ at command execution. Or making arguments optional -- only set if the
|
|||
macro value can be resolved by Icinga 2.
|
||||
|
||||
object CheckCommand "check_http" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_http" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1490,8 +1479,6 @@ This is useful for example for hiding sensitive information on the command line
|
|||
when passing credentials to database checks:
|
||||
|
||||
object CheckCommand "mysql-health" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [
|
||||
PluginDir + "/check_mysql"
|
||||
]
|
||||
|
@ -1520,9 +1507,6 @@ interfaces (email, XMPP, IRC, Twitter, etc.).
|
|||
[NotificationCommand](9-object-types.md#objecttype-notificationcommand) objects are referenced by
|
||||
[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**
|
||||
>
|
||||
> 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.
|
||||
|
||||
object NotificationCommand "mail-service-notification" {
|
||||
import "plugin-notification-command"
|
||||
|
||||
command = [ SysconfDir + "/icinga2/scripts/mail-notification.sh" ]
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
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 */
|
||||
object EventCommand "event_by_ssh" {
|
||||
import "plugin-event-command"
|
||||
|
||||
command = [ PluginDir + "/check_by_ssh" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -58,7 +58,6 @@ into your host and service objects.
|
|||
|
||||
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
|
||||
must be an array in `[ ... ]` for shell escaping.
|
||||
* 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:
|
||||
|
||||
object CheckCommand "my-snmp-int" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ CustomPluginDir + "/check_snmp_int.pl" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -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
|
||||
|
||||
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
|
||||
|
||||
object CheckCommand "my-cmd" {
|
||||
import "plugin-check-command"
|
||||
|
||||
//...
|
||||
}
|
||||
|
||||
|
|
|
@ -211,8 +211,6 @@ match your Icinga convention.
|
|||
Add an `EventCommand` configuration object for the passive service auto reset event.
|
||||
|
||||
object EventCommand "coldstart-reset-event" {
|
||||
import "plugin-event-command"
|
||||
|
||||
command = [ SysconfDir + "/icinga2/conf.d/custom/scripts/coldstart_reset_event.sh" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -323,7 +323,6 @@ and evaluating the host custom attribute `compellent` containing the `disks` thi
|
|||
solved like this:
|
||||
|
||||
object CheckCommand "check_compellent" {
|
||||
import "plugin-check-command"
|
||||
command = [ "/usr/bin/check_compellent" ]
|
||||
arguments = {
|
||||
"--disks" = {
|
||||
|
@ -410,7 +409,6 @@ returned.
|
|||
You can omit the `log()` calls, they only help debugging.
|
||||
|
||||
object NotificationCommand "mail-host-notification-test" {
|
||||
import "plugin-notification-command"
|
||||
command = {{
|
||||
log("command as function")
|
||||
var mailscript = "mail-host-notification-long.sh"
|
||||
|
|
|
@ -84,8 +84,6 @@ defined here.
|
|||
Example:
|
||||
|
||||
object CheckCommand "check_http" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_http" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -122,7 +120,7 @@ Configuration Attributes:
|
|||
|
||||
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.
|
||||
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.
|
||||
|
@ -441,8 +439,6 @@ An event command definition.
|
|||
Example:
|
||||
|
||||
object EventCommand "restart-httpd-event" {
|
||||
import "plugin-event-command"
|
||||
|
||||
command = "/opt/bin/restart-httpd.sh"
|
||||
}
|
||||
|
||||
|
@ -451,7 +447,7 @@ Configuration Attributes:
|
|||
|
||||
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.
|
||||
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.
|
||||
|
@ -1087,8 +1083,6 @@ A notification command definition.
|
|||
Example:
|
||||
|
||||
object NotificationCommand "mail-service-notification" {
|
||||
import "plugin-notification-command"
|
||||
|
||||
command = [
|
||||
SysconfDir + "/icinga2/scripts/mail-notification.sh"
|
||||
]
|
||||
|
@ -1113,7 +1107,7 @@ Configuration Attributes:
|
|||
|
||||
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.
|
||||
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.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
/* Command objects */
|
||||
|
||||
object NotificationCommand "mail-host-notification" {
|
||||
import "plugin-notification-command"
|
||||
|
||||
command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ]
|
||||
|
||||
env = {
|
||||
|
@ -20,8 +18,6 @@ object NotificationCommand "mail-host-notification" {
|
|||
}
|
||||
|
||||
object NotificationCommand "mail-service-notification" {
|
||||
import "plugin-notification-command"
|
||||
|
||||
command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]
|
||||
|
||||
env = {
|
||||
|
|
|
@ -22,8 +22,6 @@ if (!globals.contains("NscpPath")) {
|
|||
}
|
||||
|
||||
object CheckCommand "nscp-local" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ NscpPath + "\\nscp.exe", "client" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
|
||||
template CheckCommand "snmp-manubulon-command" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
object CheckCommand "disk-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_disk.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -51,8 +49,6 @@ object CheckCommand "disk-windows" {
|
|||
}
|
||||
|
||||
object CheckCommand "load-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_load.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -68,8 +64,6 @@ object CheckCommand "load-windows" {
|
|||
}
|
||||
|
||||
object CheckCommand "memory-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_memory.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -91,8 +85,6 @@ object CheckCommand "memory-windows" {
|
|||
}
|
||||
|
||||
object CheckCommand "network-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_network.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -108,8 +100,6 @@ object CheckCommand "network-windows" {
|
|||
}
|
||||
|
||||
object CheckCommand "perfmon-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_perfmon.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -143,8 +133,6 @@ object CheckCommand "perfmon-windows" {
|
|||
|
||||
|
||||
template CheckCommand "ping-common-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_ping.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -200,8 +188,6 @@ object CheckCommand "ping6-windows" {
|
|||
}
|
||||
|
||||
object CheckCommand "procs-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_procs.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -221,8 +207,6 @@ object CheckCommand "procs-windows" {
|
|||
}
|
||||
|
||||
object CheckCommand "service-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_service.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -239,8 +223,6 @@ object CheckCommand "service-windows" {
|
|||
}
|
||||
|
||||
object CheckCommand "swap-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_swap.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -263,8 +245,6 @@ object CheckCommand "swap-windows" {
|
|||
}
|
||||
|
||||
object CheckCommand "update-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_update.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -286,8 +266,6 @@ object CheckCommand "update-windows" {
|
|||
}
|
||||
|
||||
object CheckCommand "uptime-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_uptime.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -310,8 +288,6 @@ object CheckCommand "uptime-windows" {
|
|||
}
|
||||
|
||||
object CheckCommand "users-windows" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_users.exe" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -34,8 +34,6 @@ template CheckCommand "ipv4-or-ipv6" {
|
|||
}
|
||||
|
||||
template CheckCommand "ping-common" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_ping" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -99,8 +97,6 @@ object CheckCommand "hostalive6" {
|
|||
}
|
||||
|
||||
template CheckCommand "fping-common" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [
|
||||
PluginDir + "/check_fping",
|
||||
"$fping_address$"
|
||||
|
@ -142,8 +138,6 @@ object CheckCommand "fping6" {
|
|||
}
|
||||
|
||||
object CheckCommand "dummy" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [
|
||||
PluginDir + "/check_dummy",
|
||||
"$dummy_state$",
|
||||
|
@ -162,7 +156,6 @@ object CheckCommand "passive" {
|
|||
}
|
||||
|
||||
object CheckCommand "tcp" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_tcp" ]
|
||||
|
@ -266,7 +259,6 @@ object CheckCommand "tcp" {
|
|||
}
|
||||
|
||||
object CheckCommand "ssl" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_tcp" ]
|
||||
|
@ -283,7 +275,6 @@ object CheckCommand "ssl" {
|
|||
}
|
||||
|
||||
object CheckCommand "udp" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [
|
||||
|
@ -318,7 +309,6 @@ object CheckCommand "udp" {
|
|||
}
|
||||
|
||||
object CheckCommand "http" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_http" ]
|
||||
|
@ -477,7 +467,6 @@ object CheckCommand "http" {
|
|||
}
|
||||
|
||||
object CheckCommand "ftp" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_ftp" ]
|
||||
|
@ -581,7 +570,6 @@ object CheckCommand "ftp" {
|
|||
}
|
||||
|
||||
object CheckCommand "smtp" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_smtp" ]
|
||||
|
@ -622,7 +610,6 @@ object CheckCommand "smtp" {
|
|||
}
|
||||
|
||||
object CheckCommand "ssmtp" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_ssmtp" ]
|
||||
|
@ -670,7 +657,6 @@ object CheckCommand "ssmtp" {
|
|||
}
|
||||
|
||||
object CheckCommand "imap" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_imap" ]
|
||||
|
@ -718,7 +704,6 @@ object CheckCommand "imap" {
|
|||
}
|
||||
|
||||
object CheckCommand "simap" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_simap" ]
|
||||
|
@ -766,7 +751,6 @@ object CheckCommand "simap" {
|
|||
}
|
||||
|
||||
object CheckCommand "pop" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_pop" ]
|
||||
|
@ -814,7 +798,6 @@ object CheckCommand "pop" {
|
|||
}
|
||||
|
||||
object CheckCommand "spop" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_spop" ]
|
||||
|
@ -862,7 +845,6 @@ object CheckCommand "spop" {
|
|||
}
|
||||
|
||||
object CheckCommand "ntp_time" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_ntp_time" ]
|
||||
|
@ -894,7 +876,6 @@ object CheckCommand "ntp_time" {
|
|||
}
|
||||
|
||||
object CheckCommand "ntp_peer" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_ntp_peer" ]
|
||||
|
@ -927,7 +908,6 @@ object CheckCommand "ntp_peer" {
|
|||
}
|
||||
|
||||
object CheckCommand "ssh" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_ssh" ]
|
||||
|
@ -956,8 +936,6 @@ object CheckCommand "ssh" {
|
|||
}
|
||||
|
||||
object CheckCommand "disk" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_disk" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1115,8 +1093,6 @@ object CheckCommand "disk" {
|
|||
}
|
||||
|
||||
object CheckCommand "disk_smb" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_disk_smb" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1163,8 +1139,6 @@ object CheckCommand "disk_smb" {
|
|||
}
|
||||
|
||||
object CheckCommand "users" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_users" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1177,8 +1151,6 @@ object CheckCommand "users" {
|
|||
}
|
||||
|
||||
object CheckCommand "procs" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_procs" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1251,8 +1223,6 @@ object CheckCommand "procs" {
|
|||
}
|
||||
|
||||
object CheckCommand "swap" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_swap" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1287,8 +1257,6 @@ object CheckCommand "swap" {
|
|||
}
|
||||
|
||||
object CheckCommand "load" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_load" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1318,8 +1286,6 @@ object CheckCommand "load" {
|
|||
}
|
||||
|
||||
object CheckCommand "snmp" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_snmp" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1370,7 +1336,6 @@ object CheckCommand "snmp" {
|
|||
}
|
||||
|
||||
object CheckCommand "snmpv3" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_snmp" ]
|
||||
|
@ -1467,8 +1432,6 @@ object CheckCommand "snmp-uptime" {
|
|||
}
|
||||
|
||||
object CheckCommand "apt" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_apt" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1506,8 +1469,6 @@ object CheckCommand "apt" {
|
|||
}
|
||||
|
||||
object CheckCommand "dhcp" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_dhcp" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1525,7 +1486,6 @@ object CheckCommand "dhcp" {
|
|||
}
|
||||
|
||||
object CheckCommand "dns" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_dns" ]
|
||||
|
@ -1570,7 +1530,6 @@ object CheckCommand "dns" {
|
|||
}
|
||||
|
||||
object CheckCommand "dig" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_dig" ]
|
||||
|
@ -1605,7 +1564,6 @@ object CheckCommand "dig" {
|
|||
}
|
||||
|
||||
object CheckCommand "nscp" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_nt" ]
|
||||
|
@ -1638,7 +1596,6 @@ object CheckCommand "nscp" {
|
|||
}
|
||||
|
||||
object CheckCommand "by_ssh" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_by_ssh" ]
|
||||
|
@ -1689,7 +1646,6 @@ object CheckCommand "by_ssh" {
|
|||
}
|
||||
|
||||
object CheckCommand "ups" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_ups" ]
|
||||
|
@ -1736,7 +1692,6 @@ object CheckCommand "ups" {
|
|||
}
|
||||
|
||||
object CheckCommand "nrpe" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_nrpe" ]
|
||||
|
@ -1779,7 +1734,6 @@ object CheckCommand "nrpe" {
|
|||
}
|
||||
|
||||
object CheckCommand "hpjd" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_hpjd" ]
|
||||
|
@ -1794,8 +1748,6 @@ object CheckCommand "hpjd" {
|
|||
}
|
||||
|
||||
object CheckCommand "icmp" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_icmp" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -1823,7 +1775,6 @@ object CheckCommand "icmp" {
|
|||
}
|
||||
|
||||
object CheckCommand "ldap" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_ldap" ]
|
||||
|
@ -1896,8 +1847,6 @@ object CheckCommand "ldap" {
|
|||
}
|
||||
|
||||
object CheckCommand "clamd" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_clamd" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -2000,8 +1949,6 @@ object CheckCommand "clamd" {
|
|||
}
|
||||
|
||||
object CheckCommand "mailq" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_mailq" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -2035,7 +1982,6 @@ object CheckCommand "mailq" {
|
|||
}
|
||||
|
||||
object CheckCommand "pgsql" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_pgsql" ]
|
||||
|
@ -2059,7 +2005,6 @@ object CheckCommand "pgsql" {
|
|||
}
|
||||
|
||||
object CheckCommand "mysql" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_mysql" ]
|
||||
|
@ -2095,8 +2040,6 @@ object CheckCommand "mysql" {
|
|||
}
|
||||
|
||||
object CheckCommand "negate" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/negate" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -2132,8 +2075,6 @@ object CheckCommand "negate" {
|
|||
}
|
||||
|
||||
object CheckCommand "file_age" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_file_age" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -2167,8 +2108,6 @@ object CheckCommand "file_age" {
|
|||
}
|
||||
|
||||
object CheckCommand "smart" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_ide_smart" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -2181,7 +2120,6 @@ object CheckCommand "smart" {
|
|||
}
|
||||
|
||||
object CheckCommand "breeze" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_breeze" ]
|
||||
|
@ -2214,8 +2152,6 @@ object CheckCommand "breeze" {
|
|||
}
|
||||
|
||||
object CheckCommand "flexlm" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginDir + "/check_flexlm" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -2232,7 +2168,6 @@ object CheckCommand "flexlm" {
|
|||
}
|
||||
|
||||
object CheckCommand "game" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_game" ]
|
||||
|
@ -2282,7 +2217,6 @@ object CheckCommand "game" {
|
|||
}
|
||||
|
||||
object CheckCommand "mysql_query" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginDir + "/check_mysql_query" ]
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
object CheckCommand "mssql_health" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_mssql_health" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -95,7 +93,6 @@ object CheckCommand "mssql_health" {
|
|||
}
|
||||
|
||||
object CheckCommand "mysql_health" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginContribDir + "/check_mysql_health" ]
|
||||
|
@ -247,8 +244,6 @@ object CheckCommand "mysql_health" {
|
|||
}
|
||||
|
||||
object CheckCommand "db2_health" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_db2_health" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -338,8 +333,6 @@ object CheckCommand "db2_health" {
|
|||
}
|
||||
|
||||
object CheckCommand "oracle_health" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_oracle_health" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -416,7 +409,6 @@ object CheckCommand "oracle_health" {
|
|||
}
|
||||
|
||||
object CheckCommand "postgres" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginContribDir + "/check_postgres.pl" ]
|
||||
|
@ -504,8 +496,6 @@ object CheckCommand "postgres" {
|
|||
}
|
||||
|
||||
object CheckCommand "mongodb" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_mongodb.py" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -585,8 +575,6 @@ object CheckCommand "mongodb" {
|
|||
}
|
||||
|
||||
object CheckCommand "elasticsearch" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_elasticsearch" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -621,8 +609,6 @@ object CheckCommand "elasticsearch" {
|
|||
}
|
||||
|
||||
object CheckCommand "redis" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_redis.pl" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
object CheckCommand "hpasm" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginContribDir + "/check_hpasm" ]
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
template CheckCommand "icingacli" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PrefixDir + "/bin/icingacli" ]
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
object CheckCommand "ipmi-sensor" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginContribDir + "/check_ipmi_sensor" ]
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
object CheckCommand "graphite" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_graphite" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
object CheckCommand "interfacetable" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_interface_table_v3t" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -302,7 +300,6 @@ object CheckCommand "interfacetable" {
|
|||
}
|
||||
|
||||
object CheckCommand "iftraffic" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginContribDir + "/check_iftraffic.pl"]
|
||||
|
@ -351,7 +348,6 @@ object CheckCommand "iftraffic" {
|
|||
}
|
||||
|
||||
object CheckCommand "iftraffic64" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginContribDir + "/check_iftraffic64.pl"]
|
||||
|
@ -400,7 +396,6 @@ object CheckCommand "iftraffic64" {
|
|||
}
|
||||
|
||||
object CheckCommand "interfaces" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginContribDir + "/check_interfaces" ]
|
||||
|
@ -503,7 +498,6 @@ object CheckCommand "interfaces" {
|
|||
}
|
||||
|
||||
object CheckCommand "nwc_health" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginContribDir + "/check_nwc_health" ]
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
object CheckCommand "kdc" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginContribDir + "/check_kdc" ]
|
||||
|
@ -48,7 +47,6 @@ object CheckCommand "kdc" {
|
|||
}
|
||||
|
||||
object CheckCommand "rbl" {
|
||||
import "plugin-check-command"
|
||||
import "ipv4-or-ipv6"
|
||||
|
||||
command = [ PluginContribDir + "/check_rbl" ]
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
object CheckCommand "mem" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_mem.pl" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -51,8 +49,6 @@ object CheckCommand "mem" {
|
|||
}
|
||||
|
||||
object CheckCommand "running_kernel" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = {{
|
||||
var use_sudo = macro("$running_kernel_use_sudo$")
|
||||
|
||||
|
@ -75,8 +71,6 @@ object CheckCommand "running_kernel" {
|
|||
}
|
||||
|
||||
object CheckCommand "yum" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_yum" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -128,8 +122,6 @@ object CheckCommand "yum" {
|
|||
}
|
||||
|
||||
object CheckCommand "iostat" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_iostat" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
object CheckCommand "esxi_hardware" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_esxi_hardware.py" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
*/
|
||||
|
||||
template CheckCommand "vmware-esx-command" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_vmware_esx" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
******************************************************************************/
|
||||
|
||||
object CheckCommand "webinject" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_webinject" ]
|
||||
|
||||
arguments = {
|
||||
|
@ -63,8 +61,6 @@ object CheckCommand "webinject" {
|
|||
}
|
||||
|
||||
object CheckCommand "jmx4perl" {
|
||||
import "plugin-check-command"
|
||||
|
||||
command = [ PluginContribDir + "/check_jmx4perl" ]
|
||||
|
||||
arguments = {
|
||||
|
|
|
@ -243,6 +243,7 @@ const std::vector<String>& ConfigWriter::GetKeywords(void)
|
|||
keywords.push_back("locals");
|
||||
keywords.push_back("use");
|
||||
keywords.push_back("__using");
|
||||
keywords.push_back("default");
|
||||
keywords.push_back("ignore_on_error");
|
||||
keywords.push_back("current_filename");
|
||||
keywords.push_back("current_line");
|
||||
|
|
|
@ -182,6 +182,7 @@ locals return T_LOCALS;
|
|||
use return T_USE;
|
||||
__using return T_USING;
|
||||
apply return T_APPLY;
|
||||
default return T_DEFAULT;
|
||||
to return T_TO;
|
||||
where return T_WHERE;
|
||||
import return T_IMPORT;
|
||||
|
|
|
@ -144,6 +144,7 @@ static void MakeRBinaryOp(Expression** result, Expression *left, Expression *rig
|
|||
%token T_GLOBALS "globals (T_GLOBALS)"
|
||||
%token T_LOCALS "locals (T_LOCALS)"
|
||||
%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_CURRENT_FILENAME "current_filename (T_CURRENT_FILENAME)"
|
||||
%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> optional_rterm
|
||||
%type <text> target_type_specifier
|
||||
%type <boolean> default_specifier
|
||||
%type <boolean> ignore_specifier
|
||||
%type <cvlist> use_specifier
|
||||
%type <cvlist> use_specifier_items
|
||||
|
@ -370,7 +372,7 @@ object:
|
|||
context->m_Assign.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);
|
||||
}
|
||||
|
@ -381,6 +383,10 @@ object:
|
|||
context->m_ObjectAssign.pop();
|
||||
|
||||
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;
|
||||
delete $3;
|
||||
|
@ -416,7 +422,7 @@ object:
|
|||
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 */
|
||||
{
|
||||
$$ = false;
|
||||
|
|
|
@ -59,11 +59,12 @@ REGISTER_SCRIPTFUNCTION_NS(Internal, run_with_activation_context, &ConfigItem::R
|
|||
*/
|
||||
ConfigItem::ConfigItem(const String& type, const String& name,
|
||||
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 String& zone, const String& package)
|
||||
: 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_Package(package)
|
||||
{
|
||||
|
@ -99,6 +100,16 @@ bool ConfigItem::IsAbstract(void) const
|
|||
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.
|
||||
*
|
||||
|
@ -649,6 +660,26 @@ std::vector<ConfigItem::Ptr> ConfigItem::GetItems(const String& type)
|
|||
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)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(m_Mutex);
|
||||
|
|
|
@ -43,14 +43,15 @@ public:
|
|||
ConfigItem(const String& type, const String& name, bool abstract,
|
||||
const boost::shared_ptr<Expression>& exprl,
|
||||
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 String& package);
|
||||
|
||||
String GetType(void) const;
|
||||
String GetName(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;
|
||||
|
||||
|
@ -74,6 +75,7 @@ public:
|
|||
static bool RunWithActivationContext(const Function::Ptr& function);
|
||||
|
||||
static std::vector<ConfigItem::Ptr> GetItems(const String& type);
|
||||
static std::vector<ConfigItem::Ptr> GetDefaultTemplates(const String& type);
|
||||
|
||||
static void RemoveIgnoredItems(const String& allowedConfigPath);
|
||||
|
||||
|
@ -84,6 +86,7 @@ private:
|
|||
|
||||
boost::shared_ptr<Expression> m_Expression;
|
||||
boost::shared_ptr<Expression> m_Filter;
|
||||
bool m_DefaultTmpl;
|
||||
bool m_IgnoreOnError;
|
||||
DebugInfo m_DebugInfo; /**< Debug information. */
|
||||
Dictionary::Ptr m_Scope; /**< variable scope. */
|
||||
|
|
|
@ -79,6 +79,11 @@ void ConfigItemBuilder::SetFilter(const boost::shared_ptr<Expression>& filter)
|
|||
m_Filter = filter;
|
||||
}
|
||||
|
||||
void ConfigItemBuilder::SetDefaultTemplate(bool defaultTmpl)
|
||||
{
|
||||
m_DefaultTmpl = defaultTmpl;
|
||||
}
|
||||
|
||||
void ConfigItemBuilder::SetIgnoreOnError(bool ignoreOnError)
|
||||
{
|
||||
m_IgnoreOnError = ignoreOnError;
|
||||
|
@ -119,10 +124,25 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void)
|
|||
dexpr->MakeInline();
|
||||
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);
|
||||
exprl->MakeInline();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
void SetScope(const Dictionary::Ptr& scope);
|
||||
void SetZone(const String& zone);
|
||||
void SetPackage(const String& package);
|
||||
void SetDefaultTemplate(bool defaultTmpl);
|
||||
void SetIgnoreOnError(bool ignoreOnError);
|
||||
|
||||
void AddExpression(Expression *expr);
|
||||
|
@ -65,6 +66,7 @@ private:
|
|||
Dictionary::Ptr m_Scope; /**< variable scope. */
|
||||
String m_Zone; /**< The zone. */
|
||||
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. */
|
||||
};
|
||||
|
||||
|
|
|
@ -761,6 +761,26 @@ ExpressionResult ImportExpression::DoEvaluate(ScriptFrame& frame, DebugHint *dhi
|
|||
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
|
||||
{
|
||||
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,
|
||||
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
|
||||
|
|
|
@ -800,6 +800,17 @@ private:
|
|||
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
|
||||
{
|
||||
public:
|
||||
|
@ -879,9 +890,9 @@ class I2_CONFIG_API ObjectExpression : public DebuggableExpression
|
|||
public:
|
||||
ObjectExpression(bool abstract, const String& type, Expression *name, Expression *filter,
|
||||
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),
|
||||
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)
|
||||
{ }
|
||||
|
||||
|
@ -909,6 +920,7 @@ private:
|
|||
boost::shared_ptr<Expression> m_Filter;
|
||||
String m_Zone;
|
||||
String m_Package;
|
||||
bool m_DefaultTmpl;
|
||||
bool m_IgnoreOnError;
|
||||
std::map<String, Expression *> *m_ClosedVars;
|
||||
boost::shared_ptr<Expression> m_Expression;
|
||||
|
|
|
@ -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,
|
||||
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);
|
||||
|
||||
|
@ -157,12 +157,16 @@ public:
|
|||
item->SetType(type);
|
||||
item->SetName(name);
|
||||
|
||||
if (!abstract)
|
||||
item->AddExpression(new ImportDefaultTemplatesExpression());
|
||||
|
||||
item->AddExpression(new OwnedExpression(expression));
|
||||
item->SetAbstract(abstract);
|
||||
item->SetScope(EvaluateClosedVars(frame, closedVars));
|
||||
item->SetZone(zone);
|
||||
item->SetPackage(package);
|
||||
item->SetFilter(filter);
|
||||
item->SetDefaultTemplate(defaultTmpl);
|
||||
item->SetIgnoreOnError(ignoreOnError);
|
||||
item->Compile()->Register();
|
||||
|
||||
|
|
|
@ -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, "package"), OpSetLiteral, MakeLiteral(rule.GetPackage()), di));
|
||||
|
||||
|
||||
builder->AddExpression(new ImportDefaultTemplatesExpression());
|
||||
|
||||
builder->AddExpression(new OwnedExpression(rule.GetExpression()));
|
||||
|
||||
ConfigItem::Ptr dependencyItem = builder->Compile();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
System.assert(Internal.run_with_activation_context(function() {
|
||||
var _Internal = Internal.clone()
|
||||
|
||||
template TimePeriod "legacy-timeperiod" use (_Internal) {
|
||||
template TimePeriod "legacy-timeperiod" use (_Internal) default {
|
||||
update = _Internal.LegacyTimePeriod
|
||||
}
|
||||
}))
|
||||
|
|
|
@ -73,6 +73,8 @@ bool Notification::EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, co
|
|||
|
||||
builder->AddExpression(new OwnedExpression(rule.GetExpression()));
|
||||
|
||||
builder->AddExpression(new ImportDefaultTemplatesExpression());
|
||||
|
||||
ConfigItem::Ptr notificationItem = builder->Compile();
|
||||
notificationItem->Register();
|
||||
|
||||
|
|
|
@ -72,6 +72,8 @@ bool ScheduledDowntime::EvaluateApplyRuleInstance(const Checkable::Ptr& checkabl
|
|||
|
||||
builder->AddExpression(new OwnedExpression(rule.GetExpression()));
|
||||
|
||||
builder->AddExpression(new ImportDefaultTemplatesExpression());
|
||||
|
||||
ConfigItem::Ptr downtimeItem = builder->Compile();
|
||||
downtimeItem->Register();
|
||||
|
||||
|
|
|
@ -66,6 +66,8 @@ bool Service::EvaluateApplyRuleInstance(const Host::Ptr& host, const String& nam
|
|||
|
||||
builder->AddExpression(new OwnedExpression(rule.GetExpression()));
|
||||
|
||||
builder->AddExpression(new ImportDefaultTemplatesExpression());
|
||||
|
||||
ConfigItem::Ptr serviceItem = builder->Compile();
|
||||
serviceItem->Register();
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ System.assert(Internal.run_with_activation_context(function() {
|
|||
execute = _Internal.ClusterZoneCheck
|
||||
}
|
||||
|
||||
template CheckCommand "plugin-check-command" use (_Internal) {
|
||||
template CheckCommand "plugin-check-command" use (_Internal) default {
|
||||
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
|
||||
}
|
||||
|
||||
template EventCommand "plugin-event-command" use (_Internal) {
|
||||
template EventCommand "plugin-event-command" use (_Internal) default {
|
||||
execute = _Internal.PluginEvent
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue