]> granicus.if.org Git - icinga2/blob - lib/livestatus/livestatuslistener.hpp
Merge pull request #7185 from Icinga/bugfix/gelfwriter-wrong-log-facility
[icinga2] / lib / livestatus / livestatuslistener.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef LIVESTATUSLISTENER_H
4 #define LIVESTATUSLISTENER_H
5
6 #include "livestatus/i2-livestatus.hpp"
7 #include "livestatus/livestatuslistener-ti.hpp"
8 #include "livestatus/livestatusquery.hpp"
9 #include "base/socket.hpp"
10 #include <thread>
11
12 using namespace icinga;
13
14 namespace icinga
15 {
16
17 /**
18  * @ingroup livestatus
19  */
20 class LivestatusListener final : public ObjectImpl<LivestatusListener>
21 {
22 public:
23         DECLARE_OBJECT(LivestatusListener);
24         DECLARE_OBJECTNAME(LivestatusListener);
25
26         static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata);
27
28         static int GetClientsConnected();
29         static int GetConnections();
30
31         void ValidateSocketType(const Lazy<String>& lvalue, const ValidationUtils& utils) override;
32
33 protected:
34         void Start(bool runtimeCreated) override;
35         void Stop(bool runtimeRemoved) override;
36
37 private:
38         void ServerThreadProc();
39         void ClientHandler(const Socket::Ptr& client);
40
41         Socket::Ptr m_Listener;
42         std::thread m_Thread;
43 };
44
45 }
46
47 #endif /* LIVESTATUSLISTENER_H */