Guest User

Untitled

a guest
Jun 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. $_ = `ps axu |grep 'orpc-' |grep -v grep | cut -b10-15`;
  4. my %pids = map { $_ => 1 } split;
  5. my @evils;
  6.  
  7. foreach (split /\n/, `top -bn1`) {
  8. s/^\s+//;
  9. my @cols = split /\s+/;
  10. next unless $cols[0] =~ /\d/;
  11. if ($cols[8] =~ /\d{2,}/) {
  12. if ($pids{$cols[0]}) {
  13. print "$_\n";
  14. push @evils, $cols[0];
  15. }
  16. }
  17. }
  18.  
  19. print "\n";
  20. foreach my $pid (@evils) {
  21. print "Kill PID $pid ? [Y/n] ";
  22. my $ans = <>;
  23. unless ($ans =~ /N|n/) {
  24. print "killing PID $pid .. ";
  25. unless (0 == system("sudo kill $pid")) {
  26. warn sprintf "External command '%s' failed with exit status %d (signal %d). A core dump %s\n",
  27. $cmd, $? >> 8, $? & 127, $? & 128 ? "occurred" : "did not occur";
  28. } else {
  29. print "done\n";
  30. }
  31. }
  32. }
Add Comment
Please, Sign In to add comment