Skip to content

Commit 8bbcc1d

Browse files
author
vogelor
committed
monitor: enhanced the apache-check -> noe we also check if apache was able to send data and not only to establish a connection
1 parent 843dbe2 commit 8bbcc1d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

server/lib/classes/monitor_tools.inc.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,10 +1535,22 @@ private function _checkTcp($host, $port) {
15351535
$fp = @fsockopen($host, $port, $errno, $errstr, 2);
15361536

15371537
if ($fp) {
1538+
/*
1539+
* We got a connection, but maybe apache is not able to send data over this
1540+
* connection?
1541+
*/
1542+
fwrite($fp, "GET / HTTP/1.0\r\n\r\n");
1543+
stream_set_timeout($fp, 2);
1544+
$res = fread($fp, 10);
1545+
$info = stream_get_meta_data($fp);
15381546
fclose($fp);
1539-
return true;
1547+
if ($info['timed_out']) {
1548+
return false; // Apache was not able to send data over this connection
1549+
} else {
1550+
return true; // Apache was able to send data over this connection
1551+
}
15401552
} else {
1541-
return false;
1553+
return false; // Apache was not able to establish a connection
15421554
}
15431555
}
15441556

0 commit comments

Comments
 (0)