Oracle/DatafileIO.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 44 CC 1 SCAR 6.9
CC
1
Cov
0%
new
2.0
sample
2.0
BEGIN
2.0
CRAP 2.0
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;