View RSS Feed

Danny Bembibre (dbembibre) Crawlability Inc.

Plugin restrict search when server load is high

Rate this Entry
by , 10-24-2007 at 10:43 AM (3115 Views)
This is a old plugin that i make in the earling times of vBulletin 3.5

This plugin allow to you disable searches when the load average reaches a defined level.
  • Can exclude user groups of the search restriction
  • Users with search restricted can use google integrated search (by the plugin)
The code
PHP Code:
 
     $Groupids 
explode(','$vbulletin->options['Allowed_Groups']);
 
     if(
is_member_of($vbulletin->userinfo$Groupids))
     {
      
$SearchAllowed true;
     }
    
//$SearchAllowed = is_member_of($vbulletin->userinfo, explode(',',$vbulletin->options['Allowed_Groups'])) ? true : false;
 
    
if (!$SearchAllowed)
    {
 
      if (
$load = @file_get_contents("/proc/loadavg"))  //standard linux style
       
$loadavg explode(' '$load);  
      elseif (
$load=@exec('uptime'))  //unix style
       
preg_match('/averages?: ([0-9.]+),[s]+([0-9.]+),[s]+([0-9.]+)/',$load$loadavg);
      elseif (
$load = @`sysctl vm.loadavg|cut -d" " -f3-5`) //BSD style
       
$loadavg explode(' '$load);  
 
      if (
trim($loadavg[0]) > $search_load)  
      {
        
$navbits construct_navbits($navbits);
               eval(
'$navbar = "' fetch_template('navbar') . '";');
               eval(
'print_output("' fetch_template('Danny_Restrict') . '");');
      }
     } 
The plugin work with linux, freeBSD and unix servers not in WINDOWS.
Be sure that you allow access to /proc/loadavg in open_basedir in php.ini

INSTALL

Simply install as product and go to ACP->Restrict Search Config and put a load value.

SCREENSHOTS
Attached Thumbnails Attached Thumbnails blogs/danny-bembibre/attachments/6864-plugin-restrict-search-when-server-load-high-plugin1.jpg   blogs/danny-bembibre/attachments/6865-plugin-restrict-search-when-server-load-high-plugin2.jpg   blogs/danny-bembibre/attachments/6866-plugin-restrict-search-when-server-load-high-plugin3.jpg  
Attached Thumbnails Attached Files
Categories
BMW FAQ Club , Php

Comments

  1. Oleg Ignatiuk's Avatar
    Thank you for contribution!
  2. ToniLloret's Avatar
    Muchas Gracias!!

Trackbacks

Total Trackbacks 0
Trackback URL: