icinga2/components/cluster/clustercomponent.h

127 lines
5.5 KiB
C
Raw Normal View History

/******************************************************************************
* Icinga 2 *
* Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
* *
* 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. *
******************************************************************************/
#ifndef CLUSTERCOMPONENT_H
#define CLUSTERCOMPONENT_H
2012-03-28 13:24:49 +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"
#include "base/tlsutility.h"
#include "base/stdiostream.h"
#include "icinga/service.h"
#include "cluster/endpoint.h"
2013-03-16 21:18:53 +01:00
2012-03-28 13:24:49 +02:00
namespace icinga
{
/**
* @ingroup demo
*/
class ClusterComponent : public DynamicObject
2012-03-28 13:24:49 +02:00
{
public:
DECLARE_PTR_TYPEDEFS(ClusterComponent);
DECLARE_TYPENAME(ClusterComponent);
2012-03-28 13:24:49 +02:00
virtual void Start(void);
virtual void Stop(void);
String GetCertificateFile(void) const;
String GetCAFile(void) const;
String GetBindHost(void) const;
String GetBindPort(void) const;
Array::Ptr GetPeers(void) const;
String GetClusterDir(void) const;
2012-06-27 18:43:34 +02:00
2012-04-27 13:12:06 +02:00
shared_ptr<SSL_CTX> GetSSLContext(void) const;
String GetIdentity(void) const;
2012-04-27 13:12:06 +02:00
protected:
virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const;
virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes);
2012-03-28 13:24:49 +02:00
private:
String m_CertPath;
String m_CAPath;
String m_BindHost;
String m_BindPort;
Array::Ptr m_Peers;
2012-09-10 14:07:32 +02:00
shared_ptr<SSL_CTX> m_SSLContext;
String m_Identity;
2012-09-10 14:07:32 +02:00
2013-08-30 09:34:58 +02:00
Timer::Ptr m_ClusterTimer;
void ClusterTimerHandler(void);
2013-03-16 21:18:53 +01:00
std::set<TcpSocket::Ptr> m_Servers;
void AddListener(const String& service);
void AddConnection(const String& node, const String& service);
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-09-17 13:18:26 +02:00
void RelayMessage(const Endpoint::Ptr& source, const Dictionary::Ptr& message, bool persistent);
void OpenLogFile(void);
void RotateLogFile(void);
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;
double m_LogMessageTimestamp;
size_t m_LogMessageCount;
2013-08-28 11:12:20 +02:00
void CheckResultHandler(const Service::Ptr& service, const Dictionary::Ptr& cr, const String& authority);
void NextCheckChangedHandler(const Service::Ptr& service, double nextCheck, const String& authority);
2013-08-28 14:59:41 +02:00
void NextNotificationChangedHandler(const Notification::Ptr& notification, double nextCheck, const String& authority);
2013-08-28 11:12:20 +02:00
void ForceNextCheckChangedHandler(const Service::Ptr& service, bool forced, const String& authority);
void ForceNextNotificationChangedHandler(const Service::Ptr& service, bool forced, const String& authority);
2013-08-28 11:12:20 +02:00
void EnableActiveChecksChangedHandler(const Service::Ptr& service, bool enabled, const String& authority);
void EnablePassiveChecksChangedHandler(const Service::Ptr& service, bool enabled, const String& authority);
void EnableNotificationsChangedHandler(const Service::Ptr& service, bool enabled, const String& authority);
void EnableFlappingChangedHandler(const Service::Ptr& service, bool enabled, const String& authority);
2013-08-28 14:59:41 +02:00
void CommentAddedHandler(const Service::Ptr& service, const Dictionary::Ptr& comment, const String& authority);
void CommentRemovedHandler(const Service::Ptr& service, const Dictionary::Ptr& comment, const String& authority);
void DowntimeAddedHandler(const Service::Ptr& service, const Dictionary::Ptr& downtime, const String& authority);
void DowntimeRemovedHandler(const Service::Ptr& service, const Dictionary::Ptr& downtime, const String& authority);
void AcknowledgementSetHandler(const Service::Ptr& service, const String& author, const String& comment, AcknowledgementType type, double expiry, const String& authority);
void AcknowledgementClearedHandler(const Service::Ptr& service, const String& authority);
2013-08-28 11:12:20 +02:00
void MessageHandler(const Endpoint::Ptr& sender, const Dictionary::Ptr& message);
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);
2013-09-17 13:18:26 +02:00
void SetSecurityInfo(const Dictionary::Ptr& message, const DynamicObject::Ptr& object, int privs);
};
2012-03-28 13:24:49 +02:00
}
#endif /* CLUSTERCOMPONENT_H */