Skip to content

Commit

Permalink
Collect disk usage in both operations per second and bytes per second
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Sandin committed Oct 1, 2013
1 parent 26db3d7 commit 2478ef6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Linode/Longview/DataGetter/Disk.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ sub get {
$line =~ s/^\s*//;

# 202 0 xvda 3125353 13998 4980 2974 366 591 760 87320 15 366 9029
my ( $major, $minor, $device, $reads, $writes ) = ( split( /\s+/, $line ) )[ 0..3, 7 ];
my ( $major, $minor, $device, $reads, $read_sectors, $writes, $write_sectors ) = ( split( /\s+/, $line ) )[ 0..3, 5, 7, 9 ];
my $sector_size = slurp_file("/sys/block/$device/queue/hw_sector_size");
my $read_bytes = $read_sectors * $sector_size;
my $write_bytes = $write_sectors * $sector_size;
$device = '/dev/' . $device;
# escaped version for use inside the result hash
(my $e_device = $device) =~ s/\./\\\./g;
Expand Down Expand Up @@ -101,6 +104,8 @@ sub get {
}
$dataref->{LONGTERM}->{"Disk.$e_device.reads"} = $reads + 0;
$dataref->{LONGTERM}->{"Disk.$e_device.writes"} = $writes + 0;
$dataref->{LONGTERM}->{"Disk.$e_device.read_bytes"} = $read_bytes + 0;
$dataref->{LONGTERM}->{"Disk.$e_device.write_bytes"} = $write_bytes + 0;
$dataref->{INSTANT}->{"Disk.$e_device.isswap"} = (grep { $_ eq $device } @swaps) ? 1 : 0;
unless (exists($dataref->{INSTANT}->{"Disk.$e_device.mounted"})) {
$dataref->{INSTANT}->{"Disk.$e_device.mounted"} = 0;
Expand Down

0 comments on commit 2478ef6

Please sign in to comment.