Till Brehm
2016-04-22 8cad78372e31c0f9c06be4654fbf59d85ef11f0e
Merge branch 'stable-3.1' of git.ispconfig.org:ispconfig/ispconfig3 into stable-3.1
2 files renamed
6 files modified
75 ■■■■■ changed files
interface/web/admin/templates/server_config_rescue_edit.htm 2 ●●●●● patch | view | raw | blame | history
interface/web/monitor/lib/module.conf.php 3 ●●●● patch | view | raw | blame | history
interface/web/monitor/show_data.php 2 ●●●●● patch | view | raw | blame | history
interface/web/sites/database_user_edit.php 5 ●●●●● patch | view | raw | blame | history
server/lib/classes/cron.d/100-monitor_mongodb.inc.php~ patch | view | raw | blame | history
server/lib/classes/monitor_tools.inc.php 4 ●●● patch | view | raw | blame | history
server/mods-available/rescue_core_module.inc.php 59 ●●●● patch | view | raw | blame | history
server/plugins-available/mongo_clientdb_plugin.inc.php~ patch | view | raw | blame | history
interface/web/admin/templates/server_config_rescue_edit.htm
@@ -17,12 +17,14 @@
                    {tmpl_var name='do_not_try_rescue_httpd'}
                </div>
            </div>
<!--
            <div class="form-group">
                <label class="col-sm-3 control-label">{tmpl_var name='do_not_try_rescue_mongodb_txt'}</label>
                <div class="col-sm-9">
                    {tmpl_var name='do_not_try_rescue_mongodb'}
                </div>
            </div>
-->
            <div class="form-group">
                <label class="col-sm-3 control-label">{tmpl_var name='do_not_try_rescue_mysql_txt'}</label>
                <div class="col-sm-9">
interface/web/monitor/lib/module.conf.php
@@ -196,11 +196,12 @@
    'link' => 'monitor/show_data.php?type=fail2ban',
    'html_id' => 'fai2ban');
/*
$items[] = array( 'title'  => "Show MongoDB-Log",
    'target'  => 'content',
    'link' => 'monitor/show_data.php?type=mongodb',
    'html_id' => 'mongodb');
*/
$items[] = array( 'title'  => "Show IPTables",
    'target'  => 'content',
    'link' => 'monitor/show_data.php?type=iptables',
interface/web/monitor/show_data.php
@@ -138,6 +138,7 @@
    $description = '';
    $add_padding = true;
    break;
/*
case 'mongodb':
    $template = 'templates/show_data.htm';
    $output .= $app->tools_monitor->showMongoDB();
@@ -145,6 +146,7 @@
    $title = $app->lng("monitor_title_mongodb_txt") . ' (' . $monTransSrv . ' : ' . $_SESSION['monitor']['server_name'] . ')';
    $description = '';
    break;
*/
case 'iptables':
    $template = 'templates/show_data.htm';
    $output .= $app->tools_monitor->showIPTables();
interface/web/sites/database_user_edit.php
@@ -169,10 +169,11 @@
        /* prepare password for MongoDB */
        // TODO: this still doens't work as when only the username changes we have no database_password.
        // taking the one from oldData doesn't work as it's encrypted...shit!
/*
        $this->dataRecord['database_password_mongo'] = $this->dataRecord['database_user'].":mongo:".$this->dataRecord['database_password'];
        $this->dataRecord['server_id'] = 0; // we need this on all servers
*/
        parent::onBeforeUpdate();
    }
@@ -206,7 +207,7 @@
        $this->dataRecord['server_id'] = 0; // we need this on all servers
        /* prepare password for MongoDB */
        $this->dataRecord['database_password_mongo'] = $this->dataRecord['database_user'].":mongo:".$this->dataRecord['database_password'];
//        $this->dataRecord['database_password_mongo'] = $this->dataRecord['database_user'].":mongo:".$this->dataRecord['database_password'];
        parent::onBeforeInsert();
    }
server/lib/classes/cron.d/100-monitor_mongodb.inc.php~
server/lib/classes/monitor_tools.inc.php
@@ -370,14 +370,16 @@
                $state = 'error'; // because service is down
            }
        }
/*
        $data['mongodbserver'] = -1;
        if ($this->_checkTcp('localhost', 27017)) {
            $data['mongodbserver'] = 1;
        } else {
            $data['mongodbserver'] = 0;
*/
            //$state = 'error'; // because service is down
            /* TODO!!! check if this is a mongodbserver at all, otherwise it will always throw an error state!!! */
        }
