From 333ba6ee7ef67840c64010cb6f0ae9645c5313b3 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 18 Dec 2013 16:28:33 +0100 Subject: [PATCH] Livestatus: Move log entry parsing into FetchRows(). Refs #5351 --- components/livestatus/logtable.cpp | 19 ++++++++++--------- components/livestatus/logtable.h | 1 + components/livestatus/statehisttable.cpp | 19 ++++++++++--------- components/livestatus/statehisttable.h | 1 + 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/components/livestatus/logtable.cpp b/components/livestatus/logtable.cpp index 86a6f53d0..27b2086e1 100644 --- a/components/livestatus/logtable.cpp +++ b/components/livestatus/logtable.cpp @@ -49,17 +49,10 @@ using namespace icinga; LogTable::LogTable(const String& compat_log_path, time_t from, time_t until) { - Log(LogInformation, "livestatus", "Pre-selecting log file from " + Convert::ToString(from) + " until " + Convert::ToString(until)); - - /* store from & until for FetchRows */ + /* store attributes for FetchRows */ m_TimeFrom = from; m_TimeUntil = until; - - /* create log file index */ - LogUtility::CreateLogIndex(compat_log_path, m_LogFileIndex); - - /* generate log cache */ - LogUtility::CreateLogCache(m_LogFileIndex, this, from, until); + m_CompatLogPath = compat_log_path; AddColumns(this); } @@ -104,6 +97,14 @@ String LogTable::GetName(void) const void LogTable::FetchRows(const AddRowFunction& addRowFn) { + Log(LogInformation, "livestatus", "Pre-selecting log file from " + Convert::ToString(m_TimeFrom) + " until " + Convert::ToString(m_TimeUntil)); + + /* create log file index */ + LogUtility::CreateLogIndex(m_CompatLogPath, m_LogFileIndex); + + /* generate log cache */ + LogUtility::CreateLogCache(m_LogFileIndex, this, m_TimeFrom, m_TimeUntil); + unsigned long line_count; BOOST_FOREACH(boost::tie(line_count, boost::tuples::ignore), m_RowsCache) { diff --git a/components/livestatus/logtable.h b/components/livestatus/logtable.h index 082d7dc4f..4a9b4d60b 100644 --- a/components/livestatus/logtable.h +++ b/components/livestatus/logtable.h @@ -74,6 +74,7 @@ private: std::map m_RowsCache; time_t m_TimeFrom; time_t m_TimeUntil; + String m_CompatLogPath; }; } diff --git a/components/livestatus/statehisttable.cpp b/components/livestatus/statehisttable.cpp index d5d816ce9..371d8f458 100644 --- a/components/livestatus/statehisttable.cpp +++ b/components/livestatus/statehisttable.cpp @@ -50,17 +50,10 @@ using namespace icinga; StateHistTable::StateHistTable(const String& compat_log_path, time_t from, time_t until) { - Log(LogInformation, "livestatus", "Pre-selecting log file from " + Convert::ToString(from) + " until " + Convert::ToString(until)); - - /* store from & until for FetchRows */ + /* store attributes for FetchRows */ m_TimeFrom = from; m_TimeUntil = until; - - /* create log file index */ - LogUtility::CreateLogIndex(compat_log_path, m_LogFileIndex); - - /* generate log cache */ - LogUtility::CreateLogCache(m_LogFileIndex, this, from, until); + m_CompatLogPath = compat_log_path; AddColumns(this); } @@ -254,6 +247,14 @@ String StateHistTable::GetName(void) const void StateHistTable::FetchRows(const AddRowFunction& addRowFn) { + Log(LogInformation, "livestatus", "Pre-selecting log file from " + Convert::ToString(m_TimeFrom) + " until " + Convert::ToString(m_TimeUntil)); + + /* create log file index */ + LogUtility::CreateLogIndex(m_CompatLogPath, m_LogFileIndex); + + /* generate log cache */ + LogUtility::CreateLogCache(m_LogFileIndex, this, m_TimeFrom, m_TimeUntil); + Service::Ptr state_hist_service; BOOST_FOREACH(boost::tie(state_hist_service, boost::tuples::ignore), m_ServicesCache) { diff --git a/components/livestatus/statehisttable.h b/components/livestatus/statehisttable.h index 6fcc74257..88c2170b8 100644 --- a/components/livestatus/statehisttable.h +++ b/components/livestatus/statehisttable.h @@ -84,6 +84,7 @@ private: std::map m_ServicesCache; time_t m_TimeFrom; time_t m_TimeUntil; + String m_CompatLogPath; }; } -- 2.40.0