From ca7e9612ab20e7e9b7b78dd25c6ef83b70919b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?A=2E=20T=C3=A4ffner?= Date: Fri, 2 Sep 2016 10:22:38 +0200 Subject: [PATCH] began implementing nagios connectors (Part 1: Viewing Nagios Info in ISPC) --- interface/web/monitor/lib/module.conf.php | 5 ++ interface/web/monitor/show_nagios.php | 82 +++++++++++++++++++ .../web/monitor/templates/show_nagios.htm | 12 +++ 3 files changed, 99 insertions(+) create mode 100644 interface/web/monitor/show_nagios.php create mode 100644 interface/web/monitor/templates/show_nagios.htm diff --git a/interface/web/monitor/lib/module.conf.php b/interface/web/monitor/lib/module.conf.php index cd84ff3b1a..5b35053dc6 100644 --- a/interface/web/monitor/lib/module.conf.php +++ b/interface/web/monitor/lib/module.conf.php @@ -121,6 +121,11 @@ $items[] = array( 'title' => "Show Services", 'target' => 'content', 'link' => 'monitor/show_data.php?type=services', 'html_id' => 'services'); + +$items[] = array( 'title' => "Show Nagios/Check_MK", + 'target' => 'content', + 'link' => 'monitor/show_nagios.php', + 'html_id' => 'nagios'); $items[] = array( 'title' => "Show Monit", 'target' => 'content', diff --git a/interface/web/monitor/show_nagios.php b/interface/web/monitor/show_nagios.php new file mode 100644 index 0000000000..db17ce4339 --- /dev/null +++ b/interface/web/monitor/show_nagios.php @@ -0,0 +1,82 @@ +auth->check_module_permissions('monitor'); + +$app->uses('tools_monitor'); + +// Loading the template +$app->uses('tpl'); +$app->tpl->newTemplate("form.tpl.htm"); +$app->tpl->setInclude('content_tpl', 'templates/show_nagios.htm'); + +$monTransSrv = $app->lng("monitor_settings_server_txt"); +$title = 'Nagios ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')'; + +$app->tpl->setVar("list_head_txt", $title); + +if($_SESSION["s"]["user"]["typ"] == 'admin'){ + + $app->uses('getconf'); + $server_config = $app->getconf->get_server_config($_SESSION['monitor']['server_id'], 'server'); + + $nagios_url = trim($server_config['nagios_url']); + if($nagios_url != ''){ + $nagios_url = str_replace('[SERVERNAME]', $_SESSION['monitor']['server_name'], $nagios_url); + $nagios_user = trim($server_config['nagios_user']); + $nagios_password = trim($server_config['nagios_password']); + $auth_string = ''; + if($nagios_user != ''){ + $auth_string = rawurlencode($nagios_user); + } + if($nagios_user != '' && $nagios_password != ''){ + $auth_string .= ':'.rawurlencode($nagios_password); + } + if($auth_string != '') $auth_string .= '@'; + + $nagios_url_parts = parse_url($nagios_url); + + $nagios_url = $nagios_url_parts['scheme'].'://'.$auth_string.$nagios_url_parts['host'].(isset($nagios_url_parts['port']) ? ':' . $nagios_url_parts['port'] : '').(isset($nagios_url_parts['path']) ? $nagios_url_parts['path'] : '').(isset($nagios_url_parts['query']) ? '?' . $nagios_url_parts['query'] : '').(isset($nagios_url_parts['fragment']) ? '#' . $nagios_url_parts['fragment'] : ''); + + $app->tpl->setVar("nagios_url", $nagios_url); + } else { + $app->tpl->setVar("no_nagios_url_defined_txt", $app->lng("no_nagios_url_defined_txt")); + } +} else { + $app->tpl->setVar("no_permissions_to_view_nagios_txt", $app->lng("no_permissions_to_view_nagios_txt")); +} + +$app->tpl_defaults(); +$app->tpl->pparse(); +?> diff --git a/interface/web/monitor/templates/show_nagios.htm b/interface/web/monitor/templates/show_nagios.htm new file mode 100644 index 0000000000..0388cb7c65 --- /dev/null +++ b/interface/web/monitor/templates/show_nagios.htm @@ -0,0 +1,12 @@ + +

+ +
+ + + +

ERROR

  1. {tmpl_var name="no_nagios_url_defined_txt"} {tmpl_var name="no_permissions_to_view_nagios_txt"}
+
+
\ No newline at end of file -- GitLab