+function webservers_exceeded()
+{
+ return(file_exists(PROXY_PATH."/webservers_exceded.flag"));
+}
+
+function check_webservers()
+{
+ GLOBAL $G_webserver_max;
+
+ $ct = 0;
+
+ $dh = opendir('/proc');
+ while (($file = readdir($dh)) !== false) {
+ if (preg_match('/[0-9]+/', $file)) {
+ $cmdline = explode("\0", file_get_contents('/proc/'.$file.'/cmdline'));
+ // echo "xxx".$cmdline[0].$n;
+ if (strstr('/usr/sbin/apache2', $cmdline[0]) != FALSE) {
+ // echo "yyy".$cmdline[0].$n;
+ $ct++;
+ }
+ }
+ }
+ closedir($dh);
+
+ if ($ct >= $G_webserver_max) {
+ touch(PROXY_PATH."/webservers_exceded.flag");
+ }
+ else {
+ unlink(PROXY_PATH."/webservers_exceded.flag");
+ }
+ return ($ct);
+}
+