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

Method NotificationSentHandler

lib/compat/compatlogger.cpp:249–308  ·  view source on GitHub ↗

* @threadsafety Always. */

Source from the content-addressed store, hash-verified

247 * @threadsafety Always.
248 */
249void CompatLogger::NotificationSentHandler(const Checkable::Ptr& checkable,
250 const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr,
251 const String& author, const String& comment_text, const String& command_name)
252{
253 Host::Ptr host;
254 Service::Ptr service;
255 tie(host, service) = GetHostService(checkable);
256
257 String notification_type_str = Notification::NotificationTypeToStringCompat(notification_type);
258
259 /* override problem notifications with their current state string */
260 if (notification_type == NotificationProblem) {
261 if (service)
262 notification_type_str = Service::StateToString(service->GetState());
263 else
264 notification_type_str = GetHostStateString(host);
265 }
266
267 String author_comment = "";
268 if (notification_type == NotificationCustom || notification_type == NotificationAcknowledgement) {
269 author_comment = author + ";" + comment_text;
270 }
271
272 if (!cr)
273 return;
274
275 String output;
276 if (cr)
277 output = CompatUtility::GetCheckResultOutput(cr);
278
279 std::ostringstream msgbuf;
280
281 if (service) {
282 msgbuf << "SERVICE NOTIFICATION: "
283 << user->GetName() << ";"
284 << host->GetName() << ";"
285 << service->GetShortName() << ";"
286 << notification_type_str << ";"
287 << command_name << ";"
288 << output << ";"
289 << author_comment
290 << "";
291 } else {
292 msgbuf << "HOST NOTIFICATION: "
293 << user->GetName() << ";"
294 << host->GetName() << ";"
295 << notification_type_str << " "
296 << "(" << GetHostStateString(host) << ");"
297 << command_name << ";"
298 << output << ";"
299 << author_comment
300 << "";
301 }
302
303 {
304 ObjectLock oLock(this);
305 WriteLine(msgbuf.str());
306 Flush();

Callers

nothing calls this directly

Calls 2

GetStateMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected