#!/usr/bin/perl
# Hacked to work by shaolintiger.com
use lib '/scripts';
BEGIN { unshift @INC, '/usr/local/cpanel'; }
use Cpanel::SafeFile;

print "\nSearching for VPS Memory Limit.............: ";
$file = '/proc/user_beancounters';
open(INFO, $file);
@lines = <INFO>;
close(INFO);

$lines[9] =~ s/\s+/:/g;
print $lines[9]."\n";
@words = split(/:/, $lines[9]);
$size = $words[4];
print "Found VPS memory limit (estimated).........:
".int($words[4]/1024*4)." MB\n";

$lines[8] =~ s/\s+/:/g;
@words = split(/:/, $lines[8]);
print "Current VPS memory usage (estimated).......:
".int($words[2]/1024*4)." MB\n";

print "Calculating RLimitMEM......................: ";
$size = int( $size / 2 );
$size = int( $size * 1024 );
print "$size";
$size = int( $size / 3 );
print ", $size\n";

$meg = int( $size / ( 1024 * 1024 ) );
print "Suggested apache child process limit.......: ".$meg." MB\n\n";
print "You may add the following into your
/etc/httpd/conf/httpd.conf:\n\nRLimitMEM ".$size."\n\n";
