2026-01-27 09:06:40 -05:00
|
|
|
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-11-05 16:00:44 -05:00
|
|
|
|
|
|
|
|
#ifndef GELFWRITER_H
|
|
|
|
|
#define GELFWRITER_H
|
|
|
|
|
|
2018-01-18 07:50:38 -05:00
|
|
|
#include "perfdata/gelfwriter-ti.hpp"
|
2026-02-02 07:43:31 -05:00
|
|
|
#include "perfdata/perfdatawriterconnection.hpp"
|
|
|
|
|
#include "icinga/checkable.hpp"
|
2015-08-15 14:28:05 -04:00
|
|
|
#include "base/configobject.hpp"
|
2017-06-06 13:48:23 -04:00
|
|
|
#include "base/workqueue.hpp"
|
2014-11-05 16:00:44 -05:00
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
2017-06-06 13:48:23 -04:00
|
|
|
* An Icinga Gelf writer for Graylog.
|
2014-11-05 16:00:44 -05:00
|
|
|
*
|
|
|
|
|
* @ingroup perfdata
|
|
|
|
|
*/
|
2018-01-04 00:11:04 -05:00
|
|
|
class GelfWriter final : public ObjectImpl<GelfWriter>
|
2014-11-05 16:00:44 -05:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DECLARE_OBJECT(GelfWriter);
|
|
|
|
|
DECLARE_OBJECTNAME(GelfWriter);
|
|
|
|
|
|
2017-06-06 13:48:23 -04:00
|
|
|
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
|
|
|
|
|
|
2014-11-05 16:00:44 -05:00
|
|
|
protected:
|
2018-01-03 23:12:56 -05:00
|
|
|
void OnConfigLoaded() override;
|
2026-02-02 07:43:31 -05:00
|
|
|
void Start(bool runtimeCreated) override;
|
2018-10-24 07:43:38 -04:00
|
|
|
void Resume() override;
|
|
|
|
|
void Pause() override;
|
2014-11-05 16:00:44 -05:00
|
|
|
|
|
|
|
|
private:
|
2026-02-02 07:43:31 -05:00
|
|
|
PerfdataWriterConnection::Ptr m_Connection;
|
2026-05-12 03:37:17 -04:00
|
|
|
Locked<PerfdataWriterConnection::Ptr> m_LockedConnection;
|
2018-01-04 03:43:49 -05:00
|
|
|
WorkQueue m_WorkQueue{10000000, 1};
|
2026-02-02 07:43:31 -05:00
|
|
|
Shared<boost::asio::ssl::context>::Ptr m_SslContext;
|
2015-02-07 16:36:17 -05:00
|
|
|
|
2022-04-06 07:01:18 -04:00
|
|
|
boost::signals2::connection m_HandleCheckResults, m_HandleNotifications, m_HandleStateChanges;
|
2014-11-05 16:00:44 -05:00
|
|
|
|
|
|
|
|
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
2025-04-25 06:17:19 -04:00
|
|
|
void NotificationToUserHandler(const Checkable::Ptr& checkable, NotificationType notificationType, const CheckResult::Ptr& cr,
|
|
|
|
|
const String& author, const String& commentText, const String& commandName);
|
2025-04-25 06:14:31 -04:00
|
|
|
void StateChangeHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
2017-06-06 13:48:23 -04:00
|
|
|
|
|
|
|
|
String ComposeGelfMessage(const Dictionary::Ptr& fields, const String& source, double ts);
|
2019-03-19 04:32:02 -04:00
|
|
|
void SendLogMessage(const Checkable::Ptr& checkable, const String& gelfMessage);
|
2014-11-05 16:00:44 -05:00
|
|
|
|
2018-01-03 22:25:35 -05:00
|
|
|
void AssertOnWorkQueue();
|
2017-06-06 13:48:23 -04:00
|
|
|
|
|
|
|
|
void ExceptionHandler(boost::exception_ptr exp);
|
2014-11-05 16:00:44 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* GELFWRITER_H */
|