Module: check_mk
Branch: master
Commit: 7ed069efcd2cb8d9723a4f8979f36bc08fae852a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7ed069efcd2cb8…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Oct 21 10:44:39 2016 +0200
Fetched Livestatus from downstream.
---
livestatus/src/HostFileColumn.cc | 9 ++++++---
livestatus/src/Logfile.cc | 23 +++++++++++++----------
livestatus/src/OutputBuffer.cc | 7 ++++---
livestatus/src/mk_logwatch.cc | 6 +++---
livestatus/src/module.cc | 32 ++++++++++++++++++--------------
5 files changed, 44 insertions(+), 33 deletions(-)
diff --git a/livestatus/src/HostFileColumn.cc b/livestatus/src/HostFileColumn.cc
index db56e75..160e9e7 100644
--- a/livestatus/src/HostFileColumn.cc
+++ b/livestatus/src/HostFileColumn.cc
@@ -71,14 +71,16 @@ unique_ptr<vector<char>> HostFileColumn::getBlob(void
*data) {
if (fd == -1) {
// It is OK when inventory/logwatch files do not exist.
if (errno != ENOENT) {
- Warning(_logger) << generic_error("cannot open " + path);
+ generic_error ge("cannot open " + path);
+ Warning(_logger) << ge;
}
return nullptr;
}
struct stat st;
if (fstat(fd, &st) == -1) {
- Warning(_logger) << generic_error("cannot stat " + path);
+ generic_error ge("cannot stat " + path);
+ Warning(_logger) << ge;
return nullptr;
}
if (!S_ISREG(st.st_mode)) {
@@ -93,7 +95,8 @@ unique_ptr<vector<char>> HostFileColumn::getBlob(void *data)
{
ssize_t bytes_read = read(fd, buffer, bytes_to_read);
if (bytes_read == -1) {
if (errno != EINTR) {
- Warning(_logger) << generic_error("could not read " +
path);
+ generic_error ge("could not read " + path);
+ Warning(_logger) << ge;
close(fd);
return nullptr;
}
diff --git a/livestatus/src/Logfile.cc b/livestatus/src/Logfile.cc
index f69cf97..ed791ff 100644
--- a/livestatus/src/Logfile.cc
+++ b/livestatus/src/Logfile.cc
@@ -60,7 +60,8 @@ Logfile::Logfile(const CommandsHolder &commands_holder, string path,
bool watch)
, _logclasses_read(0) {
int fd = open(_path.c_str(), O_RDONLY);
if (fd < 0) {
- Informational(_logger) << generic_error("cannot open logfile " +
_path);
+ generic_error ge("cannot open logfile " + _path);
+ Informational(_logger) << ge;
return;
}
@@ -138,8 +139,8 @@ void Logfile::load(LogCache *logcache, time_t since, time_t until,
file = fopen(_path.c_str(), "r");
if (file == nullptr) {
- Informational(_logger)
- << generic_error("cannot open logfile " + _path);
+ generic_error ge("cannot open logfile " + _path);
+ Informational(_logger) << ge;
return;
}
@@ -285,14 +286,15 @@ void Logfile::updateReferences() {
char *Logfile::readIntoBuffer(size_t *size) {
int fd = open(_path.c_str(), O_RDONLY);
if (fd < 0) {
- Warning(_logger) << generic_error("cannot open " + _path +
- " for reading");
+ generic_error ge("cannot open " + _path + " for reading");
+ Warning(_logger) << ge;
return nullptr;
}
off_t o = lseek(fd, 0, SEEK_END);
if (o == -1) {
- Warning(_logger) << generic_error("cannot seek to end of " +
_path);
+ generic_error ge("cannot seek to end of " + _path);
+ Warning(_logger) << ge;
close(fd);
return nullptr;
}
@@ -303,16 +305,17 @@ char *Logfile::readIntoBuffer(size_t *size) {
// add space for binary 0 at beginning and end
char *buffer = static_cast<char *>(malloc(*size + 2));
if (buffer == nullptr) {
- Warning(_logger) << generic_error("cannot malloc buffer for reading
" +
- _path);
+ generic_error ge("cannot malloc buffer for reading " + _path);
+ Warning(_logger) << ge;
close(fd);
return nullptr;
}
ssize_t r = read(fd, buffer + 1, *size);
if (r < 0) {
- Warning(_logger) << generic_error("cannot read " +
to_string(*size) +
- " bytes from " + _path);
+ generic_error ge("cannot read " + to_string(*size) + " bytes from
" +
+ _path);
+ Warning(_logger) << ge;
free(buffer);
close(fd);
return nullptr;
diff --git a/livestatus/src/OutputBuffer.cc b/livestatus/src/OutputBuffer.cc
index 42c5b00..bd0667a 100644
--- a/livestatus/src/OutputBuffer.cc
+++ b/livestatus/src/OutputBuffer.cc
@@ -128,9 +128,10 @@ void OutputBuffer::writeData(int fd, int *termination_flag, const
char *buffer,
if (retval > 0 && FD_ISSET(fd, &fds)) {
ssize_t bytes_written = write(fd, buffer, bytes_to_write);
if (bytes_written == -1) {
- Informational(_logger) << generic_error(
- "could not write " + to_string(bytes_to_write) +
- " bytes to client socket");
+ generic_error ge("could not write " +
+ to_string(bytes_to_write) +
+ " bytes to client socket");
+ Informational(_logger) << ge;
break;
}
buffer += bytes_written;
diff --git a/livestatus/src/mk_logwatch.cc b/livestatus/src/mk_logwatch.cc
index e985e36..a8f56d9 100644
--- a/livestatus/src/mk_logwatch.cc
+++ b/livestatus/src/mk_logwatch.cc
@@ -55,8 +55,8 @@ void mk_logwatch_acknowledge(const string &host_name, const string
&file_name) {
int r = remove(path.c_str());
if (r != 0) {
- Warning(logger) << generic_error(
- "Cannot acknowledge mk_logfile file '" + file_name +
"' of host '" +
- host_name + "'");
+ generic_error ge("Cannot acknowledge mk_logfile file '" + file_name
+
+ "' of host '" + host_name +
"'");
+ Warning(logger) << ge;
}
}
diff --git a/livestatus/src/module.cc b/livestatus/src/module.cc
index bb54708..81bd123 100644
--- a/livestatus/src/module.cc
+++ b/livestatus/src/module.cc
@@ -211,8 +211,9 @@ void *main_thread(void *data) {
g_max_fd_ever = cc;
}
if (fcntl(cc, F_SETFD, FD_CLOEXEC) < 0) {
- Warning(fl_logger_livestatus) << generic_error(
+ generic_error ge(
"cannot set close-on-exec bit on client socket");
+ Warning(fl_logger_livestatus) << ge;
}
fl_client_queue->addConnection(cc); // closes fd
g_num_queued_connections++;
@@ -375,8 +376,9 @@ int open_unix_socket() {
Debug(fl_logger_nagios) << "removed old socket file "
<< g_socket_path;
} else {
- Alert(fl_logger_nagios) << generic_error(
- "cannot remove old socket file " + string(g_socket_path));
+ generic_error ge("cannot remove old socket file " +
+ string(g_socket_path));
+ Alert(fl_logger_nagios) << ge;
return false;
}
}
@@ -384,15 +386,15 @@ int open_unix_socket() {
g_unix_socket = socket(PF_UNIX, SOCK_STREAM, 0);
g_max_fd_ever = g_unix_socket;
if (g_unix_socket < 0) {
- Critical(fl_logger_nagios)
- << generic_error("cannot create UNIX socket");
+ generic_error ge("cannot create UNIX socket");
+ Critical(fl_logger_nagios) << ge;
return false;
}
// Imortant: close on exec -> check plugins must not inherit it!
if (fcntl(g_unix_socket, F_SETFD, FD_CLOEXEC) < 0) {
- Informational(fl_logger_nagios)
- << generic_error("cannot set close-on-exec bit on socket");
+ generic_error ge("cannot set close-on-exec bit on socket");
+ Informational(fl_logger_nagios) << ge;
}
// Bind it to its address. This creates the file with the name g_socket_path
@@ -401,8 +403,9 @@ int open_unix_socket() {
strncpy(sockaddr.sun_path, g_socket_path, sizeof(sockaddr.sun_path));
if (bind(g_unix_socket, reinterpret_cast<struct sockaddr *>(&sockaddr),
sizeof(sockaddr)) < 0) {
- Error(fl_logger_nagios) << generic_error(
- "cannot bind UNIX socket to adress " + string(g_socket_path));
+ generic_error ge("cannot bind UNIX socket to adress " +
+ string(g_socket_path));
+ Error(fl_logger_nagios) << ge;
close(g_unix_socket);
return false;
}
@@ -410,16 +413,17 @@ int open_unix_socket() {
// Make writable group members (fchmod didn't do nothing for me. Don't know
// why!)
if (0 != chmod(g_socket_path, 0660)) {
- Error(fl_logger_nagios) << generic_error(
- "cannot change file permissions for UNIX socket at " +
- string(g_socket_path) + " to 0660");
+ generic_error ge("cannot change file permissions for UNIX socket at "
+
+ string(g_socket_path) + " to 0660");
+ Error(fl_logger_nagios) << ge;
close(g_unix_socket);
return false;
}
if (0 != listen(g_unix_socket, 3 /* backlog */)) {
- Error(fl_logger_nagios) << generic_error(
- "cannot listen to UNIX socket at " + string(g_socket_path));
+ generic_error ge("cannot listen to UNIX socket at " +
+ string(g_socket_path));
+ Error(fl_logger_nagios) << ge;
close(g_unix_socket);
return false;
}