Fix perfdata macros.

This commit is contained in:
Gunnar Beutner 2013-03-15 13:29:41 +01:00
parent 14c837a208
commit 6d5339574a
3 changed files with 10 additions and 7 deletions

View File

@ -468,7 +468,7 @@ void Service::ProcessCheckResult(const Dictionary::Ptr& cr)
olock.Unlock();
/* Update macros - these are used by event handlers and notifications. */
cr->Set("macros", CalculateAllMacros());
cr->Set("macros", CalculateAllMacros(cr));
cr->Seal();

View File

@ -429,7 +429,7 @@ set<Service::Ptr> Service::GetParentServices(void) const
/**
* @threadsafety Always.
*/
Dictionary::Ptr Service::CalculateDynamicMacros(void) const
Dictionary::Ptr Service::CalculateDynamicMacros(const Dictionary::Ptr& crOverride) const
{
Dictionary::Ptr macros = boost::make_shared<Dictionary>();
@ -453,8 +453,11 @@ Dictionary::Ptr Service::CalculateDynamicMacros(void) const
cr = GetLastCheckResult();
}
if (crOverride)
cr = crOverride;
if (cr) {
ASSERT(cr->IsSealed());
ASSERT(crOverride || cr->IsSealed());
macros->Set("SERVICELATENCY", Service::CalculateLatency(cr));
macros->Set("SERVICEEXECUTIONTIME", Service::CalculateExecutionTime(cr));
@ -470,14 +473,14 @@ Dictionary::Ptr Service::CalculateDynamicMacros(void) const
return macros;
}
Dictionary::Ptr Service::CalculateAllMacros(void) const
Dictionary::Ptr Service::CalculateAllMacros(const Dictionary::Ptr& crOverride) const
{
vector<Dictionary::Ptr> macroDicts;
macroDicts.push_back(GetMacros());
Host::Ptr host = GetHost();
macroDicts.push_back(CalculateDynamicMacros());
macroDicts.push_back(CalculateDynamicMacros(crOverride));
if (host) {
macroDicts.push_back(host->GetMacros());

View File

@ -95,8 +95,8 @@ public:
String GetHostName(void) const;
String GetShortName(void) const;
Dictionary::Ptr CalculateDynamicMacros(void) const;
Dictionary::Ptr CalculateAllMacros(void) const;
Dictionary::Ptr CalculateDynamicMacros(const Dictionary::Ptr& crOverride = Dictionary::Ptr()) const;
Dictionary::Ptr CalculateAllMacros(const Dictionary::Ptr& crOverride = Dictionary::Ptr()) const;
set<Host::Ptr> GetParentHosts(void) const;
set<Service::Ptr> GetParentServices(void) const;