Module: check_mk
Branch: master
Commit: 1a116c130bba7c8e6c75750735bedb0cc1786f1b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1a116c130bba7c…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Feb 27 12:03:23 2019 +0100
Decouple LogEntry from MonitoringCore, part 2.
This time we do this in TableStateHistory.
CMK-1753
Change-Id: I5c7999595b2a85f2abf2d59bd22c33fe52bc3d18
---
livestatus/src/TableStateHistory.cc | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index 732c3d8..58b78d2 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -38,6 +38,7 @@
#include "HostServiceState.h"
#include "LogEntry.h"
#include "Logger.h"
+#include "MonitoringCore.h"
#include "OffsetDoubleColumn.h"
#include "OffsetIntColumn.h"
#include "OffsetSStringColumn.h"
@@ -378,6 +379,11 @@ void TableStateHistory::answerQuery(Query *query) {
HostServiceKey key = nullptr;
bool is_service = false;
+ // TODO(sp): Remove ugly casts.
+ auto entry_host =
+ reinterpret_cast<host *>(core()->find_host(entry->_host_name));
+ auto entry_service = reinterpret_cast<service *>(core()->find_service(
+ entry->_host_name, entry->_service_description));
switch (entry->_kind) {
case LogEntryKind::none:
case LogEntryKind::core_starting:
@@ -391,7 +397,7 @@ void TableStateHistory::answerQuery(Query *query) {
case LogEntryKind::state_service_initial:
case LogEntryKind::downtime_alert_service:
case LogEntryKind::flapping_service:
- key = entry->_service;
+ key = entry_service;
is_service = true;
// fall-through
case LogEntryKind::alert_host:
@@ -400,7 +406,7 @@ void TableStateHistory::answerQuery(Query *query) {
case LogEntryKind::downtime_alert_host:
case LogEntryKind::flapping_host: {
if (!is_service) {
- key = entry->_host;
+ key = entry_host;
}
if (key == nullptr) {
@@ -421,8 +427,8 @@ void TableStateHistory::answerQuery(Query *query) {
// now
state = new HostServiceState();
state->_is_host = entry->_service_description.empty();
- state->_host = entry->_host;
- state->_service = entry->_service;
+ state->_host = entry_host;
+ state->_service = entry_service;
state->_host_name = entry->_host_name;
state->_service_description = entry->_service_description;