38 |
|
} |
39 |
|
elsif ($ostype eq "Linux") { |
40 |
|
# covers: Debian r2.2 |
41 |
< |
$topbin = "/usr/bin/top -d1 -n0 -b"; |
41 |
> |
$topbin = "/usr/bin/top -d1 -n2 -b -p0"; |
42 |
|
$dfbin = "/bin/df"; |
43 |
|
$usersbin = "/usr/bin/users"; |
44 |
|
$unamebin = "/bin/uname"; |
150 |
|
# Find out some numbers from top. |
151 |
|
my(@top) = `$topbin`; |
152 |
|
my($top) = join(" ", @top); |
153 |
< |
$top =~ s/\n//g; |
153 |
> |
$top =~ s/\n/ /g; |
154 |
|
|
155 |
|
if($ostype eq "SunOS") { |
156 |
|
&print_pair(0, "packet.processes.total", $top =~ /([0-9]+?) processes:/); |
191 |
|
$swap_free/=1024 if $2 eq "K"; |
192 |
|
&print_pair(0, "packet.swap.free", $swap_free); |
193 |
|
|
194 |
– |
# AJ requested total swap instead of swap_in_use, so here we go! |
194 |
|
&print_pair(0, "packet.swap.total", $swap_free + $swap_in_use); |
195 |
|
} |
196 |
|
elsif ($ostype eq "FreeBSD") { |
243 |
|
&print_pair(0, "packet.load.load15", $3); |
244 |
|
} |
245 |
|
elsif ($ostype eq "Linux") { |
246 |
+ |
my ($top) = ""; |
247 |
+ |
foreach my $line (@top) { |
248 |
+ |
$top = $line . $top; |
249 |
+ |
} |
250 |
+ |
$top =~ s/\n/ /g; |
251 |
+ |
|
252 |
|
&print_pair(0, "packet.processes.total", $top =~ /([0-9]+?) processes:/); |
253 |
|
&print_pair(0, "packet.processes.sleeping", $top =~ /([0-9]+?) sleeping/); |
254 |
|
&print_pair(0, "packet.processes.zombie", $top =~ /([0-9]+?) zombie/); |
255 |
|
&print_pair(0, "packet.processes.stopped", $top =~ /([0-9]+?) stopped/); |
256 |
|
&print_pair(0, "packet.processes.cpu", $top =~ /([0-9]+?)\s*running/); |
257 |
|
&print_pair(0, "packet.cpu.idle", $top =~ /([^\s]+?)% idle/); |
253 |
– |
&print_pair(0, "packet.cpu.user", $top =~ /([^\s]+?)% user/); |
258 |
|
&print_pair(0, "packet.cpu.kernel", $top =~ /([^\s]+?)% system/); |
259 |
|
&print_pair(0, "packet.cpu.iowait", $top =~ /([^\s]+?)% interrupt/); |
260 |
|
&print_pair(0, "packet.cpu.swap", $top =~ /([^\s]+?)% swap/); |
261 |
+ |
|
262 |
+ |
# FreeBSD is a bit different, we need to get user and nice. |
263 |
+ |
my($user) = 0; |
264 |
+ |
if($top =~ /([^\s]+?)% user/) { $user += $1; } |
265 |
+ |
if($top =~ /([^\s]+?)% nice/) { $user += $1; } |
266 |
+ |
&print_pair(0, "packet.cpu.user", $user); |
267 |
|
|
268 |
|
# The following need to be specified in megabytes. |
269 |
|
# If they are preceeded by a G, then multiply by 1024. |