mirror of https://github.com/Icinga/icinga2.git
parent
0a0399826f
commit
aba4f1a0d5
|
@ -152,8 +152,6 @@ external commands).
|
|||
|
||||
### <a id="host-runtime-macros"></a> Host Runtime Macros
|
||||
|
||||
TODO
|
||||
|
||||
The following host custom attributes are available in all commands that are executed for
|
||||
hosts or services:
|
||||
|
||||
|
@ -182,16 +180,8 @@ hosts or services:
|
|||
host.totalservicesunknown | Number of services associated with the host which are in an `UNKNOWN` state.
|
||||
host.totalservicescritical | Number of services associated with the host which are in a `CRITICAL` state.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> `HOSTADDRESS` and `HOSTADDRESS6` macros are available as legacy vars. The
|
||||
> Icinga 2 Template Library (`ITL`) examples use the `$address$` macro instead
|
||||
> requiring that macro key to be defined.
|
||||
|
||||
### <a id="service-runtime-macros"></a> Service Runtime Macros
|
||||
|
||||
TODO
|
||||
|
||||
The following service macros are available in all commands that are executed for
|
||||
services:
|
||||
|
||||
|
@ -220,18 +210,13 @@ services:
|
|||
|
||||
### <a id="user-runtime-macros"></a> User Runtime Macros
|
||||
|
||||
TODO
|
||||
|
||||
The following custom attributes are available in all commands that are executed for
|
||||
users:
|
||||
|
||||
Name | Description
|
||||
-----------------------|--------------
|
||||
USERNAME | The name of the user object.
|
||||
USERDISPLAYNAME | The value of the display_name attribute.
|
||||
USEREMAIL | This is an alias for the `email` macro.
|
||||
USERPAGER | This is an alias for the `pager` macro.
|
||||
|
||||
user.name | The name of the user object.
|
||||
user.displayname | The value of the display_name attribute.
|
||||
|
||||
|
||||
### <a id="notification-runtime-macros"></a> Notification Runtime Macros
|
||||
|
|
|
@ -305,6 +305,11 @@ Changes to host runtime macros
|
|||
|
||||
Icinga 1.x | Icinga 2
|
||||
-----------------------|----------------------
|
||||
USERNAME | user.name
|
||||
USERDISPLAYNAME | user.displayname
|
||||
USEREMAIL | email if set as `email` custom attribute.
|
||||
USERPAGER | pager if set as `pager` custom attribute.
|
||||
|
||||
|
||||
Changes to service runtime macros
|
||||
|
||||
|
|
|
@ -68,37 +68,25 @@ TimePeriod::Ptr User::GetNotificationPeriod(void) const
|
|||
|
||||
bool User::ResolveMacro(const String& macro, const CheckResult::Ptr&, String *result) const
|
||||
{
|
||||
if (macro == "USERNAME" || macro == "CONTACTNAME") {
|
||||
*result = GetName();
|
||||
return true;
|
||||
} else if (macro == "USERDISPLAYNAME" || macro == "CONTACTALIAS") {
|
||||
*result = GetDisplayName();
|
||||
return true;
|
||||
} else if (macro.SubStr(0, 5) == "_USER") {
|
||||
Dictionary::Ptr vars = GetVars();
|
||||
*result = vars ? vars->Get(macro.SubStr(5)) : "";
|
||||
return true;
|
||||
} else if (macro.SubStr(0, 8) == "_CONTACT") {
|
||||
Dictionary::Ptr vars = GetVars();
|
||||
*result = vars ? vars->Get(macro.SubStr(8)) : "";
|
||||
return true;
|
||||
} else {
|
||||
String tmacro;
|
||||
/* require prefix for object macros */
|
||||
if (macro.SubStr(0, 5) == "user.") {
|
||||
String key = macro.SubStr(5);
|
||||
|
||||
if (macro == "USEREMAIL" || macro == "CONTACTEMAIL")
|
||||
tmacro = "email";
|
||||
else if (macro == "USERPAGER" || macro == "CONTACTPAGER")
|
||||
tmacro = "pager";
|
||||
else
|
||||
tmacro = macro;
|
||||
|
||||
Dictionary::Ptr vars = GetVars();
|
||||
|
||||
if (vars && vars->Contains(tmacro)) {
|
||||
*result = vars->Get(tmacro);
|
||||
if (key == "name") {
|
||||
*result = GetName();
|
||||
return true;
|
||||
} else if (key == "displayname") {
|
||||
*result = GetDisplayName();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
Dictionary::Ptr vars = GetVars();
|
||||
|
||||
if (vars && vars->Contains(key)) {
|
||||
*result = vars->Get(key);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue