Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
vbMicroStats: page load time, queries, GZIP and PHP version Details »»
vbMicroStats: page load time, queries, GZIP and PHP version
Version: 1.00, by TECK TECK is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 03-06-2002 Last Update: Never Installs: 594
 
No support by the author.

[high]Looking for VB3 version? Is here.[/high]

This hack will add at the bottom of each vBulletin(powered) page the following stats:

- load time of specified page in microseconds (with custom no. of digits to show)
- number of queries executed
- server GZIP library compression status
- vBulletin DEBUG mode
- PHP version
- PHP percent page usage
- MySQL percent page usage
- Server Load
[high]This is not only estethic, it will also help you troubleshoot any wierd queries that you have in your scripts.
The hack is template based so you can edit it the way you want in few seconds.[/high]
NOTE: From users experiences, this hack will work only with PHP 4.0.6 or higher. Let me know if it works with a lower PHP version.

THE FIX FOR VB2.3.0 IS HERE.

HACK UPDATES
Version 2.1
------------------------------------
Changes:
- added Server Load

NOTE: I spoked with Kevin 'tubedogg' from vBulletin Support team and he explained to me that not all the servers are configured to support the [high]@exec("uptime")[/high].
Contact your host for more details and ask them about this issue.
For a full explanation of your 3 server load values, read more here.

*If you want to have the stats viewable only by admins, read this post.

Version 2.0
------------------------------------
Changes:
- added vBulletin DEBUG Mode
- removed the Details link
- cleaned a little the code to match VB2.2.6
- better explanations into the install file.

Version 1.7
------------------------------------
[high]VB2.2.5:[/high]
Minor change in admin/db_mysql.php. Read more here on how to update your hack.
Minor change in forum/global.php. Read more here on how to update your hack.

Changes:
- corrected negative values on certain servers.

Version 1.6
------------------------------------
Changes:
- PHP version and GZIP library status viewable only to admin.
- added a link to Detailed Stats View (generated by vBulletin), for that specific page. Only admins can view that link.

To see how it looks a Detailed View, click here.

Version 1.5
------------------------------------
Added:
- GZIP library status is now related to your vBulletion options.
- GZIP library compression level.

Version 1.4
------------------------------------
Bugs corrected:
- GZIP library status not displayed properly on certain servers.

Version 1.3
------------------------------------
Bugs corrected:
- vbPortal display code in modules

The hack is template based now.
All you have to do is call it with the {getmicrostats} string, anywhere you want (for example in footer).
You also have the choice to install it as template based or coded directly into your functions.php file.

Version 1.2
------------------------------------
Added the PHP and MySQL page percentage.
(Addon by Chen 'FireFly' Avinadav)

Version 1.1
------------------------------------
vB.org decided to add this hack to their board.

Bugs corrected:
- incorrect time load
- incorrect query count


You like this hack? Please click on the [high]Install[/high] button.
To download the latest version of this hack, click below:

Show Your Support

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

Comments
  #822  
Old 04-26-2003, 04:15 PM
solent solent is offline
 
Join Date: May 2002
Posts: 66
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok that sounds resonable enought TECK i will rebuild my board from scratch and this time i will be more carefull on installing hacks.

thanks
Reply With Quote
  #823  
Old 04-27-2003, 04:57 PM
SiGmA_X SiGmA_X is offline
 
Join Date: Sep 2002
Location: Portland, OR, USA
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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($fd4096));
    
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.
Reply With Quote
  #824  
Old 05-05-2003, 11:50 PM
TECK's Avatar
TECK TECK is offline
 
Join Date: Nov 2001
Location: Canada
Posts: 4,182
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If I'm correct, that won't work in safe mode...
Reply With Quote
  #825  
Old 05-06-2003, 04:08 AM
Hobbes's Avatar
Hobbes Hobbes is offline
 
Join Date: Dec 2002
Location: Cali
Posts: 230
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I cant get them to show up......
Reply With Quote
  #826  
Old 05-06-2003, 04:17 AM
Hobbes's Avatar
Hobbes Hobbes is offline
 
