Oracle/TablespaceIO.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 Tablespace IO
3  
4 use strict;
5 use StatsView::Oracle::Monitor;
6 package StatsView::Oracle::TablespaceIO;
7 @StatsView::Oracle::TablespaceIO::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 */ tablespace_name,
17 sum(phyrds), sum(phywrts), sum(phyblkrd), sum(phyblkwrt)
18 from dba_data_files, v$filestat
19 where dba_data_files.file_id = v$filestat.file#
20 group by tablespace_name);
21 $self->{cursor} = $db->prepare($query);
22 $self->header("multirow", "Tablespace IO activity",
23 "Reads/Sec,Writes/Sec,Blocks Read/Sec,Blocks Written/Sec",
24 "NNNN");
25 $self->{cursor}->execute();
26 my ($df, $r, $w, $br, $bw);
27 while (($df, $r, $w, $br, $bw) = $self->{cursor}->fetchrow())
28 {
29 $self->{df}{$df} = [ $r, $w, $br, $bw ];
30 }
31 return($self);
32 }
33  
34 ##############################################################################
35  
36 sub sample($$)
37 {
38 my ($self, $ts) = @_;
39 $self->{cursor}->execute();
40 my (@data, $df, $r, $w, $br, $bw);
41 while (($df, $r, $w, $br, $bw) = $self->{cursor}->fetchrow())
42 {
43 my $d_r = ($r - $self->{df}{$df}[0]) / $self->{rate};
44 my $d_w = ($w - $self->{df}{$df}[1]) / $self->{rate};
45 my $d_br = ($br - $self->{df}{$df}[2]) / $self->{rate};
46 my $d_bw = ($bw - $self->{df}{$df}[3]) / $self->{rate};
47 $self->{df}{$df} = [ $r, $w, $br, $bw ];
48 push(@data, "$df,$d_r,$d_w,$d_br,$d_bw");
49 }
50 $self->data($ts, @data);
51 }
52  
53 ################################################################################
54 1;