Module: check_mk
Branch: master
Commit: 9dfc7be3661b1149e65d6497f208f1c5e240733d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9dfc7be3661b11…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Nov 14 11:55:05 2013 +0100
FIX table statehist: no more missing entries if only one logfile exists
---
.werks/34 | 8 ++++++++
ChangeLog | 1 +
livestatus/src/TableStateHistory.cc | 19 ++++++++++++-------
3 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/.werks/34 b/.werks/34
new file mode 100644
index 0000000..4a38c90
--- /dev/null
+++ b/.werks/34
@@ -0,0 +1,8 @@
+Title: table statehist: no more missing entries if only one logfile exists
+Level: 1
+Component: livestatus
+Version: 1.2.3i7
+Date: 1384426471
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index afc0415..7a65497 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -58,6 +58,7 @@
Livestatus:
* 0067 livedump: new option to mark the mode at the beginning of the dump and
documentation fixes...
* 0023 FIX: table statehist: code cleanup / minor performance improvements
+ * 0034 FIX: table statehist: no more missing entries if only one logfile exists
1.2.3i6:
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index 56ef676..a399e9e 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -351,6 +351,7 @@ void TableStateHistory::answerQuery(Query *query)
// Switch to last logfile (we have at least one)
_it_logs = g_store->logCache()->logfiles()->end();
--_it_logs;
+ _logfiles_t::iterator newest_log = _it_logs;
// Now find the log where 'since' starts.
while (_it_logs != g_store->logCache()->logfiles()->begin() &&
_it_logs->first >= _since) {
@@ -368,14 +369,18 @@ void TableStateHistory::answerQuery(Query *query)
// Determine initial logentry
LogEntry* entry;
_entries = _it_logs->second->getEntriesFromQuery(query, g_store->logCache(),
_since, _until, CLASSMASK_STATEHIST);
- _it_entries = _entries->end();
- // Check last entry. If it's younger than _since -> use this logfile too
- if (--_it_entries != _entries->begin()) {
- entry = _it_entries->second;
- if (entry->_time >= _since) {
- _it_entries = _entries->begin();
+ if (_it_logs != newest_log) {
+ _it_entries = _entries->end();
+ // Check last entry. If it's younger than _since -> use this logfile too
+ if (--_it_entries != _entries->begin()) {
+ entry = _it_entries->second;
+ if (entry->_time >= _since) {
+ _it_entries = _entries->begin();
+ }
}
- }
+ } else
+ _it_entries = _entries->begin();
+
// From now on use getPreviousLogentry() / getNextLogentry()
HostServiceKey key;