/[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

Annotation of /getload

Parent Directory Parent Directory | Revision Log Revision Log


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

1 dpavlin 1.2 #!/usr/bin/perl -w
2    
3     if ($#ARGV == 0) {
4     open(UPTIME,"ruptime |") || die "ruptime: $!";
5 dpavlin 1.4 my $host = $ARGV[0];
6 dpavlin 1.2 while(<UPTIME>) {
7     chomp;
8 dpavlin 1.4 if (/$host.+(\d+) user.+load.+?([\d\.]+), ([\d\.]+), ([\d\.]+)$/) {
9 dpavlin 1.2 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 dpavlin 1.3 my $cmd = join(" ",@ARGV) || "uptime";
17 dpavlin 1.2 open(UPTIME,"$cmd |") || die "$cmd: $!";
18     while(<UPTIME>) {
19     chomp;
20 dpavlin 1.3 if (/(\d+) user.+load.+ ([\d\.]+), ([\d\.]+), ([\d\.]+)/) {
21 dpavlin 1.2 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