icinga2/lib/livestatus/livestatuslistener.hpp

48 lines
1.0 KiB
C++
Raw Normal View History

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2013-03-10 03:09:01 +01:00
2013-09-25 09:31:52 +02:00
#ifndef LIVESTATUSLISTENER_H
#define LIVESTATUSLISTENER_H
2013-03-10 03:09:01 +01:00
2015-02-26 09:02:45 +01:00
#include "livestatus/i2-livestatus.hpp"
2018-01-18 13:50:38 +01:00
#include "livestatus/livestatuslistener-ti.hpp"
2014-05-28 14:25:12 +02:00
#include "livestatus/livestatusquery.hpp"
2014-05-25 16:23:35 +02:00
#include "base/socket.hpp"
2017-11-21 12:12:58 +01:00
#include <thread>
2013-03-17 20:19:29 +01:00
using namespace icinga;
namespace icinga
2013-03-10 03:09:01 +01:00
{
/**
* @ingroup livestatus
*/
2018-01-04 06:11:04 +01:00
class LivestatusListener final : public ObjectImpl<LivestatusListener>
2013-03-10 03:09:01 +01:00
{
public:
2014-11-03 00:44:04 +01:00
DECLARE_OBJECT(LivestatusListener);
DECLARE_OBJECTNAME(LivestatusListener);
2013-09-25 09:31:52 +02:00
static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
static int GetClientsConnected();
static int GetConnections();
2013-03-10 03:09:01 +01:00
void ValidateSocketType(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
protected:
void Start(bool runtimeCreated) override;
void Stop(bool runtimeRemoved) override;
2013-03-10 03:09:01 +01:00
private:
void ServerThreadProc();
void ClientHandler(const Socket::Ptr& client);
Socket::Ptr m_Listener;
2017-11-21 12:12:58 +01:00
std::thread m_Thread;
2013-03-10 03:09:01 +01:00
};
}
2013-09-25 09:31:52 +02:00
#endif /* LIVESTATUSLISTENER_H */