vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Board Optimization - vBMicroStats (https://vborg.vbsupport.ru/showthread.php?t=140449)

TECK 02-24-2007 10:00 PM

vBMicroStats
 
This hack will add at the bottom of each vBulletin (powered) page, the statistics listed below.
Also, it will help you troubleshoot and optimize your vBulletin board by viewing or comparing PHP/MySQL options and other statistics that are normally hidden in your forum pages.

Regular Users:
? Load time of specified page in microseconds
? Number of queries executed
? PHP percent page usage
? MySQL percent page usage

Administrators Only:
? Active users browsing the forum (members and guests) new in 1.1.0
? Server memory usage per page (in Kb)
? Display DEBUG mode status
? Browser GZIP library compression status
? Server average loads
? Uncached templates (useful to troubleshoot the code)

The code modifications were tested into a clean installed vBulletin board. They work 100%.
The hack was tested in vBulletin 3.6.4 and 3.6.5.
If you want to test it into a lower version (3.6.x), let me know.
Also, if you encounter any problems, feel free to post your questions here.

Step by step install instructions are posted into readme.html file.
In order to perform an efficient modification of your files, I recommend you to use Komodo Edit or Textpad.
Both editors will allow you to complete all steps without any coding errors.

The code changes are very safe and designed not to interfere in any way with the vBulletin performance/functionality.
Make sure you modify, save and upload one file at the time to your server.
Then, simply run the product-vbmicrostats.xml file.

[high]The PLUGIN itself is DISABLED by default.[/high]
This was done in order to make sure you properly edit your code first and to avoid surprises.
You will need to enable it, once your code modifications are completed:
Plugins and Products > Manage Products > vB Microstats > Enable (dropdown)
Then, go to your vBulletin Options, click on BB MicroStats setting group and set all your options.

Upgrade to version 1.0.2.
Upgrade to version 1.0.3.
Upgrade to version 1.1.0.

Want to be a guinea pig and try this hack into a higher vBulletin version? :)
Post your results, so others can read your feedback.

Brandon Sheley 02-25-2007 07:59 PM

thanks for porting it to 3.6.4 :)

TECK 02-25-2007 08:02 PM

It was about time... 285 years later, heh.
I really did not have time, sorry guys.

FleaBag 02-25-2007 08:11 PM

Welcome back TECK. :)

TECK 02-25-2007 08:13 PM

Thanks.
Matt, do I know you (changed nick)? Since you are old school... :D

projectego 02-25-2007 08:23 PM

Awesome! Thanks very much! ;)

bluechris 02-25-2007 08:30 PM

Great work, installed and working fine.

Thx man

TECK 02-25-2007 08:32 PM

Little boring code change, heh. Actually, the code was not elegant.
Since we are already dealing with boolean values, no need to use the deprecated iif function.
Forgot to replace that from 3.5.x files.

Upload the /plugin files again, no other changes are needed.

TECK 02-25-2007 08:44 PM

Quote:

Originally Posted by bluechris (Post 1190601)
Great work, installed and working fine.

Thx man

Thanks. :)
From your site:
Page generated in 0,84680104 seconds (73,80% PHP - 26,20% MySQL) with 67 queries

:eek: :eek: :eek:

StrifeX 02-25-2007 08:49 PM

67 Queries? Wow lol... I only have roughly 24 on Forumhome and I've got as much hacks and queries running as I need.

Good job TECK, I've been waiting for you to port this to 3.6.x :D ;)

ncweb 02-25-2007 08:51 PM

I installed version 1.0.5 for 3.5.4 and made it work with 3.6.4 by using the code below.

Maybe a dumb question, but is there any reason I should use this version instead? It seems like there are more code changes and 2 new files.

Also, before I could get this post out the version changed from 1.0 to 1.0.1; what changes were made to the /plugins files? Great mod TECK, Thank you...

Quote:

Originally Posted by LunaTech (Post 1162895)
Till TECK gets to this, all you have to do to get this working in 3.6.4 is change what you edit in class_core.php. Instead of the instructions given, replace execute_query in class_core.php with:

