Module: check_mk
Branch: master
Commit: 25341cc2cdb07774798e4efd6ce15da5bb3658c4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=25341cc2cdb077…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Apr 11 13:58:24 2019 +0200
Untie the knot between Store and NagiosCore, part 2.
Change-Id: I2f6ff7d6a08c78708f78250c6f7d1940b2204ca4
---
livestatus/src/DynamicColumn.cc | 5 ++---
livestatus/src/DynamicColumn.h | 4 +---
livestatus/src/DynamicEventConsoleReplicationColumn.cc | 4 ++--
livestatus/src/DynamicLogwatchFileColumn.h | 7 +++----
livestatus/src/Store.h | 9 ++++++---
livestatus/src/TableHosts.cc | 4 ++--
livestatus/src/TableStatus.h | 7 +++++++
7 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/livestatus/src/DynamicColumn.cc b/livestatus/src/DynamicColumn.cc
index fd1423f..8992dbf 100644
--- a/livestatus/src/DynamicColumn.cc
+++ b/livestatus/src/DynamicColumn.cc
@@ -26,11 +26,10 @@
#include <utility>
DynamicColumn::DynamicColumn(std::string name, std::string description,
- Logger *logger, int indirect_offset,
- int extra_offset, int extra_extra_offset)
+ int indirect_offset, int extra_offset,
+ int extra_extra_offset)
: _name(std::move(name))
, _description(std::move(description))
- , _logger(logger)
, _indirect_offset(indirect_offset)
, _extra_offset(extra_offset)
, _extra_extra_offset(extra_extra_offset) {}
diff --git a/livestatus/src/DynamicColumn.h b/livestatus/src/DynamicColumn.h
index 493cfe4..d39d5f7 100644
--- a/livestatus/src/DynamicColumn.h
+++ b/livestatus/src/DynamicColumn.h
@@ -29,11 +29,10 @@
#include <memory>
#include <string>
class Column;
-class Logger;
class DynamicColumn {
public:
- DynamicColumn(std::string name, std::string description, Logger *logger,
+ DynamicColumn(std::string name, std::string description,
int indirect_offset, int extra_offset,
int extra_extra_offset);
virtual ~DynamicColumn();
@@ -44,7 +43,6 @@ public:
protected:
const std::string _name;
const std::string _description; // Note: Currently unused!
- Logger *const _logger;
const int _indirect_offset;
const int _extra_offset;
const int _extra_extra_offset;
diff --git a/livestatus/src/DynamicEventConsoleReplicationColumn.cc
b/livestatus/src/DynamicEventConsoleReplicationColumn.cc
index eadcde3..f7fc2d1 100644
--- a/livestatus/src/DynamicEventConsoleReplicationColumn.cc
+++ b/livestatus/src/DynamicEventConsoleReplicationColumn.cc
@@ -74,8 +74,8 @@ private:
DynamicEventConsoleReplicationColumn::DynamicEventConsoleReplicationColumn(
const std::string &name, const std::string &description, MonitoringCore *mc,
int indirect_offset, int extra_offset, int extra_extra_offset)
- : DynamicColumn(name, description, mc->loggerLivestatus(), indirect_offset,
- extra_offset, extra_extra_offset)
+ : DynamicColumn(name, description, indirect_offset, extra_offset,
+ extra_extra_offset)
, _mc(mc) {}
std::unique_ptr<Column> DynamicEventConsoleReplicationColumn::createColumn(
diff --git a/livestatus/src/DynamicLogwatchFileColumn.h
b/livestatus/src/DynamicLogwatchFileColumn.h
index e071935..476a558 100644
--- a/livestatus/src/DynamicLogwatchFileColumn.h
+++ b/livestatus/src/DynamicLogwatchFileColumn.h
@@ -30,17 +30,16 @@
#include <string>
#include "DynamicColumn.h"
class Column;
-class Logger;
class MonitoringCore;
class DynamicLogwatchFileColumn : public DynamicColumn {
public:
DynamicLogwatchFileColumn(const std::string &name,
- const std::string &description, Logger *logger,
+ const std::string &description,
MonitoringCore *mc, int indirect_offset,
int extra_offset, int extra_extra_offset)
- : DynamicColumn(name, description, logger, indirect_offset,
- extra_offset, extra_extra_offset)
+ : DynamicColumn(name, description, indirect_offset, extra_offset,
+ extra_extra_offset)
, _mc(mc) {}
~DynamicLogwatchFileColumn() override = default;
std::unique_ptr<Column> createColumn(const std::string &name,
diff --git a/livestatus/src/Store.h b/livestatus/src/Store.h
index f107a23..03c02bf 100644
--- a/livestatus/src/Store.h
+++ b/livestatus/src/Store.h
@@ -67,7 +67,7 @@ class OutputBuffer;
#ifdef CMC
#include <cstdint>
#include "TableCachedStatehist.h"
-class GlobalConfig;
+class Core;
class Object;
#else
#include <mutex>
@@ -77,8 +77,8 @@ class Object;
class Store {
public:
- explicit Store(MonitoringCore *mc);
#ifdef CMC
+ Store(MonitoringCore *mc, Core *core);
LogCache *logCache() { return &_log_cache; };
bool answerRequest(InputBuffer *, OutputBuffer *);
bool answerGetRequest(const std::list<std::string> &lines,
@@ -94,6 +94,7 @@ public:
void addDowntimeToStatehistCache(Object *object, bool started);
void addFlappingToStatehistCache(Object *object, bool started);
#else
+ explicit Store(MonitoringCore *mc);
bool answerRequest(InputBuffer &input, OutputBuffer &output);
void registerDowntime(nebstruct_downtime_data *data);
@@ -111,6 +112,9 @@ private:
};
MonitoringCore *_mc;
+#ifdef CMC
+ Core *_core;
+#endif
#ifndef CMC
// TODO(sp) These fields should better be somewhere else, e.g. module.cc
public:
@@ -159,7 +163,6 @@ private:
void addTable(Table &table);
Table &findTable(OutputBuffer &output, const std::string &name);
#ifdef CMC
- const GlobalConfig *config() const;
uint32_t horizon() const;
#else
void logRequest(const std::string &line,
diff --git a/livestatus/src/TableHosts.cc b/livestatus/src/TableHosts.cc
index 14e8f3e..d3e7de8 100644
--- a/livestatus/src/TableHosts.cc
+++ b/livestatus/src/TableHosts.cc
@@ -662,8 +662,8 @@ void TableHosts::addColumns(Table *table, const std::string
&prefix,
table->addDynamicColumn(std::make_unique<DynamicLogwatchFileColumn>(
prefix + "mk_logwatch_file",
- "This contents of a logfile fetched via mk_logwatch",
table->logger(),
- table->core(), indirect_offset, extra_offset, -1));
+ "This contents of a logfile fetched via mk_logwatch",
table->core(),
+ indirect_offset, extra_offset, -1));
table->addColumn(std::make_unique<HostSpecialDoubleColumn>(
prefix + "staleness", "Staleness indicator for this host",
diff --git a/livestatus/src/TableStatus.h b/livestatus/src/TableStatus.h
index bceafbd..f9bea1a 100644
--- a/livestatus/src/TableStatus.h
+++ b/livestatus/src/TableStatus.h
@@ -29,12 +29,19 @@
#include <string>
#include "Table.h"
#include "global_counters.h"
+#ifdef CMC
+class Core;
+#endif
class MonitoringCore;
class Query;
class TableStatus : public Table {
public:
+#ifdef CMC
+ TableStatus(MonitoringCore *mc, Core *core);
+#else
explicit TableStatus(MonitoringCore *mc);
+#endif
std::string name() const override;
std::string namePrefix() const override;