Module: check_mk
Branch: master
Commit: 0492da9fa476a4cb701adb2db79d22dae33a891b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0492da9fa476a4…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Nov 29 13:56:01 2016 +0100
Fetched livestatus from downstream.
---
livestatus/src/LogwatchListColumn.cc | 33 +++++++++++++++++----------------
livestatus/src/mk_logwatch.cc | 15 +++------------
livestatus/src/mk_logwatch.h | 3 ---
3 files changed, 20 insertions(+), 31 deletions(-)
diff --git a/livestatus/src/LogwatchListColumn.cc b/livestatus/src/LogwatchListColumn.cc
index 03d2734..ce0b99c 100644
--- a/livestatus/src/LogwatchListColumn.cc
+++ b/livestatus/src/LogwatchListColumn.cc
@@ -25,7 +25,7 @@
#include "LogwatchListColumn.h"
#include <dirent.h>
#include "Renderer.h"
-#include "mk_logwatch.h"
+#include "pnp4nagios.h"
#ifdef CMC
#include "Host.h"
@@ -49,21 +49,22 @@ void LogwatchListColumn::output(void *row, RowRenderer &r,
#endif
ListRenderer l(r);
- string path = mk_logwatch_path_of_host(_logwatch_path, host_name);
- if (path != "") {
- if (DIR *dir = opendir(path.c_str())) {
- while (true) {
- struct dirent de;
- struct dirent *dep;
- readdir_r(dir, &de, &dep);
- if (dep == nullptr) {
- closedir(dir);
- break;
- }
- string name = dep->d_name;
- if (name != "." && name != "..") {
- l.output(name);
- }
+ if (_logwatch_path.empty()) {
+ return;
+ }
+ string path = _logwatch_path + pnp_cleanup(host_name);
+ if (DIR *dir = opendir(path.c_str())) {
+ while (true) {
+ struct dirent de;
+ struct dirent *dep;
+ readdir_r(dir, &de, &dep);
+ if (dep == nullptr) {
+ closedir(dir);
+ break;
+ }
+ string name = dep->d_name;
+ if (name != "." && name != "..") {
+ l.output(name);
}
}
}
diff --git a/livestatus/src/mk_logwatch.cc b/livestatus/src/mk_logwatch.cc
index 661cfed..da94ffc 100644
--- a/livestatus/src/mk_logwatch.cc
+++ b/livestatus/src/mk_logwatch.cc
@@ -30,12 +30,6 @@
using std::string;
-string mk_logwatch_path_of_host(const string &logwatch_path,
- const string &host_name) {
- return logwatch_path.empty() ? ""
- : (logwatch_path + pnp_cleanup(host_name));
-}
-
void mk_logwatch_acknowledge(Logger *logger, const std::string &logwatch_path,
const string &host_name, const string &file_name) {
if (file_name.find('/') != string::npos) {
@@ -43,14 +37,11 @@ void mk_logwatch_acknowledge(Logger *logger, const std::string
&logwatch_path,
<< file_name << "' of host '"
<< host_name << "'";
return;
}
-
- string path = mk_logwatch_path_of_host(logwatch_path, host_name);
- if (path.empty()) {
+ if (logwatch_path.empty()) {
return;
}
-
- int r = remove((path + "/" + file_name).c_str());
- if (r != 0) {
+ string path = logwatch_path + pnp_cleanup(host_name) + "/" + file_name;
+ if (remove(path.c_str()) != 0) {
generic_error ge("Cannot acknowledge mk_logfile file '" + file_name
+
"' of host '" + host_name +
"'");
Warning(logger) << ge;
diff --git a/livestatus/src/mk_logwatch.h b/livestatus/src/mk_logwatch.h
index 6602fba..b373911 100644
--- a/livestatus/src/mk_logwatch.h
+++ b/livestatus/src/mk_logwatch.h
@@ -29,9 +29,6 @@
#include <string>
class Logger;
-std::string mk_logwatch_path_of_host(const std::string &logwatch_path,
- const std::string &host_name);
-
void mk_logwatch_acknowledge(Logger *logger, const std::string &logwatch_path,
const std::string &host_name,
const std::string &file_name);