mirror of https://github.com/Icinga/icinga2.git
Implement TOTALHOSTSERVICES, TOTALHOSTSERVICESOK, TOTALHOSTSERVICESWARNING, TOTALHOSTSERVICESUNKNOWN and TOTALHOSTSERVICESCRITICAL macros.
This commit is contained in:
parent
0be741aca4
commit
9506b6710e
|
@ -131,6 +131,11 @@ services:
|
|||
SERVICEOUTPUT | The last check's output.
|
||||
SERVICEPERFDATA | The last check's performance data.
|
||||
LASTSERVICECHECK | The timestamp when the last check was executed.
|
||||
TOTALHOSTSERVICES | Number of services associated with the host.
|
||||
TOTALHOSTSERVICESOK | Number of services associated with the host which are in an `OK` state.
|
||||
TOTALHOSTSERVICESWARNING | Number of services associated with the host which are in a `WARNING` state.
|
||||
TOTALHOSTSERVICESUNKNOWN | Number of services associated with the host which are in an `UNKNOWN` state.
|
||||
TOTALHOSTSERVICESCRITICAL | Number of services associated with the host which are in a `CRITICAL` state.
|
||||
|
||||
### User Macros
|
||||
|
||||
|
|
|
@ -427,6 +427,29 @@ bool Service::ResolveMacro(const String& macro, const Dictionary::Ptr& cr, Strin
|
|||
} else if (macro == "SERVICEDURATIONSEC") {
|
||||
*result = Convert::ToString((long)(Utility::GetTime() - GetLastStateChange()));
|
||||
return true;
|
||||
} else if (macro == "TOTALHOSTSERVICES" || macro == "TOTALHOSTSERVICESOK" || macro == "TOTALHOSTSERVICESWARNING"
|
||||
|| macro == "TOTALHOSTSERVICESUNKNOWN" || macro == "TOTALHOSTSERVICESCRITICAL") {
|
||||
int filter = -1;
|
||||
int count = 0;
|
||||
|
||||
if (macro == "TOTALHOSTSERVICESOK")
|
||||
filter = StateOK;
|
||||
else if (macro == "TOTALHOSTSERVICESWARNING")
|
||||
filter = StateWarning;
|
||||
else if (macro == "TOTALHOSTSERVICESUNKNOWN")
|
||||
filter = StateUnknown;
|
||||
else if (macro == "TOTALHOSTSERVICESCRITICAL")
|
||||
filter = StateCritical;
|
||||
|
||||
BOOST_FOREACH(const Service::Ptr& service, GetHost()->GetServices()) {
|
||||
if (filter != -1 && service->GetState() != filter)
|
||||
continue;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
*result = Convert::ToString(count);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cr) {
|
||||
|
|
Loading…
Reference in New Issue