From 8bbcc1db8b976a9ccfdcac1dcde5a15c01495d60 Mon Sep 17 00:00:00 2001
From: vogelor <vogelor@ispconfig3>
Date: Sat, 26 Mar 2011 21:57:52 +0000
Subject: [PATCH] monitor: enhanced the apache-check -> noe we also check if
 apache was able to send data and not only to establish a connection

---
 server/lib/classes/monitor_tools.inc.php | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/server/lib/classes/monitor_tools.inc.php b/server/lib/classes/monitor_tools.inc.php
index cfe62005b..2fbd4020d 100644
--- a/server/lib/classes/monitor_tools.inc.php
+++ b/server/lib/classes/monitor_tools.inc.php
@@ -1535,10 +1535,22 @@ class monitor_tools {
 		$fp = @fsockopen($host, $port, $errno, $errstr, 2);
 
 		if ($fp) {
+			/*
+			 * We got a connection, but maybe apache is not able to send data over this
+			 * connection?
+			 */
+		    fwrite($fp, "GET / HTTP/1.0\r\n\r\n");
+			stream_set_timeout($fp, 2);
+			$res = fread($fp, 10);
+		    $info = stream_get_meta_data($fp);
 			fclose($fp);
-			return true;
+		    if ($info['timed_out']) {
+				return false; // Apache was not able to send data over this connection
+		    } else {
+				return true; // Apache was able to send data over this connection
+			}			
 		} else {
-			return false;
+			return false; // Apache was not able to establish a connection
 		}
 	}
 
-- 
GitLab