Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Microstats - load times, server loads, queries, uncached templates Details »»
Microstats - load times, server loads, queries, uncached templates
Version: 1.2.1, by ShiningArcanine ShiningArcanine is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Version: 3.5.4 Rating:
Released: 06-10-2005 Last Update: 06-08-2006 Installs: 680
Uses Plugins
 
No support by the author.

This is a derivative of Erwin's microstats hack for vBulletin 3.5.0's plugin system. The main difference is that by default it shows the page generation time and query count to the public. Server loads and Uncached Queries are shown only to administrators.

I had sent this to Erwin so he could release if he wanted to but instead he told me that I had permission to release it; hence why I am releasing it.

This should work with vBulletin 3.5.0 RC 1 through vBulletin 3.6.1 and later.

Installation is very simple. Just import the plugin via vBulletin's "Download / Upload Plugins" page in the Plugin System in the Admin Control Panel and you're done.

I'll try to correct any bugs that you find. Let me know if you like this plugin and don't forget to click the install link if you install this.

Optional config.php Variables


$config['Microstats']['replacementvariable']

Setting this variable will make microstats place its data before any instance of whatever you set this variable to. Be careful with this as you might see microstats in mutiple places. My suggestion is to use a unique comment in the HTML source to prevent any issues.

E.g. $config['Microstats']['replacementvariable'] = '<!-- display microstats here -->';

$config['Microstats']['adminonly']

Setting this variable to anything will make microstats display itself only to administrators.

E.g. $config['Microstats']['adminonly'] = true;

Update History


Product File: Uploaded a product file that replaced the plugin file.
Version 1.2.1: Fixed a bug that broke optional config.php settings
Version 1.2.0: Added OpenBSD, FreeBSD and NetBSD support; added Replacement variable setting in config.php; added Display only to Administrators Setting in config.php; fixed bug affecting Linux/Unix servers that have exec('uptime') support and not /proc/loadavg support
Version 1.1.0: Added names of uncached templates, included a bugfix for people who don't have proc avaliable on their system and made the code look a little nicer as well
Version 1.0.1: Bugfix for Windows users, sanitized the code to make it look nicer
Version 1.0.0: Initial Release

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #352  
Old 06-26-2008, 05:14 PM
odeezie odeezie is offline
 
Join Date: Jan 2008
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Working in 3.7.2, Thanks!
Reply With Quote
  #353  
Old 06-29-2008, 02:24 AM
ALil'Hope ALil'Hope is offline
 
Join Date: Jun 2008
Posts: 92
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed and working on 3.7.2.
Reply With Quote
  #354  
Old 08-05-2008, 02:17 PM
David_R David_R is offline
 
Join Date: Mar 2005
Location: Los Angeles
Posts: 212
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How do we enable this option to work for multiple usergroups ?
We want Administrators, super-moderators and moderator usergroups to be able to check server load.s

thanks
Reply With Quote
  #355  
Old 08-19-2008, 12:05 AM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How would I go about moving the location of the text that gets printed out?

I would like to put it with the copyright text... Otherwise it screws with my design:

http://www.8wayrun.com/forums.php
Reply With Quote
  #356  
Old 09-11-2008, 11:39 AM
Orakk's Avatar
Orakk Orakk is offline
 
Join Date: Nov 2007
Location: SouthOZ
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Moparx View Post
make sure you have the following in config.php:
PHP Code:
$config['Microstats']['replacementvariable'] = '<!-- display microstats here -->'
then add <!-- display microstats here --> at the very bottom of the footer template
Worked on 373PL1 :up:
Reply With Quote
  #357  
Old 11-09-2008, 05:28 AM
Neutral Singh's Avatar
Neutral Singh Neutral Singh is offline
 
Join Date: Sep 2004
Location: Sikh Philosophy Network
Posts: 545
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It is possible to see which query is taking how much time to execute? So that we can debug or optimize those queries. i am facing issued when clicking on the Forums to go to forumdisplay.php. Its taking like 25 secs on load 43 queries on a forumdisplay.php page. How can view those queries and how much they are taking. This is most urgent please.
Reply With Quote
  #358  
Old 11-09-2008, 03:31 PM
aciurczak aciurczak is offline
 
Join Date: Jun 2005
Posts: 154
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't think this hack can be used to time individual queries, it only marks the time difference between the page request and when it is complete.

43 queries on a forumdisplay.php page seems like quite a bit of them. I just loaded the forumdisplay.php page on two forums I admin. The more customized one ran 26 queries on a forumdisplay, one that is a little closer to stock ran 21 queries. To figure out what is taking so long on yours, I'd disable all plug-ins, then re-enable them 1 by 1 until you see the page load time increase dramatically.
Reply With Quote
  #359  
Old 11-28-2008, 05:24 PM
RvG2 RvG2 is offline
 
Join Date: Jan 2007
Posts: 457
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

works with 3.8.0 beta 4 as well
Reply With Quote
  #360  
Old 12-25-2008, 02:42 PM
zefyx's Avatar
zefyx zefyx is offline
 
Join Date: Oct 2008
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by David_R View Post
How do we enable this option to work for multiple usergroups ?
We want Administrators, super-moderators and moderator usergroups to be able to check server load.s


thanks
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
Reply With Quote
  #361  
Old 03-05-2009, 04:26 PM
Dimoks's Avatar
Dimoks Dimoks is offline
 
Join Date: Mar 2006
Location: Kharkiv, Ukraine
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I need this plugin :

generated this page in 0.21 seconds (79.54% PHP - 20.46% MySQL) with 11 queries.

from forum http://forums.offtopic.com/

p.s. good forum... Posts: 112,870,447
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:23 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05119 seconds
  • Memory Usage 2,318KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete