vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Microstats - load times, server loads, queries, uncached templates (https://vborg.vbsupport.ru/showthread.php?t=82900)

Xencored 04-06-2009 04:10 AM

i get

Uncached templates: awards_postbit_display (1)
Uncached templates: im_msn (1)
Uncached templates: postbit_legacy (1)
Uncached templates: postbit_onlinestatus (1)
Uncached templates: postbit_reputation (3)
Uncached templates: postbit_wrapper (1)

is this bad? :confused:

Icy 04-06-2009 06:15 AM

Yes it is! You're having 8 extra queries just for these uncached queries!

Xencored 04-06-2009 05:17 PM

Quote:

Originally Posted by Icy (Post 1784857)
Yes it is! You're having 8 extra queries just for these uncached queries!

How can i fix this than mate

Cheers

Icy 04-06-2009 05:30 PM

I guess one of your modification cause this though I'm not sure which one. Try disabling one by one and test :)

Lynne 04-06-2009 05:33 PM

Or read the article in the article section about how to cache your templates.

Icy 04-06-2009 05:54 PM

But Lynne these are the default templates which should be cached by default unless he changed something from the core vBulletin code right?

Lynne 04-06-2009 06:17 PM

Quote:

Originally Posted by Icy (Post 1785205)
But Lynne these are the default templates which should be cached by default unless he changed something from the core vBulletin code right?

You are right. I just looked at the first one (awards_) and knew that was not default. So yes, you are right in guessing some modification is causing the problem.

jw00dy 04-09-2009 12:40 AM

I use this free caching mod from Ziki: https://vborg.vbsupport.ru/showthread.php?p=1784393 Works great on 3.8 and 3.7

ubcforums 05-30-2009 04:14 PM

working on 3.82 as well !!

David_R 08-22-2009 10:49 AM

Quote:

Originally Posted by zefyx (Post 1693465)
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


EidolonAH 09-26-2009 08:53 AM

Quote:

Originally Posted by Moparx (Post 788702)
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

Life saver:up:, the instructions just weren't making any sense to me, thanks for making it clearer.

Scalemotorcars 10-29-2009 06:27 PM

Works perfectly on 3.8.4 with VBSEO and VBA

Thanks

Keesa 11-02-2009 04:21 AM

How do I understand and interpret the results?

Page generated in 0.12721 seconds with 24 queries [Server Loads: 0.57 0.50 : 0.47]

David_R 11-07-2009 10:08 AM

I still have problems this is the code for microstats:
HTML 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

And this are the lines in my config.php
Code:

$config['Microstats']['adminonly'] = true;
$config['Microstats']['replacementvariable'] = '<!-- display microstats here -->';

Now the problem is noone is able to view microstats.
I only want that microstats should display for Administrator and Super-Moderator group, it should not be visible to any other group

Adminstrator usergroup = 6
super-mod group = 5

Please help.

Speysider 12-03-2009 04:29 PM

Is it possible to move the microstats wording to another location?
Great mod.

Kolbi 12-20-2009 07:38 PM

Does it still work with vb 4.x?

Lynne 12-20-2009 08:38 PM

Quote:

Originally Posted by Kolbi (Post 1934225)
Does it still work with vb 4.x?

No. You have to change one line to get the time to render a page to work.

Andyrew 12-28-2009 05:11 PM

Quote:

Originally Posted by Lynne (Post 1934255)
No. You have to change one line to get the time to render a page to work.

?? Can you give more info, what do we change.

Kinneas 12-29-2009 09:51 AM

Quote:

Originally Posted by Andyrew (Post 1940618)
?? Can you give more info, what do we change.

Also wouldn't mind knowing :)

Kolbi 01-06-2010 12:19 PM

I tried it on vB 4 and it works but this issue appears to:
Quote:

Warning: ksort() expects parameter 1 to be array, null given in [path]\includes\functions.php(6469) : eval()'d code on line 30

Warning: Invalid argument supplied for foreach() in [path]\includes\functions.php(6469) : eval()'d code on line 32

Speysider 02-13-2010 04:42 PM

Worked out the answer to my question about moving the microstats working.

What code do I use to show how much of the page generation was PHP and MySQL, like on http://forums.relicnews.com ?

testbot 02-15-2010 05:13 AM

Quote:

Originally Posted by Lynne (Post 1934255)
No. You have to change one line to get the time to render a page to work.

what's the secret? :D

BRotondi 03-17-2010 01:31 PM

Quote:

Originally Posted by Lynne (Post 1934255)
No. You have to change one line to get the time to render a page to work.

Same here... why no one says what to change? If someone wrote it allready ... where? Thanks!

KURTZ 03-17-2010 05:08 PM

interested too :)

Kolbi 03-17-2010 05:14 PM

me, too :D

A very needed mod...

testbot 03-17-2010 06:40 PM

*sigh* i'm getting tired of no support these days. i guess in mods it's up to the developers but i've been fixing bugs myself in vb4 since it's been released. any threads i create for assistance get ignored on vb.org and vb.com.

anyway, for everyone looking for the fix here it is...

Find:
Code:

$starttime = explode(' ', $pagestarttime);
Replace:
Code:

$starttime = explode(' ', TIMESTART);

Kolbi 03-17-2010 07:23 PM

I´m getting this issue:

Warnung: ksort() expects parameter 1 to be array, null given in [path]\includes\functions.php(6783) : eval()'d code (Zeile 30)

