File: loadavg.pl

package info (click to toggle)
cacti 0.6.7-2.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,000 kB
  • ctags: 1,120
  • sloc: php: 5,059; sql: 922; sh: 302; perl: 81; makefile: 56
file content (22 lines) | stat: -rwxr-xr-x 360 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl

#get load avg for 5;15;30 min
$avg = `uptime`;
$avg =~ s/.*://;

if ($ARGV[0] eq "5") {
	$avg = `echo "$avg" | awk '\{print \$1 \}'`;
}

if ($ARGV[0] eq "15") {
	$avg = `echo "$avg" | awk '\{print \$2 \}'`;
}

if ($ARGV[0] eq "30") {
	$avg = `echo "$avg" | awk '\{print \$3 \}'`;
}

chomp $avg;
$avg =~ s/,//;

print $avg;