Module: check_mk
Branch: master
Commit: 02a80d7e7d35e17f4e9ada6fac419b03a491980a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=02a80d7e7d35e1…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Aug 25 10:22:59 2017 +0200
Centralized magic service description plus tiny cleanups.
Change-Id: Ib74c7bda02fce06653cca598504e710b19fac70b
---
livestatus/src/HostSpecialIntColumn.cc | 3 ++-
livestatus/src/pnp4nagios.cc | 13 ++++++++-----
livestatus/src/pnp4nagios.h | 9 ++++++---
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/livestatus/src/HostSpecialIntColumn.cc
b/livestatus/src/HostSpecialIntColumn.cc
index 6234b14..fbac0a0 100644
--- a/livestatus/src/HostSpecialIntColumn.cc
+++ b/livestatus/src/HostSpecialIntColumn.cc
@@ -45,7 +45,8 @@ int32_t HostSpecialIntColumn::getValue(Row row,
}
case Type::pnp_graph_present:
- return pnpgraph_present(_mc, hst->name);
+ return pnpgraph_present(_mc, hst->name,
+ dummy_service_description());
case Type::mk_inventory_last: {
return mk_inventory_last(_mc->mkInventoryPath() + "/" +
diff --git a/livestatus/src/pnp4nagios.cc b/livestatus/src/pnp4nagios.cc
index af39f7d..50b7aeb 100644
--- a/livestatus/src/pnp4nagios.cc
+++ b/livestatus/src/pnp4nagios.cc
@@ -27,7 +27,10 @@
#include <system_error>
#include "MonitoringCore.h"
-#ifndef CMC
+#ifdef CMC
+#include "Object.h"
+#include "Host.h"
+#else
#include "FileSystem.h"
#endif
@@ -68,15 +71,15 @@ int pnpgraph_present(MonitoringCore* mc, const string& host,
#ifdef CMC
// TODO(sp) Merge this with Perfdatabase::getPNPRRDPath
-fs::path rrd_path(MonitoringCore* mc, const string& host, const string& service,
+fs::path rrd_path(MonitoringCore* mc, const Object* object,
const string& varname) {
fs::path pnp_path = mc->pnpPath();
if (pnp_path.empty()) {
return "";
}
- fs::path path =
- pnp_path / pnp_cleanup(host) /
- (pnp_cleanup(service) + "_" + pnp_cleanup(varname) +
".rrd");
+ fs::path path = pnp_path / pnp_cleanup(object->host()->name()) /
+ (pnp_cleanup(object->serviceDescription()) + "_" +
+ pnp_cleanup(varname) + ".rrd");
std::error_code ec;
fs::status(path, ec);
return ec ? "" : path;
diff --git a/livestatus/src/pnp4nagios.h b/livestatus/src/pnp4nagios.h
index 3be82a1..5990223 100644
--- a/livestatus/src/pnp4nagios.h
+++ b/livestatus/src/pnp4nagios.h
@@ -31,21 +31,24 @@ class MonitoringCore;
#ifdef CMC
#include "FileSystem.h"
+class Object;
#endif
+inline std::string dummy_service_description() { return "_HOST_"; }
+
std::string pnp_cleanup(const std::string& name);
#ifndef CMC
int pnpgraph_present(MonitoringCore* mc, const std::string& host,
- const std::string& service = "_HOST_");
+ const std::string& service);
#endif
#ifdef CMC
// 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.
-fs::path rrd_path(MonitoringCore* mc, const std::string& host,
- const std::string& service, const std::string& varname);
+fs::path rrd_path(MonitoringCore* mc, const Object* object,
+ const std::string& varname);
#endif
#endif // pnp4nagios_h