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

Add SysTimeModel #40

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ smidump.exe.stackdump
rfc*.trc
dev_rfc
dev_rfc.trc
*.pm
plugins-scripts/check_*_health.ptkdb
sh.exe.stackdump
*.swp
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT(check_oracle_health,3.3.0.3)
AC_INIT(check_oracle_health,3.3.0.3-lm)
AM_INIT_AUTOMAKE([1.9 tar-pax])
AM_MAINTAINER_MODE([disable])
AC_CANONICAL_HOST
Expand Down
2 changes: 2 additions & 0 deletions plugins-scripts/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ EXTRA_MODULES=\
Nagios/DBD/Oracle/Server/Instance/Enqueue.pm \
Nagios/DBD/Oracle/Server/Instance/Session.pm \
Nagios/DBD/Oracle/Server/Instance/Sysstat.pm \
Nagios/DBD/Oracle/Server/Instance/SysTimeModel.pm \
Nagios/DBD/Oracle/Server/Instance/SysWaitClass.pm \
Nagios/DBD/Oracle/Server/Instance.pm \
Nagios/DBD/Oracle/Server/Database/User.pm \
Nagios/DBD/Oracle/Server/Database/Dataguard.pm \
Expand Down
42 changes: 42 additions & 0 deletions plugins-scripts/Nagios/DBD/Oracle/Server/Instance.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ sub init {
} else {
$self->add_nagios_critical("unable to aquire sysstats info");
}
} elsif ($params{mode} =~ /server::instance::systimemodel/) {
DBD::Oracle::Server::Instance::SysTimeModel::init_systimemodel(%params);
if (my @systimemodel =
DBD::Oracle::Server::Instance::SysTimeModel::return_systimemodel(%params)) {
$self->{systimemodel} = \@systimemodel;
} else {
$self->add_nagios_critical("unable to aquire systimemodel info");
}
} elsif ($params{mode} =~ /server::instance::syswaitclass/) {
DBD::Oracle::Server::Instance::SysWaitClass::init_syswaitclass(%params);
if (my @syswaitclass =
DBD::Oracle::Server::Instance::SysWaitClass::return_syswaitclass(%params)) {
$self->{syswaitclass} = \@syswaitclass;
} else {
$self->add_nagios_critical("unable to aquire syswaitclass info");
}
} elsif ($params{mode} =~ /server::instance::event/) {
DBD::Oracle::Server::Instance::Event::init_events(%params);
if (my @events =
Expand Down Expand Up @@ -147,6 +163,32 @@ sub nagios {
if (! $self->{nagios_level} && ! $params{selectname}) {
$self->add_nagios_ok("no wait problems");
}
} elsif ($params{mode} =~ /server::instance::systimemodel::listsystimemodel/) {
foreach (sort { $a->{name} cmp $b->{name} } @{$self->{systimemodel}}) {
printf "%10d %s\n", $_->{number}, $_->{name};
}
$self->add_nagios_ok("have fun");
} elsif ($params{mode} =~ /server::instance::systimemodel/) {
foreach (@{$self->{systimemodel}}) {
$_->nagios(%params);
$self->merge_nagios($_);
}
if (! $self->{nagios_level} && ! $params{selectname}) {
$self->add_nagios_ok("no time model problems");
}
} elsif ($params{mode} =~ /server::instance::syswaitclass::listsyswaitclass/) {
foreach (sort { $a->{name} cmp $b->{name} } @{$self->{syswaitclass}}) {
printf "%10d %s\n", $_->{number}, $_->{name};
}
$self->add_nagios_ok("have fun");
} elsif ($params{mode} =~ /server::instance::syswaitclass/) {
foreach (@{$self->{syswaitclass}}) {
$_->nagios(%params);
$self->merge_nagios($_);
}
if (! $self->{nagios_level} && ! $params{selectname}) {
$self->add_nagios_ok("no wait class problems");
}
} elsif ($params{mode} =~ /server::instance::enqueue::listenqueues/) {
foreach (sort { $a->{name} cmp $b->{name} } @{$self->{enqueues}}) {
printf "%s\n", $_->{name};
Expand Down
111 changes: 111 additions & 0 deletions plugins-scripts/Nagios/DBD/Oracle/Server/Instance/SysTimeModel.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package DBD::Oracle::Server::Instance::SysTimeModel;

use strict;

our @ISA = qw(DBD::Oracle::Server::Instance);

my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 );
my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' );

{
my @systimemodel = ();
my $initerrors = undef;

sub add_systimemodel {
push(@systimemodel, shift);
}

sub return_systimemodel {
return reverse
sort { $a->{name} cmp $b->{name} } @systimemodel;
}

sub init_systimemodel {
my %params = @_;
my $num_systimemodel = 0;
my %longnames = ();
if (($params{mode} =~ /server::instance::systimemodel::rate/) ||
($params{mode} =~ /server::instance::systimemodel::listsystimemodel/)) {
my @systimemodelresults = $params{handle}->fetchall_array(q{
SELECT stat_id, stat_name, value FROM v$sys_time_model
});
foreach (@systimemodelresults) {
my ($number, $name, $value) = @{$_};
if ($params{regexp}) {
next if $params{selectname} && $name !~ /$params{selectname}/;
} else {
next if ($params{selectname} && (
($params{selectname} !~ /^\d+$/ && (lc $params{selectname} ne lc $name)) ||
($params{selectname} =~ /^\d+$/ && ($params{selectname} != $number))));
}
my %thisparams = %params;
$thisparams{name} = $name;
$thisparams{number} = $number;
$thisparams{value} = $value;

my $systimemodel = DBD::Oracle::Server::Instance::SysTimeModel->new(
%thisparams);
add_systimemodel($systimemodel);
$num_systimemodel++;
}
if (! $num_systimemodel) {
$initerrors = 1;
return undef;
}
}
}

}

sub new {
my $class = shift;
my %params = @_;
my $self = {
handle => $params{handle},
name => $params{name},
number => $params{number},

value => $params{value},
rate => $params{rate},
count => $params{count},
warningrange => $params{warningrange},
criticalrange => $params{criticalrange},
};
#$self->{name} =~ s/^\s+//;
#$self->{name} =~ s/\s+$//;
bless $self, $class;
$self->init(%params);
return $self;
}

sub init {
my $self = shift;
my %params = @_;
$self->init_nagios();
if ($params{mode} =~ /server::instance::systimemodel::rate/) {
$params{differenciator} = lc $self->{name};
$self->valdiff(\%params, qw(value));
$self->{rate} = $self->{delta_value} / $self->{delta_timestamp};
}
}

sub nagios {
my $self = shift;
my %params = @_;
if (! $self->{nagios_level}) {
if ($params{mode} =~ /server::instance::systimemodel::rate/) {
$self->add_nagios(
$self->check_thresholds($self->{rate}, "10", "100"),
sprintf "%.6f %s/sec", $self->{rate}, $self->{name});
$self->add_perfdata(sprintf "'%s_per_sec'=%.6f;%s;%s",
$self->{name},
$self->{rate},
$self->{warningrange}, $self->{criticalrange});
$self->add_perfdata(sprintf "'%s'=%u",
$self->{name},
$self->{delta_value});
}
}
}

1;
133 changes: 133 additions & 0 deletions plugins-scripts/Nagios/DBD/Oracle/Server/Instance/SysWaitClass.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package DBD::Oracle::Server::Instance::SysWaitClass;

use strict;

our @ISA = qw(DBD::Oracle::Server::Instance);

my %ERRORS=( OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3 );
my %ERRORCODES=( 0 => 'OK', 1 => 'WARNING', 2 => 'CRITICAL', 3 => 'UNKNOWN' );

{
my @syswaitclass = ();
my $initerrors = undef;

sub add_syswaitclass {
push(@syswaitclass, shift);
}

sub return_syswaitclass {
return reverse
sort { $a->{name} cmp $b->{name} } @syswaitclass;
}

sub init_syswaitclass {
my %params = @_;
my $num_syswaitclass = 0;
my %longnames = ();
if (($params{mode} =~ /server::instance::syswaitclass::rate/) ||
($params{mode} =~ /server::instance::syswaitclass::listsyswaitclass/)) {
my @syswaitclassresults = $params{handle}->fetchall_array(q{
SELECT WAIT_CLASS_ID, WAIT_CLASS, TOTAL_WAITS, TOTAL_WAITS_FG, TIME_WAITED, TIME_WAITED_FG FROM v$system_wait_class
});
foreach (@syswaitclassresults) {
my ($number, $name, $total_waits, $total_waits_fg, $time_waited, $time_waited_fg) = @{$_};
if ($params{regexp}) {
next if $params{selectname} && $name !~ /$params{selectname}/;
} else {
next if ($params{selectname} && (
($params{selectname} !~ /^\d+$/ && (lc $params{selectname} ne lc $name)) ||
($params{selectname} =~ /^\d+$/ && ($params{selectname} != $number))));
}
my %thisparams = %params;
$thisparams{name} = $name;
$thisparams{number} = $number;
$thisparams{total_waits} = $total_waits;
$thisparams{total_waits_fg} = $total_waits_fg;
$thisparams{time_waited} = $time_waited;
$thisparams{time_waited_fg} = $time_waited_fg;

my $syswaitclass = DBD::Oracle::Server::Instance::SysWaitClass->new(
%thisparams);
add_syswaitclass($syswaitclass);
$num_syswaitclass++;
}
if (! $num_syswaitclass) {
$initerrors = 1;
return undef;
}
}
}

}

sub new {
my $class = shift;
my %params = @_;
my $self = {
handle => $params{handle},
name => $params{name},
number => $params{number},
total_waits => $params{total_waits},
total_waits_fg => $params{total_waits_fg},
time_waited => $params{time_waited},
time_waited_fg => $params{time_waited_fg},
rate => $params{rate},
count => $params{count},
warningrange => $params{warningrange},
criticalrange => $params{criticalrange},
};
#$self->{name} =~ s/^\s+//;
#$self->{name} =~ s/\s+$//;
bless $self, $class;
$self->init(%params);
return $self;
}

sub init {
my $self = shift;
my %params = @_;
$self->init_nagios();
if ($params{mode} =~ /server::instance::syswaitclass::rate/) {
$params{differenciator} = lc $self->{name};
$self->valdiff(\%params, qw(time_waited));
my $timedelta=$self->{delta_timestamp};
$self->{time_waited_rate} = $self->{delta_time_waited} / $timedelta;
$self->valdiff(\%params, qw(time_waited_fg));
$self->{time_waited_fg_rate} = $self->{delta_time_waited_fg} / $timedelta;
$self->valdiff(\%params, qw(total_waits));
$self->{total_waits_rate} = $self->{delta_total_waits} / $timedelta;
$self->valdiff(\%params, qw(total_waits_fg));
$self->{total_waits_fg_rate} = $self->{delta_total_waits_fg} / $timedelta;

}
}

sub nagios {
my $self = shift;
my %params = @_;
if (! $self->{nagios_level}) {
if ($params{mode} =~ /server::instance::syswaitclass::rate/) {
$self->add_nagios(
$self->check_thresholds($self->{time_waited_rate}, "10", "100"),
sprintf "%.6f %s/sec", $self->{time_waited_rate}, $self->{name});
$self->add_perfdata(sprintf "'%s_%s_per_sec'=%.6f;%s;%s",
$self->{name},'time_waited',
$self->{time_waited_rate},
$self->{warningrange}, $self->{criticalrange});
$self->add_perfdata(sprintf "'%s_%s_per_sec'=%.6f;%s;%s",
$self->{name},'time_waited_fg',
$self->{time_waited_fg_rate},
$self->{warningrange}, $self->{criticalrange});
$self->add_perfdata(sprintf "'%s_%s_per_sec'=%.6f;%s;%s",
$self->{name},'total_waits',
$self->{total_waits_rate},
$self->{warningrange}, $self->{criticalrange});
$self->add_perfdata(sprintf "'%s_%s_per_sec'=%.6f;%s;%s",
$self->{name},'total_waits_fg',
$self->{total_waits_fg_rate},
$self->{warningrange}, $self->{criticalrange});
}
}
}

1;
13 changes: 13 additions & 0 deletions plugins-scripts/check_oracle_health.pl
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,19 @@ package main;
['server::instance::sysstat::listsysstats',
'list-sysstats', undef,
'convenience function which lists all statistics from v$sysstat' ],
['server::instance::systimemodel::rate',
'systimemodel', undef,
'change of systimemodel values over time' ],
['server::instance::systimemodel::listsystimemodel',
'list-systimemodel', undef,
'convenience function which lists all statistics from v$syswaitclass' ],
['server::instance::syswaitclass::rate',
'syswaitclass', undef,
'change of syswaitclass values over time' ],
['server::instance::syswaitclass::listsyswaitclass',
'list-syswaitclass', undef,
'convenience function which lists all statistics from v$syswaitclass' ],

);

sub print_usage () {
Expand Down