]> granicus.if.org Git - icinga2/commitdiff
Livestatus: Move log entry parsing into FetchRows().
authorMichael Friedrich <michael.friedrich@netways.de>
Wed, 18 Dec 2013 15:28:33 +0000 (16:28 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Wed, 18 Dec 2013 15:28:33 +0000 (16:28 +0100)
Refs #5351

components/livestatus/logtable.cpp
components/livestatus/logtable.h
components/livestatus/statehisttable.cpp
components/livestatus/statehisttable.h

index 86a6f53d01f5203e1a587b7754c5b6e99d1984e1..27b2086e1d65a4b8b676cf6127c27db0a4754185 100644 (file)
@@ -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) {
index 082d7dc4f78a7351153250193e88382b6a1c5572..4a9b4d60be30b9ef3f359b54a547dae7dd6fccba 100644 (file)
@@ -74,6 +74,7 @@ private:
         std::map<time_t, Dictionary::Ptr> m_RowsCache;
         time_t m_TimeFrom;
         time_t m_TimeUntil;
+        String m_CompatLogPath;
 };
 
 }
index d5d816ce9174b8437247dc29f67df7e67827eec8..371d8f458876c593525e4f9b4899c9b873fa7179 100644 (file)
@@ -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) {
index 6fcc742570567ef0a152ea3aac342c340159f118..88c2170b8420f5b1d600f80c77d9dfe5f3c8dd3e 100644 (file)
@@ -84,6 +84,7 @@ private:
         std::map<Service::Ptr, Array::Ptr> m_ServicesCache;
         time_t m_TimeFrom;
         time_t m_TimeUntil;
+        String m_CompatLogPath;
 };
 
 }