Module: check_mk
Branch: master
Commit: e9e303bfb9f41ac894dcbac76647cd57ed45e90f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e9e303bfb9f41a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Feb 21 10:03:03 2011 +0100
PNP template for local honors all dirs
Thanks to Patrick Schaaf
---
ChangeLog | 4 +++-
pnp-templates/check_mk-local.php | 27 +++++++++++++++++----------
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c207c9a..fbf282d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,7 +22,9 @@
trends. Please look at check manpage of df for details.
* FIX: heartbeat_nodes: Fixed error handling when node is active but at least one
link is dead
* 3ware_units: Handling INITIALIZING state as warning now
- * 3ware_units: Better handling of outputs from different tw_cli versions now
+ * FIX: 3ware_units: Better handling of outputs from different tw_cli versions now
+ * FIX: local: PNP template for local now looks in all template directories for
+ specific templates (thanks to Patrick Schaaf)
Multisite:
* FIX: fix "too many values to unpack" when editing views in single layout
diff --git a/pnp-templates/check_mk-local.php b/pnp-templates/check_mk-local.php
index a1e284c..1f3914f 100644
--- a/pnp-templates/check_mk-local.php
+++ b/pnp-templates/check_mk-local.php
@@ -23,19 +23,26 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-$x = getcwd();
-
// try to find template matching a prefix of the service
// description first. Slashes are replaced by underscores.
+$template_dirs = array('.');
+if (isset($this->config->conf['template_dirs'])) {
+ $template_dirs = $this->config->conf['template_dirs'];
+}
$descr = str_replace("/", "_", $servicedesc);
-$found = 0;
-for ($i = strlen($descr); $i > 0; $i--)
-{
- $tryname = 'templates/'.substr($descr, 0, $i) . ".php";
- if (file_exists($tryname) && include($tryname)) {
- $found = 1;
- break;
- }
+foreach ($template_dirs as $template_dir) {
+ $found = 0;
+ for ($i = strlen($descr); $i > 0; $i--)
+ {
+ $tryname = $template_dir . '/' . substr($descr, 0, $i) . '.php';
+ if (file_exists($tryname) && include($tryname)) {
+ $found = 1;
+ break;
+ }
+ }
+ if ($found) {
+ break;
+ }
}
if (!$found) {