| 1 | ################################################################################ | ||
| 2 | # Monitor the Datafile IO | ||
| 3 | |||
| 4 | use strict; | ||
| 5 | use StatsView::Oracle::Monitor; | ||
| 6 | package StatsView::Oracle::DatafileIO; | ||
| 7 | @StatsView::Oracle::DatafileIO::ISA = qw(StatsView::Oracle::Monitor); | ||
| 8 | |||
| 9 | ################################################################################ | ||
| 10 | |||
| 11 | sub new($$$$) | ||
| 12 | { | ||
| 13 | my ($class, $db, $fh, $rate) = @_; | ||
| 14 | $class = ref($class) || $class; | ||
| 15 | my $self = $class->SUPER::new($db, $fh, $rate); | ||
| 16 | my $query = q(select /*+ rule */ name, phyrds, phywrts, phyblkrd, phyblkwrt | ||
| 17 | from v$filestat, v$datafile | ||
| 18 | where v$filestat.file# = v$datafile.file#); | ||
| 19 | $self->{cursor} = $db->prepare($query); | ||
| 20 | $self->header("multirow", "Datafile IO activity", | ||
| 21 | "Reads/Sec,Writes/Sec,Blocks Read/Sec,Blocks Written/Sec", | ||
| 22 | "NNNN"); | ||
| 23 | $self->{cursor}->execute(); | ||
| 24 | my ($df, $r, $w, $br, $bw); | ||
| 25 | while (($df, $r, $w, $br, $bw) = $self->{cursor}->fetchrow()) | ||
| 26 | { | ||
| 27 | $self->{df}{$df} = [ $r, $w, $br, $bw ]; | ||
| 28 | } | ||
| 29 | return($self); | ||
| 30 | } | ||
| 31 | |||
| 32 | ############################################################################## | ||
| 33 | |||
| 34 | sub sample($$) | ||
| 35 | { | ||
| 36 | my ($self, $ts) = @_; | ||
| 37 | $self->{cursor}->execute(); | ||
| 38 | my (@data, $df, $r, $w, $br, $bw); | ||
| 39 | while (($df, $r, $w, $br, $bw) = $self->{cursor}->fetchrow()) | ||
| 40 | { | ||
| 41 | my $d_r = ($r - $self->{df}{$df}[0]) / $self->{rate}; | ||
| 42 | my $d_w = ($w - $self->{df}{$df}[1]) / $self->{rate}; | ||
| 43 | my $d_br = ($br - $self->{df}{$df}[2]) / $self->{rate}; | ||
| 44 | my $d_bw = ($bw - $self->{df}{$df}[3]) / $self->{rate}; | ||
| 45 | $self->{df}{$df} = [ $r, $w, $br, $bw ]; | ||
| 46 | push(@data, "$df,$d_r,$d_w,$d_br,$d_bw"); | ||
| 47 | } | ||
| 48 | $self->data($ts, @data); | ||
| 49 | } | ||
| 50 | |||
| 51 | ################################################################################ | ||
| 52 | 1; |