add informix snmp plugin

This commit is contained in:
garnier-quentin 2019-02-21 13:17:44 +01:00
parent fec37ea44f
commit 3a18ea8436
10 changed files with 1360 additions and 0 deletions

View File

@ -0,0 +1,165 @@
#
# Copyright 2019 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 database::informix::snmp::mode::archivelevel0;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::misc;
use DateTime;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'dbspace', type => 1, cb_prefix_output => 'prefix_dbspace_output', message_multiple => 'All dbspace backups are ok' }
];
$self->{maps_counters}->{dbspace} = [
{ label => 'time', set => {
key_values => [ { name => 'seconds' }, { name => 'date'}, { name => 'display' } ],
output_template => "archive level0 last execution date '%s'",
output_use => 'date_absolute',
perfdatas => [
{ label => 'seconds', value => 'seconds_absolute', template => '%s', min => 0, unit => 's',
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_dbspace_output {
my ($self, %options) = @_;
return "Dbspace '" . $options{instance_value}->{display} . "' ";
}
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 => {
"filter-name:s" => { name => 'filter_name' },
"unknown-status:s" => { name => 'unknown_status' },
"warning-status:s" => { name => 'warning_status' },
"critical-status:s" => { name => 'critical_status', default => '%{status} =~ /inconsistent/' },
"timezone:s" => { name => 'timezone' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
$self->{option_results}->{timezone} = 'GMT' if (!defined($self->{option_results}->{timezone}) || $self->{option_results}->{timezone} eq '');
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_applName = '.1.3.6.1.2.1.27.1.1.2';
my $oid_onDbspaceName = '.1.3.6.1.4.1.893.1.1.1.6.1.2';
my $oid_onDbspaceLastFullBackupDate = '.1.3.6.1.4.1.893.1.1.1.6.1.15';
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_applName },
{ oid => $oid_onDbspaceName },
{ oid => $oid_onDbspaceLastFullBackupDate },
], return_type => 1, nothing_quit => 1
);
my $tz = centreon::plugins::misc::set_timezone(name => $self->{option_results}->{timezone});
$self->{dbspace} = {};
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$oid_onDbspaceName\.(.*?)\.(.*)/);
my ($applIndex, $dbSpaceIndex) = ($1, $2);
my $name = 'default';
$name = $snmp_result->{$oid_applName . '.' . $applIndex}
if (defined($snmp_result->{$oid_applName . '.' . $applIndex}));
$name .= '.' . $snmp_result->{$oid_onDbspaceName . '.' . $applIndex. '.' . $dbSpaceIndex};
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
my ($seconds, $date) = (-1, 'never');
if (defined($snmp_result->{$oid_onDbspaceLastFullBackupDate . '.' . $applIndex. '.' . $dbSpaceIndex})) {
my @dates = unpack('n C6 a C2', $snmp_result->{$oid_onDbspaceLastFullBackupDate . '.' . $applIndex. '.' . $dbSpaceIndex});
if ($dates[0] != 0) {
my $dt = DateTime->new(year => $dates[0], month => $dates[1], day => $dates[2], hour => $dates[3], minute => $dates[4], second => $dates[5], %$tz);
$seconds = time() - $dt->epoch;
$date = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $dates[0], $dates[1], $dates[2], $dates[3], $dates[4], $dates[5]);
}
}
$self->{dbspace}->{$name} = {
display => $name,
seconds => $seconds,
date => $date,
};
}
if (scalar(keys %{$self->{dbspace}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No dbspace found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check last full backup.
=over 8
=item B<--filter-name>
Filter dbspace name (can be a regexp).
=item B<--unknown-status>
Set warning threshold for status (Default: '').
Can used special variables like: %{status}, %{display}
=item B<--warning-status>
Set warning threshold for status (Default: '').
Can used special variables like: %{status}, %{display}
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} =~ /inconsistent/').
Can used special variables like: %{status}, %{display}
=back
=cut

View File

@ -0,0 +1,176 @@
#
# Copyright 2019 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 database::informix::snmp::mode::chunkstatus;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
sub custom_status_output {
my ($self, %options) = @_;
my $msg = sprintf("status is '%s'", $self->{result_values}->{status});
return $msg;
}
sub custom_status_calc {
my ($self, %options) = @_;
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_status'};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'chunk', type => 1, cb_prefix_output => 'prefix_chunk_output', message_multiple => 'All chunks are ok' }
];
$self->{maps_counters}->{chunk} = [
{ label => 'status', set => {
key_values => [ { name => 'status' }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_status_calc'),
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
];
}
sub prefix_chunk_output {
my ($self, %options) = @_;
return "Chunk '" . $options{instance_value}->{display} . "' ";
}
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 => {
"filter-name:s" => { name => 'filter_name' },
"unknown-status:s" => { name => 'unknown_status' },
"warning-status:s" => { name => 'warning_status' },
"critical-status:s" => { name => 'critical_status', default => '%{status} =~ /inconsistent/' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['unknown_status', 'warning_status', 'critical_status']);
}
my %mapping_status = (
1 => 'offline', 2 => 'online', 3 => 'recovering', 4 => 'inconsistent', 5 => 'dropped',
);
my $mapping = {
onChunkFileName => { oid => '.1.3.6.1.4.1.893.1.1.1.7.1.2' },
onChunkStatus => { oid => '.1.3.6.1.4.1.893.1.1.1.7.1.7', map => \%mapping_status },
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_applName = '.1.3.6.1.2.1.27.1.1.2';
my $oid_onDbspaceName = '.1.3.6.1.4.1.893.1.1.1.6.1.2';
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_applName },
{ oid => $oid_onDbspaceName },
{ oid => $mapping->{onChunkFileName}->{oid} },
{ oid => $mapping->{onChunkStatus}->{oid} },
], return_type => 1, nothing_quit => 1
);
$self->{chunk} = {};
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{onChunkFileName}->{oid}\.(.*?)\.(.*?)\.(.*)/);
my ($applIndex, $dbSpaceIndex, $chunkIndex) = ($1, $2, $3);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $applIndex . '.' . $dbSpaceIndex . '.' . $chunkIndex);
my $name = 'default';
$name = $snmp_result->{$oid_applName . '.' . $applIndex}
if (defined($snmp_result->{$oid_applName . '.' . $applIndex}));
$name .= '.' . $snmp_result->{$oid_onDbspaceName . '.' . $applIndex. '.' . $dbSpaceIndex};
$name .= '.' . $result->{onChunkFileName};
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
$self->{chunk}->{$name} = {
display => $name,
status => $result->{onChunkStatus},
};
}
if (scalar(keys %{$self->{chunk}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No chunk found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check chunck status.
=over 8
=item B<--filter-name>
Filter chunk name (can be a regexp).
=item B<--unknown-status>
Set warning threshold for status (Default: '').
Can used special variables like: %{status}, %{display}
=item B<--warning-status>
Set warning threshold for status (Default: '').
Can used special variables like: %{status}, %{display}
=item B<--critical-status>
Set critical threshold for status (Default: '%{status} =~ /inconsistent/').
Can used special variables like: %{status}, %{display}
=back
=cut

View File

@ -0,0 +1,138 @@
#
# Copyright 2019 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 database::informix::snmp::mode::dbspaceusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 1, cb_prefix_output => 'prefix_dbspace_output', message_multiple => 'All dbspaces usage are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'usage', set => {
key_values => [ { name => 'prct_used' }, { name => 'display' } ],
output_template => 'Used: %.2f%%',
perfdatas => [
{ label => 'used', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%',
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_dbspace_output {
my ($self, %options) = @_;
return "Dbspace '" . $options{instance_value}->{display} . "' ";
}
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 => {
"filter-name:s" => { name => 'filter_name' },
});
return $self;
}
my $mapping = {
onDbspaceName => { oid => '.1.3.6.1.4.1.893.1.1.1.6.1.2' },
onDbspacePagesAllocated => { oid => '.1.3.6.1.4.1.893.1.1.1.6.1.11' },
onDbspacePagesUsed => { oid => '.1.3.6.1.4.1.893.1.1.1.6.1.12' },
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_applName = '.1.3.6.1.2.1.27.1.1.2';
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_applName },
{ oid => $mapping->{onDbspaceName}->{oid} },
{ oid => $mapping->{onDbspacePagesAllocated}->{oid} },
{ oid => $mapping->{onDbspacePagesUsed}->{oid} },
], return_type => 1, nothing_quit => 1
);
$self->{global} = {};
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{onDbspaceName}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
my $name = 'default';
$name = $snmp_result->{$oid_applName}->{$oid_applName . '.' . $instance}
if (defined($snmp_result->{$oid_applName}->{$oid_applName . '.' . $instance}));
$name .= '.' . $result->{onDbspaceName};
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
$self->{global}->{$name} = {
display => $name,
prct_used => $result->{onDbspacePagesUsed} * 100 / $result->{onDbspacePagesAllocated},
};
}
if (scalar(keys %{$self->{global}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No dbspace found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check dbspaces usage.
=over 8
=item B<--filter-name>
Filter dbspace name (can be a regexp).
=item B<--warning-usage>
Threshold warning in percent.
=item B<--critical-usage>
Threshold critical in percent.
=back
=cut

View File

@ -0,0 +1,158 @@
#
# Copyright 2019 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 database::informix::snmp::mode::globalcache;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub custom_usage_calc {
my ($self, %options) = @_;
my $diff_logical = $options{new_datas}->{$self->{instance} . '_rdbmsSrvInfoLogical' . $options{extra_options}->{label_ref}} -
$options{old_datas}->{$self->{instance} . '_rdbmsSrvInfoLogical' . $options{extra_options}->{label_ref}};
my $diff_disk = $options{new_datas}->{$self->{instance} . '_rdbmsSrvInfoDisk' . $options{extra_options}->{label_ref}} -
$options{old_datas}->{$self->{instance} . '_rdbmsSrvInfoDisk' . $options{extra_options}->{label_ref}};
$self->{result_values}->{prct} = $diff_logical <= 0 ? 0 : (100 * ($diff_logical - $diff_disk) / $diff_logical);
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 1, cb_prefix_output => 'prefix_instances_output', message_multiple => 'All instances are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'read', set => {
key_values => [ { name => 'rdbmsSrvInfoDiskReads', diff => 1 }, { name => 'rdbmsSrvInfoLogicalReads', diff => 1 }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'Reads' },
output_template => 'Read Cached hitrate at %.2f%%',
threshold_use => 'prct', output_use => 'prct',
perfdatas => [
{ label => 'read', value => 'prct', template => '%.2f', min => 0, max => 100, unit => '%',
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'write', set => {
key_values => [ { name => 'rdbmsSrvInfoDiskWrites', diff => 1 }, { name => 'rdbmsSrvInfoLogicalWrites', diff => 1 }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'Writes' },
output_template => 'Write Cached hitrate at %.2f%%',
threshold_use => 'prct', output_use => 'prct',
perfdatas => [
{ label => 'write', value => 'prct', template => '%.2f', min => 0, max => 100, unit => '%',
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_instances_output {
my ($self, %options) = @_;
return "Instance '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments => {
});
return $self;
}
my $mapping = {
rdbmsSrvInfoDiskReads => { oid => '.1.3.6.1.2.1.39.1.6.1.3' },
rdbmsSrvInfoLogicalReads => { oid => '.1.3.6.1.2.1.39.1.6.1.4' },
rdbmsSrvInfoDiskWrites => { oid => '.1.3.6.1.2.1.39.1.6.1.5' },
rdbmsSrvInfoLogicalWrites => { oid => '.1.3.6.1.2.1.39.1.6.1.6' },
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_applName = '.1.3.6.1.2.1.27.1.1.2';
my $oid_rdbmsSrvInfoEntry = '.1.3.6.1.2.1.39.1.6.1';
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_applName },
{ oid => $oid_rdbmsSrvInfoEntry, start => $mapping->{rdbmsSrvInfoDiskReads}->{oid}, end => $mapping->{rdbmsSrvInfoLogicalWrites}->{oid} },
], nothing_quit => 1
);
$self->{global} = {};
foreach my $oid (keys %{$snmp_result->{$oid_rdbmsSrvInfoEntry}}) {
next if ($oid !~ /^$mapping->{rdbmsSrvInfoDiskReads}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result->{$oid_rdbmsSrvInfoEntry}, instance => $instance);
my $name = 'default';
$name = $snmp_result->{$oid_applName}->{$oid_applName . '.' . $instance}
if (defined($snmp_result->{$oid_applName}->{$oid_applName . '.' . $instance}));
$self->{global}->{$name} = {
display => $name,
%$result
};
}
$self->{cache_name} = "informix_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check write/read cached.
=over 8
=item B<--warning-read>
Threshold read cached warning in percent.
=item B<--critical-read>
Threshold read cached critical in percent.
=item B<--warning-write>
Threshold write cached warning in percent.
=item B<--critical-write>
Threshold write cached critical in percent.
=back
=cut

View File

@ -0,0 +1,134 @@
#
# Copyright 2019 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 database::informix::snmp::mode::listdbspaces;
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 => {
"filter-instance:s" => { name => 'filter_instance' },
"filter-dbspace:s" => { name => 'filter_dbspace' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_applName = '.1.3.6.1.2.1.27.1.1.2';
my $oid_onDbspaceName = '.1.3.6.1.4.1.893.1.1.1.6.1.2';
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_applName },
{ oid => $oid_onDbspaceName },
], nothing_quit => 1);
$self->{dbspace} = {};
foreach my $oid (keys %{$snmp_result->{$oid_onDbspaceName}}) {
$oid =~ /^$oid_onDbspaceName\.(.*?)\.(.*)/;
my ($applIndex, $dbSpaceIndex) = ($1, $2);
my $instance = 'default';
$instance = $snmp_result->{$oid_applName}->{$oid_applName . '.' . $applIndex}
if (defined($snmp_result->{$oid_applName}->{$oid_applName . '.' . $applIndex}));
my $dbspace = $snmp_result->{$oid_onDbspaceName}->{$oid};
if (defined($self->{option_results}->{filter_instance}) && $self->{option_results}->{filter_instance} ne '' &&
$instance !~ /$self->{option_results}->{filter_instance}/) {
$self->{output}->output_add(long_msg => "skipping instance '" . $instance . "': no matching filter.", debug => 1);
next;
}
if (defined($self->{option_results}->{filter_dbspace}) && $self->{option_results}->{filter_dbspace} ne '' &&
$dbspace !~ /$self->{option_results}->{filter_dbspace}/) {
$self->{output}->output_add(long_msg => "skipping dbspace '" . $dbspace . "': no matching filter.", debug => 1);
next;
}
$self->{dbspace}->{$applIndex . '.' . $dbSpaceIndex} = {
instance => $instance,
dbspace => $dbspace,
};
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
foreach my $instance (sort keys %{$self->{dbspace}}) {
$self->{output}->output_add(long_msg => '[instance = ' . $self->{dbspace}->{$instance}->{instance} .
"] [dbspace = '" . $self->{dbspace}->{$instance}->{dbspace} . "']");
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List dbspaces:');
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
sub disco_format {
my ($self, %options) = @_;
$self->{output}->add_disco_format(elements => ['instance', 'dbspace']);
}
sub disco_show {
my ($self, %options) = @_;
$self->manage_selection(%options);
foreach my $instance (sort keys %{$self->{dbspace}}) {
$self->{output}->add_disco_entry(
instance => $self->{dbspace}->{$instance}->{instance},
dbspace => $self->{dbspace}->{$instance}->{dbspace},
);
}
}
1;
__END__
=head1 MODE
List informix instances.
=over 8
=item B<--filter-instance>
Filter by instance name (can be a regexp).
=back
=cut

View File

@ -0,0 +1,114 @@
#
# Copyright 2019 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 database::informix::snmp::mode::listinstances;
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 => {
"filter-instance:s" => { name => 'filter_instance' },
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::init(%options);
}
sub manage_selection {
my ($self, %options) = @_;
my $oid_applName = '.1.3.6.1.2.1.27.1.1.2';
my $snmp_result = $options{snmp}->get_table(oid => $oid_applName);
$self->{instance} = {};
foreach my $oid (keys %{$snmp_result}) {
my $name = $snmp_result->{$oid};
if (defined($self->{option_results}->{filter_instance}) && $self->{option_results}->{filter_instance} ne '' &&
$name !~ /$self->{option_results}->{filter_instance}/) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
$self->{instance}->{$name} = { instance => $name };
}
if (scalar(keys %{$self->{instance}}) == 0) {
$self->{instance}->{default} = { instance => 'default' };
}
}
sub run {
my ($self, %options) = @_;
$self->manage_selection(%options);
foreach my $instance (sort keys %{$self->{instance}}) {
$self->{output}->output_add(long_msg => '[instance = ' . $self->{instance}->{$instance}->{instance} . ']');
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List instances:');
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
sub disco_format {
my ($self, %options) = @_;
$self->{output}->add_disco_format(elements => ['instance']);
}
sub disco_show {
my ($self, %options) = @_;
$self->manage_selection(%options);
foreach my $instance (sort keys %{$self->{instance}}) {
$self->{output}->add_disco_entry(instance => $self->{instance}->{$instance}->{instance});
}
}
1;
__END__
=head1 MODE
List informix instances.
=over 8
=item B<--filter-instance>
Filter by instance name (can be a regexp).
=back
=cut

View File

@ -0,0 +1,156 @@
#
# Copyright 2019 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 database::informix::snmp::mode::lockstats;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 1, cb_prefix_output => 'prefix_instances_output', message_multiple => 'All instances are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'deadlks', set => {
key_values => [ { name => 'onServerDeadLocks', diff => 1 }, { name => 'display' } ],
output_template => 'Deadlocks %d',
perfdatas => [
{ label => 'deadlks', value => 'onServerDeadLocks_absolute', template => '%s', min => 0,
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'lockwts', set => {
key_values => [ { name => 'onServerLockWaits', diff => 1 }, { name => 'display' } ],
output_template => 'Lock Waits %d',
perfdatas => [
{ label => 'lockwts', value => 'onServerLockWaits_absolute', template => '%s', min => 0,
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'lockreqs', set => {
key_values => [ { name => 'onServerLockRequests', diff => 1 }, { name => 'display' } ],
output_template => 'Lock Requests %d',
perfdatas => [
{ label => 'lockreqs', value => 'onServerLockRequests_absolute', template => '%s', min => 0,
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
{ label => 'lktouts', set => {
key_values => [ { name => 'onServerLockTimeouts', diff => 1 }, { name => 'display' } ],
output_template => 'Lock Timeouts %d',
perfdatas => [
{ label => 'lktouts', value => 'onServerLockTimeouts_absolute', template => '%s', min => 0,
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_instances_output {
my ($self, %options) = @_;
return "Instance '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$self->{version} = '1.0';
$options{options}->add_options(arguments => {
});
return $self;
}
my $mapping = {
onServerLockRequests => { oid => '.1.3.6.1.4.1.893.1.1.1.1.1.11' },
onServerLockWaits => { oid => '.1.3.6.1.4.1.893.1.1.1.1.1.12' },
onServerDeadLocks => { oid => '.1.3.6.1.4.1.893.1.1.1.1.1.16' },
onServerLockTimeouts => { oid => '.1.3.6.1.4.1.893.1.1.1.1.1.17' },
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_applName = '.1.3.6.1.2.1.27.1.1.2';
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_applName },
{ oid => $mapping->{onServerLockWaits}->{oid} },
{ oid => $mapping->{onServerLockRequests}->{oid} },
{ oid => $mapping->{onServerDeadLocks}->{oid} },
{ oid => $mapping->{onServerLockTimeouts}->{oid} },
], return_type => 1, nothing_quit => 1
);
$self->{global} = {};
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{onServerLockRequests}->{oid}\.(.*)/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
my $name = 'default';
$name = $snmp_result->{$oid_applName . '.' . $instance}
if (defined($snmp_result->{$oid_applName . '.' . $instance}));
$self->{global}->{$name} = {
display => $name,
%$result
};
}
$self->{cache_name} = "informix_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
}
1;
__END__
=head1 MODE
Check instance locks.
=over 8
=item B<--warning-*>
Threshold warning.
Can be: 'deadlks', 'lockwts', 'lockreqs', 'lktouts'.
=item B<--critical-*>
Threshold critical.
Can be: 'deadlks', 'lockwts', 'lockreqs', 'lktouts'.
=back
=cut

View File

@ -0,0 +1,144 @@
#
# Copyright 2019 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 database::informix::snmp::mode::logfileusage;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 1, cb_prefix_output => 'prefix_dbspace_output', message_multiple => 'All dbspace log files usage are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'usage', set => {
key_values => [ { name => 'prct_used' }, { name => 'display' } ],
output_template => 'Log Files Used: %.2f%%',
perfdatas => [
{ label => 'used', value => 'prct_used_absolute', template => '%.2f', min => 0, max => 100, unit => '%',
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_dbspace_output {
my ($self, %options) = @_;
return "Dbspace '" . $options{instance_value}->{display} . "' ";
}
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 => {
"filter-name:s" => { name => 'filter_name' },
});
return $self;
}
my $mapping = {
onLogicalLogDbspace => { oid => '.1.3.6.1.4.1.893.1.1.1.8.1.3' },
onLogicalLogPagesAllocated => { oid => '.1.3.6.1.4.1.893.1.1.1.8.1.7' },
onLogicalLogPagesUsed => { oid => '.1.3.6.1.4.1.893.1.1.1.8.1.8' },
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_applName = '.1.3.6.1.2.1.27.1.1.2';
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_applName },
{ oid => $mapping->{onLogicalLogDbspace}->{oid} },
{ oid => $mapping->{onLogicalLogPagesAllocated}->{oid} },
{ oid => $mapping->{onLogicalLogPagesUsed}->{oid} },
], return_type => 1, nothing_quit => 1
);
$self->{global} = {};
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{onLogicalLogDbspace}->{oid}\.(.*?)\.(.*)/);
my ($applIndex, $logIndex) = ($1, $2);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $applIndex . '.' . $logIndex);
my $name = 'default';
$name = $snmp_result->{$oid_applName . '.' . $applIndex}
if (defined($snmp_result->{$oid_applName . '.' . $applIndex}));
$name .= '.' . $result->{onLogicalLogDbspace};
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
$name !~ /$self->{option_results}->{filter_name}/) {
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1);
next;
}
if (!defined($self->{global}->{$name})) {
$self->{global}->{$name} = { display => $name, allocated => 0, used => 0 };
}
$self->{global}->{$name}->{allocated} += $result->{onLogicalLogPagesAllocated};
$self->{global}->{$name}->{used} += $result->{onLogicalLogPagesUsed};
}
foreach (keys %{$self->{global}}) {
$self->{global}->{$_}->{prct_used} = $self->{global}->{$_}->{used} * 100 / $self->{global}->{$_}->{allocated};
}
if (scalar(keys %{$self->{global}}) <= 0) {
$self->{output}->add_option_msg(short_msg => "No dbspace found.");
$self->{output}->option_exit();
}
}
1;
__END__
=head1 MODE
Check log files usage.
=over 8
=item B<--filter-name>
Filter dbspace name (can be a regexp).
=item B<--warning-usage>
Threshold warning in percent.
=item B<--critical-usage>
Threshold critical in percent.
=back
=cut

View File

@ -0,0 +1,119 @@
#
# Copyright 2019 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 database::informix::snmp::mode::sessions;
use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 1, cb_prefix_output => 'prefix_instances_output', message_multiple => 'All instances are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'sessions', set => {
key_values => [ { name => 'sessions' }, { name => 'display' } ],
output_template => '%d client sessions',
perfdatas => [
{ label => 'sessions', value => 'sessions_absolute', template => '%s', min => 0,
label_extra_instance => 1, instance_use => 'display_absolute' },
],
}
},
];
}
sub prefix_instances_output {
my ($self, %options) = @_;
return "Instance '" . $options{instance_value}->{display} . "' ";
}
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 => {
});
return $self;
}
my $mapping = {
onSessionUserName => { oid => '.1.3.6.1.4.1.893.1.1.1.10.1.2' },
onSessionUserProcessId => { oid => '.1.3.6.1.4.1.893.1.1.1.10.1.4' },
};
sub manage_selection {
my ($self, %options) = @_;
my $oid_applName = '.1.3.6.1.2.1.27.1.1.2';
my $snmp_result = $options{snmp}->get_multiple_table(oids => [
{ oid => $oid_applName },
{ oid => $mapping->{onSessionUserName}->{oid} },
{ oid => $mapping->{onSessionUserProcessId}->{oid} },
], return_type => 1, nothing_quit => 1
);
$self->{global} = {};
foreach my $oid (keys %{$snmp_result}) {
next if ($oid !~ /^$mapping->{onSessionUserName}->{oid}\.(.*?)\.(.*)/);
my ($applIndex, $sessionIndex) = ($1, $2);
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $applIndex . '.' . $sessionIndex);
my $name = 'default';
$name = $snmp_result->{$oid_applName . '.' . $applIndex}
if (defined($snmp_result->{$oid_applName . '.' . $applIndex}));
if (!defined($self->{global}->{$name})) {
$self->{global}->{$name} = { display => $name, sessions => 0 };
}
$self->{global}->{$name}->{sessions}++;
}
}
1;
__END__
=head1 MODE
Check number of open sessions ('informix' user is not counted).
=over 8
=item B<--warning-sessions>
Threshold warning.
=item B<--critical-sessions>
Threshold critical.
=back
=cut

View File

@ -0,0 +1,56 @@
#
# Copyright 2019 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 database::informix::snmp::plugin;
use strict;
use warnings;
use base qw(centreon::plugins::script_snmp);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
'archivelevel0' => 'database::informix::snmp::mode::archivelevel0',
'chunk-status' => 'database::informix::snmp::mode::chunkstatus',
'dbspace-usage' => 'database::informix::snmp::mode::dbspaceusage',
'global-cache' => 'database::informix::snmp::mode::globalcache',
'list-dbspaces' => 'database::informix::snmp::mode::listdbspaces',
'list-instances' => 'database::informix::snmp::mode::listinstances',
'logfile-usage' => 'database::informix::snmp::mode::logfileusage',
'sessions' => 'database::informix::snmp::mode::sessions',
'lock-stats' => 'database::informix::snmp::mode::lockstats',
);
return $self;
}
1;
__END__
=head1 PLUGIN DESCRIPTION
Check Informix in SNMP.
=cut