icinga2/lib/compat/compatlogger.hpp

74 lines
3.0 KiB
C++
Raw Normal View History

2013-03-19 13:04:30 +01:00
/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
2013-03-19 13:04:30 +01:00
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software Foundation *
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
******************************************************************************/
2013-09-25 10:55:50 +02:00
#ifndef COMPATLOGGER_H
#define COMPATLOGGER_H
2013-03-19 13:04:30 +01:00
2014-05-25 16:23:35 +02:00
#include "compat/compatlogger.thpp"
#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
*/
class CompatLogger : public ObjectImpl<CompatLogger>
2013-03-19 13:04:30 +01:00
{
public:
2013-09-25 10:55:50 +02:00
DECLARE_PTR_TYPEDEFS(CompatLogger);
DECLARE_TYPENAME(CompatLogger);
2013-03-19 13:04:30 +01:00
static Value StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
2013-03-25 20:47:02 +01:00
static void ValidateRotationMethod(const String& location, const Dictionary::Ptr& attrs);
2013-03-19 13:04:30 +01:00
protected:
virtual void Start(void);
private:
void WriteLine(const String& line);
void Flush(void);
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,
2014-10-28 18:04:51 +01:00
const User::Ptr& user, NotificationType notification_type, CheckResult::Ptr const& cr,
2014-08-17 17:57:20 +02:00
const String& author, const String& comment_text, const String& command_name);
2014-04-03 15:36:13 +02:00
void FlappingHandler(const Checkable::Ptr& service, FlappingState flapping_state);
void TriggerDowntimeHandler(const Checkable::Ptr& service, const Downtime::Ptr& downtime);
void RemoveDowntimeHandler(const Checkable::Ptr& service, 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
Timer::Ptr m_RotationTimer;
void RotationTimerHandler(void);
void ScheduleNextRotation(void);
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 */