Module: check_mk
Branch: master
Commit: bcd0516f4a053f0cbb4332132d1be90dd108baf6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bcd0516f4a053f…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Nov 6 13:35:37 2017 +0100
Unify contact collumn implementations.
Change-Id: I3b4225626638c71054db0eef81271634c8f8ac89
---
livestatus/src/HostContactsColumn.cc | 16 +++++++++++++++-
livestatus/src/ServiceContactsColumn.cc | 16 +++++++++++++++-
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/livestatus/src/HostContactsColumn.cc b/livestatus/src/HostContactsColumn.cc
index 5abb163..e57695d 100644
--- a/livestatus/src/HostContactsColumn.cc
+++ b/livestatus/src/HostContactsColumn.cc
@@ -23,13 +23,26 @@
// Boston, MA 02110-1301 USA.
#include "HostContactsColumn.h"
-#include <unordered_set>
#include "Row.h"
+
+#ifdef CMC
+#include "ContactList.h"
+#include "Object.h"
+#include "cmc.h"
+#else
+#include <unordered_set>
#include "nagios.h"
+#endif
std::vector<std::string> HostContactsColumn::getValue(
Row row, const contact* /*auth_user*/,
std::chrono::seconds /*timezone_offset*/) const {
+#ifdef CMC
+ if (auto object = columnData<Object>(row)) {
+ return object->_contact_list->contactNames();
+ }
+ return {};
+#else
std::unordered_set<std::string> names;
if (auto hst = columnData<host>(row)) {
for (auto cm = hst->contacts; cm != nullptr; cm = cm->next) {
@@ -43,4 +56,5 @@ std::vector<std::string> HostContactsColumn::getValue(
}
}
return std::vector<std::string>(names.begin(), names.end());
+#endif
}
diff --git a/livestatus/src/ServiceContactsColumn.cc
b/livestatus/src/ServiceContactsColumn.cc
index 2a9dd48..5f7f55d 100644
--- a/livestatus/src/ServiceContactsColumn.cc
+++ b/livestatus/src/ServiceContactsColumn.cc
@@ -23,13 +23,26 @@
// Boston, MA 02110-1301 USA.
#include "ServiceContactsColumn.h"
-#include <unordered_set>
#include "Row.h"
+
+#ifdef CMC
+#include "ContactList.h"
+#include "Object.h"
+#include "cmc.h"
+#else
+#include <unordered_set>
#include "nagios.h"
+#endif
std::vector<std::string> ServiceContactsColumn::getValue(
Row row, const contact* /*auth_user*/,
std::chrono::seconds /*timezone_offset*/) const {
+#ifdef CMC
+ if (auto object = columnData<Object>(row)) {
+ return object->_contact_list->contactNames();
+ }
+ return {};
+#else
std::unordered_set<std::string> names;
if (auto svc = columnData<service>(row)) {
for (auto cm = svc->contacts; cm != nullptr; cm = cm->next) {
@@ -43,4 +56,5 @@ std::vector<std::string> ServiceContactsColumn::getValue(
}
}
return std::vector<std::string>(names.begin(), names.end());
+#endif
}