Quote:
Originally Posted by zefyx
Go to Plugin & Products System -> Product Manager -> Microstats.
Remove the current code, replace with..
$pageendtime = microtime();
$starttime = explode(' ', $pagestarttime);
$endtime = explode(' ', $pageendtime);
$totaltime = vb_number_format($endtime[0] - $starttime[0] + $endtime[1] - $starttime[1], 5);
$debughtml = '<center><span class="smallfont">Page generated in <b>' . $totaltime . '</b> seconds with <b>' . $vbulletin->db->querycount . '</b> queries';
$usergroupid = $vbulletin->userinfo['usergroupid'];
if ($usergroupid == 5 || $usergroupid == 6 || $usergroupid == 7) {
if ($loadavg = @file_get_contents("/proc/loadavg")) {
$regs = explode(" ",$loadavg);
$serverload = ' [Server Loads: <b>' . $regs[0] .'</b> ' . $regs[1] . ' : ' . $regs[2] . ']';
}elseif ($stats=@exec('uptime')) {
preg_match('/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/',$stats,$regs);
$serverload = ' [Server Loads: <b>' . $regs[1] .'</b> ' . $regs[2] . ' : ' . $regs[3] . ']';
}elseif ($loadavg = @`sysctl vm.loadavg|cut -d" " -f3-5`) {
$regs = explode(" ",$loadavg);
$serverload = ' [Server Loads: <b>' . $regs[0] .'</b> ' . $regs[1] . ' : ' . $regs[2] . ']';
}
$debughtml .= iif($_TEMPLATEQUERIES, ' (<b>' . sizeof($_TEMPLATEQUERIES) . '</b> queries for uncached templates)', '') . "$serverload";
ksort($tempusagecache);
foreach ($tempusagecache AS $tempname => $times) {
if ($_TEMPLATEQUERIES["$tempname"]){
$debughtml .= '<center><span class="smallfont">Uncached templates: <font color="red"><b>' . $tempname . '</b></font> (' . $times . ')</span></center>';
}
}
}
$debughtml .= "</span></center>";
if (!$vbulletin->config['Microstats']['replacementvariable']) {
$vbulletin->config['Microstats']['replacementvariable'] = '</body>';
}
if (($vbulletin->config['Microstats']['adminonly'] and $vbulletin->userinfo['usergroupid'] == 5 || $usergroupid == 6 || $usergroupid == 7) or !$vbulletin->config['Microstats']['adminonly']){
$output = str_replace($vbulletin->config['Microstats']['replacementvariable'], $debughtml . $vbulletin->config['Microstats']['replacementvariable'], $output);
}
Where you see the usergroupid = 5, 6 & 7, replace those numbers with whatever your usergroup id's are that you want to see the microstats.
Hope this helps 
|
I try to use this code, it works proper for super-admin, admin and moderator groups.
but super-admin and moderators cannot see server loads.
i have also placed this line in my config.php
if (($vbulletin->config['Microstats']['adminonly'] = true ;
this my code in plugin manager for microstats
Code:
// Microstats 1.2.1 Plugin
$pageendtime = microtime();
$starttime = explode(' ', $pagestarttime);
$endtime = explode(' ', $pageendtime);
$totaltime = vb_number_format($endtime[0] - $starttime[0] + $endtime[1] - $starttime[1], 5);
$debughtml = '<center><span class="smallfont">Page generated in <b>' . $totaltime . '</b> seconds with <b>' . $vbulletin->db->querycount . '</b> queries';
if ($vbulletin->userinfo['usergroupid'] == 6) {
if ($loadavg = @file_get_contents("/proc/loadavg")) {
$regs = explode(" ",$loadavg);
$serverload = ' [Server Loads: <b>' . $regs[0] .'</b> ' . $regs[1] . ' : ' . $regs[2] . ']';
}elseif ($stats=@exec('uptime')) {
preg_match('/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/',$stats,$regs);
$serverload = ' [Server Loads: <b>' . $regs[1] .'</b> ' . $regs[2] . ' : ' . $regs[3] . ']';
}elseif ($loadavg = @`sysctl vm.loadavg|cut -d" " -f3-5`) {
$regs = explode(" ",$loadavg);
$serverload = ' [Server Loads: <b>' . $regs[0] .'</b> ' . $regs[1] . ' : ' . $regs[2] . ']';
}
$debughtml .= iif($_TEMPLATEQUERIES, ' (<b>' . sizeof($_TEMPLATEQUERIES) . '</b> queries for uncached templates)', '') . "$serverload";
ksort($tempusagecache);
foreach ($tempusagecache AS $tempname => $times) {
if ($_TEMPLATEQUERIES["$tempname"]){
$debughtml .= '<center><span class="smallfont">Uncached templates: <font color="red"><b>' . $tempname . '</b></font> (' . $times . ')</span></center>';
}
}
}
$debughtml .= "</span></center>";
if (!$vbulletin->config['Microstats']['replacementvariable']) {
$vbulletin->config['Microstats']['replacementvariable'] = '</body>';
}
if (($vbulletin->config['Microstats']['adminonly'] and $vbulletin->userinfo['usergroupid'] == 5 || $usergroupid == 6) or !$vbulletin->config['Microstats']['adminonly']){
$output = str_replace($vbulletin->config['Microstats']['replacementvariable'], $debughtml . $vbulletin->config['Microstats']['replacementvariable'], $output);
}
// Microstats 1.2.1 Plugin