Join Date: Dec 2002
Location: Cali
Posts: 230
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok, my new attach wouldn't show....
Reply With Quote
  #827  
Old 05-07-2003, 08:30 PM
N9ne N9ne is offline
 
Join Date: Feb 2002
Posts: 1,495
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For those having trouble with the functions.php replacement on 2.3.0 Final, replace your entire dovars section with the following code [it works] (NOTE!: this is for an unhacked vB! If you have modified this section at all with other hacks, don't use this!)

PHP Code:
// ###################### Start dovars #######################
function dovars($newtext$sendheader 1)
{
    
// parses replacement vars

    
global $PHP_SELF$DB_site$replacementsetid$gzipoutput$gziplevel$newpmmsg$microstats;
    static 
$vars;

    if (
connection_status())
    {
        exit;
    }

    if (!
is_array($vars))
    {
        
// build an array of $vars containing find/replace values
        
$vars = array();
        
$replacements $DB_site->query("
            SELECT findword, replaceword, replacementsetid
            FROM replacement
            WHERE replacementsetid IN(-1, '" 
intval($replacementsetid) . "')
            ORDER BY replacementsetid, replacementid DESC
        "
);
        while (
$replacement $DB_site->fetch_array($replacements))
        {
            if (
$replacement['findword'] != '')
            {
                
$vars["$replacement[findword]"] = $replacement['replaceword'];
            }
        }
        unset(
$replacement);
        
$DB_site->free_result($replacements);
    }

    
$newtext str_replace'{getmicrostats}' $microstats $newtext );

    if (
PHPVERSION '4.0.5' or 1)
    {
        
// do each replacement in turn for PHP < 4.0.5
        
reset($vars);
        while(list(
$find$replace) = each($vars))
        {
            
$newtext str_replace($find$replace$newtext);
        }
    }
    else
    {
        
// do all replacements in one go (PHP >= 4.0.5 only)
        
$newtext str_replace(array_keys($vars), $vars$newtext);
    }

    if (
$newpmmsg)
    {
        if (
substr($PHP_SELF,-strlen('private.php')) == 'private.php')
        {
            
// do nothing
        
}
        else
        {
            
$newtext preg_replace("/<body/i""<body onload=\"Javascript:confirm_newpm()\""$newtext);
        }
    }

    if (
$gzipoutput and !headers_sent())
    {
        
$newtext gzipoutput($newtext$gziplevel);
    }

    if (
$sendheader)
    {
        @
header("Content-Length: " strlen($newtext));
    }

    return 
$newtext;

Reply With Quote
  #828  
Old 05-07-2003, 11:19 PM
ogden2k's Avatar
ogden2k ogden2k is offline
 
Join Date: Apr 2003
Posts: 192
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Page generated in 0.09366798 seconds (71.57% PHP - 28.43% MySQL) with 21 queries.

Does that sound accurate? Which is better, more php then mysql or the other way around?
Reply With Quote
  #829  
Old 05-08-2003, 09:11 AM
Lethal Lethal is offline
 
Join Date: Feb 2002
Location: PA/USA
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

that looks just fine
Reply With Quote
  #830  
Old 05-08-2003, 09:19 AM
Lethal Lethal is offline
 
Join Date: Feb 2002
Location: PA/USA
Posts: 164
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok so the reason my serverload is not showing is possibly because my server doesn't allow the @exec("uptime") to be used, at least thats what I have read. If i ask them will they allow it, because I really would like to know what my server load is. Any suggestions on how to get around it?
Reply With Quote
  #831  
Old 05-14-2003, 08:05 AM
Zxin Zxin is offline
 
Join Date: Apr 2002
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you have a problem look at the part of the instructions that say
Template: home_microstats

Do NOT create a new template called home_microstats

*DO* create a template called microstats

and bing, your {getmicrostats} will show up!
Reply With Quote
Reply

Thread Tools

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 08:35 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.05394 seconds
  • Memory Usage 2,340KB
  • 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
  • (3)bbcode_php
  • (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
  • (3)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