| 1 |
# |
| 2 |
# Copyright 2024 Centreon (http://www.centreon.com/) |
| 3 |
# |
| 4 |
# Centreon is a full-fledged industry-strength solution that meets |
| 5 |
# the needs in IT infrastructure and application monitoring for |
| 6 |
# service performance. |
| 7 |
# |
| 8 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 |
# you may not use this file except in compliance with the License. |
| 10 |
# You may obtain a copy of the License at |
| 11 |
# |
| 12 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 |
# |
| 14 |
# Unless required by applicable law or agreed to in writing, software |
| 15 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 |
# See the License for the specific language governing permissions and |
| 18 |
# limitations under the License. |
| 19 |
# |
| 20 |
|
| 21 |
package network::nokia::isam::snmp::mode::hubsapusage; |
| 22 |
|
| 23 |
use base qw(centreon::plugins::templates::counter); |
| 24 |
|
| 25 |
use strict; |
| 26 |
use warnings; |
| 27 |
use Digest::MD5 qw(md5_hex); |
| 28 |
use centreon::plugins::statefile; |
| 29 |
use centreon::plugins::templates::catalog_functions qw(catalog_status_threshold_ng); |
| 30 |
|
| 31 |
sub set_counters { |
| 32 |
my ($self, %options) = @_; |
| 33 |
|
| 34 |
$self->{maps_counters_type} = [ |
| 35 |
{ name => 'global', type => 0 }, |
| 36 |
{ name => 'sap', type => 1, cb_prefix_output => 'prefix_sap_output', message_multiple => 'All SAP are ok', skipped_code => { -10 => 1 } } |
| 37 |
]; |
| 38 |
|
| 39 |
$self->{maps_counters}->{sap} = [ |
| 40 |
{ label => 'status', type => 2, critical_default => '%{admin} =~ /up/i and %{status} !~ /up/i', set => { |
| 41 |
key_values => [ { name => 'status' }, { name => 'admin' }, { name => 'display' } ], |
| 42 |
closure_custom_output => $self->can('custom_status_output'), |
| 43 |
closure_custom_perfdata => sub { return 0; }, |
| 44 |
closure_custom_threshold_check => $self->can('custom_status_threshold') |
| 45 |
} |
| 46 |
}, |
| 47 |
{ label => 'in-traffic', nlabel => 'sap.traffic.in.bitspersecond', set => { |
| 48 |
key_values => [ { name => 'in', diff => 1 }, { name => 'display' } ], |
| 49 |
closure_custom_calc => $self->can('custom_sap_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, |
| 50 |
closure_custom_output => $self->can('custom_sap_output'), |
| 51 |
closure_custom_perfdata => $self->can('custom_sap_perfdata'), |
| 52 |
closure_custom_threshold_check => $self->can('custom_qsap_threshold') |
| 53 |
} |
| 54 |
}, |
| 55 |
{ label => 'out-traffic', nlabel => 'sap.traffic.out.bitspersecond', set => { |
| 56 |
key_values => [ { name => 'out', diff => 1 }, { name => 'display' } ], |
| 57 |
closure_custom_calc => $self->can('custom_sap_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, |
| 58 |
closure_custom_output => $self->can('custom_sap_output'), |
| 59 |
closure_custom_perfdata => $self->can('custom_sap_perfdata'), |
| 60 |
closure_custom_threshold_check => $self->can('custom_sap_threshold') |
| 61 |
} |
| 62 |
} |
| 63 |
]; |
| 64 |
|
| 65 |
$self->{maps_counters}->{global} = [ |
| 66 |
{ label => 'total-in-traffic', nlabel => 'sap.traffic.in.bitspersecond', set => { |
| 67 |
key_values => [], |
| 68 |
manual_keys => 1, |
| 69 |
closure_custom_calc => $self->can('custom_total_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, |
| 70 |
closure_custom_output => $self->can('custom_total_traffic_output'), |
| 71 |
closure_custom_perfdata => $self->can('custom_total_traffic_perfdata'), |
| 72 |
closure_custom_threshold_check => $self->can('custom_total_traffic_threshold') |
| 73 |
} |
| 74 |
}, |
| 75 |
{ label => 'total-out-traffic', nlabel => 'sap.traffic.out.bitspersecond', set => { |
| 76 |
key_values => [], |
| 77 |
manual_keys => 1, |
| 78 |
closure_custom_calc => $self->can('custom_total_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, |
| 79 |
closure_custom_output => $self->can('custom_total_traffic_output'), |
| 80 |
closure_custom_perfdata => $self->can('custom_total_traffic_perfdata'), |
| 81 |
closure_custom_threshold_check => $self->can('custom_total_traffic_threshold') |
| 82 |
} |
| 83 |
}, |
| 84 |
]; |
| 85 |
} |
| 86 |
|
| 87 |
sub custom_total_traffic_perfdata { |
| 88 |
my ($self, %options) = @_; |
| 89 |
|
| 90 |
my ($warning, $critical); |
| 91 |
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { |
| 92 |
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{speed}, cast_int => 1); |
| 93 |
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{speed}, cast_int => 1); |
| 94 |
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { |
| 95 |
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}); |
| 96 |
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}); |
| 97 |
} |
| 98 |
|
| 99 |
$self->{output}->perfdata_add( |
| 100 |
label => 'total_traffic_' . $self->{result_values}->{label}, unit => 'b/s', |
| 101 |
nlabel => $self->{nlabel}, |
| 102 |
value => sprintf("%.2f", $self->{result_values}->{total_traffic}), |
| 103 |
warning => $warning, |
| 104 |
critical => $critical, |
| 105 |
min => 0, max => $self->{result_values}->{speed} |
| 106 |
); |
| 107 |
} |
| 108 |
|
| 109 |
sub custom_total_traffic_threshold { |
| 110 |
my ($self, %options) = @_; |
| 111 |
|
| 112 |
my $exit = 'ok'; |
| 113 |
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { |
| 114 |
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); |
| 115 |
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { |
| 116 |
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{total_traffic}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); |
| 117 |
} |
| 118 |
return $exit; |
| 119 |
} |
| 120 |
|
| 121 |
sub custom_total_traffic_output { |
| 122 |
my ($self, %options) = @_; |
| 123 |
|
| 124 |
my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{total_traffic}, network => 1); |
| 125 |
my ($total_value, $total_unit); |
| 126 |
if (defined($self->{result_values}->{speed}) && $self->{result_values}->{speed} =~ /[0-9]/) { |
| 127 |
($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{speed}, network => 1); |
| 128 |
} |
| 129 |
|
| 130 |
return sprintf( |
| 131 |
"Total Traffic %s : %s/s (%s on %s)", |
| 132 |
ucfirst($self->{result_values}->{label}), $traffic_value . $traffic_unit, |
| 133 |
defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-', |
| 134 |
defined($total_value) ? $total_value . $total_unit : '-' |
| 135 |
); |
| 136 |
} |
| 137 |
|
| 138 |
sub custom_total_traffic_calc { |
| 139 |
my ($self, %options) = @_; |
| 140 |
|
| 141 |
my $total_traffic = 0; |
| 142 |
foreach (keys %{$options{new_datas}}) { |
| 143 |
if (/^global_traffic_$options{extra_options}->{label_ref}_/) { |
| 144 |
my $new_total = $options{new_datas}->{$_}; |
| 145 |
next if (!defined($options{old_datas}->{$_})); |
| 146 |
my $old_total = $options{old_datas}->{$_}; |
| 147 |
|
| 148 |
my $diff_traffic = $new_total - $old_total; |
| 149 |
if ($diff_traffic < 0) { |
| 150 |
$total_traffic += $old_total; |
| 151 |
} else { |
| 152 |
$total_traffic += $diff_traffic; |
| 153 |
} |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
$self->{result_values}->{label} = $options{extra_options}->{label_ref}; |
| 158 |
$self->{result_values}->{total_traffic} = $total_traffic / $options{delta_time}; |
| 159 |
if (defined($self->{instance_mode}->{option_results}->{'speed_total_' . $self->{result_values}->{label}}) && $self->{instance_mode}->{option_results}->{'speed_total_' . $self->{result_values}->{label}} =~ /[0-9]/) { |
| 160 |
$self->{result_values}->{traffic_prct} = $self->{result_values}->{total_traffic} * 100 / ($self->{instance_mode}->{option_results}->{'speed_total_' . $self->{result_values}->{label}} * 1000 * 1000); |
| 161 |
$self->{result_values}->{speed} = $self->{instance_mode}->{option_results}->{'speed_total_' . $self->{result_values}->{label}} * 1000 * 1000; |
| 162 |
} |
| 163 |
return 0; |
| 164 |
} |
| 165 |
|
| 166 |
sub custom_status_threshold { |
| 167 |
my ($self, %options) = @_; |
| 168 |
|
| 169 |
my $status = catalog_status_threshold_ng($self, %options); |
| 170 |
$self->{instance_mode}->{last_status} = 0; |
| 171 |
if ($self->{result_values}->{admin} eq 'up') { |
| 172 |
$self->{instance_mode}->{last_status} = 1; |
| 173 |
} |
| 174 |
return $status; |
| 175 |
} |
| 176 |
|
| 177 |
sub custom_status_output { |
| 178 |
my ($self, %options) = @_; |
| 179 |
|
| 180 |
return 'Status : ' . $self->{result_values}->{status} . ' (admin: ' . $self->{result_values}->{admin} . ')'; |
| 181 |
} |
| 182 |
|
| 183 |
sub custom_sap_perfdata { |
| 184 |
my ($self, %options) = @_; |
| 185 |
|
| 186 |
my ($warning, $critical); |
| 187 |
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { |
| 188 |
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{speed}, cast_int => 1); |
| 189 |
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{speed}, cast_int => 1); |
| 190 |
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { |
| 191 |
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}); |
| 192 |
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}); |
| 193 |
} |
| 194 |
|
| 195 |
$self->{output}->perfdata_add( |
| 196 |
label => 'traffic_' . $self->{result_values}->{label}, unit => 'b/s', |
| 197 |
nlabel => $self->{nlabel}, |
| 198 |
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef, |
| 199 |
value => sprintf("%.2f", $self->{result_values}->{traffic}), |
| 200 |
warning => $warning, |
| 201 |
critical => $critical, |
| 202 |
min => 0, max => $self->{result_values}->{speed} |
| 203 |
); |
| 204 |
} |
| 205 |
|
| 206 |
sub custom_sap_threshold { |
| 207 |
my ($self, %options) = @_; |
| 208 |
|
| 209 |
my $exit = 'ok'; |
| 210 |
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) { |
| 211 |
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); |
| 212 |
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') { |
| 213 |
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]); |
| 214 |
} |
| 215 |
return $exit; |
| 216 |
} |
| 217 |
|
| 218 |
sub custom_sap_output { |
| 219 |
my ($self, %options) = @_; |
| 220 |
|
| 221 |
my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic}, network => 1); |
| 222 |
my ($total_value, $total_unit); |
| 223 |
if (defined($self->{result_values}->{speed}) && $self->{result_values}->{speed} =~ /[0-9]/) { |
| 224 |
($total_value, $total_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{speed}, network => 1); |
| 225 |
} |
| 226 |
|
| 227 |
return sprintf( |
| 228 |
"Traffic %s : %s/s (%s on %s)", |
| 229 |
ucfirst($self->{result_values}->{label}), $traffic_value . $traffic_unit, |
| 230 |
defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-', |
| 231 |
defined($total_value) ? $total_value . $total_unit : '-' |
| 232 |
); |
| 233 |
} |
| 234 |
|
| 235 |
sub custom_sap_calc { |
| 236 |
my ($self, %options) = @_; |
| 237 |
|
| 238 |
return -10 if (defined($self->{instance_mode}->{last_status}) && $self->{instance_mode}->{last_status} == 0); |
| 239 |
$self->{result_values}->{label} = $options{extra_options}->{label_ref}; |
| 240 |
$self->{result_values}->{display} = $options{new_datas}->{$self->{instance} . '_display'}; |
| 241 |
$self->{result_values}->{traffic} = ($options{new_datas}->{$self->{instance} . '_' . $self->{result_values}->{label}} - $options{old_datas}->{$self->{instance} . '_' . $self->{result_values}->{label}}) / $options{delta_time}; |
| 242 |
if (defined($self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}}) && $self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} =~ /[0-9]/) { |
| 243 |
$self->{result_values}->{traffic_prct} = $self->{result_values}->{traffic} * 100 / ($self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000); |
| 244 |
$self->{result_values}->{speed} = $self->{instance_mode}->{option_results}->{'speed_' . $self->{result_values}->{label}} * 1000 * 1000; |
| 245 |
} |
| 246 |
return 0; |
| 247 |
} |
| 248 |
|
| 249 |
sub new { |
| 250 |
my ($class, %options) = @_; |
| 251 |
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1); |
| 252 |
bless $self, $class; |
| 253 |
|
| 254 |
$options{options}->add_options(arguments => { |
| 255 |
'reload-cache-time:s' => { name => 'reload_cache_time', default => 300 }, |
| 256 |
'display-name:s' => { name => 'display_name', default => '%{SvcDescription}.%{IfName}.%{SapEncapName}' }, |
| 257 |
'filter-name:s' => { name => 'filter_name' }, |
| 258 |
'speed-in:s' => { name => 'speed_in' }, |
| 259 |
'speed-out:s' => { name => 'speed_out' }, |
| 260 |
'speed-total-in:s' => { name => 'speed_total_in' }, |
| 261 |
'speed-total-out:s' => { name => 'speed_total_out' }, |
| 262 |
'units-traffic:s' => { name => 'units_traffic', default => '%' } |
| 263 |
}); |
| 264 |
|
| 265 |
$self->{statefile_cache} = centreon::plugins::statefile->new(%options); |
| 266 |
return $self; |
| 267 |
} |
| 268 |
|
| 269 |
sub check_options { |
| 270 |
my ($self, %options) = @_; |
| 271 |
$self->SUPER::check_options(%options); |
| 272 |
|
| 273 |
$self->{statefile_cache}->check_options(%options); |
| 274 |
} |
| 275 |
|
| 276 |
sub prefix_sap_output { |
| 277 |
my ($self, %options) = @_; |
| 278 |
|
| 279 |
return "SAP '" . $options{instance_value}->{display} . "' "; |
| 280 |
} |
| 281 |
|
| 282 |
sub get_display_name { |
| 283 |
my ($self, %options) = @_; |
| 284 |
|
| 285 |
my $display_name = $self->{option_results}->{display_name}; |
| 286 |
$display_name =~ s/%\{(.*?)\}/$options{$1}/ge; |
| 287 |
return $display_name; |
| 288 |
} |
| 289 |
|
| 290 |
my %map_admin = (1 => 'up', 2 => 'down'); |
| 291 |
my %map_oper = (1 => 'up', 2 => 'down', 3 => 'ingressQosMismatch', |
| 292 |
4 => 'egressQosMismatch', 5 => 'portMtuTooSmall', 6 => 'svcAdminDown', |
| 293 |
7 => 'iesIfAdminDown' |
| 294 |
); |
| 295 |
|
| 296 |
my $mapping = { |
| 297 |
sapAdminStatus => { oid => '.1.3.6.1.4.1.6527.3.1.2.4.3.2.1.6', map => \%map_admin }, |
| 298 |
sapOperStatus => { oid => '.1.3.6.1.4.1.6527.3.1.2.4.3.2.1.7', map => \%map_oper }, |
| 299 |
fadSapStatsIngressOctets => { oid => '.1.3.6.1.4.1.637.61.1.85.17.2.2.1.2' }, |
| 300 |
fadSapStatsEgressOctets => { oid => '.1.3.6.1.4.1.637.61.1.85.17.2.2.1.4' }, |
| 301 |
}; |
| 302 |
|
| 303 |
my $oid_sapDescription = '.1.3.6.1.4.1.6527.3.1.2.4.3.2.1.5'; |
| 304 |
my $oid_svcDescription = '.1.3.6.1.4.1.6527.3.1.2.4.2.2.1.6'; |
| 305 |
my $oid_ifName = '.1.3.6.1.2.1.31.1.1.1.1'; |
| 306 |
|
| 307 |
sub reload_cache { |
| 308 |
my ($self, %options) = @_; |
| 309 |
|
| 310 |
my $datas = { last_timestamp => time() }; |
| 311 |
my $snmp_result = $options{snmp}->get_multiple_table( |
| 312 |
oids => [ |
| 313 |
{ oid => $oid_sapDescription }, |
| 314 |
{ oid => $oid_svcDescription }, |
| 315 |
{ oid => $oid_ifName } |
| 316 |
], |
| 317 |
nothing_quit => 1 |
| 318 |
); |
| 319 |
$datas->{snmp_result} = $snmp_result; |
| 320 |
|
| 321 |
if (scalar(keys %{$datas->{snmp_result}->{$oid_sapDescription}}) <= 0) { |
| 322 |
$self->{output}->add_option_msg(short_msg => "Can't construct cache..."); |
| 323 |
$self->{output}->option_exit(); |
| 324 |
} |
| 325 |
|
| 326 |
$self->{statefile_cache}->write(data => $datas); |
| 327 |
} |
| 328 |
|
| 329 |
sub manage_selection { |
| 330 |
my ($self, %options) = @_; |
| 331 |
|
| 332 |
if ($options{snmp}->is_snmpv1()) { |
| 333 |
$self->{output}->add_option_msg(short_msg => "Need to use SNMP v2c or v3."); |
| 334 |
$self->{output}->option_exit(); |
| 335 |
} |
| 336 |
|
| 337 |
my $has_cache_file = $self->{statefile_cache}->read(statefile => 'cache_nokia_isam_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode}); |
| 338 |
my $timestamp_cache = $self->{statefile_cache}->get(name => 'last_timestamp'); |
| 339 |
if ($has_cache_file == 0 || !defined($timestamp_cache) || |
| 340 |
((time() - $timestamp_cache) > (($self->{option_results}->{reload_cache_time}) * 60))) { |
| 341 |
$self->reload_cache(%options); |
| 342 |
$self->{statefile_cache}->read(); |
| 343 |
} |
| 344 |
|
| 345 |
my $snmp_result = $self->{statefile_cache}->get(name => 'snmp_result'); |
| 346 |
|
| 347 |
$self->{global} = {}; |
| 348 |
$self->{sap} = {}; |
| 349 |
foreach my $oid (keys %{$snmp_result->{$oid_sapDescription}}) { |
| 350 |
next if ($oid !~ /^$oid_sapDescription\.(.*?)\.(.*?)\.(.*?)$/); |
| 351 |
# $SvcId and $SapEncapValue is the same. We use service table |
| 352 |
my ($SvcId, $SapPortId, $SapEncapValue) = ($1, $2, $3); |
| 353 |
my $instance = $SvcId . '.' . $SapPortId . '.' . $SapEncapValue; |
| 354 |
|
| 355 |
my $SapDescription = $snmp_result->{$oid_sapDescription}->{$oid} ne '' ? |
| 356 |
$snmp_result->{$oid_sapDescription}->{$oid} : 'unknown'; |
| 357 |
my $SvcDescription = defined($snmp_result->{$oid_svcDescription}->{$oid_svcDescription . '.' . $SvcId}) && $snmp_result->{$oid_svcDescription}->{$oid_svcDescription . '.' . $SvcId} ne '' ? |
| 358 |
$snmp_result->{$oid_svcDescription}->{$oid_svcDescription . '.' . $SvcId} : $SvcId; |
| 359 |
my $IfName = defined($snmp_result->{$oid_ifName}->{$oid_ifName . '.' . $SapPortId}) && $snmp_result->{$oid_ifName}->{$oid_ifName . '.' . $SapPortId} ne '' ? |
| 360 |
$snmp_result->{$oid_ifName}->{$oid_ifName . '.' . $SapPortId} : $SapPortId; |
| 361 |
my $SapEncapName = defined($snmp_result->{$oid_svcDescription}->{$oid_svcDescription . '.' . $SapEncapValue}) && $snmp_result->{$oid_svcDescription}->{$oid_svcDescription . '.' . $SapEncapValue} ne '' ? |
| 362 |
$snmp_result->{$oid_svcDescription}->{$oid_svcDescription . '.' . $SapEncapValue} : $SapEncapValue; |
| 363 |
|
| 364 |
my $name = $self->get_display_name( |
| 365 |
SapDescription => $SapDescription, |
| 366 |
SvcDescription => $SvcDescription, |
| 367 |
SapEncapName => $SapEncapName, |
| 368 |
IfName => $IfName, |
| 369 |
SvcId => $SvcId, |
| 370 |
SapPortId => $SapPortId, |
| 371 |
SapEncapValue => $SapEncapValue |
| 372 |
); |
| 373 |
|
| 374 |
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' && |
| 375 |
$name !~ /$self->{option_results}->{filter_name}/) { |
| 376 |
$self->{output}->output_add(long_msg => "skipping '" . $name . "': no matching filter.", debug => 1); |
| 377 |
next; |
| 378 |
} |
| 379 |
|
| 380 |
$self->{sap}->{$instance} = { display => $name }; |
| 381 |
} |
| 382 |
|
| 383 |
$options{snmp}->load(oids => [$mapping->{fadSapStatsIngressOctets}->{oid}, |
| 384 |
$mapping->{fadSapStatsEgressOctets}->{oid}, |
| 385 |
$mapping->{sapAdminStatus}->{oid}, $mapping->{sapOperStatus}->{oid}], |
| 386 |
instances => [keys %{$self->{sap}}], instance_regexp => '(\d+\.\d+\.\d+)$' |
| 387 |
); |
| 388 |
|
| 389 |
$snmp_result = $options{snmp}->get_leef(nothing_quit => 1); |
| 390 |
|
| 391 |
foreach (keys %{$self->{sap}}) { |
| 392 |
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); |
| 393 |
$self->{sap}->{$_}->{in} = $result->{fadSapStatsIngressOctets} * 8; |
| 394 |
$self->{sap}->{$_}->{out} = $result->{fadSapStatsEgressOctets} * 8; |
| 395 |
$self->{sap}->{$_}->{status} = $result->{sapOperStatus}; |
| 396 |
$self->{sap}->{$_}->{admin} = $result->{sapAdminStatus}; |
| 397 |
|
| 398 |
$self->{global}->{'traffic_in_' . $_} = $result->{fadSapStatsIngressOctets} * 8; |
| 399 |
$self->{global}->{'traffic_out_' . $_} = $result->{fadSapStatsEgressOctets} * 8; |
| 400 |
} |
| 401 |
|
| 402 |
if (scalar(keys %{$self->{sap}}) <= 0) { |
| 403 |
$self->{output}->add_option_msg(short_msg => "No SAP found."); |
| 404 |
$self->{output}->option_exit(); |
| 405 |
} |
| 406 |
|
| 407 |
$self->{cache_name} = 'nokia_isam_' . $self->{mode} . '_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . |
| 408 |
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all')) . '_' . |
| 409 |
(defined($self->{option_results}->{filter_name}) ? md5_hex($self->{option_results}->{filter_name}) : md5_hex('all')); |
| 410 |
} |
| 411 |
|
| 412 |
1; |
| 413 |
|
| 414 |
__END__ |
| 415 |
|
| 416 |
=head1 MODE |
| 417 |
|
| 418 |
Check Service Access Points (SAP) QoS usage. |
| 419 |
|
| 420 |
=over 8 |
| 421 |
|
| 422 |
=item B<--display-name> |
| 423 |
|
| 424 |
Define the name to display (default: '%{SvcDescription}.%{IfName}.%{SapEncapName}'). |
| 425 |
Other available macros: %{SapDescription}, %{SapPortId} |
| 426 |
|
| 427 |
=item B<--filter-name> |
| 428 |
|
| 429 |
Filter by Service Access Point (SAP) name (can be a regexp). |
| 430 |
|
| 431 |
=item B<--speed-in> |
| 432 |
|
| 433 |
Define the actual maximum incoming traffic speed you can have on the interfaces in megabits per second. |
| 434 |
|
| 435 |
=item B<--speed-out> |
| 436 |
|
| 437 |
Define the actual maximum outgoing traffic speed you can have on the interfaces in megabits per second. |
| 438 |
|
| 439 |
=item B<--speed-total-in> |
| 440 |
|
| 441 |
Define the actual maximum total incoming traffic speed you can have on the interfaces in megabits per second. |
| 442 |
|
| 443 |
=item B<--speed-total-out> |
| 444 |
|
| 445 |
Define the actual maximum total outgoing traffic speed you can have on the interfaces in megabits per second. |
| 446 |
|
| 447 |
=item B<--units-traffic> |
| 448 |
|
| 449 |
Define the unit to use to apply to thresholds (default: '%') ('%', 'b/s'). |
| 450 |
|
| 451 |
=item B<--warning-status> |
| 452 |
|
| 453 |
Define the conditions to match for the status to be WARNING. |
| 454 |
You can use the following variables: %{admin}, %{status}, %{display} |
| 455 |
|
| 456 |
=item B<--critical-status> |
| 457 |
|
| 458 |
Define the conditions to match for the status to be CRITICAL. |
| 459 |
Default: '%{admin} =~ /up/i and %{status} !~ /up/i'. |
| 460 |
You can use the following variables: %{admin}, %{status}, %{display} |
| 461 |
|
| 462 |
=item B<--warning-*> |
| 463 |
|
| 464 |
Warning thresholds for: 'total-in-traffic', 'total-out-traffic', 'in-traffic', 'out-traffic'. |
| 465 |
|
| 466 |
=item B<--critical-*> |
| 467 |
|
| 468 |
Critical thresholds for: 'total-in-traffic', 'total-out-traffic', 'in-traffic', 'out-traffic'. |
| 469 |
|
| 470 |
=item B<--reload-cache-time> |
| 471 |
|
| 472 |
Time in seconds before reloading the cache file (default: 300). |
| 473 |
|
| 474 |
=back |
| 475 |
|
| 476 |
=cut |