Commit 6dd5d8b7 authored by A. Täffner's avatar A. Täffner

added language vars for nagios, addad check_mk authentication mechanism.

Known Bugs: CMK-URL is damaged (origtarget), iframe stays white...?
parent 22b7f842
......@@ -362,7 +362,7 @@ $form["tabs"]['server'] = array(
'formtype' => 'TEXT',
'default' => '',
'validators' => array ( 0 => array ( 'type' => 'REGEX',
'regex' => '/^((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))$/',
'regex' => '/(^$)|(^((?:http|https)(?::\\/{2}[\\w]+)(?:[\\/|\\.]?)(?:[^\\s"]*))$)/',
'errmsg'=> 'nagios_url_error_regex'),
),
'value' => '',
......
......@@ -199,10 +199,10 @@ $wb['munin_password_txt'] = 'Munin-Passwort';
$wb['munin_url_error_regex'] = 'Ungültige Munin-URL';
$wb['munin_url_note_txt'] = 'Platzhalter:';
$wb['nagios_url_txt'] = 'Nagios/Check_MK-URL';
$wb['nagios_user_txt'] = 'Nagios-Benutzer';
$wb['nagios_password_txt'] = 'Nagios-Passwort';
$wb['nagios_url_error_regex'] = 'Ungültige Nagios-URL';
$wb['nagios_url_note_txt'] = 'Platzhalter:';
$wb['nagios_user_txt'] = 'Nagios/Check_MK-Benutzer';
$wb['nagios_password_txt'] = 'Nagios/Check_MK-Passwort';
$wb['nagios_url_error_regex'] = 'Ungültige Nagios/Check_MK-URL';
$wb['nagios_url_note_txt'] = 'Check_MK wird automatisch erkannt. Platzhalter:';
$wb['backup_dir_is_mount_txt'] = 'Backupverzeichnis ist ein eigener Mount?';
$wb['backup_dir_mount_cmd_txt'] = 'Mount-Befehl, falls Backupverzeichnis nicht gemountet';
$wb['backup_delete_txt'] = 'Backups loeschen wenn eine Domain / Webseite geloescht wird';
......
......@@ -199,6 +199,11 @@ $wb['munin_user_txt'] = 'Munin User';
$wb['munin_password_txt'] = 'Munin Password';
$wb['munin_url_error_regex'] = 'Invalid Munin URL';
$wb['munin_url_note_txt'] = 'Placeholder:';
$wb['nagios_url_txt'] = 'Nagios/Check_MK URL';
$wb['nagios_user_txt'] = 'Nagios/Check_MK User';
$wb['nagios_password_txt'] = 'Nagios/Check_MK Password';
$wb['nagios_url_error_regex'] = 'Invalid Nagios/Check_MK URL';
$wb['nagios_url_note_txt'] = 'Check_MK is being autodetected. Placeholder:';
$wb["v6_prefix_txt"] = 'IPv6 Prefix';
$wb["vhost_rewrite_v6_txt"] = 'Rewrite IPv6 on Mirror';
$wb["v6_prefix_length"] = 'Prefix too long according to defined IPv6 ';
......
......@@ -96,6 +96,16 @@
<label for="munin_password" class="col-sm-3 control-label">{tmpl_var name='munin_password_txt'}</label>
<div class="col-sm-9"><input type="text" name="munin_password" id="munin_password" value="{tmpl_var name='munin_password'}" class="form-control" /></div></div>
<div class="form-group">
<label for="nagios_url" class="col-sm-3 control-label">{tmpl_var name='nagios_url_txt'}</label>
<div class="col-sm-6"><input type="text" name="nagios_url" id="nagios_url" value="{tmpl_var name='nagios_url'}" class="form-control" />&nbsp;{tmpl_var name='nagios_url_note_txt'} <a href="javascript:void(0);" class="addPlaceholder">[SERVERNAME]</a></div>
</div>
<div class="form-group">
<label for="nagios_user" class="col-sm-3 control-label">{tmpl_var name='nagios_user_txt'}</label>
<div class="col-sm-9"><input type="text" name="nagios_user" id="nagios_user" value="{tmpl_var name='nagios_user'}" class="form-control" /></div></div>
<div class="form-group">
<label for="nagios_password" class="col-sm-3 control-label">{tmpl_var name='nagios_password_txt'}</label>
<div class="col-sm-9"><input type="text" name="nagios_password" id="nagios_password" value="{tmpl_var name='nagios_password'}" class="form-control" /></div></div>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='monitor_system_updates_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='monitor_system_updates'}
......
......@@ -56,18 +56,42 @@ if($_SESSION["s"]["user"]["typ"] == 'admin'){
$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'] : '');
if (strpos($nagios_url, '/check_mk') !== false) {
//** Check_MK
if($nagios_user != ''){
$nagios_url = $nagios_url_parts['scheme'].'://'.$auth_string.$nagios_url_parts['host'].(isset($nagios_url_parts['port']) ? ':' . $nagios_url_parts['port'] : '');
$pathparts = explode('/check_mk', $nagios_url_parts['path'], 2);
$nagios_url .= $pathparts[0].'/check_mk/login.py?_login=1&_password='.rawurlencode($nagios_password).'&_username='.rawurlencode($nagios_user);
if (strlen(@$pathparts[1]) > 0) {
if (substr($pathparts[1], 0, 1) == '/') $pathparts[1] = substr($pathparts[1], 1, strlen($pathparts[1])-1);
$nagios_url .= '&_origtarget='.rawurlencode(str_replace('&', '%3D', str_replace('?', '%3F', $pathparts[1])));
}
if (isset($nagios_url_parts['query'])) $nagios_url .= '?'.$nagios_url_parts['query'];
} else {
$nagios_url = $nagios_url_parts['scheme'].'://'.$auth_string.$nagios_url_parts['host'].(isset($nagios_url_parts['port']) ? ':' . $nagios_url_parts['port'] : '');
$pathparts = explode('/check_mk', $nagios_url_parts['path'], 2);
$nagios_url .= $pathparts[0].'/check_mk/login.py';
if (strlen(@$pathparts[1]) > 0) {
if (substr($pathparts[1], 0, 1) == '/') $pathparts[1] = substr($pathparts[1], 1, strlen($pathparts[1])-1);
$nagios_url .= '?_origtarget='.rawurlencode(str_replace('&', '%3D', str_replace('?', '%3F', $pathparts[1])));
}
if (isset($nagios_url_parts['query'])) $nagios_url .= '?'.$nagios_url_parts['query'];
}
} else {
//** Nagios
$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 = $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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment