Back to vBulletin 3.7 Add-ons

TOP Server Load on AdminCP homepage
Mod Version: 1.3, by Adult SEO

This modification is in the archives.
vB Version: 3.7.x Rating: (5 votes - 4.80 average) Installs: 51
Released: 29 Nov 2008 Last Update: 07 Jul 2009 Downloads: 270
Not Supported Uses Plugins Re-usable Code Translations  

This mod will add the top server load statistics in your vBulletin admincp (if your server installation allows execution of programs via PHP)



Update (V.1.2)

Added kill process function to be able to kill a process with a click of the button.

Note: this will require the ability to execute kill -9 process_id from PHP exec();



Update (V.1.3)

Added SuperAdministrator check, to allow just super admins to see and manage server processes.

This addition was suggested by accludetuner

Spoiler (click to open)


Got this working on 3.8.2. I have it using the hook of "admin_index_main3". I also made slight change to the code to only allow Super Administrators to be able to view/kill processes due to the possible problems an unknowing user could cause. Here's my code:

PHP Code:
if (in_array($vbulletin->userinfo['userid'], preg_split('#\s*,\s*#s'$vbulletin->config['SpecialUsers']['superadministrators'], -1PREG_SPLIT_NO_EMPTY)) )
{

/* Server Load */
if ($_REQUEST["kill_process"] && is_numeric($_REQUEST["kill_process"])) {
        
$process_id $_REQUEST["kill_process"];
        if (
$_POST["no"]) {
        
        } elseif (
$_POST["yes"]) {
            
exec("kill -9 ".$process_id."");
            
print_table_start();
            
print_table_header('<a name="killprocess"></a>TOP - Server Load - Kill Process '.$process_id.'',1);
            
print_description_row('Process killed!',false,1);
            
print_table_footer(2''''false);
        } else {
            
exec('ls -la /proc/'.$process_id.'/'$procdata$error );
            
$proctxt '';
            foreach (
$procdata as $procline) {
                
$proctxt .= trim($procline)."\n";
            }
            
print_table_start();
            
print_table_header('<a name="killprocess"></a>TOP - Server Load - Kill Process '.$process_id.'',1);
            
print_description_row('<form method="post" action="index.php?do=home&kill_process='.$process_id.'#killprocess">
                Are you sure you want to kill this process? 
                <div style="padding:10px;"><textarea style="width:550px;height:200px;">'
.$proctxt.'</textarea></div><input type="submit" name="yes" value="Yes"> <input type="submit" name="no" value="No">
            </form>'
,false,1);
            
print_table_footer(2''''false);
        }
    }

    
print_table_start();
    
print_table_header('TOP - Server Load',12);
    
exec('top n 1 b i'$top$error );
    
    
$is_toptable false;
    foreach (
$top as $topline) {
        
$topline trim($topline);
        if (!
$topline) { continue 1; }
        if (!
$is_toptable && !preg_match('|^PID|Ui',$topline)) {
            if (
preg_match('|^top - (.*)$|Ui',$topline,$out)) {
                
print_description_row('<b>TOP:</b> '.$out[1],false,12);
            } else {
                if (
preg_match('|^([^:]+): (.*)$|Ui',$topline,$out)) {
                    
print_description_row('<b>'.$out[1].':</b> '.$out[2],false,12);
                } else {
                    
print_description_row($topline,false,12);
                }
            }
        } else {
            
$topvals preg_split('|[ ]+|s',$topline);
            if (!
$is_toptable) {
                foreach (
$topvals as $key => $value) {
                    
$topvals[$key] = '<b>'.$value.'</b>';
                }
            } else {
                
$topvals[0] .= ' <a href="index.php?do=home&kill_process='.$topvals[0].'#killprocess" style="color:red;">X</a>';
            }
            
print_cells_row(array(
                    
$topvals[0],
                    
$topvals[1],
                    
$topvals[2],
                    
$topvals[3],
                    
$topvals[4],
                    
$topvals[5],
                    
$topvals[6],
                    
$topvals[7],
                    
$topvals[8],
                    
$topvals[9],
                    
$topvals[10],
                    
$topvals[11]
                ), 
00, -5'top'11);
            
            
$is_toptable true;
        }
    }
    
print_table_footer(2''''false);
    

Thanks! *Installed*

Close

Download

This modification is archived, downloads are still allowed.

File Type: %1$s product-top_server_load.xml (3.4 KB, 65 downloads)

Screenshots

Click image for larger version
Name:	top2.jpg
Views:	145
Size:	85.9 KB
ID:	90008   Click image for larger version
Name:	server-load-kill-process.jpg
Views:	2001
Size:	116.8 KB
ID:	90438  

Similar Mods

[Linux] loadsock (retrieve server load from remote server) vBulletin 2.x Full Releases

vblts.ru supports vBulletin®, 2022-2024