Module: check_mk
Branch: master
Commit: c84792061e7b94517585f1a77db3812c3970b1d8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c84792061e7b94…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Wed Mar 8 11:40:22 2017 +0100
It is not an error if the logwatch directory doesn't exist.
Change-Id: I00e9f564ae68c010f818812c11747f90f6e1fd59
---
livestatus/src/LogwatchListColumn.cc | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/livestatus/src/LogwatchListColumn.cc b/livestatus/src/LogwatchListColumn.cc
index 9e84564..bed3bba 100644
--- a/livestatus/src/LogwatchListColumn.cc
+++ b/livestatus/src/LogwatchListColumn.cc
@@ -38,6 +38,9 @@ using std::string;
void LogwatchListColumn::output(void *row, RowRenderer &r,
contact * /* auth_user */) {
ListRenderer l(r);
+ if (_logwatch_path.empty()) {
+ return;
+ }
#ifdef CMC
auto hst = rowData<Host>(row);
@@ -53,15 +56,14 @@ void LogwatchListColumn::output(void *row, RowRenderer &r,
string host_name = hst->name;
#endif
- if (!_logwatch_path.empty()) {
- try {
- for (const auto &entry : fs::directory_iterator(
- _logwatch_path + pnp_cleanup(host_name))) {
+ auto dir = _logwatch_path + pnp_cleanup(host_name);
+ try {
+ if (fs::exists(dir)) {
+ for (const auto &entry : fs::directory_iterator(dir)) {
l.output(entry.path().filename().string());
}
- } catch (const fs::filesystem_error &e) {
- Warning(logger()) << "error while iterating directory: "
- << e.what();
}
+ } catch (const fs::filesystem_error &e) {
+ Warning(logger()) << "error while iterating directory: " <<
e.what();
}
}