Module: check_mk
Branch: master
Commit: b0c3d5af89f1af5b0b39f55afcdc80a70a17f6fd
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b0c3d5af89f1af…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Sep 9 11:11:30 2016 +0200
Fetched Livestatus from downstream.
---
livestatus/src/LogCache.cc | 49 ++++++++++++----------------------------------
livestatus/src/Query.cc | 2 +-
livestatus/src/Store.cc | 5 ++---
livestatus/src/module.cc | 10 +++++-----
4 files changed, 21 insertions(+), 45 deletions(-)
diff --git a/livestatus/src/LogCache.cc b/livestatus/src/LogCache.cc
index 85a93d5..1f25359 100644
--- a/livestatus/src/LogCache.cc
+++ b/livestatus/src/LogCache.cc
@@ -25,7 +25,6 @@
#include "LogCache.h"
#include <dirent.h>
#include <unistd.h>
-#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
@@ -53,25 +52,6 @@ extern char *log_file;
int num_cached_log_messages = 0;
-// Debugging logging is hard if debug messages are logged themselves...
-void debug(const char *loginfo, ...) {
- // Disable debugging, if not working in code. This can result in
- // a symlink attack otherwise...
- return;
-
- if (g_debug_level >= 3) {
- return;
- }
-
- FILE *x = fopen("/tmp/livestatus.log", "a+");
- va_list ap;
- va_start(ap, loginfo);
- vfprintf(x, loginfo, ap);
- fputc('\n', x);
- va_end(ap);
- fclose(x);
-}
-
LogCache::LogCache(const CommandsHolder &commands_holder,
unsigned long max_cached_messages)
: _commands_holder(commands_holder)
@@ -83,7 +63,8 @@ LogCache::LogCache(const CommandsHolder &commands_holder,
#ifdef CMC
void LogCache::setMaxCachedMessages(unsigned long m) {
if (m != _max_cached_messages) {
- Notice() << "Logfile cache: Changing max messages to " <<
m;
+ Notice() << "changing maximum number of messages for log file cache to
"
+ << m;
_max_cached_messages = m;
}
}
@@ -99,7 +80,7 @@ bool LogCache::logCachePreChecks(
// Do we have any logfiles (should always be the case, but we don't want to
// crash...
if (_logfiles.empty()) {
- Informational() << "Warning: no logfile found, not even "
<< log_file;
+ Informational() << "no log file found, not even " <<
log_file;
return false;
}
// Has Nagios rotated logfiles? => Update our file index. And delete all
@@ -111,7 +92,7 @@ bool LogCache::logCachePreChecks(
if (last_log_rotation > _last_index_update) {
#endif
Informational()
- << "Core has rotated logfiles. Rebuilding logfile index";
+ << "core has rotated log files, rebuilding log file index";
forgetLogfiles();
updateLogfileIndex();
}
@@ -119,7 +100,7 @@ bool LogCache::logCachePreChecks(
}
void LogCache::forgetLogfiles() {
- Informational() << "Logfile cache: flushing complete cache.";
+ Informational() << "flushing complete log file cache.";
for (auto &logfile : _logfiles) {
delete logfile.second;
}
@@ -154,8 +135,7 @@ void LogCache::updateLogfileIndex() {
free(ent);
closedir(dir);
} else {
- Informational() << "Cannot open log archive '" <<
log_archive_path
- << "'";
+ Informational() << "cannot open log archive " <<
log_archive_path;
}
}
@@ -169,7 +149,7 @@ void LogCache::scanLogfile(char *path, bool watch) {
if (_logfiles.find(since) == _logfiles.end()) {
_logfiles.emplace(since, logfile);
} else {
- Warning() << "Ignoring duplicate logfile " << path;
+ Warning() << "ignoring duplicate log file " << path;
delete logfile;
}
} else {
@@ -236,10 +216,8 @@ void LogCache::handleNewMessage(Logfile *logfile, time_t /*unused*/,
for (; it != _logfiles.end(); ++it) {
Logfile *log = it->second;
if (log->numEntries() > 0 && (log->classesRead() &
~logclasses) != 0) {
- if (g_debug_level > 2) {
- debug("Freeing classes 0x%02x of file %s", ~logclasses,
- log->path().c_str());
- }
+ Debug() << "freeing classes " << ~logclasses <<
" of file "
+ << log->path();
long freed = log->freeMessages(~logclasses); // flush only messages
// not needed for
// current query
@@ -259,7 +237,8 @@ void LogCache::handleNewMessage(Logfile *logfile, time_t /*unused*/,
for (it = ++queryit; it != _logfiles.end(); ++it) {
Logfile *log = it->second;
if (log->numEntries() > 0) {
- debug("Flush newer log, msgs %d", log->numEntries());
+ Debug() << "flush newer log, " << log->numEntries()
+ << " number of entries";
num_cached_log_messages -= log->numEntries();
log->flush();
if (static_cast<unsigned long>(num_cached_log_messages) <=
@@ -274,8 +253,6 @@ void LogCache::handleNewMessage(Logfile *logfile, time_t /*unused*/,
// despite the fact that there are still too many messages
// loaded.
- if (g_debug_level > 2) {
- debug("Cannot unload more messages. Still %d loaded (max is %d)",
- num_cached_log_messages, _max_cached_messages);
- }
+ Debug() << "cannot unload more messages, still " <<
num_cached_log_messages
+ << " loaded (max is " << _max_cached_messages <<
")";
}
diff --git a/livestatus/src/Query.cc b/livestatus/src/Query.cc
index 32d1f2e..4b02939 100644
--- a/livestatus/src/Query.cc
+++ b/livestatus/src/Query.cc
@@ -100,7 +100,7 @@ Query::Query(const list<string> &lines, Table *table,
Encoding data_encoding,
line_copy.push_back('\0');
char *buffer = &line_copy[0];
rstrip(buffer);
- if (_debug_level > 0) {
+ if (_debug_level >= 1) {
Informational() << "Query: " << buffer;
}
if (strncmp(buffer, "Filter:", 7) == 0) {
diff --git a/livestatus/src/Store.cc b/livestatus/src/Store.cc
index 70329b3..a51e244 100644
--- a/livestatus/src/Store.cc
+++ b/livestatus/src/Store.cc
@@ -22,7 +22,6 @@
// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA.
-// IWYU pragma: no_include <memory>
#include "Store.h"
#include <chrono>
#include <cstring>
@@ -134,7 +133,7 @@ bool Store::answerRequest(InputBuffer *input, OutputBuffer *output) {
}
string l = input->nextLine();
const char *line = l.c_str();
- if (g_debug_level > 0) {
+ if (g_debug_level >= 1) {
Informational() << "Query: " << line;
}
if (strncmp(line, "GET ", 4) == 0) {
@@ -214,7 +213,7 @@ void Store::answerGetRequest(const list<string> &lines,
OutputBuffer *output,
auto start = system_clock::now();
Query(lines, table, g_data_encoding, g_debug_level).process(output);
- if (g_debug_level > 0) {
+ if (g_debug_level >= 1) {
auto elapsed = duration_cast<microseconds>(system_clock::now() - start);
Informational() << "Time to process request: " <<
elapsed.count()
<< "us. Size of answer: " <<
output->size() << " bytes";
diff --git a/livestatus/src/module.cc b/livestatus/src/module.cc
index d47a8cb..e0eea10 100644
--- a/livestatus/src/module.cc
+++ b/livestatus/src/module.cc
@@ -330,7 +330,7 @@ void start_threads() {
Warning() << ex;
}
- if (g_debug_level > 0) {
+ if (g_debug_level >= 1) {
Informational() << "starting " << g_num_clientthreads
<< " client threads";
}
@@ -377,7 +377,7 @@ void terminate_threads() {
Informational() << "could not join thread no. " <<
t;
}
}
- if (g_debug_level > 0) {
+ if (g_debug_level >= 1) {
Informational() << "main thread + " <<
g_num_clientthreads
<< " client threads have finished";
}
@@ -441,7 +441,7 @@ int open_unix_socket() {
return false;
}
- if (g_debug_level > 0) {
+ if (g_debug_level >= 1) {
Informational() << "opened UNIX socket at " <<
g_socket_path;
}
return true;
@@ -919,7 +919,7 @@ void livestatus_parse_arguments(const char *args_orig) {
void omd_advertize() {
char *omd_site = getenv("OMD_SITE");
if (omd_site != nullptr) {
- if (g_debug_level > 0) {
+ if (g_debug_level >= 1) {
Informational() << "running on OMD site " << omd_site
<< ", cool.";
}
} else {
@@ -954,7 +954,7 @@ extern "C" int nebmodule_init(int flags
__attribute__((__unused__)), char *args,
<< event_broker_options << ", try setting it to
-1.";
return 1;
}
- if (g_debug_level > 0) {
+ if (g_debug_level >= 1) {
Informational()
<< "your event_broker_options are sufficient for
livestatus..";
}