2012-05-10 12:06:41 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2014-03-19 01:02:29 +01:00
|
|
|
* Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) *
|
2012-05-10 12:06:41 +02: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 *
|
2012-05-11 13:33:57 +02:00
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
2012-05-10 12:06:41 +02:00
|
|
|
******************************************************************************/
|
|
|
|
|
2013-09-25 09:36:55 +02:00
|
|
|
#ifndef CLUSTERLISTENER_H
|
|
|
|
#define CLUSTERLISTENER_H
|
2012-03-28 13:24:49 +02:00
|
|
|
|
2013-10-26 09:41:45 +02:00
|
|
|
#include "cluster/clusterlistener.th"
|
2013-08-27 12:21:41 +02:00
|
|
|
#include "base/dynamicobject.h"
|
|
|
|
#include "base/timer.h"
|
|
|
|
#include "base/array.h"
|
2013-03-16 21:18:53 +01:00
|
|
|
#include "base/tcpsocket.h"
|
|
|
|
#include "base/tlsstream.h"
|
2013-03-18 11:02:18 +01:00
|
|
|
#include "base/utility.h"
|
2013-08-27 12:21:41 +02:00
|
|
|
#include "base/tlsutility.h"
|
2013-09-03 10:08:02 +02:00
|
|
|
#include "base/stdiostream.h"
|
2013-09-18 09:09:16 +02:00
|
|
|
#include "base/workqueue.h"
|
2013-08-27 12:21:41 +02:00
|
|
|
#include "icinga/service.h"
|
2014-03-07 17:40:10 +01:00
|
|
|
#include "remote/endpoint.h"
|
2013-03-16 21:18:53 +01:00
|
|
|
|
2012-03-28 13:24:49 +02:00
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2012-05-15 16:24:04 +02:00
|
|
|
/**
|
2013-09-25 09:36:55 +02:00
|
|
|
* @ingroup cluster
|
2012-05-15 16:24:04 +02:00
|
|
|
*/
|
2013-11-04 23:14:34 +01:00
|
|
|
class ClusterListener : public ObjectImpl<ClusterListener>
|
2012-03-28 13:24:49 +02:00
|
|
|
{
|
2012-04-04 12:22:46 +02:00
|
|
|
public:
|
2013-09-25 09:36:55 +02:00
|
|
|
DECLARE_PTR_TYPEDEFS(ClusterListener);
|
|
|
|
DECLARE_TYPENAME(ClusterListener);
|
2012-03-28 13:24:49 +02:00
|
|
|
|
2014-02-17 16:34:18 +01:00
|
|
|
static Value StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& perfdata);
|
|
|
|
|
2013-08-27 12:21:41 +02:00
|
|
|
virtual void Start(void);
|
|
|
|
virtual void Stop(void);
|
2012-06-14 11:18:20 +02:00
|
|
|
|
2012-04-27 13:12:06 +02:00
|
|
|
shared_ptr<SSL_CTX> GetSSLContext(void) const;
|
2013-10-26 09:41:45 +02:00
|
|
|
String GetClusterDir(void) const;
|
2012-03-28 13:24:49 +02:00
|
|
|
|
2014-02-18 10:53:44 +01:00
|
|
|
std::pair<Dictionary::Ptr, Dictionary::Ptr> GetClusterStatus(void);
|
2014-02-13 19:23:38 +01:00
|
|
|
|
2012-05-21 23:42:54 +02:00
|
|
|
private:
|
2012-09-10 14:07:32 +02:00
|
|
|
shared_ptr<SSL_CTX> m_SSLContext;
|
|
|
|
|
2013-09-18 09:09:16 +02:00
|
|
|
WorkQueue m_RelayQueue;
|
|
|
|
WorkQueue m_MessageQueue;
|
|
|
|
WorkQueue m_LogQueue;
|
|
|
|
|
2013-08-30 09:34:58 +02:00
|
|
|
Timer::Ptr m_ClusterTimer;
|
|
|
|
void ClusterTimerHandler(void);
|
2012-05-21 23:42:54 +02:00
|
|
|
|
2013-03-16 21:18:53 +01:00
|
|
|
std::set<TcpSocket::Ptr> m_Servers;
|
2012-05-21 23:42:54 +02:00
|
|
|
|
2013-08-27 12:21:41 +02:00
|
|
|
void AddListener(const String& service);
|
|
|
|
void AddConnection(const String& node, const String& service);
|
2012-09-03 10:28:14 +02:00
|
|
|
|
2013-09-05 12:09:09 +02:00
|
|
|
static void ConfigGlobHandler(const Dictionary::Ptr& config, const String& file, bool basename);
|
2013-09-04 15:47:15 +02:00
|
|
|
|
2013-04-01 16:25:23 +02:00
|
|
|
void NewClientHandler(const Socket::Ptr& client, TlsRole role);
|
2013-04-04 16:08:02 +02:00
|
|
|
void ListenerThreadProc(const Socket::Ptr& server);
|
2013-08-27 12:21:41 +02:00
|
|
|
|
2013-09-18 09:16:29 +02:00
|
|
|
void AsyncRelayMessage(const Endpoint::Ptr& source, const Dictionary::Ptr& message, bool persistent);
|
2013-09-17 13:18:26 +02:00
|
|
|
void RelayMessage(const Endpoint::Ptr& source, const Dictionary::Ptr& message, bool persistent);
|
2013-09-02 15:12:20 +02:00
|
|
|
|
2013-09-03 10:08:02 +02:00
|
|
|
void OpenLogFile(void);
|
2013-09-03 15:56:48 +02:00
|
|
|
void RotateLogFile(void);
|
2013-09-03 10:08:02 +02:00
|
|
|
void CloseLogFile(void);
|
|
|
|
static void LogGlobHandler(std::vector<int>& files, const String& file);
|
|
|
|
void ReplayLog(const Endpoint::Ptr& endpoint, const Stream::Ptr& stream);
|
|
|
|
|
2013-09-03 14:05:03 +02:00
|
|
|
Stream::Ptr m_LogFile;
|
2013-09-03 10:08:02 +02:00
|
|
|
size_t m_LogMessageCount;
|
|
|
|
|
2014-04-10 10:58:08 +02:00
|
|
|
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const String& authority);
|
|
|
|
void NextCheckChangedHandler(const Checkable::Ptr& checkable, double nextCheck, const String& authority);
|
2013-08-28 14:59:41 +02:00
|
|
|
void NextNotificationChangedHandler(const Notification::Ptr& notification, double nextCheck, const String& authority);
|
2014-04-10 10:58:08 +02:00
|
|
|
void ForceNextCheckChangedHandler(const Checkable::Ptr& checkable, bool forced, const String& authority);
|
|
|
|
void ForceNextNotificationChangedHandler(const Checkable::Ptr& checkable, bool forced, const String& authority);
|
|
|
|
void EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled, const String& authority);
|
|
|
|
void EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable, bool enabled, const String& authority);
|
|
|
|
void EnableNotificationsChangedHandler(const Checkable::Ptr& checkable, bool enabled, const String& authority);
|
|
|
|
void EnableFlappingChangedHandler(const Checkable::Ptr& checkable, bool enabled, const String& authority);
|
|
|
|
void CommentAddedHandler(const Checkable::Ptr& checkable, const Comment::Ptr& comment, const String& authority);
|
|
|
|
void CommentRemovedHandler(const Checkable::Ptr& checkable, const Comment::Ptr& comment, const String& authority);
|
|
|
|
void DowntimeAddedHandler(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, const String& authority);
|
|
|
|
void DowntimeRemovedHandler(const Checkable::Ptr& checkable, const Downtime::Ptr& downtime, const String& authority);
|
|
|
|
void AcknowledgementSetHandler(const Checkable::Ptr& checkable, const String& author, const String& comment, AcknowledgementType type, double expiry, const String& authority);
|
|
|
|
void AcknowledgementClearedHandler(const Checkable::Ptr& checkable, const String& authority);
|
2013-09-18 09:09:16 +02:00
|
|
|
|
2013-09-18 09:16:29 +02:00
|
|
|
void AsyncMessageHandler(const Endpoint::Ptr& sender, const Dictionary::Ptr& message);
|
2013-08-28 11:12:20 +02:00
|
|
|
void MessageHandler(const Endpoint::Ptr& sender, const Dictionary::Ptr& message);
|
2013-09-13 07:49:12 +02:00
|
|
|
|
|
|
|
bool IsAuthority(const DynamicObject::Ptr& object, const String& type);
|
|
|
|
void UpdateAuthority(void);
|
2013-09-12 10:17:14 +02:00
|
|
|
|
|
|
|
static bool SupportsChecks(void);
|
|
|
|
static bool SupportsNotifications(void);
|
2014-02-13 15:15:16 +01:00
|
|
|
static bool SupportsFeature(const String& name);
|
2013-09-17 13:18:26 +02:00
|
|
|
|
|
|
|
void SetSecurityInfo(const Dictionary::Ptr& message, const DynamicObject::Ptr& object, int privs);
|
2013-09-18 09:09:16 +02:00
|
|
|
|
|
|
|
void PersistMessage(const Endpoint::Ptr& source, const Dictionary::Ptr& message);
|
2013-11-20 15:33:04 +01:00
|
|
|
|
|
|
|
static void MessageExceptionHandler(boost::exception_ptr exp);
|
2012-05-24 19:36:37 +02:00
|
|
|
};
|
|
|
|
|
2012-03-28 13:24:49 +02:00
|
|
|
}
|
|
|
|
|
2013-09-25 09:36:55 +02:00
|
|
|
#endif /* CLUSTERLISTENER_H */
|