From 5bbfc1b098302671bcbf2f754efc627d50eaa5c7 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 13 Jan 2011 09:25:59 -0500
Subject: [PATCH] Added global functions library which conatins a mail functin that supports attachments and a array_merge function that merges arrays that conatain numeric keys and strings correctly.

---
 server/mods-available/monitor_core_module.inc.php |  713 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 459 insertions(+), 254 deletions(-)

diff --git a/server/mods-available/monitor_core_module.inc.php b/server/mods-available/monitor_core_module.inc.php
index f0e7771..a29b922 100644
--- a/server/mods-available/monitor_core_module.inc.php
+++ b/server/mods-available/monitor_core_module.inc.php
@@ -53,7 +53,7 @@
 		/*
          * Do the monitor every n minutes and write the result to the db
 		*/
-		$min = date('i');
+		$min = @date('i');
 		if (($min % $this->interval) == 0) {
 			$this->doMonitor();
 		}
@@ -69,8 +69,8 @@
 
 	//** Get distribution identifier
 	//** IMPORTANT!
-	//   This is the same code as in /install/install.php
-	//   So if you change it here, you also have to change it in /install/install.php!
+	//   This is the same code as in install/lib/install.lib.php
+	//   So if you change it here, you also have to change it in there!
 	//   Please do not forget to remove the swriteln(); - lines here at this file
 	function get_distname() {
 
@@ -95,7 +95,7 @@
 			} elseif(strstr(trim(file_get_contents('/etc/debian_version')),'6.0') || trim(file_get_contents('/etc/debian_version')) == 'squeeze/sid') {
 				$distname = 'Debian';
 				$distver = 'Squeeze/Sid';
-				$distid = 'debian40';
+				$distid = 'debian60';
 				$distbaseid = 'debian';
 			}  else {
 				$distname = 'Debian';
@@ -106,7 +106,7 @@
 		}
 
 		//** OpenSuSE
