Topic: Server Load Script- Can you spot the output?
Hey folks,
I came across a little script for doing server load and it works great. Problem is it is outputing a text line that is displaying out of place. I load some stuff into variables, then dump the variable when done. Problem is this "text string" is showing up from within the function, and not down where I echo the return...
Example: http://www.phpmywebthing.com underneath center output is string:
10:45am up 31 days, 14:38, 0 users, load average: 2.33, 2.56, 2.86
Question- I can't seem to spot where the string is being echo'd / output other than the return of the function. Any help appreciated...
Here is the function:
// Get The Server Load
function get_ServerLoad()
{
if(PHP_OS != 'WINNT' && PHP_OS != 'WIN32') {
if(file_exists('/proc/loadavg') ) {
if ($fh = @fopen( '/proc/loadavg', 'r' )) {
$data = @fread( $fh, 6 );
@fclose( $fh );
$load_avg = explode( " ", $data );
$server_load = trim($load_avg[0]);
}
} else {
$data = @system('uptime');
preg_match('/(.*):{1}(.*)/', $data, $matches);
$load_arr = explode(',', $matches[2]);
$server_load = trim($load_arr[0]);
}
}
if(!$server_load) {
$server_load = 'N/A';
}
return $server_load;
}