From 8eb646a8abd3c39d37adb64d3908cd6ee6b1e5a8 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Fri, 24 Jun 2011 04:09:53 -0400
Subject: [PATCH] Fixed a firewall configuration problem.

---
 server/mods-available/monitor_core_module.inc.php |  131 ++++++++++++++++++++++++++-----------------
 1 files changed, 79 insertions(+), 52 deletions(-)

diff --git a/server/mods-available/monitor_core_module.inc.php b/server/mods-available/monitor_core_module.inc.php
index 4a6d341..4294e54 100644
--- a/server/mods-available/monitor_core_module.inc.php
+++ b/server/mods-available/monitor_core_module.inc.php
@@ -76,6 +76,7 @@
 	 */
 	// TODO: what monitoring is done should be a config-var
 	private function _doMonitor() {
+		global $app;
 		/*
 		 * We need the tools in almost every method, so initialize them once...
 		 */
@@ -85,6 +86,7 @@
 		/*
 		 * Calls the single Monitoring steps 
 		 */
+		$this->_monitorEmailQuota();
 		$this->_monitorHDQuota();
 		$this->_monitorServer();
 		$this->_monitorOsVer();
@@ -113,6 +115,31 @@
 		$this->_monitorSysLog();
 	}
 
+    private function _monitorEmailQuota() {
+        global $app;
+
+        /*
+         * First we get the Monitoring-data from the tools
+         */
+        $res = $this->_tools->monitorEmailQuota();
+
+        /*
+         * 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 _monitorHDQuota() {
 		global $app;
 
@@ -128,14 +155,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorServer() {
@@ -153,14 +180,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorOsVer() {
@@ -178,14 +205,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorIspcVer() {
@@ -203,14 +230,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorDiskUsage() {
@@ -228,14 +255,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorMemUsage() {
@@ -252,14 +279,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorCpu() {
@@ -276,14 +303,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorServices() {
@@ -301,14 +328,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorOpenVzHost() {
@@ -326,14 +353,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorOpenVzUserBeancounter() {
@@ -351,21 +378,21 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorSystemUpdate() {
 		/*
 		 *  This monitoring is expensive, so do it only once an hour
 		 */
-		$min = date('i');
+		$min = @date('i');
 		if ($min != 0)
 			return;
 
@@ -386,14 +413,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorMailQueue() {
@@ -411,14 +438,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorRaid() {
@@ -436,22 +463,22 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorRkHunter() {
 		/*
 		 *  This monitoring is expensive, so do it only once a day
 		 */
-		$min = date('i');
-		$hour = date('H');
+		$min = @date('i');
+		$hour = @date('H');
 		if (!($min == 0 && $hour == 23))
 			return;
 		/*
@@ -471,14 +498,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorFail2ban() {
@@ -496,14 +523,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorSysLog() {
@@ -521,14 +548,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorMailLog() {
@@ -546,14 +573,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorMailWarnLog() {
@@ -571,14 +598,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorMailErrLog() {
@@ -596,14 +623,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorMessagesLog() {
@@ -621,14 +648,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorISPCCronLog() {
@@ -646,14 +673,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorFreshClamLog() {
@@ -671,14 +698,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorClamAvLog() {
@@ -696,14 +723,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	private function _monitorIspConfigLog() {
@@ -721,14 +748,14 @@
 				'VALUES (' .
 				$res['server_id'] . ', ' .
 				"'" . $app->dbmaster->quote($res['type']) . "', " .
-				time() . ', ' .
+				'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($type, $res['server_id']);
+		$this->_delOldRecords($res['type'], $res['server_id']);
 	}
 
 	/**
@@ -762,4 +789,4 @@
 
 }
 
-?>
+?>
\ No newline at end of file

--
Gitblit v1.9.1