reniced: uid to username fix.

This commit is contained in:
Ole Tange 2012-03-06 15:47:41 +01:00
parent 60fba79682
commit 1efb107953
2 changed files with 10 additions and 5 deletions

3
README
View file

@ -0,0 +1,3 @@
Tools developed by Ole Tange <ole@tange.dk>.
Probably not useful for you, but then again you never now.

View file

@ -28,13 +28,15 @@ sub renice_all {
my $ps = ps(); my $ps = ps();
my @pids_to_renice = grep_ps($cpu_seconds,$ps); my @pids_to_renice = grep_ps($cpu_seconds,$ps);
my $user_pid_list = user_pid_list($ps,@pids_to_renice); my $user_pid_list = user_pid_list($ps,@pids_to_renice);
my ($login,$pass,$uid,$gid);
for my $user (keys %$user_pid_list) { for my $user (keys %$user_pid_list) {
if($user =~ /^\d+$/) { if($user =~ /^\d+$/) {
# All digits username => probably a >8 char username => lookup uid # All digits username => probably a >8 char username => lookup uid
my ($login,$pass,$uid,$gid) = getpwnam($user); ($login,$pass,$uid,$gid) = getpwuid($user);
$user = $login; } else {
$login = $user;
} }
renice_user($cpu_seconds, $user, $ps, @{$user_pid_list->{$user}}); renice_user($cpu_seconds, $login, $ps, @{$user_pid_list->{$user}});
} }
} }