+ add inin plugin in snmp
This commit is contained in:
parent
f32e1a3707
commit
ac4c5eb107
|
@ -0,0 +1,146 @@
|
||||||
|
#
|
||||||
|
# Copyright 2017 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::inin::mediaserver::snmp::mode::audioengineusage;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'engine', type => 1, cb_prefix_output => 'prefix_engine_output', message_multiple => 'All audio engines are ok' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{engine} = [
|
||||||
|
{ label => 'avg-load', set => {
|
||||||
|
key_values => [ { name => 'i3MsAudioEngineAverageLoad' }, { name => 'display' } ],
|
||||||
|
output_template => 'Average Load : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'load_avg', value => 'i3MsAudioEngineAverageLoad_absolute', template => '%s',
|
||||||
|
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'elem-count', set => {
|
||||||
|
key_values => [ { name => 'i3MsAudioEngineElementCount' }, { name => 'display' } ],
|
||||||
|
output_template => 'Total active graph elements : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'elem_count', value => 'i3MsAudioEngineElementCount_absolute', template => '%s',
|
||||||
|
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
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-location:s" => { name => 'filter_location' },
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_engine_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Audio Engine '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
my $mapping = {
|
||||||
|
i3MsAudioEngineLocation => { oid => '.1.3.6.1.4.1.2793.8227.2.1.1.4' },
|
||||||
|
i3MsAudioEngineAverageLoad => { oid => '.1.3.6.1.4.1.2793.8227.2.1.1.6' },
|
||||||
|
i3MsAudioEngineElementCount => { oid => '.1.3.6.1.4.1.2793.8227.2.1.1.8' },
|
||||||
|
};
|
||||||
|
|
||||||
|
my $oid_i3MsAudioEngineInfoTableEntry = '.1.3.6.1.4.1.2793.8227.2.1.1';
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{engine} = {};
|
||||||
|
my $snmp_result = $options{snmp}->get_table(oid => $oid_i3MsAudioEngineInfoTableEntry,
|
||||||
|
nothing_quit => 1);
|
||||||
|
|
||||||
|
|
||||||
|
foreach my $oid (keys %{$snmp_result}) {
|
||||||
|
next if ($oid !~ /^$mapping->{i3MsAudioEngineLocation}->{oid}\.(.*)$/);
|
||||||
|
my $instance = $1;
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{filter_location}) && $self->{option_results}->{filter_location} ne '' &&
|
||||||
|
$result->{i3MsAudioEngineLocation} !~ /$self->{option_results}->{filter_location}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping '" . $result->{i3MsAudioEngineLocation} . "': no matching filter.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{engine}->{$instance} = { display => $result->{i3MsAudioEngineLocation},
|
||||||
|
%$result
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scalar(keys %{$self->{engine}}) <= 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "No audio engine found.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check audio engine usage.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-counters>
|
||||||
|
|
||||||
|
Only display some counters (regexp can be used).
|
||||||
|
Example: --filter-counters='^elem-count$'
|
||||||
|
|
||||||
|
=item B<--filter-location>
|
||||||
|
|
||||||
|
Filter location name (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Threshold warning.
|
||||||
|
Can be: 'elem-count', 'avg-load'.
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Threshold critical.
|
||||||
|
Can be: 'elem-count', 'avg-load'.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,307 @@
|
||||||
|
#
|
||||||
|
# Copyright 2017 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::inin::mediaserver::snmp::mode::cmdsrvusage;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
my $instance_mode;
|
||||||
|
|
||||||
|
sub custom_status_threshold {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
my $status = 'ok';
|
||||||
|
my $message;
|
||||||
|
|
||||||
|
eval {
|
||||||
|
local $SIG{__WARN__} = sub { $message = $_[0]; };
|
||||||
|
local $SIG{__DIE__} = sub { $message = $_[0]; };
|
||||||
|
|
||||||
|
if (defined($instance_mode->{option_results}->{critical_status}) && $instance_mode->{option_results}->{critical_status} ne '' &&
|
||||||
|
eval "$instance_mode->{option_results}->{critical_status}") {
|
||||||
|
$status = 'critical';
|
||||||
|
} elsif (defined($instance_mode->{option_results}->{warning_status}) && $instance_mode->{option_results}->{warning_status} ne '' &&
|
||||||
|
eval "$instance_mode->{option_results}->{warning_status}") {
|
||||||
|
$status = 'warning';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (defined($message)) {
|
||||||
|
$self->{output}->output_add(long_msg => 'filter status issue: ' . $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_status_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $msg = 'status : ' . $self->{result_values}->{status};
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_status_calc {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{result_values}->{status} = $options{new_datas}->{$self->{instance} . '_i3MsCmdSrvStatus'};
|
||||||
|
$self->{result_values}->{accept_sessions} = $options{new_datas}->{$self->{instance} . '_i3MsCmdSrvAcceptSessions'};
|
||||||
|
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_usage_perfdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $label = 'used';
|
||||||
|
my $value_perf = $self->{result_values}->{used};
|
||||||
|
if (defined($instance_mode->{option_results}->{free})) {
|
||||||
|
$label = 'free';
|
||||||
|
$value_perf = $self->{result_values}->{free};
|
||||||
|
}
|
||||||
|
my $extra_label = '';
|
||||||
|
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||||
|
my %total_options = ();
|
||||||
|
if ($instance_mode->{option_results}->{units} eq '%') {
|
||||||
|
$total_options{total} = $self->{result_values}->{total};
|
||||||
|
$total_options{cast_int} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B',
|
||||||
|
value => $value_perf,
|
||||||
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
|
||||||
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
|
||||||
|
min => 0, max => $self->{result_values}->{total});
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_usage_threshold {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my ($exit, $threshold_value);
|
||||||
|
$threshold_value = $self->{result_values}->{used};
|
||||||
|
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free}));
|
||||||
|
if ($instance_mode->{option_results}->{units} eq '%') {
|
||||||
|
$threshold_value = $self->{result_values}->{prct_used};
|
||||||
|
$threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free}));
|
||||||
|
}
|
||||||
|
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
|
||||||
|
return $exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_usage_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
|
||||||
|
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
||||||
|
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
|
||||||
|
my $msg = sprintf("Disk Usage Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||||
|
$total_size_value . " " . $total_size_unit,
|
||||||
|
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||||
|
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_usage_calc {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||||
|
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
|
||||||
|
$self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'};
|
||||||
|
$self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free};
|
||||||
|
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
|
||||||
|
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'cmd', type => 1, cb_prefix_output => 'prefix_cmd_output', message_multiple => 'All command servers are ok' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{cmd} = [
|
||||||
|
{ label => 'status', threshold => 0, set => {
|
||||||
|
key_values => [ { name => 'i3MsCmdSrvStatus' }, { name => 'i3MsCmdSrvAcceptSessions' }, { 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 => $self->can('custom_status_threshold'),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'usage', set => {
|
||||||
|
key_values => [ { name => 'display' }, { name => 'free' }, { name => 'total' } ],
|
||||||
|
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||||
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
|
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||||
|
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ label => 'resource-count', set => {
|
||||||
|
key_values => [ { name => 'i3MsCmdSrvResourceCount' }, { name => 'display' } ],
|
||||||
|
output_template => 'Resource Count : %s',
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'resource_count', value => 'i3MsCmdSrvResourceCount_absolute', template => '%d',
|
||||||
|
min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
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-client:s" => { name => 'filter_client' },
|
||||||
|
"warning-status:s" => { name => 'warning_status', default => '' },
|
||||||
|
"critical-status:s" => { name => 'critical_status', default => '%{status} !~ /^ready/i' },
|
||||||
|
"units:s" => { name => 'units', default => '%' },
|
||||||
|
"free" => { name => 'free' },
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
|
$instance_mode = $self;
|
||||||
|
$self->change_macros();
|
||||||
|
}
|
||||||
|
|
||||||
|
sub prefix_cmd_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
return "Command Server '" . $options{instance_value}->{display} . "' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub change_macros {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
foreach (('warning_status', 'critical_status')) {
|
||||||
|
if (defined($self->{option_results}->{$_})) {
|
||||||
|
$self->{option_results}->{$_} =~ s/%\{(.*?)\}/\$self->{result_values}->{$1}/g;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my %map_status = (1 => 'unknown', 1 => 'ready', 2 => 'notready', 3 => 'error');
|
||||||
|
my %map_truth = (1 => 'true', 2 => 'false');
|
||||||
|
my $mapping = {
|
||||||
|
i3MsCmdSrvAcceptSessions => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.8', map => \%map_truth },
|
||||||
|
i3MsCmdSrvStatus => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.2', map => \%map_status },
|
||||||
|
i3MsCmdSrvClient => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.6' },
|
||||||
|
i3MsCmdSrvResourceCount => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.9' },
|
||||||
|
i3MsCmdSrvRecFreeDiskSpace => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.12' },
|
||||||
|
i3MsCmdSrvRecTotalDiskSpace => { oid => '.1.3.6.1.4.1.2793.8227.2.2.1.13' },
|
||||||
|
};
|
||||||
|
|
||||||
|
my $oid_i3MsCommandServerInfoTableEntry = '.1.3.6.1.4.1.2793.8227.2.2.1';
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{cmd} = {};
|
||||||
|
my $snmp_result = $options{snmp}->get_table(oid => $oid_i3MsCommandServerInfoTableEntry,
|
||||||
|
nothing_quit => 1);
|
||||||
|
|
||||||
|
|
||||||
|
foreach my $oid (keys %{$snmp_result}) {
|
||||||
|
next if ($oid !~ /^$mapping->{i3MsCmdSrvStatus}->{oid}\.(.*)$/);
|
||||||
|
my $instance = $1;
|
||||||
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{filter_client}) && $self->{option_results}->{filter_client} ne '' &&
|
||||||
|
$result->{i3MsCmdSrvClient} !~ /$self->{option_results}->{filter_client}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping '" . $result->{i3MsCmdSrvClient} . "': no matching filter.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{cmd}->{$instance} = {
|
||||||
|
display => $result->{i3MsCmdSrvClient},
|
||||||
|
total => $result->{i3MsCmdSrvRecTotalDiskSpace} * 1024 * 1024,
|
||||||
|
free => $result->{i3MsCmdSrvRecFreeDiskSpace} * 1024 * 1024,
|
||||||
|
%$result
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scalar(keys %{$self->{cmd}}) <= 0) {
|
||||||
|
$self->{output}->add_option_msg(short_msg => "No command server found.");
|
||||||
|
$self->{output}->option_exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check command servers usage.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-counters>
|
||||||
|
|
||||||
|
Only display some counters (regexp can be used).
|
||||||
|
Example: --filter-counters='^status$'
|
||||||
|
|
||||||
|
=item B<--filter-client>
|
||||||
|
|
||||||
|
Filter client name (can be a regexp).
|
||||||
|
|
||||||
|
=item B<--warning-status>
|
||||||
|
|
||||||
|
Set warning threshold for status.
|
||||||
|
Can used special variables like: %{accept_sessions}, %{status}, %{display}
|
||||||
|
|
||||||
|
=item B<--critical-status>
|
||||||
|
|
||||||
|
Set critical threshold for status (Default: '%{status} !~ /^ready/i').
|
||||||
|
Can used special variables like: %{accept_sessions}, %{status}, %{display}
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Threshold warning.
|
||||||
|
Can be: 'usage', 'resource-count'.
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Threshold critical.
|
||||||
|
Can be: 'usage', 'resource-count'.
|
||||||
|
|
||||||
|
=item B<--units>
|
||||||
|
|
||||||
|
Units of thresholds (Default: '%') ('%', 'B').
|
||||||
|
|
||||||
|
=item B<--free>
|
||||||
|
|
||||||
|
Thresholds are on free space left.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,138 @@
|
||||||
|
#
|
||||||
|
# Copyright 2017 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::inin::mediaserver::snmp::mode::component;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::hardware);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub set_system {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{regexp_threshold_overload_check_section_option} = '^(device)$';
|
||||||
|
|
||||||
|
$self->{cb_hook2} = 'snmp_execute';
|
||||||
|
|
||||||
|
$self->{thresholds} = {
|
||||||
|
device => [
|
||||||
|
['unknown', 'UNKNOWN'],
|
||||||
|
['up', 'OK'],
|
||||||
|
['down', 'CRITICAL'],
|
||||||
|
['congested', 'WARNING'],
|
||||||
|
['restarting', 'OK'],
|
||||||
|
['quiescing', 'OK'],
|
||||||
|
['testing', 'OK'],
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
$self->{components_path} = 'apps::inin::mediaserver::snmp::mode::components';
|
||||||
|
$self->{components_module} = ['device'];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub new {
|
||||||
|
my ($class, %options) = @_;
|
||||||
|
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_absent => 1, no_performance => 1, no_load_components => 1);
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
$self->{version} = '1.0';
|
||||||
|
$options{options}->add_options(arguments =>
|
||||||
|
{
|
||||||
|
});
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub snmp_execute {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{snmp} = $options{snmp};
|
||||||
|
$self->{results} = $self->{snmp}->get_multiple_table(oids => $self->{request});
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check hardware devices.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--component>
|
||||||
|
|
||||||
|
Which component to check (Default: '.*').
|
||||||
|
Can be: 'device'.
|
||||||
|
|
||||||
|
=item B<--no-component>
|
||||||
|
|
||||||
|
Return an error if no compenents are checked.
|
||||||
|
If total (with skipped) is 0. (Default: 'critical' returns).
|
||||||
|
|
||||||
|
=item B<--threshold-overload>
|
||||||
|
|
||||||
|
Set to overload default threshold values (syntax: section,[instance,]status,regexp)
|
||||||
|
It used before default thresholds (order stays).
|
||||||
|
Example: --threshold-overload='device,WARNING,restarting'
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
package apps::inin::mediaserver::snmp::mode::components::device;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
my %map_status = (1 => 'unknown', 2 => 'up', 3 => 'down', 4 => 'congested',
|
||||||
|
5 => 'restarting', 6 => 'quiescing', 7 => 'testing'
|
||||||
|
);
|
||||||
|
|
||||||
|
my $mapping = {
|
||||||
|
i3MsGeneralInfoOperStatus => { oid => '.1.3.6.1.4.1.2793.8227.1.2', map => \%map_status },
|
||||||
|
};
|
||||||
|
|
||||||
|
sub load {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
push @{$self->{request}}, { oid => $mapping->{i3MsGeneralInfoOperStatus}->{oid} };
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check {
|
||||||
|
my ($self) = @_;
|
||||||
|
|
||||||
|
$self->{output}->output_add(long_msg => "Checking devices");
|
||||||
|
$self->{components}->{device} = {name => 'devices', total => 0, skip => 0};
|
||||||
|
return if ($self->check_filter(section => 'device'));
|
||||||
|
|
||||||
|
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$mapping->{i3MsGeneralInfoOperStatus}->{oid}}, instance => '0');
|
||||||
|
|
||||||
|
return if (!defined($result->{i3MsGeneralInfoOperStatus}));
|
||||||
|
$self->{components}->{device}->{total}++;
|
||||||
|
$self->{output}->output_add(long_msg => sprintf("device status is '%s' [instance = %s]",
|
||||||
|
$result->{i3MsGeneralInfoOperStatus}, '0'));
|
||||||
|
my $exit = $self->get_severity(section => 'device', value => $result->{i3MsGeneralInfoOperStatus});
|
||||||
|
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
|
||||||
|
$self->{output}->output_add(severity => $exit,
|
||||||
|
short_msg => sprintf("Device status is '%s'", $result->{i3MsGeneralInfoOperStatus}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
|
@ -0,0 +1,200 @@
|
||||||
|
#
|
||||||
|
# Copyright 2017 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::inin::mediaserver::snmp::mode::diskusage;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
my $instance_mode;
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'disktracelog', type => 0 },
|
||||||
|
{ name => 'diskhttpcache', type => 0 },
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{disktracelog} = [
|
||||||
|
{ label => 'tracelog-usage', set => {
|
||||||
|
key_values => [ { name => 'free' }, { name => 'total' }, { name => 'display' } ],
|
||||||
|
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||||
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
|
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||||
|
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
$self->{maps_counters}->{diskhttpcache} = [
|
||||||
|
{ label => 'httpcache-usage', set => {
|
||||||
|
key_values => [ { name => 'free' }, { name => 'total' }, { name => 'display' } ],
|
||||||
|
closure_custom_calc => $self->can('custom_usage_calc'),
|
||||||
|
closure_custom_output => $self->can('custom_usage_output'),
|
||||||
|
closure_custom_perfdata => $self->can('custom_usage_perfdata'),
|
||||||
|
closure_custom_threshold_check => $self->can('custom_usage_threshold'),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_usage_perfdata {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $label = 'used_' . $self->{result_values}->{display};
|
||||||
|
my $value_perf = $self->{result_values}->{used};
|
||||||
|
if (defined($instance_mode->{option_results}->{free})) {
|
||||||
|
$label = 'free_' . $self->{result_values}->{display};
|
||||||
|
$value_perf = $self->{result_values}->{free};
|
||||||
|
}
|
||||||
|
my %total_options = ();
|
||||||
|
if ($instance_mode->{option_results}->{units} eq '%') {
|
||||||
|
$total_options{total} = $self->{result_values}->{total};
|
||||||
|
$total_options{cast_int} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->{output}->perfdata_add(label => $label, unit => 'B',
|
||||||
|
value => $value_perf,
|
||||||
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options),
|
||||||
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options),
|
||||||
|
min => 0, max => $self->{result_values}->{total});
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_usage_threshold {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my ($exit, $threshold_value);
|
||||||
|
$threshold_value = $self->{result_values}->{used};
|
||||||
|
$threshold_value = $self->{result_values}->{free} if (defined($instance_mode->{option_results}->{free}));
|
||||||
|
if ($instance_mode->{option_results}->{units} eq '%') {
|
||||||
|
$threshold_value = $self->{result_values}->{prct_used};
|
||||||
|
$threshold_value = $self->{result_values}->{prct_free} if (defined($instance_mode->{option_results}->{free}));
|
||||||
|
}
|
||||||
|
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]);
|
||||||
|
return $exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_usage_output {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my ($total_size_value, $total_size_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total});
|
||||||
|
my ($total_used_value, $total_used_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{used});
|
||||||
|
my ($total_free_value, $total_free_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{free});
|
||||||
|
my $msg = sprintf("Disk '%s' Total: %s Used: %s (%.2f%%) Free: %s (%.2f%%)",
|
||||||
|
$self->{result_values}->{display},
|
||||||
|
$total_size_value . " " . $total_size_unit,
|
||||||
|
$total_used_value . " " . $total_used_unit, $self->{result_values}->{prct_used},
|
||||||
|
$total_free_value . " " . $total_free_unit, $self->{result_values}->{prct_free});
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub custom_usage_calc {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
|
||||||
|
$self->{result_values}->{total} = $options{new_datas}->{$self->{instance} . '_total'};
|
||||||
|
$self->{result_values}->{free} = $options{new_datas}->{$self->{instance} . '_free'};
|
||||||
|
$self->{result_values}->{used} = $self->{result_values}->{total} - $self->{result_values}->{free};
|
||||||
|
|
||||||
|
$self->{result_values}->{prct_used} = $self->{result_values}->{used} * 100 / $self->{result_values}->{total};
|
||||||
|
$self->{result_values}->{prct_free} = 100 - $self->{result_values}->{prct_used};
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 =>
|
||||||
|
{
|
||||||
|
"units:s" => { name => 'units', default => '%' },
|
||||||
|
"free" => { name => 'free' },
|
||||||
|
});
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub check_options {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
$self->SUPER::check_options(%options);
|
||||||
|
|
||||||
|
$instance_mode = $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $oid_i3MsGeneralInfoTracelogFreeDiskSpace = '.1.3.6.1.4.1.2793.8227.1.12.0'; # MiB
|
||||||
|
my $oid_i3MsGeneralInfoTracelogTotalDiskSpace = '.1.3.6.1.4.1.2793.8227.1.13.0'; # MiB
|
||||||
|
my $oid_i3MsGeneralInfoHttpCacheFreeDiskSpace = '.1.3.6.1.4.1.2793.8227.1.15.0'; # MiB
|
||||||
|
my $oid_i3MsGeneralInfoHttpCacheTotalDiskSpace = '.1.3.6.1.4.1.2793.8227.1.16.0'; # MiB
|
||||||
|
|
||||||
|
my $snmp_result = $options{snmp}->get_leef(oids => [
|
||||||
|
$oid_i3MsGeneralInfoTracelogFreeDiskSpace, $oid_i3MsGeneralInfoTracelogTotalDiskSpace,
|
||||||
|
$oid_i3MsGeneralInfoHttpCacheFreeDiskSpace, $oid_i3MsGeneralInfoHttpCacheTotalDiskSpace
|
||||||
|
], nothing_quit => 1);
|
||||||
|
|
||||||
|
$self->{disktracelog} = {
|
||||||
|
free => $snmp_result->{$oid_i3MsGeneralInfoTracelogFreeDiskSpace} * 1024 * 1024,
|
||||||
|
total => $snmp_result->{$oid_i3MsGeneralInfoTracelogTotalDiskSpace} * 1024 * 1024,
|
||||||
|
display => 'tracelog'
|
||||||
|
};
|
||||||
|
$self->{diskhttpcache} = {
|
||||||
|
free => $snmp_result->{$oid_i3MsGeneralInfoHttpCacheFreeDiskSpace} * 1024 * 1024,
|
||||||
|
total => $snmp_result->{$oid_i3MsGeneralInfoHttpCacheTotalDiskSpace} * 1024 * 1024,
|
||||||
|
display => 'httpcache'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check disk usages.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Threshold warning.
|
||||||
|
Can be: 'httpcache-usage', 'tracelog-usage'.
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Threshold critical.
|
||||||
|
Can be: 'httpcache-usage', 'tracelog-usage'.
|
||||||
|
|
||||||
|
=item B<--units>
|
||||||
|
|
||||||
|
Default is '%', can be 'B'
|
||||||
|
|
||||||
|
=item B<--free>
|
||||||
|
|
||||||
|
Thresholds are on free space left.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,95 @@
|
||||||
|
#
|
||||||
|
# Copyright 2017 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::inin::mediaserver::snmp::mode::memoryusage;
|
||||||
|
|
||||||
|
use base qw(centreon::plugins::templates::counter);
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
sub set_counters {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
$self->{maps_counters_type} = [
|
||||||
|
{ name => 'global', type => 0, message_separator => ' - ' }
|
||||||
|
];
|
||||||
|
|
||||||
|
$self->{maps_counters}->{global} = [
|
||||||
|
{ label => 'usage', set => {
|
||||||
|
key_values => [ { name => 'used' } ],
|
||||||
|
output_template => 'Memory Used : %s %s',
|
||||||
|
output_change_bytes => 1,
|
||||||
|
perfdatas => [
|
||||||
|
{ label => 'used', value => 'used_absolute', template => '%s',
|
||||||
|
unit => 'B', min => 0 },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub manage_selection {
|
||||||
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
|
my $oid_i3MsGeneralInfoMemoryUsage = '.1.3.6.1.4.1.2793.8227.1.10.0';
|
||||||
|
my $snmp_result = $options{snmp}->get_leef(oids => [
|
||||||
|
$oid_i3MsGeneralInfoMemoryUsage
|
||||||
|
], nothing_quit => 1);
|
||||||
|
|
||||||
|
$self->{global} = { used => $snmp_result->{$oid_i3MsGeneralInfoMemoryUsage} };
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 MODE
|
||||||
|
|
||||||
|
Check memory.
|
||||||
|
|
||||||
|
=over 8
|
||||||
|
|
||||||
|
=item B<--warning-*>
|
||||||
|
|
||||||
|
Threshold warning.
|
||||||
|
Can be: 'usage' (B).
|
||||||
|
|
||||||
|
=item B<--critical-*>
|
||||||
|
|
||||||
|
Threshold critical.
|
||||||
|
Can be: 'usage' (B).
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
|
@ -0,0 +1,52 @@
|
||||||
|
#
|
||||||
|
# Copyright 2017 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::inin::mediaserver::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}} = (
|
||||||
|
'audioengine-usage' => 'apps::inin::mediaserver::snmp::mode::audioengineusage',
|
||||||
|
'cmdsrv-usage' => 'apps::inin::mediaserver::snmp::mode::cmdsrvusage',
|
||||||
|
'disk-usage' => 'apps::inin::mediaserver::snmp::mode::diskusage',
|
||||||
|
'component' => 'apps::inin::mediaserver::snmp::mode::component',
|
||||||
|
'memory-usage' => 'apps::inin::mediaserver::snmp::mode::memoryusage',
|
||||||
|
);
|
||||||
|
|
||||||
|
return $self;
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
||||||
|
=head1 PLUGIN DESCRIPTION
|
||||||
|
|
||||||
|
Check Interactive Intelligence Media Server in SNMP.
|
||||||
|
|
||||||
|
=cut
|
Loading…
Reference in New Issue