First off, I love this hack, really great; thank you
Now, I have a few comments.. Perhaps they have been covered, but I don't want to read through all of the many posts in this thread..
How does vBulletin figure out how many queries were executed? I am trying to write a script for my main site, but this is stumping me...
vbMicroStats uses
@exec("uptime") to figure out the load. The problem is, many professional servers disallow the httpd/www-data user (Might be called something else, but it's the one that Apache spawns under) from executing things such as
system() or
exec() for obvious security reasons, you would have near-root permissions. On my server, this is the case. Here's what I came up with the get around it; Perhaps not as clean as yours, but it works
File: FORUM/admin/functions.php
PHP Code:
if ($stats=@exec('uptime')) {
preg_match('/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/',$stats,$regs);
$serverload=' [Server Load: <font color="{ hovercolor}"><b>'.$regs[1].'</b></font> " '.$regs[2].' : '.$regs[3].']';
} else {
$serverload='';
}
My Fix:
PHP Code:
if ( $stats = @fopen('/proc/loadavg', 'r') ) {
if ($fd = fopen('/proc/loadavg', 'r')) {
$load = split(' ', fgets($fd, 4096));
fclose($fd);
} else
$load = array('N.A.','N.A.','N.A.');
$serverload = ' [Server Load: <font color="{ hovercolor}"><b>';
$serverload .= $load[0] . '</b></font> " ' . $load[1] . ' : ' . $load[2] . ']';
}
For me, this has worked flawlessly. The only thing that I can think to go wrong would be the loadavg file not being in /proc/loadavg, but on most (If not all) UNIX/Linux systems, it is there.