1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
6 #include "icinga/i2-icinga.hpp"
7 #include "icinga/host-ti.hpp"
8 #include "icinga/macroresolver.hpp"
9 #include "icinga/checkresult.hpp"
21 class Host final : public ObjectImpl<Host>, public MacroResolver
25 DECLARE_OBJECTNAME(Host);
27 intrusive_ptr<Service> GetServiceByShortName(const Value& name);
29 std::vector<intrusive_ptr<Service> > GetServices() const;
30 void AddService(const intrusive_ptr<Service>& service);
31 void RemoveService(const intrusive_ptr<Service>& service);
33 int GetTotalServices() const;
35 static HostState CalculateState(ServiceState state);
37 HostState GetState() const override;
38 HostState GetLastState() const override;
39 HostState GetLastHardState() const override;
40 int GetSeverity() const override;
42 bool IsStateOK(ServiceState state) const override;
43 void SaveLastState(ServiceState state, double timestamp) override;
45 static HostState StateFromString(const String& state);
46 static String StateToString(HostState state);
48 static StateType StateTypeFromString(const String& state);
49 static String StateTypeToString(StateType state);
51 bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Value *result) const override;
54 void Stop(bool runtimeRemoved) override;
56 void OnAllConfigLoaded() override;
57 void CreateChildObjects(const Type::Ptr& childType) override;
60 mutable boost::mutex m_ServicesMutex;
61 std::map<String, intrusive_ptr<Service> > m_Services;
63 static void RefreshServicesCache();
70 #include "icinga/service.hpp"