From 33e2c95c69b405f36caf9013ff9a256e6edf9500 Mon Sep 17 00:00:00 2001 From: tbrehm <t.brehm@ispconfig.org> Date: Mon, 11 Feb 2013 08:15:44 -0500 Subject: [PATCH] - htpasswd_stats file was not readable for apache user. --- server/mods-available/monitor_core_module.inc.php | 77 ++++++++++++++++++++++++-------------- 1 files changed, 48 insertions(+), 29 deletions(-) diff --git a/server/mods-available/monitor_core_module.inc.php b/server/mods-available/monitor_core_module.inc.php index ec85bed..63a813c 100644 --- a/server/mods-available/monitor_core_module.inc.php +++ b/server/mods-available/monitor_core_module.inc.php @@ -117,9 +117,20 @@ } private function _monitorEmailQuota() { - global $app; + global $app, $conf; /* + * This monitoring is expensive, so do it only every 15 minutes + */ + $min = @date('i'); + if ($min % 15 != 0) return; + + $app->uses('getconf'); + $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); + if($mail_config['mailbox_quota_stats'] == 'n') return; + + + /* * First we get the Monitoring-data from the tools */ $res = $this->_tools->monitorEmailQuota(); @@ -127,7 +138,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -152,7 +163,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -177,7 +188,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -202,7 +213,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -227,7 +238,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -252,7 +263,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -276,7 +287,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -300,7 +311,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -325,7 +336,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -350,7 +361,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -375,7 +386,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -406,11 +417,14 @@ * First we get the Monitoring-data from the tools */ $res = $this->_tools->monitorSystemUpdate(); + + //* Ensure that output is encoded so that it does not break the serialize + $res['data']['output'] = htmlentities($res['data']['output']); /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -435,7 +449,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -460,7 +474,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -495,7 +509,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -520,7 +534,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -546,7 +560,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -571,7 +585,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -596,7 +610,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -621,7 +635,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -646,7 +660,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -671,7 +685,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -692,11 +706,14 @@ * First we get the Monitoring-data from the tools */ $res = $this->_tools->monitorISPCCronLog(); + + //* Ensure that output is encoded so that it does not break the serialize + if(is_array($res) && isset($res['data'])) $res['data'] = htmlentities($res['data']); /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -721,7 +738,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -746,7 +763,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -771,7 +788,7 @@ /* * Insert the data into the database */ - $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' . + $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . 'VALUES (' . $res['server_id'] . ', ' . "'" . $app->dbmaster->quote($res['type']) . "', " . @@ -794,8 +811,10 @@ private function _delOldRecords($type, $serverId) { global $app; - $now = time(); - $old = $now - (4 * 60); // 4 minutes + // $now = time(); + // $old = $now - (4 * 60); // 4 minutes + $old = 'UNIX_TIMESTAMP() - 240'; + /* * ATTENTION if i do NOT pay attention of the server id, i delete all data (of the type) * of ALL servers. This means, if i have a multiserver-environment and a server has a -- Gitblit v1.9.1