vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   vbMicroStats: page load time, queries, GZIP and PHP version (https://vborg.vbsupport.ru/showthread.php?t=35811)

solent 04-26-2003 04:15 PM

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

SiGmA_X 04-27-2003 04:57 PM

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.

TECK 05-05-2003 11:50 PM

If I'm correct, that won't work in safe mode...

Hobbes 05-06-2003 04:08 AM

I cant get them to show up......

Hobbes 05-06-2003 04:17 AM

ok, my new attach wouldn't show....

N9ne 05-07-2003 08:30 PM

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;



ogden2k 05-07-2003 11:19 PM

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?

Lethal 05-08-2003 09:11 AM

that looks just fine

Lethal 05-08-2003 09:19 AM

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?

Zxin 05-14-2003 08:05 AM

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!


All times are GMT. The time now is 02:31 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.01691 seconds
  • Memory Usage 1,774KB
  • 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (3)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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