Module: check_mk
Branch: master
Commit: 70c11be2f730b4b9e9985f7c704af56345e964e8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=70c11be2f730b4…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Dec 27 15:52:24 2016 +0100
Fetched livestatus from downstream.
Change-Id: I09fd0dbdce1699dd9d21f730d5ecc3c93bc2e49d
---
livestatus/src/CustomVarsColumn.cc | 12 ++++++++++++
livestatus/src/CustomVarsColumn.h | 2 +-
livestatus/src/CustomVarsDictColumn.h | 9 +++++++--
livestatus/src/CustomVarsNamesColumn.h | 9 +++++++--
livestatus/src/CustomVarsValuesColumn.h | 10 +++++++---
livestatus/src/TableContacts.cc | 12 ++++++------
livestatus/src/TableServices.cc | 12 ++++++------
7 files changed, 46 insertions(+), 20 deletions(-)
diff --git a/livestatus/src/CustomVarsColumn.cc b/livestatus/src/CustomVarsColumn.cc
index 34ee280..41bf0ee 100644
--- a/livestatus/src/CustomVarsColumn.cc
+++ b/livestatus/src/CustomVarsColumn.cc
@@ -24,7 +24,12 @@
#include "CustomVarsColumn.h"
#include <utility>
+
+#ifdef CMC
+#include "Object.h"
+#else
#include "nagios.h"
+#endif
using std::string;
using std::unordered_map;
@@ -36,7 +41,13 @@ CustomVarsColumn::CustomVarsColumn(string name, string description, int
offset,
CustomVarsColumn::~CustomVarsColumn() = default;
+// TODO(sp) This should live in our abstraction layer for cores.
unordered_map<string, string> CustomVarsColumn::getCVM(void *row) const {
+#ifdef CMC
+ Object *data = static_cast<Object *>(shiftPointer(row));
+ return data == nullptr ? unordered_map<string, string>()
+ : data->customAttributes();
+#else
unordered_map<string, string> result;
if (char *data = static_cast<char *>(shiftPointer(row))) {
for (customvariablesmember *cvm =
@@ -46,6 +57,7 @@ unordered_map<string, string> CustomVarsColumn::getCVM(void *row)
const {
}
}
return result;
+#endif
}
string CustomVarsColumn::getVariable(void *row, const string &varname) {
diff --git a/livestatus/src/CustomVarsColumn.h b/livestatus/src/CustomVarsColumn.h
index 5a59f0e..8a4a3e1 100644
--- a/livestatus/src/CustomVarsColumn.h
+++ b/livestatus/src/CustomVarsColumn.h
@@ -33,7 +33,7 @@
class CustomVarsColumn : public Column {
public:
CustomVarsColumn(std::string name, std::string description, int offset,
- int indirect_offset, int extra_offset = -1);
+ int indirect_offset, int extra_offset);
virtual ~CustomVarsColumn();
virtual bool contains(void *row, const std::string &value) = 0;
std::string getVariable(void *row, const std::string &varname);
diff --git a/livestatus/src/CustomVarsDictColumn.h
b/livestatus/src/CustomVarsDictColumn.h
index 338dfd9..a2aad88 100644
--- a/livestatus/src/CustomVarsDictColumn.h
+++ b/livestatus/src/CustomVarsDictColumn.h
@@ -30,15 +30,20 @@
#include <string>
#include "Column.h"
#include "CustomVarsColumn.h"
-#include "nagios.h"
#include "opids.h"
class Filter;
class RowRenderer;
+#ifdef CMC
+#include "cmc.h"
+#else
+#include "nagios.h"
+#endif
+
class CustomVarsDictColumn : public CustomVarsColumn {
public:
CustomVarsDictColumn(std::string name, std::string description, int offset,
- int indirect_offset, int extra_offset = -1);
+ int indirect_offset, int extra_offset);
ColumnType type() override;
void output(void *row, RowRenderer &r, contact *auth_user) override;
std::unique_ptr<Filter> createFilter(RelationalOperator relOp,
diff --git a/livestatus/src/CustomVarsNamesColumn.h
b/livestatus/src/CustomVarsNamesColumn.h
index 97bb5a4..beb58af 100644
--- a/livestatus/src/CustomVarsNamesColumn.h
+++ b/livestatus/src/CustomVarsNamesColumn.h
@@ -30,15 +30,20 @@
#include <string>
#include "Column.h"
#include "CustomVarsColumn.h"
-#include "nagios.h"
#include "opids.h"
class Filter;
class RowRenderer;
+#ifdef CMC
+#include "cmc.h"
+#else
+#include "nagios.h"
+#endif
+
class CustomVarsNamesColumn : public CustomVarsColumn {
public:
CustomVarsNamesColumn(std::string name, std::string description, int offset,
- int indirect_offset, int extra_offset = -1);
+ int indirect_offset, int extra_offset);
ColumnType type() override;
void output(void *row, RowRenderer &r, contact *auth_user) override;
std::unique_ptr<Filter> createFilter(RelationalOperator relOp,
diff --git a/livestatus/src/CustomVarsValuesColumn.h
b/livestatus/src/CustomVarsValuesColumn.h
index 8161520..fd8c623 100644
--- a/livestatus/src/CustomVarsValuesColumn.h
+++ b/livestatus/src/CustomVarsValuesColumn.h
@@ -30,16 +30,20 @@
#include <string>
#include "Column.h"
#include "CustomVarsColumn.h"
-#include "nagios.h"
#include "opids.h"
class Filter;
class RowRenderer;
+#ifdef CMC
+#include "cmc.h"
+#else
+#include "nagios.h"
+#endif
+
class CustomVarsValuesColumn : public CustomVarsColumn {
public:
CustomVarsValuesColumn(std::string name, std::string description,
- int offset, int indirect_offset,
- int extra_offset = -1);
+ int offset, int indirect_offset, int extra_offset);
ColumnType type() override;
void output(void *row, RowRenderer &r, contact *auth_user) override;
std::unique_ptr<Filter> createFilter(RelationalOperator relOp,
diff --git a/livestatus/src/TableContacts.cc b/livestatus/src/TableContacts.cc
index 828000f..1ccfca5 100644
--- a/livestatus/src/TableContacts.cc
+++ b/livestatus/src/TableContacts.cc
@@ -120,17 +120,17 @@ void TableContacts::addColumns(Table *table, const string
&prefix,
table->addColumn(make_unique<CustomVarsNamesColumn>(
prefix + "custom_variable_names",
"A list of all custom variables of the contact",
- reinterpret_cast<char *>(&ctc.custom_variables) - ref,
- indirect_offset));
+ reinterpret_cast<char *>(&ctc.custom_variables) - ref,
indirect_offset,
+ -1));
table->addColumn(make_unique<CustomVarsValuesColumn>(
prefix + "custom_variable_values",
"A list of the values of all custom variables of the contact",
- reinterpret_cast<char *>(&ctc.custom_variables) - ref,
- indirect_offset));
+ reinterpret_cast<char *>(&ctc.custom_variables) - ref,
indirect_offset,
+ -1));
table->addColumn(make_unique<CustomVarsDictColumn>(
prefix + "custom_variables", "A dictionary of the custom
variables",
- reinterpret_cast<char *>(&ctc.custom_variables) - ref,
- indirect_offset));
+ reinterpret_cast<char *>(&ctc.custom_variables) - ref,
indirect_offset,
+ -1));
table->addColumn(make_unique<AttributeListAsIntColumn>(
prefix + "modified_attributes",
"A bitmask specifying which attributes have been modified",
diff --git a/livestatus/src/TableServices.cc b/livestatus/src/TableServices.cc
index 379a888..98cf537 100644
--- a/livestatus/src/TableServices.cc
+++ b/livestatus/src/TableServices.cc
@@ -458,17 +458,17 @@ void TableServices::addColumns(Table *table, const string
&prefix,
table->addColumn(make_unique<CustomVarsNamesColumn>(
prefix + "custom_variable_names",
"A list of the names of all custom variables of the service",
- reinterpret_cast<char *>(&svc.custom_variables) - ref,
- indirect_offset));
+ reinterpret_cast<char *>(&svc.custom_variables) - ref,
indirect_offset,
+ -1));
table->addColumn(make_unique<CustomVarsValuesColumn>(
prefix + "custom_variable_values",
"A list of the values of all custom variable of the service",
- reinterpret_cast<char *>(&svc.custom_variables) - ref,
- indirect_offset));
+ reinterpret_cast<char *>(&svc.custom_variables) - ref,
indirect_offset,
+ -1));
table->addColumn(make_unique<CustomVarsDictColumn>(
prefix + "custom_variables", "A dictionary of the custom
variables",
- reinterpret_cast<char *>(&svc.custom_variables) - ref,
- indirect_offset));
+ reinterpret_cast<char *>(&svc.custom_variables) - ref,
indirect_offset,
+ -1));
table->addColumn(make_unique<ServiceGroupsColumn>(
prefix + "groups", "A list of all service groups the service is
in",