icinga2/lib/perfdata/gelfwriter.hpp

70 lines
2.1 KiB
C++
Raw Normal View History

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2014-11-05 22:00:44 +01:00
#ifndef GELFWRITER_H
#define GELFWRITER_H
2018-01-18 13:50:38 +01:00
#include "perfdata/gelfwriter-ti.hpp"
2014-11-05 22:00:44 +01:00
#include "icinga/service.hpp"
#include "base/configobject.hpp"
2014-11-05 22:00:44 +01:00
#include "base/tcpsocket.hpp"
#include "base/timer.hpp"
#include "base/workqueue.hpp"
2014-11-05 22:00:44 +01:00
#include <fstream>
namespace icinga
{
/**
* An Icinga Gelf writer for Graylog.
2014-11-05 22:00:44 +01:00
*
* @ingroup perfdata
*/
2018-01-04 06:11:04 +01:00
class GelfWriter final : public ObjectImpl<GelfWriter>
2014-11-05 22:00:44 +01:00
{
public:
DECLARE_OBJECT(GelfWriter);
DECLARE_OBJECTNAME(GelfWriter);
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
2014-11-05 22:00:44 +01:00
protected:
void OnConfigLoaded() override;
void Resume() override;
void Pause() override;
2014-11-05 22:00:44 +01:00
private:
2019-05-16 19:39:06 +02:00
OptionalTlsStream m_Stream;
WorkQueue m_WorkQueue{10000000, 1};
2014-11-05 22:00:44 +01:00
Timer::Ptr m_ReconnectTimer;
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
void CheckResultHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
void NotificationToUserHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
const User::Ptr& user, NotificationType notificationType, const CheckResult::Ptr& cr,
const String& author, const String& commentText, const String& commandName);
void NotificationToUserHandlerInternal(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr,
const String& author, const String& comment_text, const String& command_name);
void StateChangeHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
void StateChangeHandlerInternal(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
String ComposeGelfMessage(const Dictionary::Ptr& fields, const String& source, double ts);
2019-03-19 09:32:02 +01:00
void SendLogMessage(const Checkable::Ptr& checkable, const String& gelfMessage);
2014-11-05 22:00:44 +01:00
void ReconnectTimerHandler();
void Disconnect();
void DisconnectInternal();
void Reconnect();
void ReconnectInternal();
void AssertOnWorkQueue();
void ExceptionHandler(boost::exception_ptr exp);
2014-11-05 22:00:44 +01:00
};
}
#endif /* GELFWRITER_H */