icinga2/lib/compat/compatlogger.hpp

61 lines
1.7 KiB
C++
Raw Normal View History

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2013-03-19 13:04:30 +01:00
2013-09-25 10:55:50 +02:00
#ifndef COMPATLOGGER_H
#define COMPATLOGGER_H
2013-03-19 13:04:30 +01:00
2018-01-18 13:50:38 +01:00
#include "compat/compatlogger-ti.hpp"
2014-05-25 16:23:35 +02:00
#include "icinga/service.hpp"
#include "base/timer.hpp"
2013-03-19 13:04:30 +01:00
#include <fstream>
namespace icinga
{
/**
* An Icinga compat log writer.
*
* @ingroup compat
*/
2018-01-04 06:11:04 +01:00
class CompatLogger final : public ObjectImpl<CompatLogger>
2013-03-19 13:04:30 +01:00
{
public:
2014-11-03 00:44:04 +01:00
DECLARE_OBJECT(CompatLogger);
DECLARE_OBJECTNAME(CompatLogger);
2013-03-19 13:04:30 +01:00
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
void ValidateRotationMethod(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
2013-03-19 13:04:30 +01:00
protected:
void Start(bool runtimeCreated) override;
void Stop(bool runtimeRemoved) override;
2013-03-19 13:04:30 +01:00
private:
void WriteLine(const String& line);
void Flush();
2013-03-19 13:04:30 +01:00
2014-04-03 15:36:13 +02:00
void CheckResultHandler(const Checkable::Ptr& service, const CheckResult::Ptr& cr);
void NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& service,
const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr,
const String& author, const String& comment_text, const String& command_name);
void FlappingChangedHandler(const Checkable::Ptr& checkable);
void EnableFlappingChangedHandler(const Checkable::Ptr& checkable);
void TriggerDowntimeHandler(const Downtime::Ptr& downtime);
void RemoveDowntimeHandler(const Downtime::Ptr& downtime);
void ExternalCommandHandler(const String& command, const std::vector<String>& arguments);
2014-04-03 15:36:13 +02:00
void EventCommandHandler(const Checkable::Ptr& service);
2013-03-19 13:04:30 +01:00
static String GetHostStateString(const Host::Ptr& host);
2013-03-19 13:04:30 +01:00
Timer::Ptr m_RotationTimer;
void RotationTimerHandler();
void ScheduleNextRotation();
2013-03-19 13:04:30 +01:00
std::ofstream m_OutputFile;
void ReopenFile(bool rotate);
2013-03-19 13:04:30 +01:00
};
}
2013-09-25 10:55:50 +02:00
#endif /* COMPATLOGGER_H */