1 /******************************************************************************
3 * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
20 #ifndef COMPATLOGGER_H
21 #define COMPATLOGGER_H
23 #include "compat/compatlogger.thpp"
24 #include "icinga/service.hpp"
25 #include "base/timer.hpp"
32 * An Icinga compat log writer.
36 class CompatLogger final : public ObjectImpl<CompatLogger>
39 DECLARE_OBJECT(CompatLogger);
40 DECLARE_OBJECTNAME(CompatLogger);
42 static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
44 void ValidateRotationMethod(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
47 void Start(bool runtimeCreated) override;
48 void Stop(bool runtimeRemoved) override;
51 void WriteLine(const String& line);
54 void CheckResultHandler(const Checkable::Ptr& service, const CheckResult::Ptr& cr);
55 void NotificationSentHandler(const Notification::Ptr& notification, const Checkable::Ptr& service,
56 const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr,
57 const String& author, const String& comment_text, const String& command_name);
58 void FlappingChangedHandler(const Checkable::Ptr& checkable);
59 void EnableFlappingChangedHandler(const Checkable::Ptr& checkable);
60 void TriggerDowntimeHandler(const Downtime::Ptr& downtime);
61 void RemoveDowntimeHandler(const Downtime::Ptr& downtime);
62 void ExternalCommandHandler(const String& command, const std::vector<String>& arguments);
63 void EventCommandHandler(const Checkable::Ptr& service);
65 static String GetHostStateString(const Host::Ptr& host);
67 Timer::Ptr m_RotationTimer;
68 void RotationTimerHandler();
69 void ScheduleNextRotation();
71 std::ofstream m_OutputFile;
72 void ReopenFile(bool rotate);
77 #endif /* COMPATLOGGER_H */