From 0915b3ef56dfac3113cce55a59a5765dc94976be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:34:54 +0200 Subject: Adding upstream version 2.13.6. Signed-off-by: Daniel Baumann --- lib/compat/statusdatawriter.hpp | 89 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 lib/compat/statusdatawriter.hpp (limited to 'lib/compat/statusdatawriter.hpp') diff --git a/lib/compat/statusdatawriter.hpp b/lib/compat/statusdatawriter.hpp new file mode 100644 index 0000000..31a5efe --- /dev/null +++ b/lib/compat/statusdatawriter.hpp @@ -0,0 +1,89 @@ +/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ + +#ifndef STATUSDATAWRITER_H +#define STATUSDATAWRITER_H + +#include "compat/statusdatawriter-ti.hpp" +#include "icinga/customvarobject.hpp" +#include "icinga/host.hpp" +#include "icinga/service.hpp" +#include "icinga/command.hpp" +#include "icinga/compatutility.hpp" +#include "base/timer.hpp" +#include "base/utility.hpp" +#include + +namespace icinga +{ + +/** + * @ingroup compat + */ +class StatusDataWriter final : public ObjectImpl +{ +public: + DECLARE_OBJECT(StatusDataWriter); + DECLARE_OBJECTNAME(StatusDataWriter); + + static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); + +protected: + void Start(bool runtimeCreated) override; + void Stop(bool runtimeRemoved) override; + +private: + Timer::Ptr m_StatusTimer; + bool m_ObjectsCacheOutdated; + + void DumpCommand(std::ostream& fp, const Command::Ptr& command); + void DumpTimePeriod(std::ostream& fp, const TimePeriod::Ptr& tp); + void DumpDowntimes(std::ostream& fp, const Checkable::Ptr& owner); + void DumpComments(std::ostream& fp, const Checkable::Ptr& owner); + void DumpHostStatus(std::ostream& fp, const Host::Ptr& host); + void DumpHostObject(std::ostream& fp, const Host::Ptr& host); + + void DumpCheckableStatusAttrs(std::ostream& fp, const Checkable::Ptr& checkable); + + template + void DumpNameList(std::ostream& fp, const T& list) + { + bool first = true; + for (const auto& obj : list) { + if (!first) + fp << ","; + else + first = false; + + fp << obj->GetName(); + } + } + + template + void DumpStringList(std::ostream& fp, const T& list) + { + bool first = true; + for (const auto& str : list) { + if (!first) + fp << ","; + else + first = false; + + fp << str; + } + } + + void DumpServiceStatus(std::ostream& fp, const Service::Ptr& service); + void DumpServiceObject(std::ostream& fp, const Service::Ptr& service); + + void DumpCustomAttributes(std::ostream& fp, const CustomVarObject::Ptr& object); + + void UpdateObjectsCache(); + void StatusTimerHandler(); + void ObjectHandler(); + + static String GetNotificationOptions(const Checkable::Ptr& checkable); +}; + +} + +#endif /* STATUSDATAWRITER_H */ -- cgit v1.2.3