Merge pull request #3 from centreon/master

Sync Master
This commit is contained in:
Sims24 2015-10-05 12:06:05 +02:00
commit 63bbd7145c
9 changed files with 187 additions and 33 deletions

View File

@ -0,0 +1,132 @@
#
# Copyright 2015 Centreon (http://www.centreon.com/)
#
# Centreon is a full-fledged industry-strength solution that meets
# the needs in IT infrastructure and application monitoring for
# service performance.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package apps::biztalk::sql::mode::rlocationdisabled;
use base qw(centreon::plugins::mode);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments =>
{
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"filter-location:s" => { name => 'filter_location' },
"filter-application:s" => { name => 'filter_application' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
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 {
my ($self, %options) = @_;
# $options{sql} = sqlmode object
$self->{sql} = $options{sql};
my $query = q{
SELECT RL.Name, RL.Disabled, APP.nvcName
FROM BizTalkMgmtDb.dbo.adm_ReceiveLocation AS RL WITH(NOLOCK)
INNER JOIN BizTalkMgmtDb.dbo.bts_receiveport AS RP WITH(NOLOCK)
ON RL.ReceivePortId = RP.nID
INNER JOIN BizTalkMgmtDb.dbo.bts_application AS APP WITH(NOLOCK)
ON RP.nApplicationID = APP.nID WHERE RL.[Disabled] = -1
};
$self->{sql}->connect();
$self->{sql}->query(query => $query);
my $count = 0;
while ((my $row = $self->{sql}->fetchrow_hashref())) {
if (defined($self->{option_results}->{filter_location}) && $self->{option_results}->{filter_location} ne '' &&
$row->{Name} !~ /$self->{option_results}->{filter_location}/) {
$self->{output}->output_add(long_msg => "Skipping '" . $row->{Name} . "': no matching filter location.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_application}) && $self->{option_results}->{filter_application} ne '' &&
$row->{nvcName} !~ /$self->{option_results}->{filter_application}/) {
$self->{output}->output_add(long_msg => "Skipping '" . $row->{nvcName} . "': no matching filter application.", debug => 1);
next;
}
$self->{output}->output_add(long_msg => "'" . $row->{Name} . "' of application '" . $row->{nvcName} . "'");
$count++;
}
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("%d receive locations are disabled", $count));
$self->{output}->perfdata_add(label => 'count',
value => $count,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);
$self->{output}->display();
$self->{output}->exit();
}
1;
__END__
=head1 MODE
Check the number of biztalk received locations disabled.
The mode should be used with mssql plugin and dyn-mode option.
=over 8
=item B<--warning>
Threshold warning.
=item B<--critical>
Threshold critical.
=item B<--filter-location>
Filter by location (regexp can be used).
=item B<--filter-application>
Filter by application (regexp can be used).
=back
=cut

View File

@ -59,20 +59,20 @@ sub run {
$self->{connector} = $options{custom};
$self->{request} = [
{ mbean => "com.merethis.studio:name=statistics,type=session" }
{ mbean => "com.centreon.studio:name=statistics,type=session" }
];
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 0);
my $exit = $self->{perfdata}->threshold_check(value => $result->{"com.merethis.studio:name=statistics,type=session"}->{AverageEventQueueSize},
my $exit = $self->{perfdata}->threshold_check(value => $result->{"com.centreon.studio:name=statistics,type=session"}->{AverageEventQueueSize},
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning'} ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Average event queue size : %d",
$result->{"com.merethis.studio:name=statistics,type=session"}->{AverageEventQueueSize}));
$result->{"com.centreon.studio:name=statistics,type=session"}->{AverageEventQueueSize}));
$self->{output}->perfdata_add(label => 'events',
value => $result->{"com.merethis.studio:name=statistics,type=session"}->{AverageEventQueueSize},
value => $result->{"com.centreon.studio:name=statistics,type=session"}->{AverageEventQueueSize},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);

View File

