Module: check_mk
Branch: master
Commit: a2ffd12f0e18f99840687d621a682ad218906ac8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a2ffd12f0e18f9…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Nov 18 15:00:57 2016 +0100
Fetched livestatus from downstream.
---
livestatus/src/LogCache.cc | 21 ++++++++-------------
livestatus/src/Query.cc | 6 +++++-
livestatus/src/TableLog.cc | 4 +++-
livestatus/src/TableStateHistory.cc | 4 +++-
4 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/livestatus/src/LogCache.cc b/livestatus/src/LogCache.cc
index 0d329bc..16ee255 100644
--- a/livestatus/src/LogCache.cc
+++ b/livestatus/src/LogCache.cc
@@ -67,25 +67,19 @@ void LogCache::setMaxCachedMessages(unsigned long m) {
LogCache::~LogCache() { forgetLogfiles(); }
bool LogCache::logCachePreChecks(MonitoringCore *core) {
- // Do we have any logfiles (should always be the case, but we don't want to
- // crash...
- if (_logfiles.empty()) {
- Informational(_logger) << "no log file found, not even " <<
log_file;
- return false;
- }
- // Has Nagios rotated logfiles? => Update our file index. And delete all
- // memorized log messages.
- if (core->last_logfile_rotation() > _last_index_update) {
- Informational(_logger)
- << "core has rotated log files, rebuilding log file index";
+ if (_logfiles.empty() ||
+ core->last_logfile_rotation() > _last_index_update) {
forgetLogfiles();
updateLogfileIndex();
}
- return true;
+ if (_logfiles.empty()) {
+ Notice(_logger) << "no log file found, not even " <<
log_file;
+ }
+ return !_logfiles.empty();
}
void LogCache::forgetLogfiles() {
- Informational(_logger) << "flushing complete log file cache.";
+ Notice(_logger) << "flushing log file index";
for (auto &logfile : _logfiles) {
delete logfile.second;
}
@@ -94,6 +88,7 @@ void LogCache::forgetLogfiles() {
}
void LogCache::updateLogfileIndex() {
+ Notice(_logger) << "updating log file index";
_last_index_update = system_clock::now();
// We need to find all relevant logfiles. This includes directory, the
// current nagios.log and all files in the archive.
diff --git a/livestatus/src/Query.cc b/livestatus/src/Query.cc
index 012d394..3b13e78 100644
--- a/livestatus/src/Query.cc
+++ b/livestatus/src/Query.cc
@@ -196,7 +196,11 @@ Query::Query(const list<string> &lines, Table *table,
Encoding data_encoding)
_all_columns.insert(_columns.begin(), _columns.end());
for (const auto &sc : _stats_columns) {
- _all_columns.insert(sc->column());
+ // TODO(sp) We should really move column() from StatsColumn, it doesn't
+ // belong there... :-P
+ if (sc->column()) {
+ _all_columns.insert(sc->column());
+ }
}
ColumnCollector cc(_all_columns);
diff --git a/livestatus/src/TableLog.cc b/livestatus/src/TableLog.cc
index b1d3386..9e867fd 100644
--- a/livestatus/src/TableLog.cc
+++ b/livestatus/src/TableLog.cc
@@ -171,7 +171,9 @@ string TableLog::namePrefix() const { return "log_"; }
void TableLog::answerQuery(Query *query) {
lock_guard<mutex> lg(_log_cache->_lock);
- _log_cache->logCachePreChecks(_core);
+ if (!_log_cache->logCachePreChecks(_core)) {
+ return;
+ }
int since = 0;
int until = time(nullptr) + 1;
diff --git a/livestatus/src/TableStateHistory.cc b/livestatus/src/TableStateHistory.cc
index 16dd2b1..262a884 100644
--- a/livestatus/src/TableStateHistory.cc
+++ b/livestatus/src/TableStateHistory.cc
@@ -355,7 +355,9 @@ void TableStateHistory::answerQuery(Query *query) {
}
lock_guard<mutex> lg(_log_cache->_lock);
- _log_cache->logCachePreChecks(_core);
+ if (!_log_cache->logCachePreChecks(_core)) {
+ return;
+ }
// This flag might be set to true by the return value of processDataset(...)
_abort_query = false;