use bigint for qos usage
This commit is contained in:
parent
c30c282364
commit
4e88d5eaac
|
@ -25,6 +25,7 @@ use base qw(centreon::plugins::templates::counter);
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Digest::MD5 qw(md5_hex);
|
use Digest::MD5 qw(md5_hex);
|
||||||
|
use bigint;
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
@ -32,7 +33,7 @@ sub set_counters {
|
||||||
$self->{maps_counters_type} = [
|
$self->{maps_counters_type} = [
|
||||||
{ name => 'total', type => 0 },
|
{ name => 'total', type => 0 },
|
||||||
{ name => 'interface_classmap', type => 1, cb_prefix_output => 'prefix_intcmap_output', message_multiple => 'All interface classmaps are ok' },
|
{ name => 'interface_classmap', type => 1, cb_prefix_output => 'prefix_intcmap_output', message_multiple => 'All interface classmaps are ok' },
|
||||||
{ name => 'classmap', type => 1, cb_prefix_output => 'prefix_cmap_output', message_multiple => 'All classmaps are ok' },
|
{ name => 'classmap', type => 1, cb_prefix_output => 'prefix_cmap_output', message_multiple => 'All classmaps are ok' }
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{interface_classmap} = [
|
$self->{maps_counters}->{interface_classmap} = [
|
||||||
|
@ -42,7 +43,7 @@ sub set_counters {
|
||||||
closure_custom_calc => $self->can('custom_traffic_calc'),
|
closure_custom_calc => $self->can('custom_traffic_calc'),
|
||||||
closure_custom_output => $self->can('custom_traffic_output'),
|
closure_custom_output => $self->can('custom_traffic_output'),
|
||||||
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
closure_custom_perfdata => $self->can('custom_traffic_perfdata'),
|
||||||
closure_custom_threshold_check => $self->can('custom_traffic_threshold'),
|
closure_custom_threshold_check => $self->can('custom_traffic_threshold')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'int-cmap-drop', set => {
|
{ label => 'int-cmap-drop', set => {
|
||||||
|
@ -51,10 +52,10 @@ sub set_counters {
|
||||||
output_template => 'Drop : %s %s/s',
|
output_template => 'Drop : %s %s/s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'icmap_drop', value => 'drop_usage_per_second', template => '%d',
|
{ label => 'icmap_drop', value => 'drop_usage_per_second', template => '%d',
|
||||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
$self->{maps_counters}->{classmap} = [
|
$self->{maps_counters}->{classmap} = [
|
||||||
{ label => 'cmap-traffic', set => {
|
{ label => 'cmap-traffic', set => {
|
||||||
|
@ -63,8 +64,8 @@ sub set_counters {
|
||||||
output_template => 'Traffic : %s %s/s',
|
output_template => 'Traffic : %s %s/s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'cmap_traffic', value => 'traffic_usage_per_second', template => '%d',
|
{ label => 'cmap_traffic', value => 'traffic_usage_per_second', template => '%d',
|
||||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'cmap-drop', set => {
|
{ label => 'cmap-drop', set => {
|
||||||
|
@ -73,11 +74,12 @@ sub set_counters {
|
||||||
output_template => 'Drop : %s %s/s',
|
output_template => 'Drop : %s %s/s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'cmap_drop', value => 'drop_usage_per_second', template => '%d',
|
{ label => 'cmap_drop', value => 'drop_usage_per_second', template => '%d',
|
||||||
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'b/s', min => 0, label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{total} = [
|
$self->{maps_counters}->{total} = [
|
||||||
{ label => 'total-traffic', set => {
|
{ label => 'total-traffic', set => {
|
||||||
key_values => [ { name => 'traffic_usage', diff => 1 } ],
|
key_values => [ { name => 'traffic_usage', diff => 1 } ],
|
||||||
|
@ -85,8 +87,8 @@ sub set_counters {
|
||||||
output_template => 'Total Traffic : %s %s/s',
|
output_template => 'Total Traffic : %s %s/s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'total_traffic', value => 'traffic_usage_per_second', template => '%d',
|
{ label => 'total_traffic', value => 'traffic_usage_per_second', template => '%d',
|
||||||
unit => 'b/s', min => 0 },
|
unit => 'b/s', min => 0 }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'total-drop', set => {
|
{ label => 'total-drop', set => {
|
||||||
|
@ -95,10 +97,10 @@ sub set_counters {
|
||||||
output_template => 'Total Drop : %s %s/s',
|
output_template => 'Total Drop : %s %s/s',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ label => 'total_drop', value => 'drop_usage_per_second', template => '%d',
|
{ label => 'total_drop', value => 'drop_usage_per_second', template => '%d',
|
||||||
unit => 'b/s', min => 0 },
|
unit => 'b/s', min => 0 }
|
||||||
],
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,10 +144,11 @@ sub custom_traffic_output {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_seconds}, network => 1);
|
my ($traffic_value, $traffic_unit) = $self->{perfdata}->change_bytes(value => $self->{result_values}->{traffic_per_seconds}, network => 1);
|
||||||
my $msg = sprintf("Traffic : %s/s (%s)",
|
return sprintf(
|
||||||
|
'Traffic : %s/s (%s)',
|
||||||
$traffic_value . $traffic_unit,
|
$traffic_value . $traffic_unit,
|
||||||
defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-');
|
defined($self->{result_values}->{traffic_prct}) ? sprintf("%.2f%%", $self->{result_values}->{traffic_prct}) : '-'
|
||||||
return $msg;
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub custom_traffic_calc {
|
sub custom_traffic_calc {
|
||||||
|
@ -182,10 +185,10 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
"filter-source:s" => { name => 'filter_source' },
|
'filter-source:s' => { name => 'filter_source' },
|
||||||
"oid-filter:s" => { name => 'oid_filter', default => 'ifname' },
|
'oid-filter:s' => { name => 'oid_filter', default => 'ifname' },
|
||||||
"oid-display:s" => { name => 'oid_display', default => 'ifname' },
|
'oid-display:s' => { name => 'oid_display', default => 'ifname' },
|
||||||
"units-traffic:s" => { name => 'units_traffic', default => '%' },
|
'units-traffic:s' => { name => 'units_traffic', default => '%' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -218,23 +221,20 @@ sub check_oids_label {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $mapping = {
|
my $mapping = {
|
||||||
cbQosCMPrePolicyByteOverflow => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.4' },
|
|
||||||
cbQosCMPrePolicyByte => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.5' },
|
|
||||||
cbQosCMPrePolicyByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.6' },
|
|
||||||
cbQosCMPostPolicyByteOverflow => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.8' },
|
cbQosCMPostPolicyByteOverflow => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.8' },
|
||||||
cbQosCMPostPolicyByte => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.9' },
|
cbQosCMPostPolicyByte => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.9' },
|
||||||
cbQosCMPostPolicyByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.10' },
|
cbQosCMPostPolicyByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.10' },
|
||||||
cbQosCMDropByteOverflow => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.15' },
|
cbQosCMDropByteOverflow => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.15' },
|
||||||
cbQosCMDropByte => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.16' },
|
cbQosCMDropByte => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.16' },
|
||||||
cbQosCMDropByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.17' },
|
cbQosCMDropByte64 => { oid => '.1.3.6.1.4.1.9.9.166.1.15.1.1.17' }
|
||||||
};
|
};
|
||||||
my $mapping2 = {
|
my $mapping2 = {
|
||||||
cbQosTSCfgRate => { oid => '.1.3.6.1.4.1.9.9.166.1.13.1.1.1' }, # bps
|
cbQosTSCfgRate => { oid => '.1.3.6.1.4.1.9.9.166.1.13.1.1.1' }, # bps
|
||||||
cbQosTSCfgRate64 => { oid => '.1.3.6.1.4.1.9.9.166.1.13.1.1.11' }, # bps
|
cbQosTSCfgRate64 => { oid => '.1.3.6.1.4.1.9.9.166.1.13.1.1.11' } # bps
|
||||||
};
|
};
|
||||||
my $mapping3 = {
|
my $mapping3 = {
|
||||||
cbQosQueueingCfgBandwidth => { oid => '.1.3.6.1.4.1.9.9.166.1.9.1.1.1' },
|
cbQosQueueingCfgBandwidth => { oid => '.1.3.6.1.4.1.9.9.166.1.9.1.1.1' },
|
||||||
cbQosQueueingCfgBandwidthUnits => { oid => '.1.3.6.1.4.1.9.9.166.1.9.1.1.2' },
|
cbQosQueueingCfgBandwidthUnits => { oid => '.1.3.6.1.4.1.9.9.166.1.9.1.1.2' }
|
||||||
};
|
};
|
||||||
|
|
||||||
my $oid_cbQosIfIndex = '.1.3.6.1.4.1.9.9.166.1.1.1.1.4';
|
my $oid_cbQosIfIndex = '.1.3.6.1.4.1.9.9.166.1.1.1.1.4';
|
||||||
|
@ -294,9 +294,9 @@ sub manage_selection {
|
||||||
{ oid => $oid_cbQosConfigIndex },
|
{ oid => $oid_cbQosConfigIndex },
|
||||||
{ oid => $oid_cbQosCMName },
|
{ oid => $oid_cbQosCMName },
|
||||||
{ oid => $oid_cbQosQueueingCfgEntry, end => $mapping3->{cbQosQueueingCfgBandwidthUnits}->{oid} },
|
{ oid => $oid_cbQosQueueingCfgEntry, end => $mapping3->{cbQosQueueingCfgBandwidthUnits}->{oid} },
|
||||||
{ oid => $oid_cbQosCMStatsEntry, start => $mapping->{cbQosCMPrePolicyByteOverflow}->{oid}, end => $mapping->{cbQosCMDropByte64}->{oid} },
|
{ oid => $oid_cbQosCMStatsEntry, start => $mapping->{cbQosCMPostPolicyByteOverflow}->{oid}, end => $mapping->{cbQosCMDropByte64}->{oid} },
|
||||||
{ oid => $oid_cbQosParentObjectsIndex },
|
{ oid => $oid_cbQosParentObjectsIndex },
|
||||||
{ oid => $oid_cbQosTSCfgEntry, end => $mapping2->{cbQosTSCfgRate64}->{oid} },
|
{ oid => $oid_cbQosTSCfgEntry, end => $mapping2->{cbQosTSCfgRate64}->{oid} }
|
||||||
];
|
];
|
||||||
push @$request_oids, { oid => $self->{oids_label}->{$self->{option_results}->{oid_display}} }
|
push @$request_oids, { oid => $self->{oids_label}->{$self->{option_results}->{oid_display}} }
|
||||||
if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display});
|
if ($self->{option_results}->{oid_filter} ne $self->{option_results}->{oid_display});
|
||||||
|
@ -321,7 +321,7 @@ sub manage_selection {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (keys %{$self->{results}->{$oid_cbQosCMStatsEntry}}) {
|
foreach (keys %{$self->{results}->{$oid_cbQosCMStatsEntry}}) {
|
||||||
next if (!/$mapping->{cbQosCMPrePolicyByte}->{oid}\.(\d+)\.(\d+)/);
|
next if (!/$mapping->{cbQosCMPostPolicyByteOverflow}->{oid}\.(\d+)\.(\d+)/);
|
||||||
|
|
||||||
my ($policy_index, $qos_object_index) = ($1, $2);
|
my ($policy_index, $qos_object_index) = ($1, $2);
|
||||||
|
|
||||||
|
@ -338,8 +338,13 @@ sub manage_selection {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $qos_data = $self->build_qos_information(class_name => $class_name, policy_index => $policy_index, object_index => $qos_object_index,
|
my $qos_data = $self->build_qos_information(
|
||||||
link_queueing => $link_queueing, link_shaping => $link_shaping);
|
class_name => $class_name,
|
||||||
|
policy_index => $policy_index,
|
||||||
|
object_index => $qos_object_index,
|
||||||
|
link_queueing => $link_queueing,
|
||||||
|
link_shaping => $link_shaping
|
||||||
|
);
|
||||||
|
|
||||||
my $interface_filter = $self->{results}->{$self->{oids_label}->{$self->{option_results}->{oid_filter}}}->{$self->{oids_label}->{$self->{option_results}->{oid_filter}} . '.' . $if_index};
|
my $interface_filter = $self->{results}->{$self->{oids_label}->{$self->{option_results}->{oid_filter}}}->{$self->{oids_label}->{$self->{option_results}->{oid_filter}} . '.' . $if_index};
|
||||||
my $name = $interface_filter . ':' . $qos_data->{complete_name};
|
my $name = $interface_filter . ':' . $qos_data->{complete_name};
|
||||||
|
@ -369,7 +374,9 @@ sub manage_selection {
|
||||||
|
|
||||||
$self->{interface_classmap}->{$policy_index . '.' . $qos_object_index} = {
|
$self->{interface_classmap}->{$policy_index . '.' . $qos_object_index} = {
|
||||||
display => $name,
|
display => $name,
|
||||||
traffic_usage => $traffic_usage * 8, drop_usage => $drop_usage * 8, total => $total
|
traffic_usage => $traffic_usage * 8,
|
||||||
|
drop_usage => $drop_usage * 8,
|
||||||
|
total => $total
|
||||||
};
|
};
|
||||||
|
|
||||||
my @tabname = split /:/, $name;
|
my @tabname = split /:/, $name;
|
||||||
|
@ -387,12 +394,12 @@ sub manage_selection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{cache_name} = "cisco_qos_" . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
$self->{cache_name} = 'cisco_qos_' . $options{snmp}->get_hostname() . '_' . $options{snmp}->get_port() . '_' . $self->{mode} . '_' .
|
||||||
(defined($self->{option_results}->{filter_source}) ? md5_hex($self->{option_results}->{filter_source}) : md5_hex('all')) . '_' .
|
(defined($self->{option_results}->{filter_source}) ? md5_hex($self->{option_results}->{filter_source}) : md5_hex('all')) . '_' .
|
||||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||||
|
|
||||||
if (scalar(keys %{$self->{interface_classmap}}) <= 0 && !defined($options{disco})) {
|
if (scalar(keys %{$self->{interface_classmap}}) <= 0 && !defined($options{disco})) {
|
||||||
$self->{output}->add_option_msg(short_msg => "Cannot found classmap.");
|
$self->{output}->add_option_msg(short_msg => 'Cannot found classmap.');
|
||||||
$self->{output}->option_exit();
|
$self->{output}->option_exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue