MCPcopy Create free account
hub / github.com/Icinga/icinga2 / CheckResultHandler

Method CheckResultHandler

lib/perfdata/perfdatawriter.cpp:98–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98void PerfdataWriter::CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr)
99{
100 if (IsPaused())
101 return;
102
103 CONTEXT("Writing performance data for object '" << checkable->GetName() << "'");
104
105 if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !checkable->GetEnablePerfdata())
106 return;
107
108 Service::Ptr service = dynamic_pointer_cast<Service>(checkable);
109 Host::Ptr host;
110
111 if (service)
112 host = service->GetHost();
113 else
114 host = static_pointer_cast<Host>(checkable);
115
116 MacroProcessor::ResolverList resolvers;
117 if (service)
118 resolvers.emplace_back("service", service);
119 resolvers.emplace_back("host", host);
120
121 if (service) {
122 String line = MacroProcessor::ResolveMacros(GetServiceFormatTemplate(), resolvers, cr, nullptr, &PerfdataWriter::EscapeMacroMetric);
123
124 {
125 std::unique_lock<std::mutex> lock(m_StreamMutex);
126
127 if (!m_ServiceOutputFile.good())
128 return;
129
130 m_ServiceOutputFile << line << "\n";
131 }
132 } else {
133 String line = MacroProcessor::ResolveMacros(GetHostFormatTemplate(), resolvers, cr, nullptr, &PerfdataWriter::EscapeMacroMetric);
134
135 {
136 std::unique_lock<std::mutex> lock(m_StreamMutex);
137
138 if (!m_HostOutputFile.good())
139 return;
140
141 m_HostOutputFile << line << "\n";
142 }
143 }
144}
145
146void PerfdataWriter::RotateFile(std::ofstream& output, const String& temp_path, const String& perfdata_path)
147{

Callers

nothing calls this directly

Calls 2

GetNameMethod · 0.45
GetHostMethod · 0.45

Tested by

no test coverage detected