summaryrefslogtreecommitdiffstats
path: root/lib/compat/statusdatawriter.hpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:34:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:34:54 +0000
commit0915b3ef56dfac3113cce55a59a5765dc94976be (patch)
treea8fea11d50b4f083e1bf0f90025ece7f0824784a /lib/compat/statusdatawriter.hpp
parentInitial commit. (diff)
downloadicinga2-0915b3ef56dfac3113cce55a59a5765dc94976be.tar.xz
icinga2-0915b3ef56dfac3113cce55a59a5765dc94976be.zip
Adding upstream version 2.13.6.upstream/2.13.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--lib/compat/statusdatawriter.hpp89
1 files changed, 89 insertions, 0 deletions
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 <iostream>
+
+namespace icinga
+{
+
+/**
+ * @ingroup compat
+ */
+class StatusDataWriter final : public ObjectImpl<StatusDataWriter>
+{
+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<typename T>
+ 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<typename T>
+ 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 */