ftimme
2013-07-21 a4814eea469c780bd2095f03662be46dda6818fc
- Monit integration into Monitoring module; allows to start/stop/restart services.
- Added [SERVERNAME] placeholder to webmail URL.
2 files added
14 files modified
178 ■■■■■ changed files
install/tpl/server.ini.master 3 ●●●●● patch | view | raw | blame | history
interface/web/admin/form/server_config.tform.php 28 ●●●●● patch | view | raw | blame | history
interface/web/admin/form/system_config.tform.php 3 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/de_server_config.lng 5 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/de_system_config.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_server_config.lng 5 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_system_config.lng 2 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_server_edit.htm 12 ●●●●● patch | view | raw | blame | history
interface/web/admin/templates/system_config_mail_edit.htm 2 ●●● patch | view | raw | blame | history
interface/web/admin/templates/system_config_sites_edit.htm 2 ●●● patch | view | raw | blame | history
interface/web/mail/webmailer.php 11 ●●●● patch | view | raw | blame | history
interface/web/monitor/lib/lang/de.lng 3 ●●●●● patch | view | raw | blame | history
interface/web/monitor/lib/lang/en.lng 3 ●●●●● patch | view | raw | blame | history
interface/web/monitor/lib/module.conf.php 5 ●●●●● patch | view | raw | blame | history
interface/web/monitor/show_monit.php 82 ●●●●● patch | view | raw | blame | history
interface/web/monitor/templates/show_monit.htm 10 ●●●●● patch | view | raw | blame | history
install/tpl/server.ini.master
@@ -16,6 +16,9 @@
admin_notify_events=1
backup_dir=/var/backup
backup_mode=rootgz
monit_url=
monit_user=
monit_password=
[mail]
module=postfix_mysql
interface/web/admin/form/server_config.tform.php
@@ -179,6 +179,34 @@
            'width' => '40',
            'maxlength' => '255'
        ),
        'monit_url' => array(
            'datatype' => 'VARCHAR',
            'formtype' => 'TEXT',
            'default' => '',
            'validators'    => array ( 0 => array (    'type'    => 'REGEX',
                                                                'regex' => '/^[0-9a-zA-Z\:\/\-\.\[\]]{0,255}$/',
                                                                'errmsg'=> 'monit_url_error_regex'),
                                                ),
            'value' => '',
            'width' => '40',
            'maxlength' => '255'
        ),
        'monit_user' => array(
            'datatype' => 'VARCHAR',
            'formtype' => 'TEXT',
            'default' => '',
            'value' => '',
            'width' => '40',
            'maxlength' => '255'
        ),
        'monit_password' => array(
            'datatype' => 'VARCHAR',
            'formtype' => 'TEXT',
            'default' => '',
            'value' => '',
            'width' => '40',
            'maxlength' => '255'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
interface/web/admin/form/system_config.tform.php
@@ -190,7 +190,8 @@
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array ( 0 => array (    'type'    => 'REGEX',
                                                                'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}(\?.+)?$/',
                                                                /*'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}(\?.+)?$/',*/
                                                                'regex' => '/^[0-9a-zA-Z\:\/\-\.\[\]]{0,255}$/',
                                                                'errmsg'=> 'webmail_url_error_regex'),
                                                ),
            'default'    => '',
interface/web/admin/lib/lang/de_server_config.lng
@@ -178,4 +178,9 @@
$wb['overquota_notify_freq_note_txt'] = '0 = Meldung nur einmalig versenden, keine Wiederholung';
$wb['admin_notify_events_txt'] = 'Sende E-Mail an Administrator ab folgendem Level';
$wb['no_notifications_txt'] = 'Keine Benachrichtigungen';
$wb['monit_url_txt'] = 'Monit-URL';
$wb['monit_user_txt'] = 'Monit-Benutzer';
$wb['monit_password_txt'] = 'Monit-Passwort';
$wb['monit_url_error_regex'] = 'Ungültige Monit-URL';
$wb['monit_url_note_txt'] = 'Platzhalter:';
?>
interface/web/admin/lib/lang/de_system_config.lng
@@ -50,4 +50,6 @@
$wb['mailbox_show_mail_filter_tab_txt'] = 'Zeige E-Mail Filter Reiter in E-Mail Kontodetails';
$wb['mailbox_show_custom_rules_tab_txt'] = 'Zeige Benutzerregel Reiter in E-Mail Kontodetails';
$wb['webmail_url_error_regex'] = 'Falsche Webmail URL';
$wb['phpmyadmin_url_note_txt'] = 'Platzhalter:';
$wb['webmail_url_note_txt'] = 'Platzhalter:';
?>
interface/web/admin/lib/lang/en_server_config.lng
@@ -178,4 +178,9 @@
$wb['overquota_notify_freq_note_txt'] = '0 = send message just once, no repeated messages';
$wb['admin_notify_events_txt'] = 'Send email to admin starting with the following level';
$wb['no_notifications_txt'] = 'No Notifications';
$wb['monit_url_txt'] = 'Monit URL';
$wb['monit_user_txt'] = 'Monit User';
$wb['monit_password_txt'] = 'Monit Password';
$wb['monit_url_error_regex'] = 'Invalid Monit URL';
$wb['monit_url_note_txt'] = 'Placeholder:';
?>
interface/web/admin/lib/lang/en_system_config.lng
@@ -50,4 +50,6 @@
$wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details';
$wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details';
$wb['webmail_url_error_regex'] = 'Invalid webmail URL';
$wb['phpmyadmin_url_note_txt'] = 'Placeholder:';
$wb['webmail_url_note_txt'] = 'Placeholder:';
?>
interface/web/admin/templates/server_config_server_edit.htm
@@ -65,6 +65,18 @@
                    {tmpl_var name='backup_mode'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="monit_url">{tmpl_var name='monit_url_txt'}</label>
                <input name="monit_url" id="monit_url" value="{tmpl_var name='monit_url'}" size="40" maxlength="255" type="text" class="textInput" />&nbsp;{tmpl_var name='monit_url_note_txt'} <a href="javascript:void(0);" class="addPlaceholder">[SERVERNAME]</a>
            </div>
            <div class="ctrlHolder">
                <label for="monit_user">{tmpl_var name='monit_user_txt'}</label>
                <input name="monit_user" id="monit_user" value="{tmpl_var name='monit_user'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
            <div class="ctrlHolder">
                <label for="monit_password">{tmpl_var name='monit_password_txt'}</label>
                <input name="monit_password" id="monit_password" value="{tmpl_var name='monit_password'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
        </fieldset>
            
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
interface/web/admin/templates/system_config_mail_edit.htm
@@ -19,7 +19,7 @@
            </div>
            <div class="ctrlHolder">
                <label for="webmail_url">{tmpl_var name='webmail_url_txt'}</label>
                <input name="webmail_url" id="webmail_url" value="{tmpl_var name='webmail_url'}" size="30" maxlength="255" type="text" class="textInput" />
                <input name="webmail_url" id="webmail_url" value="{tmpl_var name='webmail_url'}" size="30" maxlength="255" type="text" class="textInput" />&nbsp;{tmpl_var name='webmail_url_note_txt'} <a href="javascript:void(0);" class="addPlaceholder">[SERVERNAME]</a>
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='mailmailinglist_link_txt'}</p>
interface/web/admin/templates/system_config_sites_edit.htm
@@ -33,7 +33,7 @@
            </div>
            <div class="ctrlHolder">
                <label for="phpmyadmin_url">{tmpl_var name='phpmyadmin_url_txt'}</label>
                <input name="phpmyadmin_url" id="phpmyadmin_url" value="{tmpl_var name='phpmyadmin_url'}" size="30" maxlength="255" type="text" class="textInput" />
                <input name="phpmyadmin_url" id="phpmyadmin_url" value="{tmpl_var name='phpmyadmin_url'}" size="30" maxlength="255" type="text" class="textInput" />&nbsp;{tmpl_var name='phpmyadmin_url_note_txt'} <a href="javascript:void(0);" class="addPlaceholder">[SERVERNAME]</a>, <a href="javascript:void(0);" class="addPlaceholder">[DATABASENAME]</a>
            </div>
            <div class="ctrlHolder">
                <label for="webftp_url">{tmpl_var name='webftp_url_txt'}</label>
interface/web/mail/webmailer.php
@@ -55,14 +55,21 @@
$global_config = $app->getconf->get_global_config('mail');
if($global_config['webmail_url'] != '') {
    header('Location:' . $global_config['webmail_url']);
    $webmail_url = $global_config['webmail_url'];
    $webmail_url = str_replace('[SERVERNAME]', $serverData['server_name'], $webmail_url);
    header('Location:' . $webmail_url);
} else {
/*
 * We only redirect to the login-form, so there is no need, to check any rights
 */
    isset($_SERVER['HTTPS'])? $http = 'https' : $http = 'http';
    header('Location:' . $http . '://' . $serverData['server_name'] . '/webmail');
    if($web_config['server_type'] == 'nginx') {
        header('Location: http://' . $serverData['server_name'] . ':8081/webmail');
    } else {
        header('Location: ' . $http . '://' . $serverData['server_name'] . '/webmail');
    }
    isset($_SERVER['HTTPS'])? $http = 'https' : $http = 'http';
}
exit;
?>
interface/web/monitor/lib/lang/de.lng
@@ -146,4 +146,7 @@
$wb['Show fail2ban-Log'] = 'Fail2ban Protokoll anzeigen';
$wb['Show IPTables'] = 'IPTables anzeigen';
$wb['Show OpenVz VE BeanCounter'] = 'OpenVz VE BeanCounter anzeigen';
$wb['Show Monit'] = 'Monit anzeigen';
$wb['no_monit_url_defined_txt'] = 'Keine Monit-URL definiert.';
$wb['no_permissions_to_view_monit_txt'] = 'Sie haben nicht die Berechtigung, auf Monit zuzugreifen.';
?>
interface/web/monitor/lib/lang/en.lng
@@ -146,4 +146,7 @@
$wb['monitor_title_beancounter_txt'] = 'OpenVz VE BeanCounter';
$wb['monitor_updates_nosupport_txt'] = 'Your distribution is not supported for this monitoring';
$wb['monitor_beancounter_nosupport_txt'] = 'This server is not a OpenVz VE and has no beancounter information';
$wb['Show Monit'] = 'Show Monit';
$wb['no_monit_url_defined_txt'] = 'No Monit URL defined.';
$wb['no_permissions_to_view_monit_txt'] = 'You are not allowed to access Monit.';
?>
interface/web/monitor/lib/module.conf.php
@@ -115,6 +115,11 @@
                  'target'     => 'content',
                  'link'    => 'monitor/show_data.php?type=services',
                  'html_id' => 'services');