Code:

        function &execute_query($buffered = true, &$link)
        {
                $this->connection_recent =& $link;
                $this->querycount++;

                // start microstats timer
                $this->mstimer_start();
                $queryresult = $this->functions[$buffered ? 'query' : 'query_unbuffered']($this->sql, $link);
                $this->mstimer_stop();

                if ($queryresult)
                {
                        // unset $sql to lower memory .. this isn't an error, so it's not needed
                        $this->sql = '';

                        return $queryresult;
                }
                else
                {
                        $this->halt();

                        // unset $sql to lower memory .. error will have already been thrown
                        $this->sql = '';
                }
        }

        /**
        * vBMicroStats: Query execution time
        *
        * @return        string
        */
        var $mstime_total = 0;
        var $mstime_before = array();
        function mstimer_start()
        {
                $this->mstime_before[] = microtime();
        }
        function mstimer_stop($qtime_total = true)
        {
                $mstime_after  = microtime();
                $mspage_start  = explode(' ', TIMESTART);
                $mspage_start  = $mspage_start[0] + $mspage_start[1];
                $mstime_before = explode(' ', array_pop($this->mstime_before));
                $mstime_before = $mstime_before[0] + $mstime_before[1] - $mspage_start;
                $mstime_after  = explode(' ', $mstime_after);
                $mstime_after  = $mstime_after[0] + $mstime_after[1] - $mspage_start;
                $mstime_taken  = $mstime_after - $mstime_before;
                if ($qtime_total)
                {
                        $this->mstime_total += $mstime_taken;
                }
        }



TECK 02-25-2007 09:55 PM

One, the code edit in the above function is not accurate, the execution time will not be reflected properly.
Two, there are 2 execute_query() functions in VB, totally different. You DO NOT paste the same code in both places.

Hmm, I think I found a bug. Guys do this, logout and tell me if you still see the admin microstats.
You should only see the regular microstats, the second line should be hidden.

thincom2000 02-25-2007 09:57 PM

Never thought I would say this, but now I wish I could turn on enable-memory-limit.

TECK 02-25-2007 10:00 PM

Guys, make me a favor, logout and tell me if you still see the admin microstats.
Thanks.

thincom2000 02-25-2007 10:55 PM

Quote:

Originally Posted by TECK (Post 1190644)
Guys, make me a favor, logout and tell me if you still see the admin microstats.
Thanks.

In plugins/hook_global_complete.php, find:
PHP Code:

    $show['adminoptions'] = $vbulletin->options['vb36_mstats_adminactive'] AND $vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']; 

Replace with:
PHP Code:

    $show['adminoptions'] = ($vbulletin->options['vb36_mstats_adminactive'] AND $vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']) ? true false


TECK 02-25-2007 11:08 PM

Thanks. So, does it show the admin stats when logged out?
The code should be:
Code:

$show['adminoptions'] = (bool)($vbulletin->options['vb36_mstats_adminactive'] AND $vbulletin->userinfo['permissions']['adminpermissions'] & $vbulletin->bf_ugp_adminpermissions['cancontrolpanel']);
Still, those are both boolean values, is like saying twice true or false.

For some servers, the data needs to be loaded directly into memory.
Can you guys post and tell me if with the actual unchanged code from version 1.0.1 you see the admin stats while logged out.

The fix is easy, but I need to make sure.

ncweb 02-26-2007 12:06 AM

In 1.0.1 yes, I do see the admin stats as guest, registered and admin user.

/installed ;)

TECK 02-26-2007 12:31 AM

Perfect, thanks. :)
Fixing this bug is very easy. I also decided to load into memory all data, it should improve performance.

To upgrade to version 1.0.2, all you have to do is:
1. Uninstall the vBMicrostats product but leave class_core.php and init.php code modifications in place.
They are good.

2. Delete folder /plugins.

3. Download the new 1.0.2 .zip file.

