/[cricket]/getload
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /getload

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Sat May 31 13:50:23 2003 UTC (16 years, 2 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +2 -1 lines
fix ruptime parsing

1 #!/usr/bin/perl -w
2
3 if ($#ARGV == 0) {
4 open(UPTIME,"ruptime |") || die "ruptime: $!";
5 my $host = $ARGV[0];
6 while(<UPTIME>) {
7 chomp;
8 if (/$host.+(\d+) user.+load.+?([\d\.]+), ([\d\.]+), ([\d\.]+)$/) {
9 print "$2\n$3\n$4\n$1\n";
10 # } else {
11 # print "skip: $_\n";
12 }
13 }
14 } else {
15 shift @ARGV; # ship hostname (used for ruptime)
16 my $cmd = join(" ",@ARGV) || "uptime";
17 open(UPTIME,"$cmd |") || die "$cmd: $!";
18 while(<UPTIME>) {
19 chomp;
20 if (/(\d+) user.+load.+ ([\d\.]+), ([\d\.]+), ([\d\.]+)/) {
21 print "$2\n$3\n$4\n$1\n";
22 # } else {
23 # print "skip: $_\n";
24 }
25 }
26 }

  ViewVC Help
Powered by ViewVC 1.1.26