use instance with no tag name

This commit is contained in:
garnier-quentin 2019-11-08 16:14:06 +01:00
parent a517476b00
commit aec242ca0e
1 changed files with 146 additions and 124 deletions

View File

@ -36,7 +36,8 @@ sub set_counters {
];
$self->{maps_counters}->{tag} = [
{ label => 'status', threshold => 0, set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' },
{ name => 'rttMonCtrlAdminTag' },
{ name => 'rttMonCtrlAdminRttType' },
{ name => 'rttMonCtrlAdminThreshold' },
@ -52,7 +53,8 @@ sub set_counters {
}
},
{ label => 'CompletionTime', set => {
key_values => [ { name => 'rttMonLatestRttOperCompletionTime' }, { name => 'rttMonEchoAdminPrecision' }, { name => 'rttMonCtrlAdminTag' }
key_values => [
{ name => 'rttMonLatestRttOperCompletionTime' }, { name => 'rttMonEchoAdminPrecision' }, { name => 'rttMonCtrlAdminTag' }
],
output_template => 'Completion Time : %s',
perfdatas => [
@ -62,7 +64,8 @@ sub set_counters {
}
},
{ label => 'NumberOverThresholds', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'OverThresholds_1' }, { name => 'OverThresholds_2' }, { name => 'OverThresholds_times' },
],
closure_custom_calc => $self->can('custom_NumberOverThresholds_calc'),
@ -76,7 +79,8 @@ sub set_counters {
}
},
{ label => 'AverageDelaySD', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'OWSumSD_1' }, { name => 'OWSumSD_2' }, { name => 'OWSumSD_times' },
{ name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' },
],
@ -106,7 +110,8 @@ sub set_counters {
}
},
{ label => 'PacketLossRatio', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'PacketLossDS_1' }, { name => 'PacketLossDS_2' }, { name => 'PacketLossDS_times' },
{ name => 'PacketLossSD_1' }, { name => 'PacketLossSD_2' }, { name => 'PacketLossSD_times' },
{ name => 'PacketMIA_1' }, { name => 'PacketMIA_2' }, { name => 'PacketMIA_times' },
@ -125,7 +130,8 @@ sub set_counters {
}
},
{ label => 'PercentagePacketsPositiveJitter', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'NumOfPositivesSD_1' }, { name => 'NumOfPositivesSD_2' }, { name => 'NumOfPositivesSD_times' },
{ name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
],
@ -140,7 +146,8 @@ sub set_counters {
}
},
{ label => 'AverageJitterPerPacketPositiveJitter', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' },
{ name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
],
@ -155,7 +162,8 @@ sub set_counters {
}
},
{ label => 'PercentagePacketsNegativeJitter', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'NumOfNegativesSD_1' }, { name => 'NumOfNegativesSD_2' }, { name => 'NumOfNegativesSD_times' },
{ name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
],
@ -170,7 +178,8 @@ sub set_counters {
}
},
{ label => 'AverageJitterPerPacketNegativeJitter', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'SumOfNegativesSD_1' }, { name => 'SumOfNegativesSD_2' }, { name => 'SumOfNegativesSD_times' },
{ name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
],
@ -185,7 +194,8 @@ sub set_counters {
}
},
{ label => 'AverageJitter', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'SumOfPositivesDS_1' }, { name => 'SumOfPositivesDS_2' }, { name => 'SumOfPositivesDS_times' },
{ name => 'SumOfNegativesDS_1' }, { name => 'SumOfNegativesDS_2' }, { name => 'SumOfNegativesDS_times' },
{ name => 'SumOfPositivesSD_1' }, { name => 'SumOfPositivesSD_2' }, { name => 'SumOfPositivesSD_times' },
@ -206,7 +216,8 @@ sub set_counters {
}
},
{ label => 'RTTStandardDeviation', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'RTTSum2High_1' }, { name => 'RTTSum2High_2' }, { name => 'RTTSum2High_times' },
{ name => 'RTTSum2Low_1' }, { name => 'RTTSum2Low_2' }, { name => 'RTTSum2Low_times' },
{ name => 'NumOfRTT_1' }, { name => 'NumOfRTT_2' }, { name => 'NumOfRTT_times' },
@ -223,7 +234,8 @@ sub set_counters {
}
},
{ label => 'DelaySource2DestinationStandardDeviation', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'OWSum2SDHigh_1' }, { name => 'OWSum2SDHigh_2' }, { name => 'OWSum2SDHigh_times' },
{ name => 'OWSum2SDLow_1' }, { name => 'OWSum2SDLow_2' }, { name => 'OWSum2SDLow_times' },
{ name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' },
@ -240,7 +252,8 @@ sub set_counters {
}
},
{ label => 'DelayDestination2SourceStandardDeviation', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'OWSum2DSHigh_1' }, { name => 'OWSum2DSHigh_2' }, { name => 'OWSum2DSHigh_times' },
{ name => 'OWSum2DSLow_1' }, { name => 'OWSum2DSLow_2' }, { name => 'OWSum2DSLow_times' },
{ name => 'NumOfOW_1' }, { name => 'NumOfOW_2' }, { name => 'NumOfOW_times' },
@ -257,7 +270,8 @@ sub set_counters {
}
},
{ label => 'JitterSource2DestinationStandardDeviation', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'Sum2PositivesSDHigh_1' }, { name => 'Sum2PositivesSDHigh_2' }, { name => 'Sum2PositivesSDHigh_times' },
{ name => 'Sum2PositivesSDLow_1' }, { name => 'Sum2PositivesSDLow_2' }, { name => 'Sum2PositivesSDLow_times' },
{ name => 'Sum2NegativesSDHigh_1' }, { name => 'Sum2NegativesSDHigh_2' }, { name => 'Sum2NegativesSDHigh_times' },
@ -278,7 +292,8 @@ sub set_counters {
}
},
{ label => 'JitterDestination2SourceStandardDeviation', set => {
key_values => [ { name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
key_values => [
{ name => 'rttMonCtrlAdminStatus' }, { name => 'rttMonCtrlAdminRttType' },
{ name => 'Sum2PositivesDSHigh_1' }, { name => 'Sum2PositivesDSHigh_2' }, { name => 'Sum2PositivesDSHigh_times' },
{ name => 'Sum2PositivesDSLow_1' }, { name => 'Sum2PositivesDSLow_2' }, { name => 'Sum2PositivesDSLow_times' },
{ name => 'Sum2NegativesDSHigh_1' }, { name => 'Sum2NegativesDSHigh_2' }, { name => 'Sum2NegativesDSHigh_times' },
@ -562,8 +577,11 @@ sub custom_AverageJitter_calc {
return -3;
}
$self->{result_values}->{value} = (get_my_delta($self, %options, name => 'SumOfPositivesDS') + get_my_delta($self, %options, name => 'SumOfNegativesDS') + get_my_delta($self, %options, name => 'SumOfPositivesSD') + get_my_delta($self, %options, name => 'SumOfNegativesSD')) /
$divide;
$self->{result_values}->{value} = (
get_my_delta($self, %options, name => 'SumOfPositivesDS') +
get_my_delta($self, %options, name => 'SumOfNegativesDS') +
get_my_delta($self, %options, name => 'SumOfPositivesSD') +
get_my_delta($self, %options, name => 'SumOfNegativesSD')) / $divide;
return 0;
}
@ -582,8 +600,9 @@ sub custom_RTTStandardDeviation_calc {
return -3;
}
$self->{result_values}->{value} = sqrt ( ((get_my_delta($self, %options, name => 'RTTSum2High') * 2 ** 32 + get_my_delta($self, %options, name => 'RTTSum2Low'))
/ $num_of_rtt) - (get_my_delta($self, %options, name => 'RTTSum') / $num_of_rtt) ** 2
$self->{result_values}->{value} = sqrt(
((get_my_delta($self, %options, name => 'RTTSum2High') * 2 ** 32 + get_my_delta($self, %options, name => 'RTTSum2Low')) / $num_of_rtt) -
(get_my_delta($self, %options, name => 'RTTSum') / $num_of_rtt) ** 2
);
return 0;
}
@ -603,8 +622,9 @@ sub custom_DelaySource2DestinationStandardDeviation_calc {
return -3;
}
$self->{result_values}->{value} = sqrt ( ((get_my_delta($self, %options, name => 'OWSum2SDHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'OWSum2SDLow')) /
$num_of_ow) - (get_my_delta($self, %options, name => 'OWSumSD') / $num_of_ow) ** 2
$self->{result_values}->{value} = sqrt(
((get_my_delta($self, %options, name => 'OWSum2SDHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'OWSum2SDLow')) / $num_of_ow) -
(get_my_delta($self, %options, name => 'OWSumSD') / $num_of_ow) ** 2
);
return 0;
}
@ -624,8 +644,9 @@ sub custom_DelayDestination2SourceStandardDeviation_calc {
return -3;
}
$self->{result_values}->{value} = sqrt ( ((get_my_delta($self, %options, name => 'OWSum2DSHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'OWSum2DSLow')) /
$num_of_ow) - (get_my_delta($self, %options, name => 'OWSumDS') / $num_of_ow) ** 2
$self->{result_values}->{value} = sqrt(
((get_my_delta($self, %options, name => 'OWSum2DSHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'OWSum2DSLow')) / $num_of_ow) -
(get_my_delta($self, %options, name => 'OWSumDS') / $num_of_ow) ** 2
);
return 0;
}
@ -645,10 +666,9 @@ sub custom_JitterSource2DestinationStandardDeviation_calc {
return -3;
}
$self->{result_values}->{value} = sqrt ( ((get_my_delta($self, %options, name => 'Sum2PositivesSDHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2PositivesSDLow') + get_my_delta($self, %options, name => 'Sum2NegativesSDHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2NegativesSDLow'))
/ $divide) -
((get_my_delta($self, %options, name => 'SumOfPositivesSD') + get_my_delta($self, %options, name => 'SumOfNegativesSD')) /
$divide) ** 2
$self->{result_values}->{value} = sqrt(
((get_my_delta($self, %options, name => 'Sum2PositivesSDHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2PositivesSDLow') + get_my_delta($self, %options, name => 'Sum2NegativesSDHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2NegativesSDLow')) / $divide) -
((get_my_delta($self, %options, name => 'SumOfPositivesSD') + get_my_delta($self, %options, name => 'SumOfNegativesSD')) / $divide) ** 2
);
return 0;
}
@ -668,10 +688,9 @@ sub custom_JitterDestination2SourceStandardDeviation_calc {
return -3;
}
$self->{result_values}->{value} = sqrt ( ((get_my_delta($self, %options, name => 'Sum2PositivesDSHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2PositivesDSLow') + get_my_delta($self, %options, name => 'Sum2NegativesDSHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2NegativesDSLow'))
/ $divide) -
((get_my_delta($self, %options, name => 'SumOfPositivesDS') + get_my_delta($self, %options, name => 'SumOfNegativesDS')) /
$divide) ** 2
$self->{result_values}->{value} = sqrt(
((get_my_delta($self, %options, name => 'Sum2PositivesDSHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2PositivesDSLow') + get_my_delta($self, %options, name => 'Sum2NegativesDSHigh') * 2 ** 32 + get_my_delta($self, %options, name => 'Sum2NegativesDSLow')) / $divide) -
((get_my_delta($self, %options, name => 'SumOfPositivesDS') + get_my_delta($self, %options, name => 'SumOfNegativesDS')) / $divide) ** 2
);
return 0;
}
@ -800,10 +819,9 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"filter-tag:s" => { name => 'filter_tag', default => '.*' },
"threshold-overload:s@" => { name => 'threshold_overload' },
$options{options}->add_options(arguments => {
'filter-tag:s' => { name => 'filter_tag', default => '.*' },
'threshold-overload:s@' => { name => 'threshold_overload' },
});
return $self;
@ -839,18 +857,22 @@ sub manage_selection {
(defined($self->{option_results}->{filter_tag}) ? md5_hex($self->{option_results}->{filter_tag}) : md5_hex('all')) . '_' .
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
$self->{results} = $options{snmp}->get_multiple_table(oids => [ { oid => $oid_rttMonCtrlAdminEntry },
$self->{results} = $options{snmp}->get_multiple_table(
oids => [
{ oid => $oid_rttMonCtrlAdminEntry, end => $mapping->{rttMonCtrlAdminStatus}->{oid} },
{ oid => $oid_rttMonEchoAdminPrecision },
{ oid => $oid_rttMonLatestRttOperEntry },
{ oid => $oid_rttMonLatestRttOperEntry, end => $mapping3->{rttMonLatestRttOperApplSpecificSense}->{oid} },
{ oid => $oid_rttMonJitterStatsEntry },
],
nothing_quit => 1);
nothing_quit => 1
);
$self->{tag} = {};
foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$self->{results}->{$oid_rttMonCtrlAdminEntry}})) {
next if ($oid !~ /^$mapping->{rttMonCtrlAdminTag}->{oid}\.(.*)$/);
my $instance = $1;
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $self->{results}->{$oid_rttMonCtrlAdminEntry}, instance => $instance);
$result->{rttMonCtrlAdminTag} = defined($result->{rttMonCtrlAdminTag}) && $result->{rttMonCtrlAdminTag} ne '' ? $result->{rttMonCtrlAdminTag} : $instance;
my $tag_name = $result->{rttMonCtrlAdminTag};
if (!defined($tag_name) || $tag_name eq '') {
$self->{output}->output_add(long_msg => "skipping: please set a tag name");