4. Run the product-vbmicrostats.xml installer.

5. Enable all BB MicroStats options, like before.

You are done. :)

DementedMindz 02-26-2007 12:39 AM

teck will this code mod still work from this post? https://vborg.vbsupport.ru/showpost....1&postcount=34

TECK 02-26-2007 12:40 AM

Yes. :)
Use the new conditionals, compare the code.

DementedMindz 02-26-2007 12:42 AM

ok thank you working on it now

Kaleem 02-26-2007 12:44 AM

Installed Thank You :)

TECK 02-26-2007 12:51 AM

Let me know how is the new version.

TECK 02-26-2007 01:09 AM

Reeve of shinra is checking my thread, as I type.
Good to see you, old school friend. :)

DementedMindz 02-26-2007 01:09 AM

seems like its working alot better then the last one. my stats use to stay the same alot on the 3.5.4 one but this one is reading the stats pretty well Page generated in 0.32 seconds (70.22% PHP - 29.78% MySQL) with 21 queries and the php and mysql change with each refresh where as the last one was reading it wrong it seemed.

TECK 02-26-2007 01:12 AM

Thanks for the feedback. That's the reason why I told to ncweb not to use the old code.
The new one is pretty elegant. :)

You can see if it's working well this way: 70.22% PHP + 29.78% MySQL = 100% code ops.

DementedMindz 02-26-2007 01:22 AM

yeah the last version on 3.5.4 wouldn't do that this is much nicer and works 100% every time only thing I have left to do now is enable-memory-limit in php. thanks again.

ncweb 02-26-2007 01:26 AM

I find two instances of this in File: init.php (folder /includes)
Code:

if (!empty($db->explain))
{
        $db->timer_stop(false);
}

One is at line: 213 and the other near the end at line: 432. I should be replacing the one at the end right?

Either way I am getting some very wierd numbers (-28 php - 128% mysql); please see screenshot. It always says more mysql than php, shouldn't that be the other way around? Thanks...

DementedMindz 02-26-2007 01:43 AM

Quote:

Originally Posted by ncweb (Post 1190785)
I find two instances of this in File: init.php (folder /includes)
Code:

if (!empty($db->explain))
{
        $db->timer_stop(false);
}

One is at line: 213 and the other near the end at line: 432. I should be replacing the one at the end right?

Either way I am getting some very wierd numbers (-28 php - 128% mysql); please see screenshot. It always says more mysql than php, shouldn't that be the other way around? Thanks...


how can you find that one when it says to search for this..

Code:

if ($vbulletin->session->vars['styleid'] != 0)
{
        $vbulletin->userinfo['styleid'] = $vbulletin->session->vars['styleid'];
}

if (!empty($db->explain))
{
        $db->timer_stop(false);
}


ncweb 02-26-2007 01:46 AM

Quote:

Originally Posted by ncweb (Post 1190785)
Either way I am getting some very wierd numbers (-28 php - 128% mysql); please see screenshot. It always says more mysql than php, shouldn't that be the other way around? Thanks...

Any Ideas on this; it happens on both my winXP and CentOS 4.4 dev box. Has anyone else seen results like this? I'd provide some details of my LAMP setup but don't know what would be helpful. I was getting normal results before and this has me scratching my head :eek:

Smoothie 02-26-2007 01:47 AM

Mr. F, welcome back.

TECK 02-26-2007 01:50 AM

Quote:

Originally Posted by Smoothie (Post 1190808)
Mr. F, welcome back.

Thanks. :)
Quote:

Originally Posted by ncweb (Post 1190807)
Any Ideas on this; it happens on both my winXP and CentOS 4.4 dev box. Has anyone else seen results like this? I'd provide some details of my LAMP setup but don't know what would be helpful. I was getting normal results before and this has me scratching my head :eek:

Yes, you need to replace ONLY the very last one.
Will update the readme file.

About the negative values, is all related to server time clock, microtime(). It's a confirmed bug.
Freddie (vB dev) managed to reproduce the bug but did not released a fix.
Since I use the vB core functions, this error is reflected into your time, if you are not lucky.

