(plugin) network::sonus::sbc::snmp - refactoring + metric v2 (#4370)

This commit is contained in:
qgarnier 2023-04-19 15:25:55 +02:00 committed by GitHub
parent 3de4cf4e69
commit ef3ff929d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 891 additions and 338 deletions

View File

@ -26,84 +26,77 @@ use strict;
use warnings;
use Digest::MD5 qw(md5_hex);
sub prefix_port_output {
my ($self, %options) = @_;
return "Port '" . $options{instance_value}->{display} . "' number of calls ";
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'port', type => 1, cb_prefix_output => 'prefix_port_output', message_multiple => 'All calls stats on ports are OK' },
{ name => 'port', type => 1, cb_prefix_output => 'prefix_port_output', message_multiple => 'All ports call statistics are ok' }
];
$self->{maps_counters}->{port} = [
{ label => 'current-calls', set => {
{ label => 'current', nlabel => 'port.calls.current.count', set => {
key_values => [ { name => 'current' }, { name => 'display' } ],
output_template => 'Current calls : %s',
output_template => 'current: %s',
perfdatas => [
{ label => 'current', template => '%d',
min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' },
],
{ template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'total-per-sec', set => {
key_values => [ { name => 'total', per_second => 1 }, { name => 'display' } ],
output_template => 'total calls: %.2f/s',
{ label => 'total', nlabel => 'port.calls.total.count', set => {
key_values => [ { name => 'total', diff => 1 }, { name => 'display' } ],
output_template => 'total: %s',
perfdatas => [
{ label => 'total', template => '%.2f',
min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' },
],
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'connected-per-sec', set => {
key_values => [ { name => 'connected', per_second => 1 }, { name => 'display' } ],
output_template => 'connected calls: %.2f/s',
{ label => 'connected', nlabel => 'port.calls.connected.count', set => {
key_values => [ { name => 'connected', diff => 1 }, { name => 'display' } ],
output_template => 'connected: %s',
perfdatas => [
{ label => 'connected', template => '%.2f',
min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' },
],
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'refused-per-sec', set => {
key_values => [ { name => 'refused', per_second => 1 }, { name => 'display' } ],
output_template => 'refused calls: %.2f/s',
{ label => 'refused', nlabel => 'port.calls.refused.count', set => {
key_values => [ { name => 'refused', diff => 1 }, { name => 'display' } ],
output_template => 'refused: %s',
perfdatas => [
{ label => 'refused', template => '%.2f',
min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' },
],
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'errored-per-sec', set => {
key_values => [ { name => 'errored', per_second => 1 }, { name => 'display' } ],
output_template => 'errored calls: %.2f/s',
{ label => 'errored', nlabel => 'port.calls.errored.count', set => {
key_values => [ { name => 'errored', diff => 1 }, { name => 'display' } ],
output_template => 'errored: %s',
perfdatas => [
{ label => 'errored', template => '%.2f',
min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' },
],
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'blocked-per-sec', set => {
key_values => [ { name => 'blocked', per_second => 1 }, { name => 'display' } ],
output_template => 'blocked calls: %.2f/s',
{ label => 'blocked', nlabel => 'port.calls.blocked.count', set => {
key_values => [ { name => 'blocked', diff => 1 }, { name => 'display' } ],
output_template => 'blocked: %s',
perfdatas => [
{ label => 'blocked', template => '%.2f',
min => 0, unit => 'calls', label_extra_instance => 1, instance_use => 'display' },
],
{ template => '%s', min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
},
}
];
}
sub prefix_dsp_output {
my ($self, %options) = @_;
return "Port => '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments => {
});
$options{options}->add_options(arguments => {});
return $self;
}
@ -114,34 +107,36 @@ my $mapping = {
uxPTConnectedCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.7' },
uxPTRefusedCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.8' },
uxPTErroredCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.9' },
uxPTBlockedCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.18' },
uxPTBlockedCalls => { oid => '.1.3.6.1.4.1.177.15.1.5.1.2.1.18' }
};
my $oid_uxPortTable = '.1.3.6.1.4.1.177.15.1.5.1.2.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $snmp_result = $options{snmp}->get_table(
oid => $oid_uxPortTable,
nothing_quit => 1
);
foreach my $oid (keys %$snmp_result) {
next if ($oid !~ /^$mapping->{uxPTCurrentCalls}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$self->{port}->{$instance} = {
current => $result->{uxPTCurrentCalls},
total => $result->{uxPTTotalCalls},
connected => $result->{uxPTConnectedCalls},
refused => $result->{uxPTRefusedCalls},
errored => $result->{uxPTErroredCalls},
blocked => $result->{uxPTBlockedCalls},
display => $instance
};
}
$self->{cache_name} = "sonus_" . $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'));
$self->{results} = $options{snmp}->get_table(oid => $oid_uxPortTable,
nothing_quit => 1);
foreach my $oid (keys %{$self->{results}}) {
next if $oid !~ /^$mapping->{uxPTCurrentCalls}->{oid}\.(.*)$/;
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
$self->{port}->{$instance} = { current => $result->{uxPTCurrentCalls},
total => $result->{uxPTTotalCalls},
connected => $result->{uxPTConnectedCalls},
refused => $result->{uxPTRefusedCalls},
errored => $result->{uxPTErroredCalls},
blocked => $result->{uxPTBlockedCalls},
display => $instance };
}
}
1;
@ -150,17 +145,13 @@ __END__
=head1 MODE
Check Call statistics
Check port call statistics.
=over 8
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Warning on counters. Can be ('current-calls', 'total-per-sec', 'connected-per-sec', 'refused-per-sec', 'errored-per-sec', 'blocked-per-sec')
=item B<--critical-*>
Critical on counters. Can be ('current-calls', 'total-per-sec', 'connected-per-sec', 'refused-per-sec', 'errored-per-sec', 'blocked-per-sec')
Thresholds. Can be: 'current', 'total', 'connected', 'refused', 'errored', 'blocked'.
=back

View File

@ -24,253 +24,250 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_status_output {
my ($self, %options) = @_;
my $msg;
if ($self->{result_values}->{admstatus} eq 'disabled') {
$msg = ' is disabled (admin)';
$msg = 'is disabled (admin)';
} else {
$msg = 'Oper Status : ' . $self->{result_values}->{opstatus};
$msg = 'oper status: ' . $self->{result_values}->{opstatus};
}
return $msg;
}
sub custom_status_calc {
sub prefix_channel_output {
my ($self, %options) = @_;
$self->{result_values}->{opstatus} = $options{new_datas}->{$self->{instance} . '_opstatus'};
$self->{result_values}->{admstatus} = $options{new_datas}->{$self->{instance} . '_admstatus'};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
return sprintf(
"channel '%s/%s/%s/%s' ",
$options{instance_value}->{shelf},
$options{instance_value}->{slot},
$options{instance_value}->{port},
$options{instance_value}->{channel}
);
}
sub prefix_global_output {
my ($self, %options) = @_;
return 'number of channels ';
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'global', type => 0 },
{ name => 'channels', type => 1, cb_prefix_output => 'prefix_channels_output', message_multiple => 'All channels are ok' }
{ name => 'global', type => 0, cb_prefix_output => 'prefix_global_output' },
{ name => 'channels', type => 1, cb_prefix_output => 'prefix_channel_output', message_multiple => 'All channels are ok' }
];
$self->{maps_counters}->{global} = [
{ label => 'total', set => {
{ label => 'channels-total', nlabel => 'channels.total.count', display_ok => 0, set => {
key_values => [ { name => 'total' } ],
output_template => 'Total channels : %s',
output_template => 'total: %s',
perfdatas => [
{ label => 'total', value => 'total', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-outofservice', set => {
{ label => 'channels-outofservice', nlabel => 'channels.outofservice.count', display_ok => 0, set => {
key_values => [ { name => 'outofservice' } ],
output_template => 'OutOfService : %s',
output_template => 'out of service: %s',
perfdatas => [
{ label => 'total_outofservice', value => 'outofservice', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-idle', set => {
{ label => 'channels-idle', nlabel => 'channels.idle.count', display_ok => 0, set => {
key_values => [ { name => 'idle' } ],
output_template => 'Idle : %s',
output_template => 'idle: %s',
perfdatas => [
{ label => 'total_idle', value => 'idle', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-pending', set => {
{ label => 'channels-pending', nlabel => 'channels.pending.count', display_ok => 0, set => {
key_values => [ { name => 'pending' } ],
output_template => 'Pending : %s',
output_template => 'pending: %s',
perfdatas => [
{ label => 'total_pending', value => 'pending', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-waitingforroute', set => {
{ label => 'channels-waitingforroute', nlabel => 'channels.waiting_for_route.count', display_ok => 0, set => {
key_values => [ { name => 'waitingforroute' } ],
output_template => 'WaitingForRoute : %s',
output_template => 'waiting for route: %s',
perfdatas => [
{ label => 'total_waitingforroute', value => 'waitingforroute', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-actionlist', set => {
{ label => 'channels-actionlist', nlabel => 'channels.action_list.count', display_ok => 0, set => {
key_values => [ { name => 'actionlist' } ],
output_template => 'ActionList : %s',
output_template => 'action list: %s',
perfdatas => [
{ label => 'total_actionlist', value => 'actionlist', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-waitingfordigits', set => {
{ label => 'channels-waitingfordigits', nlabel => 'channels.waiting_for_digits.count', display_ok => 0, set => {
key_values => [ { name => 'waitingfordigits' } ],
output_template => 'WaitingForDigits : %s',
output_template => 'waiting for digits: %s',
perfdatas => [
{ label => 'total_waitingfordigits', value => 'waitingfordigits', template => '%s',
min => 0 },
],
{ template => '%s',
min => 0 }
]
}
},
{ label => 'total-remotesetup', set => {
{ label => 'channels-remotesetup', nlabel => 'channels.remote_setup.count', display_ok => 0, set => {
key_values => [ { name => 'remotesetup' } ],
output_template => 'RemoteSetup : %s',
output_template => 'remote setup: %s',
perfdatas => [
{ label => 'total_remotesetup', value => 'remotesetup', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-peersetup', set => {
{ label => 'channels-peersetup', nlabel => 'channels.peer_setup.count', display_ok => 0, set => {
key_values => [ { name => 'peersetup' } ],
output_template => 'PeerSetup : %s',
output_template => 'peer setup: %s',
perfdatas => [
{ label => 'total_peersetup', value => 'peersetup', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-alerting', set => {
{ label => 'channels-alerting', nlabel => 'channels.alerting.count', display_ok => 0, set => {
key_values => [ { name => 'alerting' } ],
output_template => 'Alerting : %s',
output_template => 'alerting: %s',
perfdatas => [
{ label => 'total_alerting', value => 'alerting', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-inbandinfo', set => {
{ label => 'channels-inbandinfo', nlabel => 'channels.inband_info.count', display_ok => 0, set => {
key_values => [ { name => 'inbandinfo' } ],
output_template => 'InBandInfo : %s',
output_template => 'inband info: %s',
perfdatas => [
{ label => 'total_inbandinfo', value => 'inbandinfo', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-connected', set => {
{ label => 'channels-connected', nlabel => 'channels.connected.count', display_ok => 0, set => {
key_values => [ { name => 'connected' } ],
output_template => 'Connected : %s',
output_template => 'connected: %s',
perfdatas => [
{ label => 'total_connected', value => 'connected', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-tonegeneration', set => {
{ label => 'channels-tonegeneration', nlabel => 'channels.tone_generation.count', display_ok => 0, set => {
key_values => [ { name => 'tonegeneration' } ],
output_template => 'ToneGeneration : %s',
output_template => 'tone generation: %s',
perfdatas => [
{ label => 'total_tonegeneration', value => 'tonegeneration', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-releasing', set => {
{ label => 'channels-releasing', nlabel => 'channels.releasing.count', display_ok => 0, set => {
key_values => [ { name => 'releasing' } ],
output_template => 'Releasing : %s',
output_template => 'releasing: %s',
perfdatas => [
{ label => 'total_releasing', value => 'releasing', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-aborting', set => {
{ label => 'channels-aborting', nlabel => 'channels.aborting.count', display_ok => 0, set => {
key_values => [ { name => 'aborting' } ],
output_template => 'Aborting : %s',
output_template => 'aborting: %s',
perfdatas => [
{ label => 'total_aborting', value => 'aborting', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-resetting', set => {
{ label => 'channels-resetting', nlabel => 'channels.resetting.count', display_ok => 0, set => {
key_values => [ { name => 'resetting' } ],
output_template => 'Resetting : %s',
output_template => 'resetting: %s',
perfdatas => [
{ label => 'total_resetting', value => 'resetting', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-up', set => {
{ label => 'channels-up', nlabel => 'channels.up.count', display_ok => 0, set => {
key_values => [ { name => 'up' } ],
output_template => 'Up : %s',
output_template => 'up: %s',
perfdatas => [
{ label => 'total_up', value => 'up', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
{ label => 'total-down', set => {
{ label => 'channels-down', nlabel => 'channels.down.count', display_ok => 0, set => {
key_values => [ { name => 'down' } ],
output_template => 'Down : %s',
output_template => 'down: %s',
perfdatas => [
{ label => 'total_down', value => 'down', template => '%s',
min => 0 },
],
{ template => '%s', min => 0 }
]
}
},
}
];
$self->{maps_counters}->{channels} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'opstatus' }, { name => 'admstatus' }, { name => 'display' } ],
closure_custom_calc => $self->can('custom_status_calc'),
{ label => 'status', type => 2, critical_default => '%{admstatus} eq "enable" and %{opstatus} !~ /up|idle|connected/', set => {
key_values => [
{ name => 'opstatus' }, { name => 'admstatus' },
{ name => 'shelf' }, { name => 'slot' }, { name => 'port' }, { name => 'channel' }
],
closure_custom_output => $self->can('custom_status_output'),
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'seconds', set => {
key_values => [ { name => 'seconds' }, { name => 'display' } ],
output_template => 'lifetime : %s seconds',
perfdatas => [
{ label => 'seconds', value => 'seconds', template => '%s',
min => 0, unit => 's', label_extra_instance => 1, instance_use => 'display' },
],
{ label => 'channel-lifetime', nlabel => 'channel.lifetime.seconds', set => {
key_values => [ { name => 'seconds' }, { name => 'shelf' }, { name => 'slot' }, { name => 'port' }, { name => 'channel' } ],
output_template => 'lifetime: %s seconds',
closure_custom_perfdata => sub {
my ($self, %options) = @_;
$self->{output}->perfdata_add(
nlabel => $self->{nlabel},
unit => 's',
instances => [
'shelf' . $self->{result_values}->{shelf},
'slot' . $self->{result_values}->{slot},
'port' . $self->{result_values}->{port},
'channel' . $self->{result_values}->{channel},
],
value => $self->{result_values}->{seconds},
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}),
min => 0
);
}
}
},
}
];
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{admstatus} eq "enable" and %{opstatus} !~ /up|idle|connected/' },
});
$options{options}->add_options(arguments => {
'filter-shelf-id:s' => { name => 'filter_shelf_id' },
'filter-slot-id:s' => { name => 'filter_slot_id' },
'filter-port-id:s' => { name => 'filter_port_id' },
'filter-channel-id:s' => { name => 'filter_channel_id' }
});
return $self;
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
$self->change_macros(macros => ['warning_status', 'critical_status']);
}
sub prefix_channels_output {
my ($self, %options) = @_;
return "Channels '" . $options{instance_value}->{display} . "' ";
}
my %map_admin_status = (
0 => 'down',
1 => 'up',
1 => 'up'
);
my %map_operation_status = (
0 => 'outOfService',
@ -289,45 +286,63 @@ my %map_operation_status = (
13 => 'aborting',
14 => 'resetting',
15 => 'up',
16 => 'down',
16 => 'down'
);
my $mapping = {
uxChAdminState => { oid => '.1.3.6.1.4.1.177.15.1.5.6.1.5', map => \%map_admin_status },
uxChOperState => { oid => '.1.3.6.1.4.1.177.15.1.5.6.1.6', map => \%map_operation_status },
uxChInUseSeconds => { oid => '.1.3.6.1.4.1.177.15.1.5.6.1.7' },
uxChAdminState => { oid => '.1.3.6.1.4.1.177.15.1.5.6.1.5', map => \%map_admin_status },
uxChOperState => { oid => '.1.3.6.1.4.1.177.15.1.5.6.1.6', map => \%map_operation_status },
uxChInUseSeconds => { oid => '.1.3.6.1.4.1.177.15.1.5.6.1.7' }
};
my $oid_uxChannelStatusEntry = '.1.3.6.1.4.1.177.15.1.5.6.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{global} = {
total => 0, outofservice => 0, idle => 0,
pending => 0, waitingforroute => 0, actionlist => 0,
waitingfordigits => 0, remotesetup => 0, peersetup => 0,
alerting => 0, inbandinfo => 0, connected => 0, tonegeneration => 0,
releasing => 0, aborting => 0, resetting => 0, up => 0, down => 0
};
my $snmp_result = $options{snmp}->get_table(
oid => $oid_uxChannelStatusEntry,
nothing_quit => 1
);
$self->{channels} = {};
$self->{global} = { total => 0, outofservice => 0, idle => 0,
pending => 0, waitingforroute => 0, actionlist => 0,
waitingfordigits => 0, remotesetup => 0, peersetup => 0,
alerting => 0, inbandinfo => 0, connected => 0, tonegeneration => 0,
releasing => 0, aborting => 0, resetting => 0, up => 0, down => 0 };
foreach my $oid (keys %$snmp_result) {
next if($oid !~ /^$mapping->{uxChOperState}->{oid}\.(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
my ($shelf, $slot, $port, $channel) = ($1, $2, $3, $4);
$self->{results} = $options{snmp}->get_table(oid => $oid_uxChannelStatusEntry,
nothing_quit => 1);
next if (defined($self->{option_results}->{filter_shelf_id}) && $self->{option_results}->{filter_shelf_id} ne '' &&
$shelf !~ /$self->{option_results}->{filter_shelf_id}/);
next if (defined($self->{option_results}->{filter_slot_id}) && $self->{option_results}->{filter_slot_id} ne '' &&
$slot !~ /$self->{option_results}->{filter_slot_id}/);
next if (defined($self->{option_results}->{filter_port_id}) && $self->{option_results}->{filter_port_id} ne '' &&
$port !~ /$self->{option_results}->{filter_port_id}/);
next if (defined($self->{option_results}->{filter_channel_id}) && $self->{option_results}->{filter_channel_id} ne '' &&
$channel !~ /$self->{option_results}->{filter_channel_id}/);
foreach my $oid (keys %{$self->{results}}) {
next if($oid !~ /^$mapping->{uxChOperState}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
my $instance = $shelf . '.' . $slot . '.' . $port . '.' . $channel;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
$self->{global}->{total}++;
my $oper_state = lc($result->{uxChOperState});
$self->{global}->{$oper_state}++;
$self->{channels}->{$instance} = {display => $instance,
opstatus => $result->{uxChOperState},
admstatus => $result->{uxChAdminState},
seconds => $result->{uxChInUseSeconds}};
$self->{channels}->{$instance} = {
shelf => $shelf,
slot => $slot,
port => $port,
channel => $channel,
opstatus => $result->{uxChOperState},
admstatus => $result->{uxChAdminState},
seconds => $result->{uxChInUseSeconds}
};
}
}
1;
@ -336,13 +351,29 @@ __END__
=head1 MODE
Check Channels on Sonus
Check channels.
=over 8
=item B<--filter-counters>
Only display some counters (Can be 'channels' or 'global').
Only display some counters.
=item B<--filter-shelf-id>
Filter channels by shelf id (can be a regexp).
=item B<--filter-slot-id>
Filter channels by slot id (can be a regexp).
=item B<--filter-port-id>
Filter channels by port id (can be a regexp).
=item B<--filter-channel-id>
Filter channels by channel id (can be a regexp).
=item B<--warning-status>
@ -354,15 +385,14 @@ Can used special variables like: %{admstatus}, %{opstatus}, %{display}
Set critical threshold for status.
Can used special variables like: %{admstatus}, %{opstatus}, %{display}
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Threshold warning.
Can be: 'total', 'total-outofservice', 'total-disassociating', 'total-idle', 'total-pending', 'total-waitingforroute', 'total-actionlist', 'total-waitingfordigits', 'total-remotesetup', 'total-peersetup', 'total-alerting', 'total-inbandinfo', 'total-connected', 'total-tonegeneration', 'total-releasing', 'total-aborting', 'total-resetting', 'total-up', 'total-down', 'seconds'
=item B<--critical-*>
Threshold critical.
Can be: 'total', 'total', 'total-outofservice', 'total-disassociating', 'total-idle', 'total-pending', 'total-waitingforroute', 'total-actionlist', 'total-waitingfordigits', 'total-remotesetup', 'total-peersetup', 'total-alerting', 'total-inbandinfo', 'total-connected', 'total-tonegeneration', 'total-releasing', 'total-aborting', 'total-resetting', 'total-up', 'total-down', 'seconds'
Thresholds.
Can be: 'channels-total', 'channels-outofservice', 'channels-idle', 'channels-pending',
'channels-waitingforroute', 'channels-actionlist', 'channels-waitingfordigits',
'channels-remotesetup', 'channels-peersetup', 'channels-alerting',
'channels-inbandinfo', 'channels-connected', 'channels-tonegeneration', 'channels-releasing',
'channels-aborting', 'channels-resetting', 'channels-up', 'channels-down', 'channel-lifetime'.
=back

View File

@ -0,0 +1,59 @@
#
# Copyright 2023 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 network::sonus::sbc::snmp::mode::cpudetailed;
use base qw(snmp_standard::mode::cpudetailed);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
return $self;
}
1;
__END__
=head1 MODE
Check system CPUs (UCD-SNMP-MIB) (User, Nice, System, Idle, Wait, Kernel, Interrupt, SoftIRQ, Steal, Guest, GuestNice)
An average of all CPUs.
=over 8
=item B<--warning-*>
Threshold warning in percent.
Can be: 'user', 'nice', 'system', 'idle', 'wait', 'kernel', 'interrupt', 'softirq', 'steal', 'guest', 'guestnice'.
=item B<--critical-*>
Threshold critical in percent.
Can be: 'user', 'nice', 'system', 'idle', 'wait', 'kernel', 'interrupt', 'softirq', 'steal', 'guest', 'guestnice'.
=back
=cut

View File

@ -24,57 +24,12 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold);
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng);
sub custom_state_output {
my ($self, %options) = @_;
my $msg = sprintf("state is '%s'", $self->{result_values}->{state});
return $msg;
}
sub custom_state_calc {
my ($self, %options) = @_;
$self->{result_values}->{state} = $options{new_datas}->{$self->{instance} . '_state'};
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'};
return 0;
}
sub set_counters {
my ($self, %options) = @_;
$self->{maps_counters_type} = [
{ name => 'dsp', type => 1, cb_prefix_output => 'prefix_dsp_output', message_multiple => 'All DSP stats and states are OK' },
];
$self->{maps_counters}->{dsp} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'state' }, { name => 'display' } ],
closure_custom_calc => \&custom_state_calc,
closure_custom_output => \&custom_state_output,
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold,
}
},
{ label => 'cpu', set => {
key_values => [ { name => 'cpu' }, { name => 'display' } ],
output_template => 'CPU Usage: %s',
perfdatas => [
{ label => 'cpu', value => 'cpu', template => '%d',
min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' },
],
}
},
{ label => 'channels', set => {
key_values => [ { name => 'channels' }, { name => 'display' } ],
output_template => 'Active Channels: %s',
perfdatas => [
{ label => 'channels', value => 'channels', template => '%d',
min => 0, unit => 'channels', label_extra_instance => 1, instance_use => 'display' },
],
}
},
];
return sprintf("state is '%s'", $self->{result_values}->{state});
}
sub prefix_dsp_output {
@ -83,59 +38,84 @@ sub prefix_dsp_output {
return "DSP '" . $options{instance_value}->{display} . "' ";
}
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
sub set_counters {
my ($self, %options) = @_;
$options{options}->add_options(arguments =>
{
"warning-status:s" => { name => 'warning_status', default => '' },
"critical-status:s" => { name => 'critical_status', default => '%{state} eq "down"' },
});
return $self;
$self->{maps_counters_type} = [
{ name => 'dsp', type => 1, cb_prefix_output => 'prefix_dsp_output', message_multiple => 'All DSP stats and states are ok' }
];
$self->{maps_counters}->{dsp} = [
{ label => 'status', type => 2, critical_default => '%{state} eq "down"', set => {
key_values => [ { name => 'state' }, { name => 'display' } ],
closure_custom_output => \&custom_state_output,
closure_custom_perfdata => sub { return 0; },
closure_custom_threshold_check => \&catalog_status_threshold_ng
}
},
{ label => 'cpu-utilization', nlabel => 'dsp.cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu' }, { name => 'display' } ],
output_template => 'CPU usage: %.2f %%',
perfdatas => [
{ template => '%.2f', min => 0, max => 100, unit => '%', label_extra_instance => 1, instance_use => 'display' }
]
}
},
{ label => 'channels-active', nlabel => 'dsp.channels.active.count', set => {
key_values => [ { name => 'channels' }, { name => 'display' } ],
output_template => 'active channels: %s',
perfdatas => [
{ template => '%d', min => 0, label_extra_instance => 1, instance_use => 'display' }
]
}
}
];
}
sub check_options {
my ($self, %options) = @_;
$self->SUPER::check_options(%options);
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
$self->change_macros(macros => ['warning_status', 'critical_status']);
$options{options}->add_options(arguments => {});
return $self;
}
my %map_status = (
0 => 'down',
1 => 'up',
1 => 'up'
);
my $mapping = {
uxDSPIsPresent => { oid => '.1.3.6.1.4.1.177.15.1.6.1.3' },
uxDSPCPUUsage => { oid => '.1.3.6.1.4.1.177.15.1.6.1.4' },
uxDSPChannelsInUse => { oid => '.1.3.6.1.4.1.177.15.1.6.1.5' },
uxDSPServiceStatus => { oid => '.1.3.6.1.4.1.177.15.1.6.1.6', map => \%map_status },
uxDSPIsPresent => { oid => '.1.3.6.1.4.1.177.15.1.6.1.3' },
uxDSPCPUUsage => { oid => '.1.3.6.1.4.1.177.15.1.6.1.4' },
uxDSPChannelsInUse => { oid => '.1.3.6.1.4.1.177.15.1.6.1.5' },
uxDSPServiceStatus => { oid => '.1.3.6.1.4.1.177.15.1.6.1.6', map => \%map_status }
};
my $oid_uxDSPResourceTable = '.1.3.6.1.4.1.177.15.1.6.1';
sub manage_selection {
my ($self, %options) = @_;
$self->{snmp} = $options{snmp};
my $snmp_result = $options{snmp}->get_table(
oid => $oid_uxDSPResourceTable,
nothing_quit => 1
);
$self->{results} = $options{snmp}->get_table(oid => $oid_uxDSPResourceTable,
nothing_quit => 1);
foreach my $oid (keys %{$self->{results}}) {
foreach my $oid (keys %$snmp_result) {
next if($oid !~ /^$mapping->{uxDSPServiceStatus}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $self->{results}, instance => $instance);
my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $instance);
next if ($result->{uxDSPIsPresent} eq '0');
$self->{dsp}->{$instance} = { state => $result->{uxDSPServiceStatus},
cpu => $result->{uxDSPCPUUsage},
channels => $result->{uxDSPChannelsInUse},
display => $instance };
$self->{dsp}->{$instance} = {
state => $result->{uxDSPServiceStatus},
cpu => $result->{uxDSPCPUUsage},
channels => $result->{uxDSPChannelsInUse},
display => $instance
};
}
}
@ -145,27 +125,23 @@ __END__
=head1 MODE
Check Digital Signal Processing statistics
Check Digital Signal Processing statistics.
=over 8
=item B<--warning-*>
=item B<--warning-*> B<--critical-*>
Warning on counters. Can be ('cpu', 'channels')
=item B<--critical-*>
Warning on counters. Can be ('cpu', 'channels')
Thresholds. Can be: 'cpu-utilization', 'channels-active'.
=item B<--warning-status>
Set warning threshold for status. Use "%{state}" as a special variable.
Useful to be notified when tunnel is up "%{state} eq 'up'"
Set warning threshold for status.
Can used special variables like: %{state}, %{display}
=item B<--critical-status>
Set critical threshold for status. Use "%{state}" as a special variable.
Useful to be notified when tunnel is up "%{state} eq 'up'"
Set critical threshold for status (Default: '%{state} eq "down"').
Can used special variables like: %{state}, %{display}
=back

View File

@ -0,0 +1,182 @@
#
# Copyright 2023 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 network::sonus::sbc::snmp::mode::interfaces;
use base qw(snmp_standard::mode::interfaces);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
return $self;
}
1;
__END__
=head1 MODE
Check interfaces.
=over 8
=item B<--add-global>
Check global port statistics (By default if no --add-* option is set).
=item B<--add-status>
Check interface status.
=item B<--add-duplex-status>
Check duplex status (with --warning-status and --critical-status).
=item B<--add-traffic>
Check interface traffic.
=item B<--add-errors>
Check interface errors.
=item B<--add-cast>
Check interface cast.
=item B<--add-speed>
Check interface speed.
=item B<--add-volume>
Check interface data volume between two checks (not supposed to be graphed, useful for BI reporting).
=item B<--check-metrics>
If the expression is true, metrics are checked (Default: '%{opstatus} eq "up"').
=item B<--warning-status>
Set warning threshold for status.
Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
=item B<--critical-status>
Set critical threshold for status (Default: '%{admstatus} eq "up" and %{opstatus} ne "up"').
Can used special variables like: %{admstatus}, %{opstatus}, %{duplexstatus}, %{display}
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'total-port', 'total-admin-up', 'total-admin-down', 'total-oper-up', 'total-oper-down',
'in-traffic', 'out-traffic', 'in-error', 'in-discard', 'out-error', 'out-discard',
'in-ucast', 'in-bcast', 'in-mcast', 'out-ucast', 'out-bcast', 'out-mcast',
'speed' (b/s).
=item B<--units-traffic>
Units of thresholds for the traffic (Default: 'percent_delta') ('percent_delta', 'bps', 'counter').
=item B<--units-errors>
Units of thresholds for errors/discards (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'counter').
=item B<--units-cast>
Units of thresholds for communication types (Default: 'percent_delta') ('percent_delta', 'percent', 'delta', 'counter').
=item B<--nagvis-perfdata>
Display traffic perfdata to be compatible with nagvis widget.
=item B<--interface>
Set the interface (number expected) ex: 1,2,... (empty means 'check all interface').
=item B<--name>
Allows to use interface name with option --interface instead of interface oid index (Can be a regexp)
=item B<--speed>
Set interface speed for incoming/outgoing traffic (in Mb).
=item B<--speed-in>
Set interface speed for incoming traffic (in Mb).
=item B<--speed-out>
Set interface speed for outgoing traffic (in Mb).
=item B<--map-speed-dsl>
Get interface speed configuration for interface type 'adsl' and 'vdsl2'.
Syntax: --map-speed-dsl=interface-src-name,interface-dsl-name
E.g: --map-speed-dsl=Et0.835,Et0-vdsl2
=item B<--force-counters64>
Force to use 64 bits counters only. Can be used to improve performance.
=item B<--force-counters32>
Force to use 32 bits counters (even in snmp v2c and v3). Should be used when 64 bits counters are buggy.
=item B<--reload-cache-time>
Time in minutes before reloading cache file (default: 180).
=item B<--oid-filter>
Choose OID used to filter interface (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
=item B<--oid-display>
Choose OID used to display interface (default: ifName) (values: ifDesc, ifAlias, ifName, IpAddr).
=item B<--oid-extra-display>
Add an OID to display.
=item B<--display-transform-src>
Regexp src to transform display value.
=item B<--display-transform-dst>
Regexp dst to transform display value.
=item B<--show-cache>
Display cache interface datas.
=back
=cut

View File

@ -0,0 +1,60 @@
#
# Copyright 2023 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 network::sonus::sbc::snmp::mode::load;
use base qw(snmp_standard::mode::loadaverage);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
return $self;
}
1;
__END__
=head1 MODE
Check system load-average.
=over 8
=item B<--warning>
Threshold warning (1min,5min,15min).
=item B<--critical>
Threshold critical (1min,5min,15min).
=item B<--average>
Load average for the number of CPUs.
=back
=cut

View File

@ -0,0 +1,67 @@
#
# Copyright 2023 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 network::sonus::sbc::snmp::mode::memory;
use base qw(snmp_standard::mode::memory);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
return $self;
}
1;
__END__
=head1 MODE
Check memory usage (UCD-SNMP-MIB).
=over 8
=item B<--units>
Units of thresholds (Default: '%') ('%', 'absolute') (Deprecated. Please use new counters directly)
=item B<--free>
Thresholds are on free space left (Deprecated. Please use new counters directly)
=item B<--swap>
Check swap also.
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%),
'swap' (B), 'swap-free' (B), 'swap-prct' (%),
'buffer' (B), 'cached' (B), 'shared' (B).
=back
=cut

View File

@ -0,0 +1,132 @@
#
# Copyright 2023 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 network::sonus::sbc::snmp::mode::storage;
use base qw(snmp_standard::mode::storage);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
return $self;
}
1;
__END__
=head1 MODE
=over 8
=item B<--warning-usage>
Threshold warning.
=item B<--critical-usage>
Threshold critical.
=item B<--warning-access>
Threshold warning.
=item B<--critical-access>
Threshold critical.
Check if storage is readOnly: --critical-access=readOnly
=item B<--add-access>
Check storage access (readOnly, readWrite).
=item B<--units>
Units of thresholds (Default: '%') ('%', 'B').
=item B<--free>
Thresholds are on free space left.
=item B<--storage>
Set the storage (number expected) ex: 1, 2,... (empty means 'check all storage').
=item B<--name>
Allows to use storage name with option --storage instead of storage oid index.
=item B<--regexp>
Allows to use regexp to filter storage (with option --name).
=item B<--regexp-isensitive>
Allows to use regexp non case-sensitive (with --regexp).
=item B<--path-best-match>
Allows to select best path mount point (with --name).
=item B<--reload-cache-time>
Time in minutes before reloading cache file (default: 180).
=item B<--oid-filter>
Choose OID used to filter storage (default: hrStorageDescr) (values: hrStorageDescr, hrFSMountPoint).
=item B<--oid-display>
Choose OID used to display storage (default: hrStorageDescr) (values: hrStorageDescr, hrFSMountPoint).
=item B<--display-transform-src>
Regexp src to transform display value. (security risk!!!)
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
=item B<--show-cache>
Display cache storage datas.
=item B<--space-reservation>
Some filesystem has space reserved (like ext4 for root).
The value is in percent of total (Default: none) (results like 'df' command).
=item B<--filter-duplicate>
Filter duplicate storages (in used size and total size).
=item B<--filter-storage-type>
Filter storage types with a regexp (Default: '^(hrStorageFixedDisk|hrStorageNetworkDisk|hrFSBerkeleyFFS)$').
=back
=cut

View File

@ -0,0 +1,57 @@
#
# Copyright 2023 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 network::sonus::sbc::snmp::mode::swap;
use base qw(snmp_standard::mode::swap);
use strict;
use warnings;
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options, force_new_perfdata => 1);
bless $self, $class;
return $self;
}
1;
__END__
=head1 MODE
Check swap memory (UCD-SNMP-MIB).
=over 8
=item B<--no-swap>
Threshold if no active swap (default: 'critical').
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%).
=back
=cut

View File

@ -29,20 +29,19 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$self->{version} = '1.0';
%{$self->{modes}} = (
$self->{modes} = {
'call-statistics' => 'network::sonus::sbc::snmp::mode::callstats',
'channels' => 'network::sonus::sbc::snmp::mode::channels',
'cpu' => 'snmp_standard::mode::cpu',
'cpu-detailed' => 'snmp_standard::mode::cpudetailed',
'cpu-detailed' => 'network::sonus::sbc::snmp::mode::cpudetailed',
'dsp-stats' => 'network::sonus::sbc::snmp::mode::dspstats',
'interfaces' => 'snmp_standard::mode::interfaces',
'interfaces' => 'network::sonus::sbc::snmp::mode::interfaces',
'list-interfaces' => 'snmp_standard::mode::listinterfaces',
'load' => 'snmp_standard::mode::loadaverage',
'memory' => 'snmp_standard::mode::memory',
'storage' => 'snmp_standard::mode::storage',
'swap' => 'snmp_standard::mode::swap',
);
'load' => 'network::sonus::sbc::snmp::mode::load',
'memory' => 'network::sonus::sbc::snmp::mode::memory',
'storage' => 'network::sonus::sbc::snmp::mode::storage',
'swap' => 'network::sonus::sbc::snmp::mode::swap'
};
return $self;
}