Module: check_mk
Branch: master
Commit: 3a88914b4919e6b3b07adf910b80bef14baa50d8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3a88914b4919e6…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Mar 15 08:22:59 2017 +0100
Removed redundant MonitoringCore* members.
Change-Id: Icb55f91e4dc86a5ba304217af5609da078c2f514
---
livestatus/src/Table.h | 1 +
livestatus/src/TableContactGroups.cc | 5 ++---
livestatus/src/TableContactGroups.h | 3 ---
livestatus/src/TableEventConsole.cc | 16 ++++++++--------
livestatus/src/TableEventConsole.h | 2 --
livestatus/src/TableLog.cc | 4 ++--
livestatus/src/TableLog.h | 1 -
livestatus/src/TableStateHistory.cc | 4 ++--
livestatus/src/TableStateHistory.h | 1 -
9 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/livestatus/src/Table.h b/livestatus/src/Table.h
index 95d97bc..80195a7 100644
--- a/livestatus/src/Table.h
+++ b/livestatus/src/Table.h
@@ -93,6 +93,7 @@ public:
virtual bool isAuthorized(contact *ctc, void *data);
virtual void *findObject(const std::string &objectspec);
+ MonitoringCore *core() const { return _mc; }
Logger *logger() const;
private:
diff --git a/livestatus/src/TableContactGroups.cc b/livestatus/src/TableContactGroups.cc
index 651f080..05821bb 100644
--- a/livestatus/src/TableContactGroups.cc
+++ b/livestatus/src/TableContactGroups.cc
@@ -36,8 +36,7 @@ using std::string;
extern contactgroup *contactgroup_list;
-TableContactGroups::TableContactGroups(MonitoringCore *mc)
- : Table(mc), _mc(mc) {
+TableContactGroups::TableContactGroups(MonitoringCore *mc) : Table(mc) {
addColumn(make_unique<OffsetStringColumn>(
"name", "The name of the contactgroup",
DANGEROUS_OFFSETOF(contactgroup, group_name), -1, -1, -1));
@@ -61,5 +60,5 @@ void TableContactGroups::answerQuery(Query *query) {
}
void *TableContactGroups::findObject(const string &objectspec) {
- return _mc->find_contactgroup(objectspec);
+ return core()->find_contactgroup(objectspec);
}
diff --git a/livestatus/src/TableContactGroups.h b/livestatus/src/TableContactGroups.h
index 5116c33..d99e820 100644
--- a/livestatus/src/TableContactGroups.h
+++ b/livestatus/src/TableContactGroups.h
@@ -39,9 +39,6 @@ public:
std::string namePrefix() const override;
void answerQuery(Query *query) override;
void *findObject(const std::string &objectspec) override;
-
-private:
- MonitoringCore *_mc;
};
#endif // TableContactGroups_h
diff --git a/livestatus/src/TableEventConsole.cc b/livestatus/src/TableEventConsole.cc
index 03b882c..23d9498 100644
--- a/livestatus/src/TableEventConsole.cc
+++ b/livestatus/src/TableEventConsole.cc
@@ -98,13 +98,13 @@ private:
};
} // namespace
-TableEventConsole::TableEventConsole(MonitoringCore *mc) : Table(mc), _mc(mc) {}
+TableEventConsole::TableEventConsole(MonitoringCore *mc) : Table(mc) {}
void TableEventConsole::answerQuery(Query *query) {
- if (_mc->mkeventdEnabled()) {
+ if (core()->mkeventdEnabled()) {
try {
// skip "eventconsole" prefix :-P
- ECTableConnection(_mc, name().substr(12), query).run();
+ ECTableConnection(core(), name().substr(12), query).run();
} catch (const generic_error &ge) {
query->invalidRequest(ge.what());
}
@@ -127,8 +127,8 @@ bool TableEventConsole::isAuthorizedForEvent(contact *ctc, void *data)
{
isAuthorizedForEventViaHost(c, r, result) ||
isAuthorizedForEventViaContactGroups(c, r, result);
} else {
- Error(_mc->loggerLivestatus()) << "unknown precedence '"
<< precedence
- << "' in table " <<
name();
+ Error(logger()) << "unknown precedence '" << precedence
<< "' in table "
+ << name();
result = false;
}
return result;
@@ -142,8 +142,8 @@ bool TableEventConsole::isAuthorizedForEventViaContactGroups(
return false;
}
for (const auto &name : col->getValue(row)) {
- if (_mc->is_contact_member_of_contactgroup(_mc->find_contactgroup(name),
- ctc)) {
+ if (core()->is_contact_member_of_contactgroup(
+ core()->find_contactgroup(name), ctc)) {
return (result = true, true);
}
}
@@ -153,7 +153,7 @@ bool TableEventConsole::isAuthorizedForEventViaContactGroups(
bool TableEventConsole::isAuthorizedForEventViaHost(
MonitoringCore::Contact *ctc, Row *row, bool &result) {
if (MonitoringCore::Host *hst = row->_host) {
- return (result = _mc->host_has_contact(hst, ctc), true);
+ return (result = core()->host_has_contact(hst, ctc), true);
}
return false;
}
diff --git a/livestatus/src/TableEventConsole.h b/livestatus/src/TableEventConsole.h
index 24f5c4a..167b037 100644
--- a/livestatus/src/TableEventConsole.h
+++ b/livestatus/src/TableEventConsole.h
@@ -196,8 +196,6 @@ protected:
bool isAuthorizedForEvent(contact *ctc, void *data);
private:
- MonitoringCore *_mc;
-
bool isAuthorizedForEventViaContactGroups(MonitoringCore::Contact *ctc,
Row *row, bool &result);
bool isAuthorizedForEventViaHost(MonitoringCore::Contact *ctc, Row *row,
diff --git a/livestatus/src/TableLog.cc b/livestatus/src/TableLog.cc
index 98befde..fe7c0b5 100644
--- a/livestatus/src/TableLog.cc
+++ b/livestatus/src/TableLog.cc
@@ -61,7 +61,7 @@ TableLog::TableLog(LogCache *log_cache,
#endif
,
MonitoringCore *mc)
- : Table(mc), _mc(mc), _log_cache(log_cache) {
+ : Table(mc), _log_cache(log_cache) {
addColumn(make_unique<OffsetTimeColumn>(
"time", "Time of the log event (UNIX timestamp)",
DANGEROUS_OFFSETOF(LogEntry, _time), -1, -1, -1));
@@ -150,7 +150,7 @@ string TableLog::namePrefix() const { return "log_"; }
void TableLog::answerQuery(Query *query) {
lock_guard<mutex> lg(_log_cache->_lock);
- if (!_log_cache->logCachePreChecks(_mc)) {
+ if (!_log_cache->logCachePreChecks(core())) {
return;
}
diff --git a/livestatus/src/TableLog.h b/livestatus/src/TableLog.h
index 088a2d4..7898424 100644
--- a/livestatus/src/TableLog.h
+++ b/livestatus/src/TableLog.h
@@ -62,7 +62,6 @@ public:
std::shared_ptr<Column> column(std::string colname) override;
private:
- MonitoringCore *_mc;
LogCache *_log_cache;
bool answerQuery(Query *, Logfile *, time_t, time_t);
};
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index f549cc3..e07f8cf 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -109,7 +109,7 @@ TableStateHistory::TableStateHistory(LogCache *log_cache,
#endif
,
MonitoringCore *mc)
- : Table(mc), _mc(mc), _log_cache(log_cache) {
+ : Table(mc), _log_cache(log_cache) {
addColumn(make_unique<OffsetTimeColumn>(
"time", "Time of the log event (seconds since 1/1/1970)",
DANGEROUS_OFFSETOF(HostServiceState, _time), -1, -1, -1));
@@ -321,7 +321,7 @@ void TableStateHistory::answerQuery(Query *query) {
}
lock_guard<mutex> lg(_log_cache->_lock);
- if (!_log_cache->logCachePreChecks(_mc)) {
+ if (!_log_cache->logCachePreChecks(core())) {
return;
}
diff --git a/livestatus/src/TableStateHistory.h b/livestatus/src/TableStateHistory.h
index 0a21ace..fa3a2b5 100644
--- a/livestatus/src/TableStateHistory.h
+++ b/livestatus/src/TableStateHistory.h
@@ -72,7 +72,6 @@ protected:
bool _abort_query;
private:
- MonitoringCore *_mc;
LogCache *_log_cache;
int _query_timeframe;