add filter name for pdu eaton
This commit is contained in:
parent
2099b7ccd9
commit
1b33f69e12
|
@ -27,9 +27,9 @@ use warnings;
|
||||||
|
|
||||||
sub set_counters {
|
sub set_counters {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{maps_counters_type} = [
|
$self->{maps_counters_type} = [
|
||||||
{ name => 'group', type => 1, cb_prefix_output => 'prefix_group_output', message_multiple => 'All groups are ok', skipped_code => { -10 => 1 } },
|
{ name => 'group', type => 1, cb_prefix_output => 'prefix_group_output', message_multiple => 'All groups are ok', skipped_code => { -10 => 1 } }
|
||||||
];
|
];
|
||||||
|
|
||||||
$self->{maps_counters}->{group} = [
|
$self->{maps_counters}->{group} = [
|
||||||
|
@ -38,8 +38,8 @@ sub set_counters {
|
||||||
output_template => 'Current : %.2f A',
|
output_template => 'Current : %.2f A',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'groupCurrent_absolute', template => '%.2f',
|
{ value => 'groupCurrent_absolute', template => '%.2f',
|
||||||
min => 0, unit => 'A', label_extra_instance => 1, instance_use => 'display_absolute' },
|
min => 0, unit => 'A', label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'voltage', nlabel => 'group.voltage.volt', set => {
|
{ label => 'voltage', nlabel => 'group.voltage.volt', set => {
|
||||||
|
@ -47,8 +47,8 @@ sub set_counters {
|
||||||
output_template => 'Voltage : %.2f V',
|
output_template => 'Voltage : %.2f V',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'groupVoltage_absolute', template => '%.2f',
|
{ value => 'groupVoltage_absolute', template => '%.2f',
|
||||||
unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'V', label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ label => 'power', nlabel => 'group.power.watt', set => {
|
{ label => 'power', nlabel => 'group.power.watt', set => {
|
||||||
|
@ -56,10 +56,10 @@ sub set_counters {
|
||||||
output_template => 'Power : %.2f W',
|
output_template => 'Power : %.2f W',
|
||||||
perfdatas => [
|
perfdatas => [
|
||||||
{ value => 'groupWatts_absolute', template => '%.2f',
|
{ value => 'groupWatts_absolute', template => '%.2f',
|
||||||
unit => 'W', label_extra_instance => 1, instance_use => 'display_absolute' },
|
unit => 'W', label_extra_instance => 1, instance_use => 'display_absolute' }
|
||||||
],
|
]
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
|
'filter-name:s' => { name => 'filter_name' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -90,7 +91,6 @@ my $mapping = {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{group} = {};
|
|
||||||
my $snmp_result = $options{snmp}->get_multiple_table(
|
my $snmp_result = $options{snmp}->get_multiple_table(
|
||||||
oids => [
|
oids => [
|
||||||
{ oid => $mapping->{groupName}->{oid} },
|
{ oid => $mapping->{groupName}->{oid} },
|
||||||
|
@ -101,11 +101,12 @@ sub manage_selection {
|
||||||
return_type => 1, nothing_quit => 1
|
return_type => 1, nothing_quit => 1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$self->{group} = {};
|
||||||
foreach my $oid (keys %{$snmp_result}) {
|
foreach my $oid (keys %{$snmp_result}) {
|
||||||
$oid =~ /\.(\d+)\.(\d+)$/;
|
$oid =~ /\.(\d+)\.(\d+)$/;
|
||||||
my ($strapping_index, $group_index) = ($1, $2);
|
my ($strapping_index, $group_index) = ($1, $2);
|
||||||
next if (defined($self->{group}->{$strapping_index . '.' . $group_index}));
|
next if (defined($self->{group}->{$strapping_index . '.' . $group_index}));
|
||||||
|
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $strapping_index . '.' . $group_index);
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $strapping_index . '.' . $group_index);
|
||||||
$result->{groupVoltage} *= 0.001 if (defined($result->{groupVoltage}));
|
$result->{groupVoltage} *= 0.001 if (defined($result->{groupVoltage}));
|
||||||
$result->{groupCurrent} *= 0.001 if (defined($result->{groupCurrent}));
|
$result->{groupCurrent} *= 0.001 if (defined($result->{groupCurrent}));
|
||||||
|
@ -113,6 +114,13 @@ sub manage_selection {
|
||||||
if (defined($result->{groupName}) && $result->{groupName} ne '') {
|
if (defined($result->{groupName}) && $result->{groupName} ne '') {
|
||||||
$display = $result->{groupName} . ' strapping ' . $strapping_index;
|
$display = $result->{groupName} . ' strapping ' . $strapping_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
|
$display !~ /$self->{option_results}->{filter_name}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping '" . $display . "': no matching filter.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
$self->{group}->{$strapping_index . '.' . $group_index} = { display => $display, %$result };
|
$self->{group}->{$strapping_index . '.' . $group_index} = { display => $display, %$result };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +140,10 @@ Check group metrics (voltage, current and power).
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
Filter group name (can be a regexp).
|
||||||
|
|
||||||
=item B<--warning-*>
|
=item B<--warning-*>
|
||||||
|
|
||||||
Threshold warning.
|
Threshold warning.
|
||||||
|
|
|
@ -69,6 +69,7 @@ sub new {
|
||||||
bless $self, $class;
|
bless $self, $class;
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
|
'filter-name:s' => { name => 'filter_name' }
|
||||||
});
|
});
|
||||||
|
|
||||||
return $self;
|
return $self;
|
||||||
|
@ -90,7 +91,6 @@ my $mapping = {
|
||||||
sub manage_selection {
|
sub manage_selection {
|
||||||
my ($self, %options) = @_;
|
my ($self, %options) = @_;
|
||||||
|
|
||||||
$self->{outlet} = {};
|
|
||||||
my $snmp_result = $options{snmp}->get_multiple_table(
|
my $snmp_result = $options{snmp}->get_multiple_table(
|
||||||
oids => [
|
oids => [
|
||||||
{ oid => $mapping->{outletName}->{oid} },
|
{ oid => $mapping->{outletName}->{oid} },
|
||||||
|
@ -101,12 +101,13 @@ sub manage_selection {
|
||||||
return_type => 1, nothing_quit => 1
|
return_type => 1, nothing_quit => 1
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$self->{outlet} = {};
|
||||||
foreach my $oid (keys %{$snmp_result}) {
|
foreach my $oid (keys %{$snmp_result}) {
|
||||||
$oid =~ /\.(\d+)\.(\d+)$/;
|
$oid =~ /\.(\d+)\.(\d+)$/;
|
||||||
my ($strapping_index, $outlet_index) = ($1, $2);
|
my ($strapping_index, $outlet_index) = ($1, $2);
|
||||||
|
|
||||||
next if (defined($self->{outlet}->{$strapping_index . '.' . $outlet_index}));
|
next if (defined($self->{outlet}->{$strapping_index . '.' . $outlet_index}));
|
||||||
|
|
||||||
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $strapping_index . '.' . $outlet_index);
|
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $strapping_index . '.' . $outlet_index);
|
||||||
$result->{outletVoltage} *= 0.001 if (defined($result->{outletVoltage}));
|
$result->{outletVoltage} *= 0.001 if (defined($result->{outletVoltage}));
|
||||||
$result->{outletCurrent} *= 0.001 if (defined($result->{outletCurrent}));
|
$result->{outletCurrent} *= 0.001 if (defined($result->{outletCurrent}));
|
||||||
|
@ -114,6 +115,13 @@ sub manage_selection {
|
||||||
if (defined($result->{outletName}) && $result->{outletName} ne '') {
|
if (defined($result->{outletName}) && $result->{outletName} ne '') {
|
||||||
$display = $result->{outletName} . ' strapping ' . $strapping_index;
|
$display = $result->{outletName} . ' strapping ' . $strapping_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined($self->{option_results}->{filter_name}) && $self->{option_results}->{filter_name} ne '' &&
|
||||||
|
$display !~ /$self->{option_results}->{filter_name}/) {
|
||||||
|
$self->{output}->output_add(long_msg => "skipping '" . $display . "': no matching filter.", debug => 1);
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
$self->{outlet}->{$strapping_index . '.' . $outlet_index} = { display => $display, %$result };
|
$self->{outlet}->{$strapping_index . '.' . $outlet_index} = { display => $display, %$result };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +141,10 @@ Check outlet metrics (voltage, current and power).
|
||||||
|
|
||||||
=over 8
|
=over 8
|
||||||
|
|
||||||
|
=item B<--filter-name>
|
||||||
|
|
||||||
|
Filter outlet name (can be a regexp).
|
||||||
|
|
||||||
=item B<--warning-*>
|
=item B<--warning-*>
|
||||||
|
|
||||||
Threshold warning.
|
Threshold warning.
|
||||||
|
|
Loading…
Reference in New Issue