icinga2/lib/perfdata/gelfwriter.hpp

59 lines
1.7 KiB
C++
Raw Permalink Normal View History

Replace all existing copyright headers with `SPDX` headers I've used the following command to replace the original copyright header lines in a C-style comment block: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{/\*[^*]*\(\s*c\s*\)\s*(\d{4})\s*Icinga\s+GmbH[^*]*\*/}{// SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n// SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ``` For files that use shell-style comments (#) like CMakeLists.txt, I've used this command: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f -exec perl -pi -e 's{#.*\(\s*c\s*\)\s(\d{4})\sIcinga\s+GmbH.*}{# SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n# SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ``` And for SQL files: ``` $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{--.*\(c\)\s(\d{4})\sIcinga\sGmbH.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + $ find . \( -type d \( -name '\..*' -o -name third-party -o -name scripts -o -name prefix -o -name malloc -o -name server -o -name docker -o -name build -o -name doc \) -prune \) -o -type f \( -name '*.sql' \) -exec perl -pi -e 's{-- Copyright \(c\)\s(\d{4})\sIcinga\s+Development\sTeam.*}{-- SPDX-FileCopyrightText: \1 Icinga GmbH <https://icinga.com>\n-- SPDX-License-Identifier: GPL-2.0-or-later}gi' {} + ```
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"
#include "perfdata/perfdatawriterconnection.hpp"
#include "icinga/checkable.hpp"
#include "base/configobject.hpp"
#include "base/workqueue.hpp"
2014-11-05 16:00:44 -05:00
namespace icinga
{
/**
* 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);
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
2014-11-05 16:00:44 -05:00
protected:
void OnConfigLoaded() override;
void Start(bool runtimeCreated) override;
void Resume() override;
void Pause() override;
2014-11-05 16:00:44 -05:00
private:
PerfdataWriterConnection::Ptr m_Connection;
Locked<PerfdataWriterConnection::Ptr> m_LockedConnection;
WorkQueue m_WorkQueue{10000000, 1};
Shared<boost::asio::ssl::context>::Ptr m_SslContext;
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);
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);
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
void AssertOnWorkQueue();
void ExceptionHandler(boost::exception_ptr exp);
2014-11-05 16:00:44 -05:00
};
}
#endif /* GELFWRITER_H */