From dae3b41faee2777046b0b612e2bd8b28caf0f189 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 19 Jul 2012 04:07:53 -0400
Subject: [PATCH] Fixed a warning in cron log on non web servers.
---
server/mods-available/monitor_core_module.inc.php | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/server/mods-available/monitor_core_module.inc.php b/server/mods-available/monitor_core_module.inc.php
index a0410c8..2bc95d8 100644
--- a/server/mods-available/monitor_core_module.inc.php
+++ b/server/mods-available/monitor_core_module.inc.php
@@ -86,7 +86,7 @@
/*
* Calls the single Monitoring steps
*/
-// $this->_monitorEmailQuota();
+ $this->_monitorEmailQuota();
$this->_monitorHDQuota();
$this->_monitorServer();
$this->_monitorOsVer();
@@ -112,13 +112,25 @@
$this->_monitorRaid();
$this->_monitorRkHunter();
$this->_monitorFail2ban();
+ $this->_monitorIPTables();
$this->_monitorSysLog();
}
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();
@@ -405,6 +417,9 @@
* 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
@@ -509,12 +524,38 @@
}
private function _monitorFail2ban() {
+ global $app;
+
+ /*
+ * First we get the Monitoring-data from the tools
+ */
+ $res = $this->_tools->monitorFail2ban();
+
+ /*
+ * Insert the data into the database
+ */
+ $sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+ 'VALUES (' .
+ $res['server_id'] . ', ' .
+ "'" . $app->dbmaster->quote($res['type']) . "', " .
+ 'UNIX_TIMESTAMP(), ' .
+ "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " .
+ "'" . $res['state'] . "'" .
+ ')';
+ $app->dbmaster->query($sql);
+
+ /* The new data is written, now we can delete the old one */
+ $this->_delOldRecords($res['type'], $res['server_id']);
+ }
+
+
+ private function _monitorIPTables() {
global $app;
/*
* First we get the Monitoring-data from the tools
*/
- $res = $this->_tools->monitorFail2ban();
+ $res = $this->_tools->monitorIPTables();
/*
* Insert the data into the database
@@ -665,6 +706,9 @@
* 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
+ $res['data']['output'] = htmlentities($res['data']['output']);
/*
* Insert the data into the database
@@ -767,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