@ -78,7 +78,7 @@ sub run {
$self->{connector} = $options{custom};
$self->{request} = [
{ mbean => "com.merethis.studio:name=statistics,type=whatsup" }
{ mbean => "com.centreon.studio.map:name=statistics,type=whatsup" }
];
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 0);
@ -94,10 +94,10 @@ sub run {
}
foreach my $type ('EventCount', 'EventTypeCreate', 'EventTypeUpdate', 'EventTypeRemove') {
$new_datas->{$type} = $result->{"com.merethis.studio:name=statistics,type=whatsup"}->{$type}->{andIncrement};
$new_datas->{$type} = $result->{"com.centreon.studio.map:name=statistics,type=whatsup"}->{$type}->{andIncrement};
my $old_val = $self->{statefile_cache}->get(name => $type);
next if (!defined($old_val) || $result->{"com.merethis.studio:name=statistics,type=whatsup"}->{$type}->{andIncrement} < $old_val);
my $value = int(($result->{"com.merethis.studio:name=statistics,type=whatsup"}->{$type}->{andIncrement} - $old_val) / ($new_datas->{last_timestamp} - $old_timestamp));
next if (!defined($old_val) || $result->{"com.centreon.studio.map:name=statistics,type=whatsup"}->{$type}->{andIncrement} < $old_val);
my $value = int(($result->{"com.centreon.studio.map:name=statistics,type=whatsup"}->{$type}->{andIncrement} - $old_val) / ($new_datas->{last_timestamp} - $old_timestamp));
$self->{output}->perfdata_add(label => $type,
value => $value,

View File

@ -59,22 +59,22 @@ sub run {
$self->{connector} = $options{custom};
$self->{request} = [
{ mbean => "com.merethis.map:name=BusinessGate,type=repo" }
{ mbean => "com.centreon.studio.map:name=BusinessGate,type=repo" }
];
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
my $gates = $result->{"com.merethis.map:name=BusinessGate,type=repo"}->{LoadedModelCount};
my $gates = $result->{"com.centreon.studio.map:name=BusinessGate,type=repo"}->{LoadedModelCount};
my $exit = $self->{perfdata}->threshold_check(value => $gates,
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning'} ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Business gates opened : %d",
$result->{"com.merethis.map:name=BusinessGate,type=repo"}->{LoadedModelCount}));
$result->{"com.centreon.studio.map:name=BusinessGate,type=repo"}->{LoadedModelCount}));
$self->{output}->perfdata_add(label => 'gates',
value => $result->{"com.merethis.map:name=BusinessGate,type=repo"}->{LoadedModelCount},
value => $result->{"com.centreon.studio.map:name=BusinessGate,type=repo"}->{LoadedModelCount},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);

View File

@ -59,20 +59,20 @@ sub run {
$self->{connector} = $options{custom};
$self->{request} = [
{ mbean => "com.merethis.studio:name=statistics,type=session" }
{ mbean => "com.centreon.studio:name=statistics,type=session" }
];
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 0);
my $exit = $self->{perfdata}->threshold_check(value => $result->{"com.merethis.studio:name=statistics,type=session"}->{SessionCount},
my $exit = $self->{perfdata}->threshold_check(value => $result->{"com.centreon.studio:name=statistics,type=session"}->{SessionCount},
threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning'} ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("Current sessions : %d",
$result->{"com.merethis.studio:name=statistics,type=session"}->{SessionCount}));
$result->{"com.centreon.studio:name=statistics,type=session"}->{SessionCount}));
$self->{output}->perfdata_add(label => 'sessions',
value => $result->{"com.merethis.studio:name=statistics,type=session"}->{SessionCount},
value => $result->{"com.centreon.studio:name=statistics,type=session"}->{SessionCount},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
min => 0);

View File

@ -73,6 +73,26 @@ sub check_options {
}
}
sub check_nexus_cpu {
my ($self, %options) = @_;
if (!defined($self->{results}->{$options{oid}}->{$options{oid} . '.0'})) {
return 0;
}
my $cpu = $self->{results}->{$options{oid}}->{$options{oid} . '.0'};
my $exit = $self->{perfdata}->threshold_check(value => $cpu,
threshold => [ { label => 'crit5m', exit_litteral => 'critical' }, { label => 'warn5m', exit_litteral => 'warning' } ]);
$self->{output}->output_add(severity => $exit,
short_msg => sprintf("CPU Usage : %s %%", $cpu));
$self->{output}->perfdata_add(label => "cpu", unit => '%',
value => $cpu,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'),
min => 0, max => 100);
return 1;
}
sub check_table_cpu {
my ($self, %options) = @_;
@ -113,21 +133,21 @@ sub check_table_cpu {
}
if (defined($cpu5sec)) {
$self->{output}->perfdata_add(label => "cpu_" . $instance . "_5s",
$self->{output}->perfdata_add(label => "cpu_" . $instance . "_5s", unit => '%',
value => $cpu5sec,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5s'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5s'),
min => 0, max => 100);
}
if (defined($cpu1min)) {
$self->{output}->perfdata_add(label => "cpu_" . $instance . "_1m",
$self->{output}->perfdata_add(label => "cpu_" . $instance . "_1m", unit => '%',
value => $cpu1min,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn1m'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit1m'),
min => 0, max => 100);
}
if (defined($cpu5min)) {
$self->{output}->perfdata_add(label => "cpu_" . $instance . "_5m",
$self->{output}->perfdata_add(label => "cpu_" . $instance . "_5m", unit => '%',
value => $cpu5min,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warn5m'),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'crit5m'),
@ -157,14 +177,18 @@ sub run {
my $oid_busyPer = '.1.3.6.1.4.1.9.2.1.56'; # .0 in reality
my $oid_avgBusy1 = '.1.3.6.1.4.1.9.2.1.57'; # .0 in reality
my $oid_avgBusy5 = '.1.3.6.1.4.1.9.2.1.58'; # .0 in reality
# Cisco Nexus
my $oid_cseSysCPUUtilization = '.1.3.6.1.4.1.9.9.305.1.1.1'; # .0 in reality
$self->{results} = $self->{snmp}->get_multiple_table(oids => [
{ oid => $oid_cpmCPUTotalEntry,
start => $oid_cpmCPUTotal5sec, end => $oid_cpmCPUTotal5minRev
},
{ oid => $oid_lcpu,
start => $oid_busyPer, end => $oid_avgBusy5 }],
nothing_quit => 1);
start => $oid_busyPer, end => $oid_avgBusy5 },
{ oid => $oid_cseSysCPUUtilization },
],
nothing_quit => 1);
$self->{output}->output_add(severity => 'OK',
short_msg => 'All CPUs are ok.');
@ -173,8 +197,10 @@ sub run {
&& !$self->check_table_cpu(entry => $oid_cpmCPUTotalEntry, sec5 => $oid_cpmCPUTotal5sec, min1 => $oid_cpmCPUTotal1min, min5 => $oid_cpmCPUTotal5min)
&& !$self->check_table_cpu(entry => $oid_lcpu, sec5 => $oid_busyPer, min1 => $oid_avgBusy1, min5 => $oid_avgBusy5)
) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => sprintf("Cannot find CPU informations."));
if (!$self->check_nexus_cpu(oid => $oid_cseSysCPUUtilization)) {
$self->{output}->output_add(severity => 'UNKNOWN',
short_msg => sprintf("Cannot find CPU informations."));
}
}
$self->{output}->display();
@ -187,17 +213,19 @@ __END__
=head1 MODE
Check cpu usage (CISCO-PROCESS-MIB).
Check cpu usage (CISCO-PROCESS-MIB and CISCO-SYSTEM-EXT-MIB).
=over 8
=item B<--warning>
Threshold warning in percent (5s,1min,5min).
Used 5min threshold when you have only 'cpu' metric.
=item B<--critical>
Threshold critical in percent (5s,1min,5min).
Used 5min threshold when you have only 'cpu' metric.
=back