$items[] = array( 'title'     => "Show Monit",
                  'target'     => 'content',
                  'link'    => 'monitor/show_monit.php',
                  'html_id' => 'monit');
$items[] = array( 'title'     => "Show OpenVz VE BeanCounter",
                  'target'     => 'content',
interface/web/monitor/show_monit.php
New file
@@ -0,0 +1,82 @@
<?php
/*
Copyright (c) 2007-2008, Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
//* Check permissions for module
$app->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_monit.htm');
$monTransSrv = $app->lng("monitor_settings_server_txt");
$title = 'Monit ('. $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');
    $monit_url = trim($server_config['monit_url']);
    if($monit_url != ''){
        $monit_url = str_replace('[SERVERNAME]', $_SESSION['monitor']['server_name'], $monit_url);
        $monit_user = trim($server_config['monit_user']);
        $monit_password = trim($server_config['monit_password']);
        $auth_string = '';
        if($monit_user != ''){
            $auth_string = $monit_user;
        }
        if($monit_user != '' && $monit_password != ''){
            $auth_string .= ':'.$monit_password;
        }
        if($auth_string != '') $auth_string .= '@';
        $monit_url_parts = parse_url($monit_url);
        $monit_url = $monit_url_parts['scheme'].'://'.$auth_string.$monit_url_parts['host'].(isset($monit_url_parts['port']) ? ':' . $monit_url_parts['port'] : '').(isset($monit_url_parts['path']) ? $monit_url_parts['path'] : '').(isset($monit_url_parts['query']) ? '?' . $monit_url_parts['query'] : '').(isset($monit_url_parts['fragment']) ? '#' . $monit_url_parts['fragment'] : '');
        $app->tpl->setVar("monit_url", $monit_url);
    } else {
        $app->tpl->setVar("no_monit_url_defined_txt", $app->lng("no_monit_url_defined_txt"));
    }
} else {
    $app->tpl->setVar("no_permissions_to_view_monit_txt", $app->lng("no_permissions_to_view_monit_txt"));
}
$app->tpl_defaults();
$app->tpl->pparse();
?>
interface/web/monitor/templates/show_monit.htm
New file
@@ -0,0 +1,10 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_system">
<tmpl_if name='monit_url'>
    <iframe src="{tmpl_var name="monit_url"}" width="100%" height="1000" frameborder="0" style="overflow:visible;"></iframe>
<tmpl_else>
    <div id="errorMsg"><h3>ERROR</h3><ol><li>{tmpl_var name="no_monit_url_defined_txt"} {tmpl_var name="no_permissions_to_view_monit_txt"}<br></li></ol></div>
</tmpl_if>
</div>