Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oracle collector #106

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Collect stat for standby database log gap
  • Loading branch information
Laimonas Anusauskas committed Feb 20, 2014
commit f2f2c88d650af992a490fd254c4cd8cf1c07c394
53 changes: 48 additions & 5 deletions collectors/0/oracle.pl
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@
while (($sid,$connection_info) = each(%$connections)) {
next if !$connection_info->{DBH};
if ($report_instance_tag) {
collect_stats($connection_info->{STATEMENTS}[0],$connection_info->{STATEMENTS}[1],$sid);
collect_stats($connection_info,$sid);
} else {
collect_stats($connection_info->{STATEMENTS}[0],$connection_info->{STATEMENTS}[1],0);
collect_stats($connection_info,0);
}
}

Expand Down Expand Up @@ -307,7 +307,7 @@ sub maintain_connections {
sub prepare_statements {

my $dbh = shift;
my ($sql,$stat_sth,$wait_sth);
my ($sql,$stat_sth,$wait_sth,$dataguard_sth);

# Fetch data from v$sysstat
$sql = q{
Expand Down Expand Up @@ -342,14 +342,51 @@ sub prepare_statements {

$wait_sth = $dbh->prepare($sql);

return ($stat_sth,$wait_sth);
$sql = q{
select
d.destination,
current_log.seq-max_applied_log.seq seq_diff
from
(
-- Current max archived log on primary for this incarnation
select max(sequence#) seq
from V$ARCHIVED_LOG l
where resetlogs_change# = (
select resetlogs_change# from V$DATABASE
)
and standby_dest = 'NO'
) current_log,
(
-- Max applied log on each standby
select dest_id,max(sequence#) seq
from V$ARCHIVED_LOG
where resetlogs_change# = (
select resetlogs_change# from V$DATABASE
)
and applied = 'YES'
group by dest_id
) max_applied_log,
(
-- Active standbys
select dest_id,destination,delay_mins
from V$ARCHIVE_DEST
where target = 'STANDBY'
and status in ('VALID','ERROR','DEFERRED')
) d
where d.dest_id = max_applied_log.dest_id
};

$dataguard_sth = $dbh->prepare($sql);

return ($stat_sth,$wait_sth,$dataguard_sth);

}

# Collect stats from particular instance
sub collect_stats {

my ($stat_sth,$wait_sth,$instance_tag) = @_;
my ($connection_info,$instance_tag) = @_;
my ($stat_sth,$wait_sth,$dataguard_sth) = @{$connection_info->{STATEMENTS}};

# Add instance tag if requested
$instance_tag = $instance_tag ? "instance=$instance_tag" : "" ;
Expand Down Expand Up @@ -406,6 +443,12 @@ sub collect_stats {
print("oracle.wait.timeouts $current_time $row->{TOTAL_TIMEOUTS} class=$row->{WAIT_CLASS} $instance_tag\n");
print("oracle.wait.time_waited $current_time $row->{TIME_WAITED} class=$row->{WAIT_CLASS} $instance_tag\n");
}

# Dataguard stats
$dataguard_sth->execute() or return(0);
while ($row = $dataguard_sth->fetchrow_hashref()) {
print("oracle.standby_gap $current_time $row->{SEQ_DIFF} dest=$row->{DESTINATION} $instance_tag\n");
}

return 1;
}
Expand Down