Module: check_mk
Branch: master
Commit: eaff1ae1819f2a68fdffa3951554bb2cbe2d991d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eaff1ae1819f2a…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Nov 6 10:05:05 2017 +0100
Unifiy host/service groups column implementation.
Change-Id: I141809e0c34f9a4a6cceae4ab2e38b5d2887e395
---
livestatus/src/HostGroupsColumn.cc | 17 +++++++++++++++++
livestatus/src/ServiceGroupsColumn.cc | 17 +++++++++++++++++
livestatus/src/ServiceGroupsColumn.h | 2 +-
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/livestatus/src/HostGroupsColumn.cc b/livestatus/src/HostGroupsColumn.cc
index 22f470c..63460aa 100644
--- a/livestatus/src/HostGroupsColumn.cc
+++ b/livestatus/src/HostGroupsColumn.cc
@@ -24,13 +24,29 @@
#include "HostGroupsColumn.h"
#include "Row.h"
+
+#ifdef CMC
+#include "Object.h"
+#include "ObjectGroup.h"
+#include "cmc.h"
+#else
#include "auth.h"
#include "nagios.h"
+#endif
std::vector<std::string> HostGroupsColumn::getValue(
Row row, const contact *auth_user,
std::chrono::seconds /*timezone_offset*/) const {
std::vector<std::string> group_names;
+#ifdef CMC
+ if (auto object = columnData<Object>(row)) {
+ for (const auto &og : object->_groups) {
+ if (og->isContactAuthorized(_mc, auth_user)) {
+ group_names.push_back(og->name());
+ }
+ }
+ }
+#else
if (auto p = columnData<objectlist *>(row)) {
for (objectlist *list = *p; list != nullptr; list = list->next) {
auto hg = static_cast<hostgroup *>(list->object_ptr);
@@ -39,5 +55,6 @@ std::vector<std::string> HostGroupsColumn::getValue(
}
}
}
+#endif
return group_names;
}
diff --git a/livestatus/src/ServiceGroupsColumn.cc
b/livestatus/src/ServiceGroupsColumn.cc
index a5f6aed..af7451f 100644
--- a/livestatus/src/ServiceGroupsColumn.cc
+++ b/livestatus/src/ServiceGroupsColumn.cc
@@ -24,13 +24,29 @@
#include "ServiceGroupsColumn.h"
#include "Row.h"
+
+#ifdef CMC
+#include "Object.h"
+#include "ObjectGroup.h"
+#include "cmc.h"
+#else
#include "auth.h"
#include "nagios.h"
+#endif
std::vector<std::string> ServiceGroupsColumn::getValue(
Row row, const contact *auth_user,
std::chrono::seconds /*timezone_offset*/) const {
std::vector<std::string> group_names;
+#ifdef CMC
+ if (auto object = columnData<Object>(row)) {
+ for (const auto &og : object->_groups) {
+ if (og->isContactAuthorized(_mc, auth_user)) {
+ group_names.push_back(og->name());
+ }
+ }
+ }
+#else
if (auto p = columnData<objectlist *>(row)) {
for (objectlist *list = *p; list != nullptr; list = list->next) {
auto sg = static_cast<servicegroup *>(list->object_ptr);
@@ -39,5 +55,6 @@ std::vector<std::string> ServiceGroupsColumn::getValue(
}
}
}
+#endif
return group_names;
}
diff --git a/livestatus/src/ServiceGroupsColumn.h b/livestatus/src/ServiceGroupsColumn.h
index ec1d199..f715a7e 100644
--- a/livestatus/src/ServiceGroupsColumn.h
+++ b/livestatus/src/ServiceGroupsColumn.h
@@ -45,7 +45,7 @@ public:
std::vector<std::string> getValue(
Row row, const contact *auth_user,
- std::chrono::seconds /*timezone_offset*/) const override;
+ std::chrono::seconds timezone_offset) const override;
private:
MonitoringCore *const _mc;