Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Renicing your server (automatically) so it has priority and less latancy
09-02-2008, 10:57 AM
Post: #1
Renicing your server (automatically) so it has priority and less latancy
If your server isn't on a dedicated box running NOTHING else you may experiance latancy when apache pegs the CPU at 100% for days on end (you know, because new supporters are downloading your (truthful) propaganda... or maybe playing your web-terminal enabled little videogames... or apache has some bug... who knows) and this will kill any performance in the game.

The soultion is RENICE (on linux boxes). But you restart your server sometimes, so the soultion becomes renice in a script placed in /etc/cron.hourly/

Code:
#!/usr/bin/perl
#autorenice_of_x by MikeeUSA ((C) GNU GPL v2)

delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};   # Make %ENV safer
##$ENV{'PATH'} = '/bin/';

$username = "nexuizuser"; #User that program belongs to
$niceness = "-14";  #Nice value (less == higher priority)
$program = 'nexuiz-linux-686-dedicated';  #Program to renice

$rnpid = '';
$user = '';
##print"$program\n";
dict0();
$pid = `/bin/pidof $program`;
##print"$pid\n";
chomp($pid);
dict1();

sub dict0 {
    $program =~ s/\W\-\_//g;
}

sub dict1 {
    ##print"$pid\n";
    (@buffe) = split(/ /,$pid);
    ##print"@buffe\n";
    foreach (@buffe) {
        $_ =~ s/\W//g;
        $rnpid = $_;
        $user = `ps -p $_ -o user`;
        $user =~ s/USER//g;
        $user =~ s/\n//g;
        ##print"$user\n";
        $user =~ s/\W//g;
        ##print"$user\n";
        if ($user eq $username) {
            print"renice $niceness -p $rnpid";
                system("renice $niceness -p $rnpid");
                print "Reniced $rnpid ($program) to $niceness\n";
        }

    }
}
mikeeusa, proud to be a member of Nexuiz Ninjaz - Practicing the Ninja Art of Nexuiz since Apr 2008.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


Contact Us | Nexuiz Ninjaz Home | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication