2013-03-19 13:04:30 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2014-03-19 01:02:29 +01:00
|
|
|
* 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
|
|
|
|
2013-10-26 09:41:45 +02:00
|
|
|
#include "compat/compatlogger.th"
|
2013-06-28 16:08:43 +02:00
|
|
|
#include "icinga/service.h"
|
2013-03-19 13:04:30 +01:00
|
|
|
#include "base/timer.h"
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An Icinga compat log writer.
|
|
|
|
*
|
|
|
|
* @ingroup compat
|
|
|
|
*/
|
2013-11-04 23:14:34 +01:00
|
|
|
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
|
|
|
|
2014-02-17 16:34:18 +01:00
|
|
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::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);
|
|
|
|
|
2013-11-09 14:22:38 +01:00
|
|
|
void CheckResultHandler(const Service::Ptr& service, const CheckResult::Ptr& cr);
|
2014-01-27 17:22:48 +01:00
|
|
|
void NotificationSentHandler(const Notification::Ptr& notification, const Service::Ptr& service,
|
|
|
|
const User::Ptr& user, NotificationType const& notification_type, CheckResult::Ptr const& cr,
|
|
|
|
const String& author, const String& comment_text, const String& command_name);
|
2013-07-01 14:29:07 +02:00
|
|
|
void FlappingHandler(const Service::Ptr& service, FlappingState flapping_state);
|
2013-11-09 22:08:26 +01:00
|
|
|
void TriggerDowntimeHandler(const Service::Ptr& service, const Downtime::Ptr& downtime);
|
|
|
|
void RemoveDowntimeHandler(const Service::Ptr& service, const Downtime::Ptr& downtime);
|
2013-11-09 14:22:38 +01:00
|
|
|
void ExternalCommandHandler(const String& command, const std::vector<String>& arguments);
|
|
|
|
void EventCommandHandler(const Service::Ptr& service);
|
2013-03-19 13:04:30 +01:00
|
|
|
|
|
|
|
Timer::Ptr m_RotationTimer;
|
|
|
|
void RotationTimerHandler(void);
|
2013-03-20 11:11:46 +01:00
|
|
|
void ScheduleNextRotation(void);
|
2013-03-19 13:04:30 +01:00
|
|
|
|
|
|
|
std::ofstream m_OutputFile;
|
2013-03-20 11:11:46 +01:00
|
|
|
void ReopenFile(bool rotate);
|
2013-03-19 13:04:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-09-25 10:55:50 +02:00
|
|
|
#endif /* COMPATLOGGER_H */
|