//        }
        /*
         * Return the Result
server/mods-available/rescue_core_module.inc.php
@@ -97,7 +97,7 @@
        /*
         * rescue MongoDB if needed
         */
        $this->_rescueMongoDB();
//        $this->_rescueMongoDB();
        /*
         * rescue mysql if needed (maybe httpd depends on mysql, so try this first!)
@@ -311,42 +311,43 @@
        $this->_rescueDaemon($daemon);
    }
    /**
     * restarts MongoDB, if needed
     */
    private function _rescueMongoDB(){
        global $app, $conf;
//    private function _rescueMongoDB(){
//        global $app, $conf;
        /*
         * do nothing, if it is not allowed to rescue mysql
         */
        if ((isset($conf['serverconfig']['rescue']['do_not_try_rescue_mongodb']) && ($conf['serverconfig']['rescue']['do_not_try_rescue_mongodb']) == 'y')){
            return;
        }
//        if ((isset($conf['serverconfig']['rescue']['do_not_try_rescue_mongodb']) && ($conf['serverconfig']['rescue']['do_not_try_rescue_mongodb']) == 'y')){
//            return;
//        }
        /*
         * if the service is up and running, or the service is not installed there is nothing to do...
         */
        if ($this->_monitoringData[0][0]['data']['mongodbserver'] != 0){
            /* Clear the try counter, because we do not have to try to rescue the service */
            $this->_rescueData['mongodbserver']['try_counter'] = 0;
            return;
        }
//        if ($this->_monitoringData[0][0]['data']['mongodbserver'] != 0){
//            /* Clear the try counter, because we do not have to try to rescue the service */
//            $this->_rescueData['mongodbserver']['try_counter'] = 0;
//            return;
//        }
        /*
         * OK, the service is installed and down.
         * Maybe this is because of a restart of the service by the admin.
         * This means, we check the data 1 minute ago
         */
        if ((!isset($this->_monitoringData[1][0]['data']['mongodbserver'])) ||
            ((isset($this->_monitoringData[1][0]['data']['mongodbserver'])) && ($this->_monitoringData[1][0]['data']['mongodbserver'] != 0))){
//        if ((!isset($this->_monitoringData[1][0]['data']['mongodbserver'])) ||
//            ((isset($this->_monitoringData[1][0]['data']['mongodbserver'])) && ($this->_monitoringData[1][0]['data']['mongodbserver'] != 0))){
            /*
             * We do NOT have this data or we have this data, but the webserver was not down 1 minute ago.
             * This means, it could be, that the admin is restarting the server.
             * We wait one more minute...
             */
            return;
        }
//            return;
//        }
        /*#####
         * The service is down and it was down 1 minute ago.
@@ -354,28 +355,28 @@
         *#####*/
        /* Get the try counter */
        $tryCount = (!isset($this->_rescueData['mongodbserver']['try_counter']))? 1 : $this->_rescueData['mongodbserver']['try_counter'] + 1;
//        $tryCount = (!isset($this->_rescueData['mongodbserver']['try_counter']))? 1 : $this->_rescueData['mongodbserver']['try_counter'] + 1;
        /* Set the new try counter */
        $this->_rescueData['mongodbserver']['try_counter'] = $tryCount;
//        $this->_rescueData['mongodbserver']['try_counter'] = $tryCount;
        /* if 5 times will not work, we have to give up... */
        if ($tryCount > 5){
            $app->log('MongoDB is down! Rescue will not help!', LOGLEVEL_ERROR);
            return;
        }
//        if ($tryCount > 5){
//            $app->log('MongoDB is down! Rescue will not help!', LOGLEVEL_ERROR);
//            return;
//        }
        $app->log('MongoDB is down! Try rescue MongoDB (try:' . $tryCount . ')...', LOGLEVEL_WARN);
//        $app->log('MongoDB is down! Try rescue MongoDB (try:' . $tryCount . ')...', LOGLEVEL_WARN);
        if(is_file($conf['init_scripts'] . '/' . 'mongodb')) {
            $daemon = 'mongodb';
        } else {
            $daemon = 'mongodb';
        }
//        if(is_file($conf['init_scripts'] . '/' . 'mongodb')) {
//            $daemon = 'mongodb';
//        } else {
//            $daemon = 'mongodb';
//        }
        $this->_rescueDaemon($daemon);
    }
//        $this->_rescueDaemon($daemon);
//    }
    /**
     * restarts mysql, if needed
server/plugins-available/mongo_clientdb_plugin.inc.php~