Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
920 B

  1. #!/usr/bin/perl
  2. # $RCSfile: myrup,v $$Revision: 4.1 $$Date: 92/08/07 17:20:26 $
  3. # This was a customization of ruptime requested by someone here who wanted
  4. # to be able to find the least loaded machine easily. It uses the
  5. # /etc/ghosts file that's defined for gsh and gcp to prune down the
  6. # number of entries to those hosts we have administrative control over.
  7. print "node load (u)\n------- --------\n";
  8. open(ghosts,'/etc/ghosts') || die "Can't open /etc/ghosts: $!";
  9. line: while (<ghosts>) {
  10. next line if /^#/;
  11. next line if /^$/;
  12. next line if /=/;
  13. ($host) = split;
  14. $wanted{$host} = 1;
  15. }
  16. open(ruptime,'ruptime|') || die "Can't run ruptime: $!";
  17. open(sort,'|sort +1n');
  18. while (<ruptime>) {
  19. ($host,$upness,$foo,$users,$foo,$foo,$load) = split(/[\s,]+/);
  20. if ($wanted{$host} && $upness eq 'up') {
  21. printf sort "%s\t%s (%d)\n", $host, $load, $users;
  22. }
  23. }