Module: check_mk
Branch: master
Commit: 94e83aee382e83eef43cdfcc9baf08eec18a614a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=94e83aee382e83…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Oct 27 12:08:48 2016 +0200
Fetched Livestatus from downstream.
---
livestatus/src/Query.cc | 7 ++++---
livestatus/src/Store.cc | 23 ++++++++++++++++++-----
livestatus/src/Store.h | 2 ++
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/livestatus/src/Query.cc b/livestatus/src/Query.cc
index baa8566..1c211e2 100644
--- a/livestatus/src/Query.cc
+++ b/livestatus/src/Query.cc
@@ -99,7 +99,6 @@ Query::Query(const list<string> &lines, Table *table, Encoding
data_encoding)
line_copy.push_back('\0');
char *buffer = &line_copy[0];
rstrip(buffer);
- Informational(_logger) << "Query: " << buffer;
if (strncmp(buffer, "Filter:", 7) == 0) {
parseFilterLine(lstrip(buffer + 7), _filter);
@@ -712,8 +711,10 @@ void Query::parseLocaltimeLine(char *line) {
return;
}
_timezone_offset = full * 1800;
- Debug(_logger) << "Timezone difference is " <<
(_timezone_offset / 3600.0)
- << " hours";
+ if (_timezone_offset != 0) {
+ Debug(_logger) << "timezone difference is " <<
_timezone_offset / 3600.0
+ << " hours";
+ }
}
bool Query::doStats() { return !_stats_columns.empty(); }
diff --git a/livestatus/src/Store.cc b/livestatus/src/Store.cc
index 7b8d788..c6db114 100644
--- a/livestatus/src/Store.cc
+++ b/livestatus/src/Store.cc
@@ -129,6 +129,14 @@ list<string> getLines(InputBuffer *input) {
}
} // namespace
+void Store::logRequest(const string &line, const list<string> &lines) {
+ Informational info(_logger);
+ info << "Request: " << line;
+ for (const auto &l : lines) {
+ info << R"(\n)" << l;
+ }
+}
+
bool Store::answerRequest(InputBuffer *input, OutputBuffer *output) {
output->reset();
InputBuffer::Result res = input->readRequest();
@@ -142,17 +150,21 @@ bool Store::answerRequest(InputBuffer *input, OutputBuffer *output)
{
}
string l = input->nextLine();
const char *line = l.c_str();
- Informational(_logger) << "Query: " << line;
if (strncmp(line, "GET ", 4) == 0) {
- answerGetRequest(getLines(input), output,
- lstrip(const_cast<char *>(line) + 4));
+ auto lines = getLines(input);
+ logRequest(l, lines);
+ answerGetRequest(lines, output, lstrip(const_cast<char *>(line) + 4));
} else if (strcmp(line, "GET") == 0) {
// only to get error message
- answerGetRequest(getLines(input), output, "");
+ auto lines = getLines(input);
+ logRequest(l, lines);
+ answerGetRequest(lines, output, "");
} else if (strncmp(line, "COMMAND ", 8) == 0) {
+ logRequest(l, {});
answerCommandRequest(lstrip(const_cast<char *>(line) + 8));
output->setDoKeepalive(true);
} else if (strncmp(line, "LOGROTATE", 9) == 0) {
+ logRequest(l, {});
Informational(_logger) << "Forcing logfile rotation";
rotate_log_file(time(nullptr));
schedule_new_event(EVENT_LOG_ROTATION, 1, get_next_log_rotation_time(),
@@ -160,7 +172,8 @@ bool Store::answerRequest(InputBuffer *input, OutputBuffer *output) {
reinterpret_cast<void *>(get_next_log_rotation_time),
1, nullptr, nullptr, 0);
} else {
- Warning(_logger) << "Invalid request '" << line
<< "'";
+ logRequest(l, {});
+ Warning(_logger) << "Invalid request '" << l <<
"'";
output->setError(OutputBuffer::ResponseCode::invalid_request,
"Invalid request method");
}
diff --git a/livestatus/src/Store.h b/livestatus/src/Store.h
index 1380081..68ac738 100644
--- a/livestatus/src/Store.h
+++ b/livestatus/src/Store.h
@@ -102,6 +102,8 @@ private:
void addTable(Table *table);
Table *findTable(const std::string &name);
+ void logRequest(const std::string &line,
+ const std::list<std::string> &lines);
void answerGetRequest(const std::list<std::string> &lines, OutputBuffer *,
const char *);
void answerCommandRequest(const char *);