Jump to content
InvisionCommunity.de - Der Deutsche Invision Community Support
Sign in to follow this  
zer0

Server-Load hinzufügen?

Recommended Posts

Hi Loite

Ich sah heute ein Forum das die Server-Ladezeit unten im Footer angezeigt hat.

Bsp. [ Script Execution time: 0.6000 ] [ 10 queries used ] [ GZIP Enabled ] [ Server Load: 25.06 ]

Jetzt meine Frage: Wie krieg ich das auch so hin? Google hat mir leider keine nützlichen Infos ausgespuckt... :(

Freue mich wie immer über Antworten :)

mfg

Share this post


Link to post

Wenn du im ACP unter System Settings => CPU Saving => Server Load Limit ein Limit eingibst, wird dieses bei jedem Aufruf geprüft und falls dein Webhoster dir erlaubt auf die Datei /proc/loadavg zuzugreifen und somit ein Wert ermittelt werden kann, wird es automatisch zu den bestehenden Infos hinzugefügt. :)

Falls du sowas in eigenen Scripten realisieren willst, schau dir einfach die Funktion im IPB an.

       	 if ( file_exists('/proc/loadavg') )
       {
         if ( $fh = @fopen( '/proc/loadavg', 'r' ) )
         {
         $data = @fread( $fh, 6 );
         @fclose( $fh );

         $load_avg = explode( " ", $data );

         $ibforums->server_load = trim($load_avg[0]);

         if ($ibforums->server_load > $ibforums->vars['load_limit'])
         {
           $std->Error( array( 'LEVEL' => 1, 'MSG' => 'server_too_busy', 'INIT' => 1 ) );
         }
         }
       }
       else
       {
   if ( $serverstats = @exec("uptime") )
   {
   preg_match( "/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/", $serverstats, $load );

   $ibforums->server_load = $load[1];
   }
 }

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×