Read more here:
http://www.vbulletin.com/forum/bugs3...iew&bugid=2481

TECK 02-26-2007 01:57 AM

Thinking out loud, what PHP version you have? I have 5.2.1, working perfectly here:
http://67.68.90.79/forum/

Reeve of shinra 02-26-2007 02:08 AM

Quote:

Originally Posted by TECK (Post 1190764)
Reeve of shinra is checking my thread, as I type.
Good to see you, old school friend. :)

Sup man! Its been ages since we last chatted so im gonna hijack your thread! how you been? :)


The stats are awesome, this has always been one of my favorite mods.

Things are working like a charm but I forgot that I had an older version (1.0.5) installed. I didn't choose to over write and I have two options in the admincp for the mod. No biggie, I disabled it for now and will probably uninstall later when I do a backup. Just thought I'd point that out if anyone else runs across it.

ncweb 02-26-2007 02:11 AM

Quote:

Originally Posted by TECK (Post 1190810)
About the negative values, is all related to server time clock, microtime(). It's a confirmed bug.
Freddie (vB dev) managed to reproduce the bug but did not released a fix.
Since I use the vB core functions, this error is reflected into your time, if you are not lucky.

Read more here:
http://www.vbulletin.com/forum/bugs3...iew&bugid=2481


Looks like the bug referenced at http://www.vbulletin.com/forum/bugs3...iew&bugid=2481
never got fixed in 3.6.x.

Quote:

Originally Posted by TECK (Post 1190816)
Thinking out loud, what PHP version you have? I have 5.2.1, working perfectly here:
http://67.68.90.79/forum/


I'm running PHP 4.4.4; I saw on http://67.68.90.79/forum/ that the mysql % was higher than that of php. If that basically a default install then I guess that?s normal. Thanks for your time and the replies TECK

TECK 02-26-2007 02:12 AM

Quote:

Originally Posted by ncweb (Post 1190821)
I'm running PHP 4.4.4; I saw on http://67.68.90.79/forum/ that the mysql % was higher than that of php. If that basically a default install then I guess that’s normal. Thanks for your time and the replies TECK

Ya, is normal. The easiest way to see if you have the stats right is to enable the debug mode, the do an explain. Look at the time spent to do PHP and MySQl things, they are pretty balanced.
Those times reflect the percentage. You will also see there negative results, so that should answer your questions related to the vB bug.

Let's take an example shall we?
http://67.68.90.79/forum/showthread.php?t=1
Page generated in 0.13296827 seconds (61.87% PHP - 38.13% MySQL) with 9 queries
And the Explain:
Page generated in 0.13317393951416 seconds with 9 queries, spending 0.011376857757568 doing MySQL queries and 0.12249708175659 doing PHP things.

Glad I could help. :)
Quote:

Originally Posted by Reeve of shinra (Post 1190820)
Sup man! Its been ages since we last chatted so im gonna hijack your thread! how you been? :)

Good to see you to Reeve. Trying to make people happy, since many wanted the microstats for 3.6.4.
I remember when people used to queue on your board for your hacks... good times. :)
If you feel like talking on MSN, drop me a PM, I'll send you the ID.

COBRAws 02-26-2007 02:29 AM

Thanks for updating this m8

Lizard King 02-26-2007 02:56 AM

Thanks for updating this after my request Floren :)

It is also nice to see you back alive at vb.org

Atakan KOC 02-26-2007 08:20 AM

Nice. Thanks. :)

Xplorer4x4 02-26-2007 08:22 AM

Quote:

0KB Used | DEBUG Mode OFF | GZIP ON (level 1) | 0.54 : 0.59 : 0.55 | NO Uncached Template
I have turned debug on in ACP options but it does not show on the forum.


All times are GMT. The time now is 07:14 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.01623 seconds
  • Memory Usage 1,849KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (2)bbcode_php_printable
  • (13)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete