0, 'S' => 0, 'R'=>0, 'W'=>0, 'K'=>0, 'D'=>0, 'C'=>0, 'L'=>0, 'G'=>0, 'I'=>0, '_O'=>0]; /* ***Types of Threads*** _W --- waiting S --- starting up R --- reading request W --- sending reply K --- keepalive D --- DNS lookup C --- closing connection L --- logging G --- graceful finishing I --- idle cleanup _O --- open slot */ $url = "http://$host/server-status?auto"; $result = file_get_contents($url); $array_result = []; $array_result = explode("\n",(string) $result); $i = 0; $output = ''; $line = []; foreach ($array_result as $newline) { $line = explode(':', $newline); switch ($line[0]) { case 'Total Accesses': if (($section == 'hits') || ($section == 'all')) { $output .= $variables[0] . ':' . trim($line[1]) . ' '; } break; case 'Total kBytes': if (($section == 'kbytes') || ($section == 'all')) { $output .= $variables[1] . ':' . trim($line[1]) . ' '; } break; case 'BusyServers': case 'BusyWorkers': if (($section == 'workers') || ($section == 'all')) { $output .= $variables[2] . ':' . trim($line[1]) . ' '; } break; case 'IdleServers': case 'IdleWorkers': if (($section == 'workers') || ($section == 'all')) { $output .= $variables[3] . ':' . trim($line[1]) . ' '; } break; case 'CPULoad': if (($section == 'cpuload') || ($section == 'all')) { $output .= $variables[4] . ':' . trim($line[1]) . ' '; } break; case 'Scoreboard': $string = trim($line[1]); $length = strlen($string); for ($j = 0; $j < $length; $j++) { $char = $string[$j]; if ($char == '_') { $threads['_W']++; } elseif ($char == '.') { $threads['_O']++; } else { $threads[$char]++; } } break; } } if (($section == 'threads') || ($section == 'all')) { foreach ($threads as $type => $num_threads) { $output .= 'thread' . $type . ':' . $num_threads . ' '; } } return trim(str_replace(["\r", "\n"],'', $output)); }