View File

@ -31,7 +31,7 @@ use Module::Load;
my $CloudwatchMetrics = {
cpu => "cloud::aws::mode::metrics::ec2instancecpu",
traffic' => "cloud::aws::mode::metrics::ec2instancenetwork",
traffic => "cloud::aws::mode::metrics::ec2instancenetwork",
cpucreditusage => "cloud::aws::mode::metrics::ec2instancecpucreditusage",
cpucreditbalance => "cloud::aws::mode::metrics::ec2instancecpucreditbalance",
bucketsize => "cloud::aws::mode::metrics::s3bucketsize",

View File

@ -88,15 +88,12 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
my $oid_ibm3100FaultError = '.1.3.6.1.4.1.2.6.210.3.1.1.22.1';
my $oid_ibm3100FaultDesc = '.1.3.6.1.4.1.2.6.210.3.1.1.24.1';
my $oid_ibm3100StatusGlobalStatus = '.1.3.6.1.4.1.2.6.210.2.1.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3100StatusGlobalStatus, $oid_ibm3100FaultError, $oid_ibm3100FaultDesc], nothing_quit => 1);
my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3100StatusGlobalStatus], nothing_quit => 1);
$self->{output}->output_add(severity => $self->get_severity(value => $result->{$oid_ibm3100StatusGlobalStatus}),
short_msg => sprintf("Overall global status is '%s'.",
${$states{$result->{$oid_ibm3100StatusGlobalStatus}}}[0]));
$self->{output}->output_add(long_msg => sprintf("Error state: '%s' Error code: '%i'", $result->{$oid_ibm3100FaultDesc}, $result->{$oid_ibm3100FaultError}));
$self->{output}->display();
$self->{output}->exit();

View File

@ -88,15 +88,12 @@ sub run {
# $options{snmp} = snmp object
$self->{snmp} = $options{snmp};
my $oid_ibm3200FaultError = '.1.3.6.1.4.1.2.6.211.3.1.1.22.1';
my $oid_ibm3200FaultDesc = '.1.3.6.1.4.1.2.6.211.3.1.1.24.1';
my $oid_ibm3200StatusGlobalStatus = '.1.3.6.1.4.1.2.6.211.2.1.0';
my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3200StatusGlobalStatus, $oid_ibm3200FaultError, $oid_ibm3200FaultDesc], nothing_quit => 1);
my $result = $self->{snmp}->get_leef(oids => [$oid_ibm3200StatusGlobalStatus], nothing_quit => 1);
$self->{output}->output_add(severity => $self->get_severity(value => $result->{$oid_ibm3200StatusGlobalStatus}),
short_msg => sprintf("Overall global status is '%s'.",
${$states{$result->{$oid_ibm3200StatusGlobalStatus}}}[0]));
$self->{output}->output_add(long_msg => sprintf("Error state: '%s' Error code: '%i'", $result->{$oid_ibm3200FaultDesc}, $result->{$oid_ibm3200FaultError}));
$self->{output}->display();
$self->{output}->exit();
}