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)

Sebastian 12-05-2002 10:32 AM

doesn't work... still get the redeclare error.

Fatal error: Cannot redeclare serveruptime() in /home/www/html/forum/admin/functions.php on line 518

Raptor 12-05-2002 11:45 AM

worked perfect first time using vb 2.2.9 :)

Page generated in 0.33490300 seconds (43.71% PHP - 56.29% MySQL) with 21 queries.
[Debug Mode OFF] [PHP v4.2.3] [GZIP enabled - level 1] [Server Load: 1.05 ? 1.10 : 1.08]

is it possible for the admin only stuff to be view by anyone ?

TECK 12-05-2002 02:21 PM

Quote:

Originally posted by Sebastian
doesn't work... still get the redeclare error.


Fatal error: Cannot redeclare serveruptime() in /home/www/html/forum/admin/functions.php on line 518

Aha, you probably have my admin hack installed.
Code:

function uptime() {
      $fd = fopen( '/proc/uptime' , 'r' );
      $ar_buf = split( ' ' , fgets( $fd , 4096 ) );
      fclose( $fd );
      $sys_ticks = trim( $ar_buf[0] );
      $min = $sys_ticks / 60;
      $hours = $min / 60;
      $days = floor( $hours / 24 );
      $hours = floor( $hours - ( $days * 24 ) );
      $min = floor( $min - ( $days * 60 * 24 ) - ( $hours * 60 ) );

      if ( $days != 1 ) {
        $value = $days . ' days, ';
      } else {
        $value = $days . ' day, ';
      }
      if ( $hours != 1 ) {
        $value .= $hours . ' hours and ';
      } else {
        $value .= $hours . ' hour and ';
      }
      if ( $min != 1 ) {
        $value .= $min . ' minutes';
      } else {
        $value .= $min . ' minute';
      }

      return $value;
    }

    if ( $stats = @exec( 'uptime' ) ) {
      preg_match( '/averages?: ([0-9\.]+),[\s]+([0-9\.]+) , [\s]+([0-9\.]+)/' , $stats , $regs );
      $serveruptime = uptime();
      $serverload = ' [Server Load: '.$regs[1].' : '.$regs[2].' : '.$regs[3].'][Server Uptime: ' . $serveruptime . ']';
    } else {
      $serverload = '';
    }


Boofo 12-05-2002 02:33 PM

Teck, how would we get the serveruptime to show in the admin part of microstats at the bottom of the page? :)

TECK 12-05-2002 08:02 PM

Boofo, find:
Code:

    if ($stats=@exec('uptime')) {
      preg_match('/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/',$stats,$regs);
      $serverload=' [Server Load: '.$regs[1].' : '.$regs[2].' : '.$regs[3].']';
    } else {
      $serverload='';
    }

Replace with:
Code:

    if ( $stats = @exec( 'uptime' ) ) {
      preg_match( '/averages?: ([0-9\.]+) , [\s]+([0-9\.]+) , [\s]+([0-9\.]+)/' , $stats , $regs );

      function getserveruptime() {
        $fd = fopen( '/proc/uptime' , 'r' );
        $ar_buf = split( ' ' , fgets( $fd , 4096 ) );
        fclose( $fd );
        $sys_ticks = trim( $ar_buf[0] );
        $min = $sys_ticks / 60;
        $hours = $min / 60;
        $days = floor( $hours / 24 );
        $hours = floor( $hours - ( $days * 24 ) );
        $min = floor( $min - ( $days * 60 * 24 ) - ( $hours * 60 ) );

        if ( $days != 1 ) {
          $value = $days . ' days, ';
        } else {
          $value = $days . ' day, ';
        }
        if ( $hours != 1 ) {
          $value .= $hours . ' hours and ';
        } else {
          $value .= $hours . ' hour and ';
        }
        if ( $min != 1 ) {
          $value .= $min . ' minutes';
        } else {
          $value .= $min . ' minute';
        }

        return $value;
      }

      $serveruptime = getserveruptime();
      $serverload = ' [Server Load: ' . $regs[1] . ' : ' . $regs[2] . ' : ' . $regs[3] . '] [Server UpTime: ' . $serveruptime . ']';
    } else {
      $serverload = '';
    }


Boofo 12-05-2002 09:17 PM

Thanks, Floren, :) When I added the code you gave me, my Server Load has no numbers after it now. It only shows : :. Any ideas? :) And how can I get it to show on the next line?

Sebastian 12-05-2002 10:22 PM

yeah TECK, it works but then doesn't show the server load averages, just : :

TECK 12-06-2002 09:17 PM

That's really wierd.. I simply added a function, so it should display it...
Code:

      function getserveruptime() {
        $fd = fopen( '/proc/uptime' , 'r' );
        $ar_buf = split( ' ' , fgets( $fd , 4096 ) );
        fclose( $fd );
        $sys_ticks = trim( $ar_buf[0] );
        $min = $sys_ticks / 60;
        $hours = $min / 60;
        $days = floor( $hours / 24 );
        $hours = floor( $hours - ( $days * 24 ) );
        $min = floor( $min - ( $days * 60 * 24 ) - ( $hours * 60 ) );

        if ( $days != 1 ) {
          $value = $days . ' days, ';
        } else {
          $value = $days . ' day, ';
        }
        if ( $hours != 1 ) {
          $value .= $hours . ' hours and ';
        } else {
          $value .= $hours . ' hour and ';
        }
        if ( $min != 1 ) {
          $value .= $min . ' minutes';
        } else {
          $value .= $min . ' minute';
        }

        return $value;
      }

      $serveruptime = getserveruptime();

The rest is unchanged.
Boofo, simply call $serveruptime anywhere you want... you could use this:
'][high]<br />[/high][Server UpTime: ' . $serveruptime . ']';
from the line listed above, it will display it under the actual line of admin stats... let me know if everything is ok... simply add the above function below this line:
Code:

      preg_match('/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/',$stats,$regs);

Boofo 12-07-2002 01:52 AM

Thank you, Floren. It worked great! Once again you have proven yourself the Microstats Wizard. ;) This is why it won Hack of the Month. If they ever have a hack of the year contest, you got my vote! ;)

One last question (2 actually). What is the difference between Server Uptime and MySQL uptime? I have both of them installed and they are about 5 days off from one another.

Also, could you show me how to add (I know this will sound stupid) seconds to the uptime, please? :)

TECK 12-07-2002 08:54 AM

1. There is a link I posted in the first thread that will explain the diff between, is done by Eva2000 at VB.com site.
2. For seconds, use this:
Code:

$sec = floor( $sys_ticks - ( $days * 60 * 24 ) - ( $hours * 60 ) - ( $min * 60 ) );
Then:
Code:

        if ( $sec != 1 ) {
          $value .= $sec . ' seconds';
        } else {
          $value .= $sec . ' second';
        }

Just play with the "and" word...


All times are GMT. The time now is 11:14 AM.

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.01694 seconds
  • Memory Usage 1,755KB
  • 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
  • (7)bbcode_code_printable
  • (1)bbcode_quote_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