From dc246a91b8a4f2c8d5e2f4996bfa152aac510064 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Thu, 16 Jan 2020 16:16:10 +0100 Subject: [PATCH] refactoring kingdee: wip --- apps/kingdee/eas/mode/oracleksqltemptable.pm | 88 ++++----- apps/kingdee/eas/mode/oraclerecyclebin.pm | 90 ++++----- apps/kingdee/eas/mode/oracleredolog.pm | 116 +++++------ apps/kingdee/eas/mode/oraclesession.pm | 198 ++++++++----------- 4 files changed, 222 insertions(+), 270 deletions(-) diff --git a/apps/kingdee/eas/mode/oracleksqltemptable.pm b/apps/kingdee/eas/mode/oracleksqltemptable.pm index 45deb945a..0411e646d 100644 --- a/apps/kingdee/eas/mode/oracleksqltemptable.pm +++ b/apps/kingdee/eas/mode/oracleksqltemptable.pm @@ -21,76 +21,71 @@ package apps::kingdee::eas::mode::oracleksqltemptable; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'datasource', type => 1, cb_prefix_output => 'prefix_datasource_output', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{datasource} = [ + { label => 'table-ksqltemp', nlabel => 'datasource.table.ksqltemp.count', set => { + key_values => [ { name => 'ksqltemp_count' } ], + output_template => 'ksqltemp table: %s', + perfdatas => [ + { value => 'ksqltemp_count_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + ], + } + } + ]; +} + +sub prefix_datasource_output { + my ($self, %options) = @_; + + return "Datasource '" . $options{instance_value}->{display} . "' "; +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkoraclevt.jsp" }, - "datasource:s" => { name => 'datasource' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + $options{options}->add_options(arguments => { + 'urlpath:s' => { name => 'url_path', default => "/easportal/tools/nagios/checkoraclevt.jsp" }, + 'datasource:s' => { name => 'datasource' }, + }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); if (!defined($self->{option_results}->{datasource}) || $self->{option_results}->{datasource} eq "") { $self->{output}->add_option_msg(short_msg => "Missing datasource name."); $self->{output}->option_exit(); } $self->{option_results}->{url_path} .= "?ds=" . $self->{option_results}->{datasource}; - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } } -sub run { +sub manage_selection { my ($self, %options) = @_; - - my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path}); + my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path}); if ($webcontent !~ /^COUNT.*?=\d+/i) { - $self->{output}->output_add( - severity => 'UNKNOWN', - short_msg => "Cannot find ksql temptable status." - ); + $self->{output}->add_option_msg(short_msg => 'Cannot find ksql temptable status.'); $self->{output}->option_exit(); } - - my $count = $1 if $webcontent =~ /^COUNT.*?=(\d+)/i; - - my $exit = $self->{perfdata}->threshold_check(value => $count, threshold => [ - { label => 'critical', 'exit_litteral' => 'critical' }, - { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, short_msg => sprintf("KSQLTempTableCount: %d", $count)); - - $self->{output}->perfdata_add(label => "KSQLTempTableCount", unit => '', - value => sprintf("%d", $count), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - ); - - $self->{output}->display(); - $self->{output}->exit(); + $self->{datasource}->{$self->{option_results}->{datasource}} = { display => $self->{option_results}->{datasource} }; + $self->{datasource}->{$self->{option_results}->{datasource}}->{ksqltemp_count} = $1 if ($webcontent =~ /^COUNT.*?=(\d+)/i); } 1; @@ -111,13 +106,10 @@ Set path to get status page. (Default: '/easportal/tools/nagios/checkoraclevt.js Specify the datasource name. -=item B<--warning> +=item B<--warning-*> B<--critical-*> -Warning Threshold. - -=item B<--critical> - -Critical Threshold. +Thresholds. +Can be: 'table-ksqltemp'. =back diff --git a/apps/kingdee/eas/mode/oraclerecyclebin.pm b/apps/kingdee/eas/mode/oraclerecyclebin.pm index a2770bc87..b8adcf29b 100644 --- a/apps/kingdee/eas/mode/oraclerecyclebin.pm +++ b/apps/kingdee/eas/mode/oraclerecyclebin.pm @@ -21,76 +21,71 @@ package apps::kingdee::eas::mode::oraclerecyclebin; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'datasource', type => 1, cb_prefix_output => 'prefix_datasource_output', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{datasource} = [ + { label => 'table-recyclebin', nlabel => 'datasource.table.recyclebin.count', set => { + key_values => [ { name => 'recyclebin_count' } ], + output_template => 'recyclebin table: %s', + perfdatas => [ + { value => 'recyclebin_count_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + ], + } + } + ]; +} + +sub prefix_datasource_output { + my ($self, %options) = @_; + + return "Datasource '" . $options{instance_value}->{display} . "' "; +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkoraclerecyclebin.jsp" }, - "datasource:s" => { name => 'datasource' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + $options{options}->add_options(arguments => { + 'urlpath:s' => { name => 'url_path', default => "/easportal/tools/nagios/checkoraclerecyclebin.jsp" }, + 'datasource:s' => { name => 'datasource' }, + }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); if (!defined($self->{option_results}->{datasource}) || $self->{option_results}->{datasource} eq "") { $self->{output}->add_option_msg(short_msg => "Missing datasource name."); $self->{output}->option_exit(); } $self->{option_results}->{url_path} .= "?ds=" . $self->{option_results}->{datasource}; - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } } -sub run { +sub manage_selection { my ($self, %options) = @_; - - my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path}); - if ( $webcontent !~ /^COUNT.*?=\d+/i ) { - $self->{output}->output_add( - severity => 'UNKNOWN', - short_msg => "Cannot find oracle recyclebin status." - ); + my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path}); + if ($webcontent !~ /^COUNT.*?=\d+/i) { + $self->{output}->add_option_msg(short_msg => 'Cannot find oracle recyclebin status.'); $self->{output}->option_exit(); } - - my $count = $1 if $webcontent =~ /^COUNT.*?=(\d+)/i; - - my $exit = $self->{perfdata}->threshold_check(value => $count, threshold => [ - { label => 'critical', 'exit_litteral' => 'critical' }, - { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, short_msg => sprintf("RecyclebinTableCount: %d", $count)); - - $self->{output}->perfdata_add(label => "RecyclebinTableCount", unit => '', - value => sprintf("%d", $count), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - ); - - $self->{output}->display(); - $self->{output}->exit(); + $self->{datasource}->{$self->{option_results}->{datasource}} = { display => $self->{option_results}->{datasource} }; + $self->{datasource}->{$self->{option_results}->{datasource}}->{recyclebin_count} = $1 if ($webcontent =~ /^COUNT.*?=(\d+)/i); } 1; @@ -111,13 +106,10 @@ Set path to get status page. (Default: '/easportal/tools/nagios/checkoraclerecyc Specify the datasource name. -=item B<--warning> +=item B<--warning-*> B<--critical-*> -Warning Threshold. - -=item B<--critical> - -Critical Threshold. +Thresholds. +Can be: 'table-recyclebin'. =back diff --git a/apps/kingdee/eas/mode/oracleredolog.pm b/apps/kingdee/eas/mode/oracleredolog.pm index 7f57134b5..c2125d010 100644 --- a/apps/kingdee/eas/mode/oracleredolog.pm +++ b/apps/kingdee/eas/mode/oracleredolog.pm @@ -21,84 +21,89 @@ package apps::kingdee::eas::mode::oracleredolog; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'datasource', type => 1, cb_prefix_output => 'prefix_datasource_output', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{datasource} = [ + { label => 'oracle-redolog-inactive', nlabel => 'datasource.oracle.redolog.inactive.count', set => { + key_values => [ { name => 'inactive' } ], + output_template => 'inactive: %s', + perfdatas => [ + { value => 'inactive_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + ], + } + }, + { label => 'oracle-redolog-active', nlabel => 'datasource.oracle.redolog.active.count', set => { + key_values => [ { name => 'inactive' } ], + output_template => 'active: %s', + perfdatas => [ + { value => 'active_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + ], + } + }, + { label => 'oracle-redolog-current', nlabel => 'datasource.oracle.redolog.current.count', set => { + key_values => [ { name => 'current' } ], + output_template => 'current: %s', + perfdatas => [ + { value => 'current_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + ], + } + }, + ]; +} + +sub prefix_datasource_output { + my ($self, %options) = @_; + + return "Datasource '" . $options{instance_value}->{display} . "' oracle redolog "; +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkoracleredolog.jsp" }, - "datasource:s" => { name => 'datasource' }, - "warning:s" => { name => 'warning' }, - "critical:s" => { name => 'critical' }, - }); + $options{options}->add_options(arguments => { + 'urlpath:s' => { name => 'url_path', default => "/easportal/tools/nagios/checkoracleredolog.jsp" }, + 'datasource:s' => { name => 'datasource' }, + }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); if (!defined($self->{option_results}->{datasource}) || $self->{option_results}->{datasource} eq "") { $self->{output}->add_option_msg(short_msg => "Missing datasource name."); $self->{output}->option_exit(); } $self->{option_results}->{url_path} .= "?ds=" . $self->{option_results}->{datasource}; - - if (($self->{perfdata}->threshold_validate(label => 'warning', value => $self->{option_results}->{warning})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning threshold '" . $self->{option_results}->{warning} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'critical', value => $self->{option_results}->{critical})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical threshold '" . $self->{option_results}->{critical} . "'."); - $self->{output}->option_exit(); - } } -sub run { +sub manage_selection { my ($self, %options) = @_; - + my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path}); if ($webcontent !~ /^STATUS=CURRENT/mi) { - $self->{output}->output_add( - severity => 'UNKNOWN', - short_msg => "Cannot find oracle redolog status." - ); + $self->{output}->add_option_msg(short_msg => 'Cannot find oracle redolog status.'); $self->{output}->option_exit(); } - - my ($activecount, $inactivecount, $currentcount) = (0, 0, 0); - $activecount = $1 if $webcontent =~ /^STATUS=ACTIVE\sCOUNT=(\d+)/mi ; - $inactivecount = $1 if $webcontent =~ /^STATUS=INACTIVE\sCOUNT=(\d+)/mi ; - $currentcount = $1 if $webcontent =~ /^STATUS=CURRENT\sCOUNT=(\d+)/mi ; - - my $exit = $self->{perfdata}->threshold_check(value => $inactivecount, threshold => [ - { label => 'critical', 'exit_litteral' => 'critical' }, - { label => 'warning', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, short_msg => sprintf("InactiveCount: %d", $inactivecount)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("ActiveCount: %d", $activecount)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("CurrentCount: %d", $currentcount)); - - $self->{output}->perfdata_add(label => "InactiveCount", unit => '', - value => sprintf("%d", $inactivecount), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'), - ); - $self->{output}->perfdata_add(label => "ActiveCount", unit => '', - value => sprintf("%d", $activecount)); - $self->{output}->perfdata_add(label => "CurrentCount", unit => '', - value => sprintf("%d", $currentcount)); - - $self->{output}->display(); - $self->{output}->exit(); + $self->{datasource}->{$self->{option_results}->{datasource}} = { display => $self->{option_results}->{datasource} }; + $self->{datasource}->{$self->{option_results}->{datasource}}->{active} = $1 if ($webcontent =~ /^STATUS=ACTIVE\sCOUNT=(\d+)/mi); + $self->{datasource}->{$self->{option_results}->{datasource}}->{inactive} = $1 if ($webcontent =~ /^STATUS=INACTIVE\sCOUNT=(\d+)/mi); + $self->{datasource}->{$self->{option_results}->{datasource}}->{current} = $1 if ($webcontent =~ /^STATUS=CURRENT\sCOUNT=(\d+)/mi); } 1; @@ -107,7 +112,7 @@ __END__ =head1 MODE -Check oracle redolog status . +Check oracle redolog status. =over 8 @@ -119,13 +124,10 @@ Set path to get status page. (Default: '/easportal/tools/nagios/checkoracleredol Specify the datasource name. -=item B<--warning> +=item B<--warning-*> B<--critical-*> -Warning Threshold for INACTIVE count. - -=item B<--critical> - -Critical Threshold for INACTIVE count. +Thresholds. +Can be: 'oracle-redolog-inactive', 'oracle-redolog-'active', 'oracle-redolog-current'. =back diff --git a/apps/kingdee/eas/mode/oraclesession.pm b/apps/kingdee/eas/mode/oraclesession.pm index 30fcb728d..2b3305f99 100644 --- a/apps/kingdee/eas/mode/oraclesession.pm +++ b/apps/kingdee/eas/mode/oraclesession.pm @@ -21,150 +21,115 @@ package apps::kingdee::eas::mode::oraclesession; -use base qw(centreon::plugins::mode); +use base qw(centreon::plugins::templates::counter); use strict; use warnings; +sub set_counters { + my ($self, %options) = @_; + + $self->{maps_counters_type} = [ + { name => 'datasource', type => 1, cb_prefix_output => 'prefix_datasource_output', skipped_code => { -10 => 1 } }, + ]; + + $self->{maps_counters}->{datasource} = [ + { label => 'oracle-sessions-active', nlabel => 'datasource.oracle.sessions.active.count', set => { + key_values => [ { name => 'active' } ], + output_template => 'sessions active: %s', + perfdatas => [ + { value => 'active_absolute', template => '%s', min => 0, max => 'total_absolute', label_extra_instance => 1 }, + ], + } + }, + { label => 'oracle-sessions-inactive', nlabel => 'datasource.oracle.sessions.inactive.count', set => { + key_values => [ { name => 'inactive' } ], + output_template => 'sessions inactive: %s', + perfdatas => [ + { value => 'inactive_absolute', template => '%s', min => 0, max => 'total_absolute', label_extra_instance => 1 }, + ], + } + }, + ]; + + foreach ( + ('other', 'queueing', 'network', 'administrative', 'configuration', + 'commit', 'application', 'concurrency', + 'scheduler', 'idle', 'userio', 'systemio') + ) { + push @{$self->{maps_counters}->{datasource}}, + { label => 'oracle-waitclass-' . $_, nlabel => 'datasource.oracle.waitclass.' . $_ . '.count', display_ok => 0, set => { + key_values => [ { name => $_ } ], + output_template => 'wait class ' . $_ . ': %s', + perfdatas => [ + { value => $_ . '_absolute', template => '%s', min => 0, label_extra_instance => 1 }, + ], + } + }; + } +} + +sub prefix_datasource_output { + my ($self, %options) = @_; + + return "Datasource '" . $options{instance_value}->{display} . "' oracle "; +} + sub new { my ($class, %options) = @_; - my $self = $class->SUPER::new(package => __PACKAGE__, %options); + my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1); bless $self, $class; - $options{options}->add_options(arguments => - { - "urlpath:s" => { name => 'url_path', default => "/easportal/tools/nagios/checkoraclesession.jsp" }, - "datasource:s" => { name => 'datasource' }, - "warning:s" => { name => 'warning', default => "," }, - "critical:s" => { name => 'critical', default => "," }, - }); + $options{options}->add_options(arguments => { + 'urlpath:s' => { name => 'url_path', default => "/easportal/tools/nagios/checkoraclesession.jsp" }, + 'datasource:s' => { name => 'datasource' }, + }); return $self; } sub check_options { my ($self, %options) = @_; - $self->SUPER::init(%options); + $self->SUPER::check_options(%options); if (!defined($self->{option_results}->{datasource}) || $self->{option_results}->{datasource} eq "") { $self->{output}->add_option_msg(short_msg => "Missing datasource name."); $self->{output}->option_exit(); } $self->{option_results}->{url_path} .= "?ds=" . $self->{option_results}->{datasource}; - - ($self->{warn_activecount}, $self->{warn_totalcount}) = split /,/, $self->{option_results}->{"warning"}; - ($self->{crit_activecount}, $self->{crit_totalcount}) = split /,/, $self->{option_results}->{"critical"}; - - # warning - if (($self->{perfdata}->threshold_validate(label => 'warn_activecount', value => $self->{warn_activecount})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning activecount threshold '" . $self->{warn_activecount} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'warn_totalcount', value => $self->{warn_totalcount})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong warning totalcount threshold '" . $self->{warn_totalcount} . "'."); - $self->{output}->option_exit(); - } - # critical - if (($self->{perfdata}->threshold_validate(label => 'crit_activecount', value => $self->{crit_activecount})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical activecount threshold '" . $self->{crit_activecount} . "'."); - $self->{output}->option_exit(); - } - if (($self->{perfdata}->threshold_validate(label => 'crit_totalcount', value => $self->{crit_totalcount})) == 0) { - $self->{output}->add_option_msg(short_msg => "Wrong critical totalcount threshold '" . $self->{crit_totalcount} . "'."); - $self->{output}->option_exit(); - } } -sub run { +sub manage_selection { my ($self, %options) = @_; - + my $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path} . '&groupby=status'); if ($webcontent !~ /^STATUS=ACTIVE/mi) { - $self->{output}->output_add( - severity => 'UNKNOWN', - short_msg => "Cannot find oracle session info." - ); + $self->{output}->add_option_msg(short_msg => 'Cannot find oracle session info.'); $self->{output}->option_exit(); } - - my ($activecount, $inactivecount, $totalcount) = (0, 0, 0); - $activecount = $1 if $webcontent =~ /^STATUS=ACTIVE\sCOUNT=(\d+)/mi ; - $inactivecount = $1 if $webcontent =~ /^STATUS=INACTIVE\sCOUNT=(\d+)/mi ; - $totalcount = $activecount + $inactivecount; + + $self->{datasource}->{$self->{option_results}->{datasource}} = { display => $self->{option_results}->{datasource} }; + $self->{datasource}->{$self->{option_results}->{datasource}}->{active} = $1 if ($webcontent =~ /^STATUS=ACTIVE\sCOUNT=(\d+)/mi); + $self->{datasource}->{$self->{option_results}->{datasource}}->{inactive} = $1 if ($webcontent =~ /^STATUS=INACTIVE\sCOUNT=(\d+)/mi); + $self->{datasource}->{$self->{option_results}->{datasource}}->{total} = + $self->{datasource}->{$self->{option_results}->{datasource}}->{active} + $self->{datasource}->{$self->{option_results}->{datasource}}->{inactive}; $webcontent = $options{custom}->request(path => $self->{option_results}->{url_path} . '&groupby=wait_class&status=ACTIVE'); if ($webcontent !~ /^WAIT_CLASS=.*?COUNT=\d+/i) { - $self->{output}->output_add( - severity => 'UNKNOWN', - short_msg => "Cannot find oracle session info." - ); + $self->{output}->add_option_msg(short_msg => 'Cannot find oracle session info.'); $self->{output}->option_exit(); } - my ($other, $queueing, $network, $administrative, $configuation, $commit) = (0, 0, 0, 0, 0, 0); - my ($application, $concurrency, $systemio, $userio, $scheduler, $idle) = (0, 0, 0, 0, 0, 0); - - $other = $1 if $webcontent =~ /^WAIT_CLASS=Other\sCOUNT=(\d+)/mi; - $queueing = $1 if $webcontent =~ /^WAIT_CLASS=Queueing\sCOUNT=(\d+)/mi; - $network = $1 if $webcontent =~ /^WAIT_CLASS=Network\sCOUNT=(\d+)/mi; - $administrative = $1 if $webcontent =~ /^WAIT_CLASS=Administrative\sCOUNT=(\d+)/mi; - $configuation = $1 if $webcontent =~ /^WAIT_CLASS=Configuration\sCOUNT=(\d+)/mi; - $commit = $1 if $webcontent =~ /^WAIT_CLASS=Commit\sCOUNT=(\d+)/mi; - $application = $1 if $webcontent =~ /^WAIT_CLASS=Application\sCOUNT=(\d+)/mi; - $concurrency = $1 if $webcontent =~ /^WAIT_CLASS=Concurrency\sCOUNT=(\d+)/mi; - $systemio = $1 if $webcontent =~ /^WAIT_CLASS=\'System\sI\/O\'\sCOUNT=(\d+)/mi; - $userio = $1 if $webcontent =~ /^WAIT_CLASS='User\sI\/O\'\sCOUNT=(\d+)/mi; - $scheduler = $1 if $webcontent =~ /^WAIT_CLASS=Scheduler\sCOUNT=(\d+)/mi; - $idle = $1 if $webcontent =~ /^WAIT_CLASS=Idle\sCOUNT=(\d+)/mi; + foreach ( + ('other', 'queueing', 'network', 'administrative', 'configuration', + 'commit', 'application', 'concurrency', + 'scheduler', 'idle') + ) { + $self->{datasource}->{$self->{option_results}->{datasource}}->{$_} = $1 if ($webcontent =~ /^WAIT_CLASS=$_\sCOUNT=(\d+)/mi); + } - my $cpuandwait = $idle + $network; - - $self->{output}->output_add(severity => "ok", short_msg => sprintf("Other: %d", $other)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("Queueing: %d", $queueing)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("Administrative: %d", $administrative)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("Configuration: %d", $configuation)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("Commit: %d", $commit)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("Application: %d", $application)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("Concurrency: %d", $concurrency)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("System I/O: %d", $systemio)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("User I/O: %d", $userio)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("Scheduler: %d", $scheduler)); - $self->{output}->output_add(severity => "ok", short_msg => sprintf("CPU + CPU Wait: %d", $cpuandwait)); - - my $exit = $self->{perfdata}->threshold_check(value => $activecount, threshold => [ { label => 'crit_activecount', exit_litteral => 'critical' }, - { label => 'warn_activecount', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, short_msg => sprintf("ActiveCount: %d", $activecount)); - - $exit = $self->{perfdata}->threshold_check(value => $totalcount, threshold => [ { label => 'crit_totalcount', exit_litteral => 'critical' }, - { label => 'warn_totalcount', exit_litteral => 'warning' } ]); - $self->{output}->output_add(severity => $exit, short_msg => sprintf("TotalCount: %d", $totalcount)); - - $self->{output}->perfdata_add(label => "Other", unit => '', value => sprintf("%d", $other)); - $self->{output}->perfdata_add(label => "Queueing", unit => '', value => sprintf("%d", $queueing)); - $self->{output}->perfdata_add(label => "Administrative", unit => '', value => sprintf("%d", $administrative)); - $self->{output}->perfdata_add(label => "Configuration", unit => '', value => sprintf("%d", $configuation)); - $self->{output}->perfdata_add(label => "Commit", unit => '', value => sprintf("%d", $commit)); - $self->{output}->perfdata_add(label => "Application", unit => '', value => sprintf("%d", $application)); - $self->{output}->perfdata_add(label => "Concurrency", unit => '', value => sprintf("%d", $concurrency)); - $self->{output}->perfdata_add(label => "System I/O", unit => '', value => sprintf("%d", $systemio)); - $self->{output}->perfdata_add(label => "User I/O", unit => '', value => sprintf("%d", $userio)); - $self->{output}->perfdata_add(label => "Scheduler", unit => '', value => sprintf("%d", $scheduler)); - $self->{output}->perfdata_add(label => "CPU + CPU Wait", unit => '', value => sprintf("%d", $cpuandwait)); - - $self->{output}->perfdata_add(label => "ActiveCount", unit => '', - value => sprintf("%d", $activecount), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_activecount'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_activecount'), - ); - $self->{output}->perfdata_add(label => "TotalCount", unit => '', - value => sprintf("%d", $totalcount), - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn_totalcount'), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit_totalcount'), - ); - - $self->{output}->display(); - $self->{output}->exit(); - + $self->{datasource}->{$self->{option_results}->{datasource}}->{systemio} = $1 if ($webcontent =~ /^WAIT_CLASS='System\s+I\/O'\sCOUNT=(\d+)/mi); + $self->{datasource}->{$self->{option_results}->{datasource}}->{userio} = $1 if ($webcontent =~ /^WAIT_CLASS='User\s+I\/O'\sCOUNT=(\d+)/mi); } 1; @@ -185,13 +150,14 @@ Set path to get status page. (Default: '/easportal/tools/nagios/checkoraclesessi Specify the datasource name. -=item B<--warning> +=item B<--warning-*> B<--critical-*> -Warning Threshold. (activecount,totalcount) for example: --warning=50,200 - -=item B<--critical> - -Critical Threshold. (activecount,totalcount) for example: --critical=100,300 +Thresholds. +Can be: 'oracle-sessions-active', 'oracle-sessions-inactive', 'oracle-waitclass-other', +'oracle-waitclass-queueing', 'oracle-waitclass-network', 'oracle-waitclass-administrative', +'oracle-waitclass-configuration', 'oracle-waitclass-commit', 'oracle-waitclass-application', +'oracle-waitclass-concurrency', 'oracle-waitclass-scheduler', 'oracle-waitclass-idle', +'oracle-waitclass-userio', 'oracle-waitclass-systemio'. =back