Skip to content

Commit

Permalink
Add support for disk I/O in FreeBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Aug 7, 2024
1 parent f5b3f9c commit 6bc70a7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion proc/freebsd-lib.pl
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,20 @@ sub get_cpu_io_usage
my @lines = split(/\r?\n/, $out);
my @w = split(/\s+/, $lines[$#lines]);
shift(@w) if ($w[0] eq '');
return ( $w[-3], $w[-2], $w[-1], 0, 0, undef, undef );
my ($bi, $bo) = (0, 0);
my $out2 = &backquote_command("iostat -Ix -d -t da 0.25 2 2>/dev/null");
if (!$?) {
foreach my $l (split(/\r?\n/, $out2)) {
# Getting the 4th and 5th columns of the last line for direct access device
# device r/i w/i kr/i kw/i qlen tsvc_t/i sb/i
# ada0 3457.0 134574.0 61068.0 8443152.0 0 36.3 19.2
if ($l =~ /^.*?da\d+\s+\S+\s+\S+\s+(\S+)\s+(\S+)\s+\d/) {
$bi = int($1) * 4; # kr/i per period, i.e. 0.25 seconds
$bo = int($2) * 4; # kw/i per period, i.e. 0.25 seconds
}
}
}
return ( $w[-3], $w[-2], $w[-1], 0, 0, $bi, $bo );
}

1;
Expand Down

0 comments on commit 6bc70a7

Please sign in to comment.