Warnung: Invalid argument supplied for foreach() in [path]\includes\functions.php(6783) : eval()'d code (Zeile 32)

KURTZ 03-18-2010 09:56 AM

Quote:

Originally Posted by testbot (Post 2005715)
*sigh* i'm getting tired of no support these days. i guess in mods it's up to the developers but i've been fixing bugs myself in vb4 since it's been released. any threads i create for assistance get ignored on vb.org and vb.com.

anyway, for everyone looking for the fix here it is...

Find:
Code:

$starttime = explode(' ', $pagestarttime);
Replace:
Code:

$starttime = explode(' ', TIMESTART);


if this fix works, release a new version for the suite ... :)

BRotondi 03-18-2010 07:30 PM

Thanks testbot for the fix! This gives me the correct time.
Quote:

Originally Posted by Kolbi (Post 2005725)
Warnung: ksort() expects parameter 1 to be array, null given in [path]\includes\functions.php(6783) : eval()'d code (Zeile 30)Warnung: Invalid argument supplied for foreach() in [path]\includes\functions.php(6783) : eval()'d code (Zeile 32)

I have this 2nd issue too, but not so important. Needed only the time for debugging :).
If you have a working version on your Server, can you please poste the code from Plugin “Microstats”? This is all, this AddOn is about.

btw: Use Firebug's "Network" for the best survey!

Thanks!
Bruno

testbot 03-18-2010 07:34 PM

Quote:

Originally Posted by KURTZ (Post 2005878)
if this fix works, release a new version for the suite ... :)

i don't think it would be ethical to reuse someone's code and release their product under my name. :(

KURTZ 03-19-2010 12:22 PM

Quote:

Originally Posted by testbot (Post 2006025)
i don't think it would be ethical to reuse someone's code and release their product under my name. :(

just send a PM to the author ... :)

Fraxter 03-19-2010 07:00 PM

Quote:

Developer Last Online: Oct 2008
I think there is no much chance for get the permissions...

KURTZ 03-22-2010 12:17 PM

Quote:

Originally Posted by Pander23 (Post 2006657)
I think there is no much chance for get the permissions...

just put the older author like 'co-author' and link the original hack in the first post ... however there isn't any disclaimer here ...

testbot 03-22-2010 01:49 PM

if Lyne says it's ok i'll update this for vb4 and provide support the best i can.

Lynne 03-22-2010 02:05 PM

I cannot give an OK for this to be posted. The only person who can give an OK for this to be ported to vB4 is the developer and he is not even responding to PMs (I sent him one a while ago about this).

testbot 03-22-2010 02:18 PM

as always thanks for the info, Lynne :)

Kolbi 03-22-2010 04:14 PM

Just recode it...

Jaxel 04-02-2010 01:33 PM

The new error is from THIS code:

Code:

        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>';
                }
    }

It is because the variable "$tempusagecache" no longer exists (just as how "$pagestarttime" no longer exists). If someone finds out what variable "$tempusagecache" is now called, we can fix this mod.

Jaxel 04-02-2010 02:07 PM

FIXED!

I'm awesome... this is the new plugin... DONT JUST CUT AND PASTE THIS CODE, READ MY COMMENT BELOW FIRST!

Code:

// Microstats 1.2.1 Plugin

$pageendtime = microtime();
$starttime = explode(' ', TIMESTART);
$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] . ']';
       
        }

        $tempusagecache = vB_Template::$template_usage;
        $_TEMPLATEQUERIES = vB_Template::$template_queries;

        $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'] == 6) or !$vbulletin->config['Microstats']['adminonly']){

        $output = str_replace($vbulletin->config['Microstats']['replacementvariable'], $debughtml . $vbulletin->config['Microstats']['replacementvariable'], $output);

}

// Microstats 1.2.1 Plugin


OKAY... right now the code above ISN'T working, vb.org is giving me errors with a single line of code when I'm trying to post it here, so let me explain what you need to do to fix it. Search for the following piece of text in the code above:

Code:

@exec(uptime)
Add SINGLE QUOTES around the word 'uptime'. It looks like VB.ORG is having problems with executing the exec function inside of posts. VB.ORG people, if you are reading this, you need to fix this IMMEDIATELY! Someone could potentially execute code from posts with this error.



A comment about copyright with code... History has shown us, that if you give two engineers the same problem and unlimited amount of time, they will both eventually come up with the same solution; especially if there is only ONE way to fix the problem. With this modification, there is really only ONE way to do it. I mean I could rewrite the code, come up with new variable names and everything... but its pretty much going to be the same exact code, even though I wrote it from scratch. If I rewrite the code, can I post it as a new mod? Even though its going to look pretty much the same?

testbot 04-02-2010 02:21 PM

Quote:

Originally Posted by Jaxel (Post 2014629)
The new error is from THIS code:

Code:

        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>';
                }
    }

It is because the variable "$tempusagecache" no longer exists (just as how "$pagestarttime" no longer exists). If someone finds out what variable "$tempusagecache" is now called, we can fix this mod.

tempusagecache still exists in includes/functions.php on line 6675 in vb4.


All times are GMT. The time now is 11:34 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.01865 seconds
  • Memory Usage 1,875KB
  • 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
  • (10)bbcode_code_printable
  • (1)bbcode_html_printable
  • (1)bbcode_php_printable
  • (17)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)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