-		elseif(file_exists("/etc/SuSE-release")) {
+		elseif(file_exists('/etc/SuSE-release')) {
 			if(stristr(file_get_contents('/etc/SuSE-release'),'11.0')) {
 				$distname = 'openSUSE';
 				$distver = '11.0';
@@ -132,7 +132,7 @@
 
 
 		//** Redhat
-		elseif(file_exists("/etc/redhat-release")) {
+		elseif(file_exists('/etc/redhat-release')) {
 
 			$content = file_get_contents('/etc/redhat-release');
 
@@ -170,7 +170,7 @@
 		}
 
 		//** Gentoo
-		elseif(file_exists("/etc/gentoo-release")) {
+		elseif(file_exists('/etc/gentoo-release')) {
 
 			$content = file_get_contents('/etc/gentoo-release');
 
@@ -181,7 +181,7 @@
 			$distbaseid = 'gentoo';
 
 		} else {
-			die('unrecognized linux distribution');
+			die('Unrecognized GNU/Linux distribution');
 		}
 
 		return array('name' => $distname, 'version' => $distver, 'id' => $distid, 'baseid' => $distbaseid);
@@ -195,14 +195,18 @@
 	// TODO: what monitoring is done should be a config-var
 	function doMonitor() {
 		/* Calls the single Monitoring steps */
+		$this->monitorHDQuota();
 		$this->monitorServer();
 		$this->monitorOSVer();
+		$this->monitorIspCVer();
 		$this->monitorDiskUsage();
 		$this->monitorMemUsage();
 		$this->monitorCpu();
 		$this->monitorServices();
-		$this->monitorOpenVzHost();
-		$this->monitorOpenVzUserBeancounter();
+		if(@file_exists('/proc/user_beancounters')) {
+			$this->monitorOpenVzHost();
+			$this->monitorOpenVzUserBeancounter();
+		}
 		$this->monitorMailLog();
 		$this->monitorMailWarnLog();
 		$this->monitorMailErrLog();
@@ -218,13 +222,106 @@
 		$this->monitorFail2ban();
 		$this->monitorSysLog();
 	}
+	
+	function monitorHDQuota() {
+		global $app;
+		global $conf;
+		
+		/* Initialize data array */
+		$data = array();
 
+		/* the id of the server as int */
+		$server_id = intval($conf['server_id']);
+
+		/** The type of the data */
+		$type = 'harddisk_quota';
+
+		/** The state of the harddisk_quota. */
+		$state = 'ok';
+		
+		/** Fetch the data for all users*/
+		$dfData = shell_exec('repquota -au');
+
+		// split into array
+		$df = explode("\n", $dfData);
+
+		/*
+         * ignore the first 5 lines, process the rest
+		*/
+		for($i=5; $i <= sizeof($df); $i++) {
+			if ($df[$i] != '') {
+				/*
+                 * Make a array of the data
+				*/
+				$s = preg_split ('/[\s]+/', $df[$i]);
+				$username = $s[0];
+				if(substr($username,0,3) == 'web') {
+				if(isset($data['user'][$username])) {
+					$data['user'][$username]['used'] += $s[2];
+					$data['user'][$username]['soft'] += $s[3];
+					$data['user'][$username]['hard'] += $s[4];
+				} else {
+					$data['user'][$username]['used'] = $s[2];
+					$data['user'][$username]['soft'] = $s[3];
+					$data['user'][$username]['hard'] = $s[4];
+				}
+				}
+			}
+		}
+		
+		/** Fetch the data for all users*/
+		$dfData = shell_exec('repquota -ag');
+
+		// split into array
+		$df = explode("\n", $dfData);
+
+		/*
+         * ignore the first 5 lines, process the rest
+		*/
+		for($i=5; $i <= sizeof($df); $i++) {
+			if ($df[$i] != '') {
+				/*
+                 * Make a array of the data
+				*/
+				$s = preg_split ('/[\s]+/', $df[$i]);
+				$groupname = $s[0];
+				if(substr($groupname,0,6) == 'client') {
+				if(isset($data['group'][$groupname])) {
+					$data['group'][$groupname]['used'] += $s[1];
+					$data['group'][$groupname]['soft'] += $s[2];
+					$data['group'][$groupname]['hard'] += $s[3];
+				} else {
+					$data['group'][$groupname]['used'] = $s[1];
+					$data['group'][$groupname]['soft'] = $s[2];
+					$data['group'][$groupname]['hard'] = $s[3];
+				}
+				}
+			}
+		}
+
+		/*
+        Insert the data into the database
+		*/
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
+				"'" . $app->dbmaster->quote($type) . "', " .
+				time() . ', ' .
+				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
+				"'" . $state . "'" .
+				')';
+		$app->dbmaster->query($sql);
+
+		/* The new data is written, now we can delete the old one */
+		$this->_delOldRecords($type, 4);
+	}
+	
 	function monitorServer() {
 		global $app;
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'server_load';
@@ -237,15 +334,15 @@
 		$data['up_hours'] = floor(($procUptime-$data['up_days']*86400)/3600);
 		$data['up_minutes'] = floor(($procUptime-$data['up_days']*86400-$data['up_hours']*3600)/60);
 
-		$data['uptime'] = shell_exec("uptime");
+		$data['uptime'] = shell_exec('uptime');
 
-		$tmp = explode(",", $data['uptime'], 4);
-		$tmpUser = explode(" ", trim($tmp[2]));
+		$tmp = explode(',', $data['uptime'], 4);
+		$tmpUser = explode(' ', trim($tmp[2]));
 		$data['user_online'] = intval($tmpUser[0]);
 
 		//* New Load Average code to fix "always zero" bug in non-english distros. NEEDS TESTING
 		$loadTmp = shell_exec("cat /proc/loadavg | cut -f1-3 -d' '");
-		$load = explode(" ", $loadTmp);
+		$load = explode(' ', $loadTmp);
 		$data['load_1'] = floatval(str_replace(',', '.', $load[0]));
 		$data['load_5'] = floatval(str_replace(',', '.', $load[1]));
 		$data['load_15'] = floatval(str_replace(',', '.', $load[2]));
@@ -260,14 +357,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -279,7 +376,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'os_info';
@@ -298,14 +395,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -313,12 +410,48 @@
 	}
 
 
+	function monitorIspcVer() {
+		global $app;
+		global $conf;
+
+		/* the id of the server as int */
+		$server_id = intval($conf['server_id']);
+
+		/** The type of the data */
+		$type = 'ispc_info';
+
+		/*
+        Fetch the data into a array
+		*/
+		$data['name'] = ISPC_APP_TITLE;
+		$data['version'] = ISPC_APP_VERSION;
+
+		/* the ISPC-Version has no state. It is, what it is */
+		$state = 'no_state';
+
+		/*
+        Insert the data into the database
+		*/
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
+				"'" . $app->dbmaster->quote($type) . "', " .
+				time() . ', ' .
+				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
+				"'" . $state . "'" .
+				')';
+		$app->dbmaster->query($sql);
+
+		/* The new data is written, now we can delete the old one */
+		$this->_delOldRecords($type, 4);
+	}
+
 	function monitorDiskUsage() {
 		global $app;
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'disk_usage';
@@ -327,7 +460,7 @@
 		$state = 'ok';
 
 		/** Fetch the data of ALL devices into a array (needed for monitoring!)*/
-		$dfData = shell_exec("df -hT");
+		$dfData = shell_exec('df -hT');
 
 		// split into array
 		$df = explode("\n", $dfData);
@@ -338,9 +471,9 @@
 		for($i=1; $i <= sizeof($df); $i++) {
 			if ($df[$i] != '') {
 				/*
-                 * Make a array of the data
+                 * Make an array of the data
 				*/
-				$s = preg_split ("/[\s]+/", $df[$i]);
+				$s = preg_split ('/[\s]+/', $df[$i]);
 				$data[$i]['fs'] = $s[0];
 				$data[$i]['type'] = $s[1];
 				$data[$i]['size'] = $s[2];
@@ -353,12 +486,21 @@
 				*/
 				$usePercent = floatval($data[$i]['percent']);
 
-				//* We dont want to check the cdrom drive as a cd / dvd is always 100% full
-				if($data[$i]['type'] != 'iso9660' && $data[$i]['type'] != 'cramfs' && $data[$i]['type'] != 'udf') {
-					if ($usePercent > 75) $state = $this->_setState($state, 'info');
-					if ($usePercent > 80) $state = $this->_setState($state, 'warning');
-					if ($usePercent > 90) $state = $this->_setState($state, 'critical');
-					if ($usePercent > 95) $state = $this->_setState($state, 'error');
+				//* We don't want to check some filesystem which have no sensible filling levels
+				switch($data[$i]['type']) {
+					case 'iso9660':
+					case 'cramfs':
+					case 'udf':
+					case 'tmpfs':
+					case 'devtmpfs':
+					case 'udev':
+						break;
+					default: 
+						if ($usePercent > 75) $state = $this->_setState($state, 'info');
+						if ($usePercent > 80) $state = $this->_setState($state, 'warning');
+						if ($usePercent > 90) $state = $this->_setState($state, 'critical');
+						if ($usePercent > 95) $state = $this->_setState($state, 'error');
+						break;
 				}
 			}
 		}
@@ -367,14 +509,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -387,7 +529,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'mem_usage';
@@ -395,14 +537,14 @@
 		/*
         Fetch the data into a array
 		*/
-		$miData = shell_exec("cat /proc/meminfo");
+		$miData = shell_exec('cat /proc/meminfo');
 
 		$memInfo = explode("\n", $miData);
 
 		foreach($memInfo as $line) {
-			$part = preg_split("/:/", $line);
+			$part = preg_split('/:/', $line);
 			$key = trim($part[0]);
-			$tmp = explode(" ", trim($part[1]));
+			$tmp = explode(' ', trim($part[1]));
 			$value = 0;
 			if ($tmp[1] == 'kB') $value = $tmp[0] * 1024;
 			$data[$key] = $value;
@@ -417,14 +559,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -437,7 +579,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'cpu_info';
@@ -445,33 +587,48 @@
 		/*
         Fetch the data into a array
 		*/
-		$cpuData = shell_exec("cat /proc/cpuinfo");
-		$cpuInfo = explode("\n", $cpuData);
-		$processor = 0;
+		if(file_exists('/proc/cpuinfo')) {
+			$cpuData = shell_exec('cat /proc/cpuinfo');
+			$cpuInfo = explode("\n", $cpuData);
+			$processor = 0;
 
-		foreach($cpuInfo as $line) {
+			foreach($cpuInfo as $line) {
 
-			$part = preg_split("/:/", $line);
-			$key = trim($part[0]);
-			$value = trim($part[1]);
-			if($key == 'processor') $processor = intval($value);
-			if($key != '') $data[$key.' '.$processor] = $value;
+				$part = preg_split('/:/', $line);
+				$key = trim($part[0]);
+				$value = trim($part[1]);
+				if($key == 'processor') $processor = intval($value);
+				if($key != '') $data[$key.' '.$processor] = $value;
+			}
+
+			/* the cpu has no state. It is, what it is */
+			$state = 'no_state';
+		} else {
+			/*
+             * It is not Linux, so there is no data and no state
+             *
+             * no_state, NOT unknown, because "unknown" is shown as state
+             * inside the GUI. no_state is hidden.
+             *
+             * We have to write NO DATA inside the DB, because the GUI
+             * could not know, if there is any dat, or not...
+			*/
+			$state = 'no_state';
+			$data['output']= '';
 		}
 
-		/* the cpu has no state. It is, what it is */
-		$state = 'no_state';
 
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -484,16 +641,16 @@
 		global $conf;
 
 		/** the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** get the "active" Services of the server from the DB */
-		$services = $app->dbmaster->queryOneRecord("SELECT * FROM server WHERE server_id = " . $server_id);
+		$services = $app->dbmaster->queryOneRecord('SELECT * FROM server WHERE server_id = ' . $server_id);
 
 		/* The type of the Monitor-data */
 		$type = 'services';
 
 		/** the State of the monitoring */
-		/* ok, if ALL aktive services are running,
+		/* ok, if ALL active services are running,
          * error, if not
          * There is no other state!
 		*/
@@ -565,7 +722,7 @@
 			}
 		}
 
-		/* Monitor MYSQL-Server */
+		/* Monitor MySQL Server */
 		$data['mysqlserver'] = -1; // unknown - not needed
 		if ($services['db_server'] == 1) {
 			if($this->_checkTcp('localhost', 3306)) {
@@ -580,14 +737,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -600,7 +757,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'openvz_veinfo';
@@ -618,14 +775,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -637,7 +794,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'openvz_beancounter';
@@ -666,7 +823,7 @@
 			foreach ($test as $item) {
 				/*
 			     * eliminate all doubled spaces and spaces at the beginning and end
-				 */
+				*/
 				while (strpos($item, '  ') !== false) {
 					$item = str_replace('  ', ' ', $item);
 				}
@@ -674,7 +831,7 @@
 
 				/*
 			     * The failcounter is the LAST
-				 */
+				*/
 				if ($item != '') {
 					$tmp = explode(' ', $item);
 					$failCounter = $tmp[sizeof($tmp)-1];
@@ -689,14 +846,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -706,7 +863,7 @@
 
 	function monitorSystemUpdate() {
 		/*
-         *  This monitoring is expensive, so do it only once a hour
+         *  This monitoring is expensive, so do it only once an hour
 		*/
 		$min = date('i');
 		if ($min != 0) return;
@@ -718,16 +875,16 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'system_update';
 
-		/* This monitoring is only available at debian or Ubuntu */
+		/* This monitoring is only available on Debian or Ubuntu */
 		if(file_exists('/etc/debian_version')) {
 
 			/*
-             * first update the "update-database"
+             * first update the "apt database"
 			*/
 			shell_exec('apt-get update');
 
@@ -753,7 +910,7 @@
 			*/
 			$data['output'] = shell_exec('apt-get -s -q dist-upgrade');
 		}
-		elseif (file_exists("/etc/gentoo-release")) {
+		elseif (file_exists('/etc/gentoo-release')) {
 
 			/*
         	 * first update the portage tree
@@ -782,24 +939,21 @@
              * Then test the upgrade.
              * if there is any output, then there is a needed update
 			*/
-			$emergeData = shell_exec('emerge -puDNt --color n --nospinner --quiet world');
+			$emergeData = shell_exec('glsa-check -t affected');
 			if ($emergeData == '') {
 				/* There is nothing to update! */
 				$state = 'ok';
+				$data['output'] = 'No unapplied GLSA\'s found on the system.';
 			}
 			else {
 				/* There is something to update! */
-				$state = 'warning';
+				$state = 'info';
+				$data['output'] = shell_exec('glsa-check -pv --nocolor affected 2>/dev/null');
 			}
-
-			/*
-             * Fetch the output
-			*/
-			$data['output'] = shell_exec('emerge -pvuDNt --color n --nospinner world');
 		}
 		else {
 			/*
-             * It is not debian/Ubuntu, so there is no data and no state
+             * It is not Debian/Ubuntu, so there is no data and no state
              *
              * no_state, NOT unknown, because "unknown" is shown as state
              * inside the GUI. no_state is hidden.
@@ -814,14 +968,14 @@
 		/*
          * Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -833,7 +987,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'mailq';
@@ -860,14 +1014,14 @@
 		/*
          * Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -880,14 +1034,21 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'raid_state';
 
-		/* This monitoring is only available if mdadm is installed */
-		system('which mdadm', $retval);
-		if($retval === 0) {
+		/*
+		 * We support several RAID types, but if we can't find any of them, we have no data
+		*/
+		$state = 'no_state';
+		$data['output']= '';
+
+		/*
+		 * Check, if Software-RAID is enabled
+		*/
+		if(file_exists('/proc/mdstat')) {
 			/*
              * Fetch the output
 			*/
@@ -935,33 +1096,71 @@
 					}
 				}
 			}
-
 		}
-		else {
-			/*
-             * mdadm is not installed, so there is no data and no state
-             *
-             * no_state, NOT unknown, because "unknown" is shown as state
-             * inside the GUI. no_state is hidden.
-             *
-             * We have to write NO DATA inside the DB, because the GUI
-             * could not know, if there is any dat, or not...
-			*/
-			$state = 'no_state';
-			$data['output']= '';
+		/*
+		 * Check, if we have mpt-status installed (LSIsoftware-raid)
+		*/
+		if(file_exists('/proc/mpt/summary')) {
+			system('which mpt-status', $retval);
+			if($retval === 0) {
+				/*
+				* Fetch the output
+				*/
+				$data['output'] = shell_exec('mpt-status --autoload -n');
+
+				/*
+				* Then calc the state.
+				*/
+				$state = 'ok';
+				foreach ($data['output'] as $item) {
+					/*
+					* The output contains information for every RAID and every HDD.
+					* We only need the state of the RAID
+					*/
+					if (strpos($item, 'raidlevel:') !== false) {
+						/*
+						* We found a raid, process the state of it
+						*/
+						if (strpos($item, ' ONLINE ') !== false) {
+							$this->_setState($state, 'ok');
+						}
+						elseif (strpos($item, ' OPTIMAL ') !== false) {
+							$this->_setState($state, 'ok');
+						}
+						elseif (strpos($item, ' INITIAL ') !== false) {
+							$this->_setState($state, 'info');
+						}
+						elseif (strpos($item, ' INACTIVE ') !== false) {
+							$this->_setState($state, 'critical');
+						}
+						elseif (strpos($item, ' RESYNC ') !== false) {
+							$this->_setState($state, 'info');
+						}
+						elseif (strpos($item, ' DEGRADED ') !== false) {
+							$this->_setState($state, 'critical');
+						}
+						else {
+							/* we don't know the state. so we set the state to critical, that the
+							* admin is warned, that something is wrong
+							*/
+							$this->_setState($state, 'critical');
+						}
+					}
+				}
+			}
 		}
 
 		/*
          * Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -980,7 +1179,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'rkhunter';
@@ -1015,14 +1214,14 @@
 		/*
          * Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1034,7 +1233,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'log_fail2ban';
@@ -1068,14 +1267,14 @@
 		/*
          * Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1087,7 +1286,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'sys_log';
@@ -1096,7 +1295,7 @@
 		 * is there any warning or error for this server?
 		*/
 		$state = 'ok';
-		$dbData = $app->dbmaster->queryAllRecords("SELECT loglevel FROM sys_log WHERE server_id = " . $server_id . " AND loglevel > 0");
+		$dbData = $app->dbmaster->queryAllRecords('SELECT loglevel FROM sys_log WHERE server_id = ' . $server_id . ' AND loglevel > 0');
 		if (is_array($dbData)) {
 			foreach($dbData as $item) {
 				if ($item['loglevel'] == 1) $state = $this->_setState($state, 'warning');
@@ -1110,14 +1309,14 @@
 		/*
          * Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1129,7 +1328,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'log_mail';
@@ -1146,14 +1345,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1165,7 +1364,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'log_mail_warn';
@@ -1182,14 +1381,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1201,7 +1400,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'log_mail_err';
@@ -1218,14 +1417,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1238,7 +1437,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'log_messages';
@@ -1255,14 +1454,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1274,7 +1473,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'log_ispc_cron';
@@ -1291,14 +1490,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1310,7 +1509,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'log_freshclam';
@@ -1327,16 +1526,16 @@
 
 		$tmp = explode("\n", $data);
 		$lastLog = array();
-		if ($tmp[sizeof($tmp)-1] == "") {
+		if ($tmp[sizeof($tmp)-1] == '') {
 			/* the log ends with an empty line remove this */
 			array_pop($tmp);
 		}
-		if (strpos($tmp[sizeof($tmp)-1], "-------------") !== false) {
+		if (strpos($tmp[sizeof($tmp)-1], '-------------') !== false) {
 			/* the log ends with "-----..." remove this */
 			array_pop($tmp);
 		}
 		for ($i = sizeof($tmp) -1; $i > 0; $i--) {
-			if (strpos($tmp[$i], "---------") === false) {
+			if (strpos($tmp[$i], '---------') === false) {
 				/* no delimiter found, so add this to the last-log */
 				$lastLog[] = $tmp[$i];
 			}
@@ -1351,7 +1550,7 @@
          * Check if the outdated-string is found...
 		*/
 		foreach($lastLog as $line) {
-			if (strpos(strtolower($line), "outdated") !== false) {
+			if (strpos(strtolower($line), 'outdated') !== false) {
 				/*
 				 * Outdatet is only info, because if we set this to warning, the server is
 				 * as long in state warning, as there is a new version of ClamAv which takes
@@ -1364,14 +1563,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1383,7 +1582,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'log_clamav';
@@ -1397,14 +1596,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1416,7 +1615,7 @@
 		global $conf;
 
 		/* the id of the server as int */
-		$server_id = intval($conf["server_id"]);
+		$server_id = intval($conf['server_id']);
 
 		/** The type of the data */
 		$type = 'log_ispconfig';
@@ -1430,14 +1629,14 @@
 		/*
         Insert the data into the database
 		*/
-		$sql = "INSERT INTO monitor_data (server_id, type, created, data, state) " .
-				"VALUES (".
-				$server_id . ", " .
+		$sql = 'INSERT INTO monitor_data (server_id, type, created, data, state) ' .
+				'VALUES ('.
+				$server_id . ', ' .
 				"'" . $app->dbmaster->quote($type) . "', " .
-				time() . ", " .
+				time() . ', ' .
 				"'" . $app->dbmaster->quote(serialize($data)) . "', " .
 				"'" . $state . "'" .
-				")";
+				')';
 		$app->dbmaster->query($sql);
 
 		/* The new data is written, now we can delete the old one */
@@ -1446,69 +1645,75 @@
 
 
 	function _getLogData($log) {
+		global $conf;
 
 		$dist = '';
 		$logfile = '';
 
-		if(@is_file('/etc/debian_version')) $dist = 'debian';
-		if(@is_file('/etc/redhat-release')) $dist = 'redhat';
-		if(@is_file('/etc/SuSE-release')) $dist = 'suse';
-		if(@is_file('/etc/gentoo-release')) $dist = 'gentoo';
+		if(@is_file('/etc/debian_version')) {
+			$dist = 'debian';
+		} elseif(@is_file('/etc/redhat-release')) {
+			$dist = 'redhat';
+		} elseif(@is_file('/etc/SuSE-release')) {
+			$dist = 'suse';
+		} elseif(@is_file('/etc/gentoo-release')) {
+			$dist = 'gentoo';
+		}
 
 		switch($log) {
 			case 'log_mail':
-				if($dist == 'debian') $logfile = '/var/log/mail.log';
-				if($dist == 'redhat') $logfile = '/var/log/maillog';
-				if($dist == 'suse') $logfile = '/var/log/mail.info';
-				if($dist == 'gentoo') $logfile = '/var/log/maillog';
+				if($dist == 'debian') { $logfile = '/var/log/mail.log'; }
+				elseif($dist == 'redhat') { $logfile = '/var/log/maillog'; }
+				elseif($dist == 'suse') { $logfile = '/var/log/mail.info'; }
+				elseif($dist == 'gentoo') { $logfile = '/var/log/maillog'; }
 				break;
 			case 'log_mail_warn':
-				if($dist == 'debian') $logfile = '/var/log/mail.warn';
-				if($dist == 'redhat') $logfile = '/var/log/maillog';
-				if($dist == 'suse') $logfile = '/var/log/mail.warn';
-				if($dist == 'gentoo') $logfile = '/var/log/maillog';
+				if($dist == 'debian') { $logfile = '/var/log/mail.warn'; }
+				elseif($dist == 'redhat') { $logfile = '/var/log/maillog'; }
+				elseif($dist == 'suse') { $logfile = '/var/log/mail.warn'; }
+				elseif($dist == 'gentoo') { $logfile = '/var/log/maillog'; }
 				break;
 			case 'log_mail_err':
-				if($dist == 'debian') $logfile = '/var/log/mail.err';
-				if($dist == 'redhat') $logfile = '/var/log/maillog';
-				if($dist == 'suse') $logfile = '/var/log/mail.err';
-				if($dist == 'gentoo') $logfile = '/var/log/maillog';
+				if($dist == 'debian') { $logfile = '/var/log/mail.err'; }
+				elseif($dist == 'redhat') { $logfile = '/var/log/maillog'; }
+				elseif($dist == 'suse') { $logfile = '/var/log/mail.err'; }
+				elseif($dist == 'gentoo') { $logfile = '/var/log/maillog'; }
 				break;
 			case 'log_messages':
-				if($dist == 'debian') $logfile = '/var/log/messages';
-				if($dist == 'redhat') $logfile = '/var/log/messages';
-				if($dist == 'suse') $logfile = '/var/log/messages';
-				if($dist == 'gentoo') $logfile = '/var/log/messages';
+				if($dist == 'debian') { $logfile = '/var/log/messages'; }
+				elseif($dist == 'redhat') { $logfile = '/var/log/messages'; }
+				elseif($dist == 'suse') { $logfile = '/var/log/messages'; }
+				elseif($dist == 'gentoo') { $logfile = '/var/log/messages'; }
 				break;
 			case 'log_ispc_cron':
-				if($dist == 'debian') $logfile = '/var/log/ispconfig/cron.log';
-				if($dist == 'redhat') $logfile = '/var/log/ispconfig/cron.log';
-				if($dist == 'suse') $logfile = '/var/log/ispconfig/cron.log';
-				if($dist == 'gentoo') $logfile = '/var/log/cron';
+				if($dist == 'debian') { $logfile = $conf['ispconfig_log_dir'].'/cron.log'; }
+				elseif($dist == 'redhat') { $logfile = $conf['ispconfig_log_dir'].'/cron.log'; }
+				elseif($dist == 'suse') { $logfile = $conf['ispconfig_log_dir'].'/cron.log'; }
+				elseif($dist == 'gentoo') { $logfile = '/var/log/cron'; }
 				break;
 			case 'log_freshclam':
-				if($dist == 'debian') $logfile = '/var/log/clamav/freshclam.log';
-				if($dist == 'redhat') $logfile = (is_file('/var/log/clamav/freshclam.log') ? '/var/log/clamav/freshclam.log' : '/var/log/freshclam.log');
-				if($dist == 'suse') $logfile = '';
-				if($dist == 'gentoo') $logfile = '/var/log/clamav/freshclam.log';
+				if($dist == 'debian') { $logfile = '/var/log/clamav/freshclam.log'; }
+				elseif($dist == 'redhat') { $logfile = (is_file('/var/log/clamav/freshclam.log') ? '/var/log/clamav/freshclam.log' : '/var/log/freshclam.log'); }
+				elseif($dist == 'suse') { $logfile = '/var/log/freshclam.log'; }
+				elseif($dist == 'gentoo') { $logfile = '/var/log/clamav/freshclam.log'; }
 				break;
 			case 'log_clamav':
-				if($dist == 'debian') $logfile = '/var/log/clamav/clamav.log';
-				if($dist == 'redhat') $logfile = (is_file('/var/log/clamav/clamd.log') ? '/var/log/clamav/clamd.log' : '/var/log/maillog');
-				if($dist == 'suse') $logfile = '';
-				if($dist == 'gentoo') $logfile = '/var/log/clamav/clamd.log';
+				if($dist == 'debian') { $logfile = '/var/log/clamav/clamav.log'; }
+				elseif($dist == 'redhat') { $logfile = (is_file('/var/log/clamav/clamd.log') ? '/var/log/clamav/clamd.log' : '/var/log/maillog'); }
+				elseif($dist == 'suse') { $logfile = '/var/log/clamd.log'; }
+				elseif($dist == 'gentoo') { $logfile = '/var/log/clamav/clamd.log'; }
 				break;
 			case 'log_fail2ban':
-				if($dist == 'debian') $logfile = '/var/log/fail2ban.log';
-				if($dist == 'redhat') $logfile = '/var/log/fail2ban.log';
-				if($dist == 'suse') $logfile = '/var/log/fail2ban.log';
-				if($dist == 'gentoo') $logfile = '/var/log/fail2ban.log';
+				if($dist == 'debian') { $logfile = '/var/log/fail2ban.log'; }
+				elseif($dist == 'redhat') { $logfile = '/var/log/fail2ban.log'; }
+				elseif($dist == 'suse') { $logfile = '/var/log/fail2ban.log'; }
+				elseif($dist == 'gentoo') { $logfile = '/var/log/fail2ban.log'; }
 				break;
 			case 'log_ispconfig':
-				if($dist == 'debian') $logfile = '/var/log/ispconfig/ispconfig.log';
-				if($dist == 'redhat') $logfile = '/var/log/ispconfig/ispconfig.log';
-				if($dist == 'suse') $logfile = '/var/log/ispconfig/ispconfig.log';
-				if($dist == 'gentoo') $logfile = '/var/log/ispconfig/ispconfig.log';
+				if($dist == 'debian') { $logfile = $conf['ispconfig_log_dir'].'/ispconfig.log'; }
+				elseif($dist == 'redhat') { $logfile = $conf['ispconfig_log_dir'].'/ispconfig.log'; }
+				elseif($dist == 'suse') { $logfile = $conf['ispconfig_log_dir'].'/ispconfig.log'; }
+				elseif($dist == 'gentoo') { $logfile = $conf['ispconfig_log_dir'].'/ispconfig.log'; }
 				break;
 			default:
 				$logfile = '';
@@ -1524,7 +1729,7 @@
 			else {
 				$log = '';
 				if(is_readable($logfile)) {
-					if($fd = popen("tail -n 100 $logfile", 'r')) {
+					if($fd = popen('tail -n 100 '.$logfile, 'r')) {
 						while (!feof($fd)) {
 							$log .= fgets($fd, 4096);
 							$n++;
@@ -1585,11 +1790,11 @@
 
 		$now = time();
 		$old = $now - ($min * 60) - ($hour * 60 * 60) - ($days * 24 * 60 * 60);
-		$sql = "DELETE FROM monitor_data " .
-				"WHERE " .
-				"type =" . "'" . $app->dbmaster->quote($type) . "' " .
-				"AND " .
-				"created < " . $old;
+		$sql = 'DELETE FROM monitor_data ' .
+				'WHERE ' .
+				'type =' . "'" . $app->dbmaster->quote($type) . "' " .
+				'AND ' .
+				'created < ' . $old;
 		$app->dbmaster->query($sql);
 	}
 
@@ -1666,4 +1871,4 @@
 		return $res;
 	}
 }
-?>
\ No newline at end of file
+?>

--
Gitblit v1.9.1