1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
6 #include "perfdata/gelfwriter-ti.hpp"
7 #include "icinga/service.hpp"
8 #include "base/configobject.hpp"
9 #include "base/tcpsocket.hpp"
10 #include "base/timer.hpp"
11 #include "base/workqueue.hpp"
18 * An Icinga Gelf writer for Graylog.
22 class GelfWriter final : public ObjectImpl<GelfWriter>
25 DECLARE_OBJECT(GelfWriter);
26 DECLARE_OBJECTNAME(GelfWriter);
28 static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
31 void OnConfigLoaded() override;
32 void Resume() override;
33 void Pause() override;
37 WorkQueue m_WorkQueue{10000000, 1};
39 Timer::Ptr m_ReconnectTimer;
41 void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
42 void CheckResultHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
43 void NotificationToUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
44 const User::Ptr& user, NotificationType notificationType, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
45 const String& author, const String& commentText, const String& commandName);
46 void NotificationToUserHandlerInternal(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
47 const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
48 const String& author, const String& comment_text, const String& command_name);
49 void StateChangeHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
50 void StateChangeHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
52 String ComposeGelfMessage(const Dictionary::Ptr& fields, const String& source, double ts);
53 void SendLogMessage(const Checkable::Ptr& checkable, const String& gelfMessage);
55 void ReconnectTimerHandler();
58 void DisconnectInternal();
60 void ReconnectInternal();
62 void AssertOnWorkQueue();
64 void ExceptionHandler(boost::exception_ptr exp);
69 #endif /* GELFWRITER_H */