Module: check_mk
Branch: master
Commit: bf9a37e13e388c262f35ab3e00c0aad1cdd6142e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bf9a37e13e388c…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Tue Feb 28 10:20:06 2017 +0100
Heavy cleanup of RRD-related file name handling.
* Use std::filesystem::path instead of std::string where appropriate.
* Centralize path calculations.
* Only create a directory when necessary, fixing gitbug #2818.
Change-Id: Ie7e541849be6cadc73886b197b696f2fd78b4497
---
.bugs/2818 | 6 ++++--
livestatus/src/pnp4nagios.cc | 7 +++----
livestatus/src/pnp4nagios.h | 7 +++++--
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/.bugs/2818 b/.bugs/2818
index 65dbf4f..af50522 100644
--- a/.bugs/2818
+++ b/.bugs/2818
@@ -1,9 +1,9 @@
Title: Old host rrd directory is created even when using new one
Component: core
-State: open
+Class: bug
+State: done
Date: 2016-04-05 17:04:56
Targetversion: 1.4.0
-Class: bug
Unsure where the issue is located, but what happens is:
@@ -19,3 +19,5 @@ for storing the RRD files.
This is done by Perfdatabase::getPNPBase() which class makeDirectory(base).
TODO(sp): Please investigate and clean this up.
+
+2017-02-28 14:39:53: changed state open -> done
diff --git a/livestatus/src/pnp4nagios.cc b/livestatus/src/pnp4nagios.cc
index 5f89127..c90d6c1 100644
--- a/livestatus/src/pnp4nagios.cc
+++ b/livestatus/src/pnp4nagios.cc
@@ -26,8 +26,7 @@
#include <cstddef>
#ifdef CMC
#include <sys/stat.h>
-#endif
-#ifndef CMC
+#else
#include <unistd.h>
#endif
@@ -69,8 +68,8 @@ int pnpgraph_present(const string& host, const string& service)
{
#endif
#ifdef CMC
-string rrd_path(const string& host, const string& service,
- const string& varname) {
+fs::path rrd_path(const string& host, const string& service,
+ const string& varname) {
string pnp_path(g_pnp_path);
if (pnp_path.empty()) {
return "";
diff --git a/livestatus/src/pnp4nagios.h b/livestatus/src/pnp4nagios.h
index a322ffd..5cfc496 100644
--- a/livestatus/src/pnp4nagios.h
+++ b/livestatus/src/pnp4nagios.h
@@ -27,6 +27,9 @@
#include "config.h" // IWYU pragma: keep
#include <string>
+#ifdef CMC
+#include "FileSystem.h"
+#endif
std::string pnp_cleanup(const std::string& name);
@@ -39,8 +42,8 @@ int pnpgraph_present(const std::string& host,
// Determines if a RRD database exists and returns its path name. Returns an
// empty string otherwise. This assumes paths created in the PNP4Nagios style
// with storage type MULTIPLE.
-std::string rrd_path(const std::string& host, const std::string& service,
- const std::string& varname);
+fs::path rrd_path(const std::string& host, const std::string& service,
+ const std::string& varname);
#endif
#endif // pnp4nagios_h