mode interfaces,/storage/inodes/diskusage - security fix (#4578)

This commit is contained in:
qgarnier 2023-08-07 19:39:26 +02:00 committed by GitHub
parent c21dd75d02
commit ceb2f5df46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
56 changed files with 354 additions and 358 deletions

View File

@ -169,13 +169,11 @@ Define the OID that will be used to name the interfaces (default: ifDesc) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -85,13 +85,11 @@ Define the OID to be used to filter interfaces (default: ifDesc) (values: ifDesc
Define the OID that will be used to name the interfaces (default: ifDesc) (values: ifDesc, ifAlias, ifName).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--add-extra-oid>

View File

@ -102,13 +102,11 @@ Choose OID used to filter storage (default: hrStorageDescr) (values: hrStorageDe
Choose OID used to display storage (default: hrStorageDescr) (values: hrStorageDescr, hrFSMountPoint).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the storage name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='dev' --display-transform-dst='run' will replace all occurrences of 'dev' with 'run'
=item B<--show-cache>

View File

@ -177,13 +177,11 @@ Define the OID that will be used to name the interfaces (default: ifDesc) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -85,13 +85,11 @@ Define the OID to be used to filter interfaces (default: ifDesc) (values: ifDesc
Define the OID that will be used to name the interfaces (default: ifDesc) (values: ifDesc, ifAlias, ifName).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--add-extra-oid>

View File

@ -448,13 +448,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -176,13 +176,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -299,13 +299,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -375,13 +375,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -141,13 +141,11 @@ Define the OID to be used to filter interfaces (default: ifDesc) (values: ifDesc
Define the OID that will be used to name the interfaces (default: ifDesc) (values: ifDesc, ifAlias).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--add-extra-oid>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -469,13 +469,11 @@ Define the OID that will be used to name the interfaces (default: atrConnCepGenD
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -85,8 +85,7 @@ sub default_oid_display_name {
sub new {
my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options,
no_speed => 1);
my $self = $class->SUPER::new(package => __PACKAGE__, %options, no_speed => 1);
bless $self, $class;
return $self;
}
@ -131,13 +130,11 @@ Define the OID to be used to filter interfaces (default: atrConnCepGenDescr) (va
Define the OID that will be used to name the interfaces (default: atrConnCepGenDescr) (values: atrConnIngDescr, atrConnCepGenDescr).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--add-extra-oid>

View File

@ -369,13 +369,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -162,13 +162,11 @@ Define the OID to be used to filter interfaces (default: ifName) (values: fcPort
Define the OID that will be used to name the interfaces (default: ifName) (values: fcPortName, ifDesc, ifAlias, ifName).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--add-extra-oid>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -240,13 +240,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -193,13 +193,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ efine the OID that will be used to name the interfaces (default: ifName) (values
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -386,13 +386,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -295,13 +295,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -370,13 +370,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -102,13 +102,11 @@ Choose OID used to filter storage (default: hrStorageDescr) (values: hrStorageDe
Choose OID used to display storage (default: hrStorageDescr) (values: hrStorageDescr, hrFSMountPoint).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the storage name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='dev' --display-transform-dst='run' will replace all occurrences of 'dev' with 'run'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -266,13 +266,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -529,13 +529,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -107,13 +107,11 @@ Define the OID to be used to filter interfaces (default: atrConnCepGenDescr) (va
Define the OID that will be used to name the interfaces (default: atrConnCepGenDescr) (values: atrConnIngDescr, atrConnCepGenDescr).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--add-extra-oid>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -187,13 +187,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -24,6 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Safe;
my $oid_spvBCNName = '.1.3.6.1.4.1.36773.3.2.2.1.1.1';
my $oid_spvBCNGlobalStatus = '.1.3.6.1.4.1.36773.3.2.2.1.1.4';
@ -42,16 +43,19 @@ sub new {
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
bless $self, $class;
$options{options}->add_options(arguments =>
{
"bcn:s" => { name => 'bcn' },
"name" => { name => 'use_name' },
"regexp" => { name => 'use_regexp' },
"display-transform-src:s" => { name => 'display_transform_src' },
"display-transform-dst:s" => { name => 'display_transform_dst' },
});
$options{options}->add_options(arguments => {
"bcn:s" => { name => 'bcn' },
"name" => { name => 'use_name' },
"regexp" => { name => 'use_regexp' },
"display-transform-src:s" => { name => 'display_transform_src' },
"display-transform-dst:s" => { name => 'display_transform_dst' }
});
$self->{bcn_id_selected} = [];
$self->{safe} = Safe->new();
$self->{safe}->share('$assign_var');
return $self;
}
@ -102,28 +106,38 @@ sub run {
$self->{snmp} = $options{snmp};
$self->manage_selection();
$self->{snmp}->load(oids => [$oid_spvBCNGlobalStatus],
instances => $self->{bcn_id_selected});
$self->{snmp}->load(
oids => [$oid_spvBCNGlobalStatus],
instances => $self->{bcn_id_selected}
);
my $result = $self->{snmp}->get_leef();
if (!defined($self->{option_results}->{bcn}) || defined($self->{option_results}->{use_regexp})) {
$self->{output}->output_add(severity => 'OK',
short_msg => 'All BCN are ok.');
$self->{output}->output_add(
severity => 'OK',
short_msg => 'All BCN are ok.'
);
}
foreach my $instance (sort @{$self->{bcn_id_selected}}) {
my $name = $self->{result_names}->{$oid_spvBCNName . '.' . $instance};
$name = $self->get_display_value(value => $name);
my $status = $result->{$oid_spvBCNGlobalStatus . '.' . $instance};
my $exit_from_snmp = ${$bcn_status{$status}}[1];
$self->{output}->output_add(long_msg => sprintf("BCN '%s' global status is '%s'",
$name, ${$bcn_status{$status}}[0]));
$self->{output}->output_add(
long_msg => sprintf(
"BCN '%s' global status is '%s'",
$name, ${$bcn_status{$status}}[0]
)
);
if (!$self->{output}->is_status(value => $exit_from_snmp, compare => 'ok', litteral => 1) || (defined($self->{option_results}->{bcn}) && !defined($self->{option_results}->{use_regexp}))) {
$self->{output}->output_add(severity => $exit_from_snmp,
short_msg => sprintf("BCN '%s' global status is '%s'", $name, ${$bcn_status{$status}}[0]));
$self->{output}->output_add(
severity => $exit_from_snmp,
short_msg => sprintf("BCN '%s' global status is '%s'", $name, ${$bcn_status{$status}}[0])
);
}
my $extra_label = '';
$extra_label = '_' . $name if (!defined($self->{option_results}->{bcn}) || defined($self->{option_results}->{use_regexp}));
#$self->{output}->perfdata_add(label => 'eurt' . $extra_label,
@ -132,20 +146,25 @@ sub run {
# critical => $critth,
# min => 0);
}
$self->{output}->display();
$self->{output}->exit();
}
sub get_display_value {
my ($self, %options) = @_;
my $value = $options{value};
our $assign_var = $options{value};
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}", 1);
if ($@) {
die 'Unsafe code evaluation: ' . $@;
}
}
return $value;
return $assign_var;
}
1;
@ -160,25 +179,22 @@ Check BCN status.
=item B<--bcn>
Set the bcn (number expected) ex: 1, 2,... (empty means 'check all bcn').
Set the BCN (number expected) ex: 1, 2,... (empty means 'check all bcn').
=item B<--name>
Allows to use bcn name with option --bcn instead of bcn oid index.
Allows to use BCN name with option --bcn instead of bcn oid index.
=item B<--regexp>
Allows to use regexp to filter bcn (with option --name).
Allows to use regexp to filter BCN (with option --name).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the BCN name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='-' --display-transform-dst='_' will replace all occurrences of '-' with '_'
=back
=cut

View File

@ -24,6 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Safe;
my $oid_spvBCNName = '.1.3.6.1.4.1.36773.3.2.2.1.1.1';
@ -42,6 +43,9 @@ sub new {
$self->{bcn_id_selected} = [];
$self->{safe} = Safe->new();
$self->{safe}->share('$assign_var');
return $self;
}
@ -104,13 +108,18 @@ sub run {
sub get_display_value {
my ($self, %options) = @_;
my $value = $options{value};
our $assign_var = $options{value};
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}", 1);
if ($@) {
die 'Unsafe code evaluation: ' . $@;
}
}
return $value;
return $assign_var;
}
sub disco_format {
@ -147,25 +156,22 @@ List BCN.
=item B<--bcn>
Set the bcn (number expected) ex: 1, 2,... (empty means 'check all bcn').
Set the BCN (number expected) ex: 1, 2,... (empty means 'check all bcn').
=item B<--name>
Allows to use bcn name with option --bcn instead of bcn oid index.
Allows to use BCN name with option --bcn instead of bcn oid index.
=item B<--regexp>
Allows to use regexp to filter bcn (with option --name).
Allows to use regexp to filter BCN (with option --name).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the BCN name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='-' --display-transform-dst='_' will replace all occurrences of '-' with '_'
=back
=cut

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -102,13 +102,11 @@ Choose OID used to filter storage (default: hrStorageDescr) (values: hrStorageDe
Choose OID used to display storage (default: hrStorageDescr) (values: hrStorageDescr, hrFSMountPoint).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the storage name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='dev' --display-transform-dst='run' will replace all occurrences of 'dev' with 'run'
=item B<--show-cache>

View File

@ -165,13 +165,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -299,13 +299,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -85,13 +85,11 @@ Define the OID to be used to filter interfaces (default: ifDesc) (values: ifDesc
Define the OID that will be used to name the interfaces (default: ifDesc) (values: ifDesc, ifAlias, ifName).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--add-extra-oid>

View File

@ -24,6 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Safe;
sub new {
my ($class, %options) = @_;
@ -35,6 +36,9 @@ sub new {
'display-transform-dst:s' => { name => 'display_transform_dst' }
});
$self->{safe} = Safe->new();
$self->{safe}->share('$assign_var');
return $self;
}
@ -55,16 +59,20 @@ my $map_types = {
6 => 'ramDisk'
};
sub get_display_value {
my ($self, %options) = @_;
my $value = $options{name};
our $assign_var = $options{name};
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}", 1);
if ($@) {
die 'Unsafe code evaluation: ' . $@;
}
}
return $value;
return $assign_var;
}
sub manage_selection {
@ -104,6 +112,7 @@ sub run {
severity => 'OK',
short_msg => 'List storages:'
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -134,13 +143,11 @@ List storages.
=over 8
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the storage name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='dev' --display-transform-dst='run' will replace all occurrences of 'dev' with 'run'
=back

View File

@ -26,6 +26,7 @@ use strict;
use warnings;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
use Safe;
sub custom_usage_output {
my ($self, %options) = @_;
@ -132,6 +133,9 @@ sub new {
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
$self->{safe} = Safe->new();
$self->{safe}->share('$assign_var');
return $self;
}
@ -343,13 +347,17 @@ sub get_selection {
sub get_display_value {
my ($self, %options) = @_;
my $value = $options{value};
our $assign_var = $options{value};
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}", 1);
if ($@) {
die 'Unsafe code evaluation: ' . $@;
}
}
return $value;
return $assign_var;
}
1;
@ -383,13 +391,11 @@ Filter disks according to their device name.
Time in minutes before reloading cache file (default: 180).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the disk name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='dev' --display-transform-dst='run' will replace all occurrences of 'dev' with 'run'
=item B<--show-cache>

View File

@ -24,6 +24,7 @@ use base qw(centreon::plugins::templates::counter);
use strict;
use warnings;
use Safe;
sub set_counters {
my ($self, %options) = @_;
@ -67,6 +68,9 @@ sub new {
'display-transform-dst:s' => { name => 'display_transform_dst' },
});
$self->{safe} = Safe->new();
$self->{safe}->share('$assign_var');
return $self;
}
@ -79,10 +83,15 @@ my $mapping = {
sub manage_selection {
my ($self, %options) = @_;
my $results = $options{snmp}->get_multiple_table(oids => [ { oid => $mapping->{dskPath}->{oid} },
{ oid => $mapping->{dskDevice}->{oid} },
{ oid => $mapping->{dskPercentNode}->{oid} } ],
return_type => 1, nothing_quit => 1);
my $results = $options{snmp}->get_multiple_table(
oids => [
{ oid => $mapping->{dskPath}->{oid} },
{ oid => $mapping->{dskDevice}->{oid} },
{ oid => $mapping->{dskPercentNode}->{oid} }
],
return_type => 1,
nothing_quit => 1
);
$self->{disk} = {};
foreach my $oid ($options{snmp}->oid_lex_sort(keys %{$results})) {
next if ($oid !~ /^$mapping->{dskPath}->{oid}\.(.*)/);
@ -90,9 +99,9 @@ sub manage_selection {
my $result = $options{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance);
$result->{dskPath} = $self->get_display_value(value => $result->{dskPath});
$self->{output}->output_add(long_msg => sprintf("disk path : '%s', device : '%s'", $result->{dskPath}, $result->{dskDevice}), debug => 1);
if (!defined($result->{dskPercentNode})) {
$self->{output}->output_add(long_msg => sprintf("skipping '%s' : no inode usage value", $result->{dskPath}), debug => 1);
next;
@ -131,8 +140,7 @@ sub manage_selection {
next;
}
}
$self->{disk}->{$result->{dskPath}} = {
display => $result->{dskPath},
usage => $result->{dskPercentNode}
@ -147,13 +155,18 @@ sub manage_selection {
sub get_display_value {
my ($self, %options) = @_;
my $value = $options{value};
our $assign_var = $options{value};
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}", 1);
if ($@) {
die 'Unsafe code evaluation: ' . $@;
}
}
return $value;
return $assign_var;
}
1;
@ -191,13 +204,11 @@ Allows to use regexp to filter diskpath (with option --name).
Allows to use regexp non case-sensitive (with --regexp).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the disk path name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='dev' --display-transform-dst='run' will replace all occurrences of 'dev' with 'run'
=item B<--filter-device>

View File

@ -26,6 +26,7 @@ use strict;
use warnings;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
use Safe;
#########################
# Calc functions
@ -987,6 +988,9 @@ sub new {
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
$self->{safe} = Safe->new();
$self->{safe}->share('$assign_var');
return $self;
}
@ -1059,12 +1063,16 @@ sub check_options {
sub get_display_value {
my ($self, %options) = @_;
my $value = $self->{statefile_cache}->get(name => $self->{option_results}->{oid_display} . "_" . $options{id});
our $assign_var = $self->{statefile_cache}->get(name => $self->{option_results}->{oid_display} . "_" . $options{id});
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}", 1);
if ($@) {
die 'Unsafe code evaluation: ' . $@;
}
}
return $value;
return $assign_var;
}
sub check_oids_options_change {
@ -1729,13 +1737,11 @@ Define the OID that will be used to name the interfaces (default: ifName) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>

View File

@ -24,6 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Safe;
my $oid_dskPath = '.1.3.6.1.4.1.2021.9.1.2';
my $oid_dskTotalLow = '.1.3.6.1.4.1.2021.9.1.11';
@ -46,6 +47,9 @@ sub new {
$self->{diskpath_id_selected} = [];
$self->{safe} = Safe->new();
$self->{safe}->share('$assign_var');
return $self;
}
@ -75,8 +79,10 @@ sub run {
$self->{output}->output_add(long_msg => "'" . $display_value . "' [id = " . $_ . ']');
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List disk path:');
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List disk path:'
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -95,13 +101,18 @@ sub get_additional_information {
sub get_display_value {
my ($self, %options) = @_;
my $value = $self->{datas}->{'dskPath_' . $options{id}};
our $assign_var = $self->{datas}->{'dskPath_' . $options{id}};
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}", 1);
if ($@) {
die 'Unsafe code evaluation: ' . $@;
}
}
return $value;
return $assign_var;
}
sub manage_selection {
@ -179,8 +190,10 @@ sub disco_show {
}
my $display_value = $self->get_display_value(id => $_);
$self->{output}->add_disco_entry(name => $display_value,
diskpathid => $_);
$self->{output}->add_disco_entry(
name => $display_value,
diskpathid => $_
);
}
}
@ -211,13 +224,11 @@ Allows to use regexp to filter diskpath (with option --name).
Allows to use regexp non case-sensitive (with --regexp).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the disk path name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='dev' --display-transform-dst='run' will replace all occurrences of 'dev' with 'run'
=item B<--skip-total-size-zero>

View File

@ -24,6 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Safe;
use snmp_standard::mode::resources::types qw($map_iftype);
my $oid_speed32 = '.1.3.6.1.2.1.2.2.1.5'; # in b/s
@ -113,6 +114,9 @@ sub new {
$self->{interface_id_selected} = [];
$self->{safe} = Safe->new();
$self->{safe}->share('$assign_var');
return $self;
}
@ -223,12 +227,17 @@ sub get_additional_information {
sub get_display_value {
my ($self, %options) = @_;
my $value = $self->{datas}->{$self->{option_results}->{oid_display} . '_' . $options{id}};
our $assign_var = $self->{datas}->{$self->{option_results}->{oid_display} . '_' . $options{id}};
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}", 1);
if ($@) {
die 'Unsafe code evaluation: ' . $@;
}
}
return $value;
return $assign_var;
}
sub manage_selection {
@ -365,6 +374,7 @@ sub disco_show {
$extra_values->{type} = defined($result->{ $self->{oid_iftype} . '.' . $_ }) && defined($map_iftype->{ $result->{ $self->{oid_iftype} . '.' . $_ } }) ?
$map_iftype->{ $result->{ $self->{oid_iftype} . '.' . $_ } } : 'unknown';
}
$self->{output}->add_disco_entry(
name => $display_value,
total => $interface_speed,
@ -415,13 +425,11 @@ Define the OID to be used to filter interfaces (default: ifName) (values: ifDesc
Define the OID that will be used to name the interfaces (default: ifName) (values: ifDesc, ifAlias, ifName).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--add-extra-oid>

View File

@ -24,6 +24,7 @@ use base qw(centreon::plugins::mode);
use strict;
use warnings;
use Safe;
my %oids_hrStorageTable = (
'hrstoragedescr' => '.1.3.6.1.2.1.25.2.3.1.3',
@ -90,7 +91,10 @@ sub new {
});
$self->{storage_id_selected} = [];
$self->{safe} = Safe->new();
$self->{safe}->share('$assign_var');
return $self;
}
@ -129,8 +133,10 @@ sub run {
$self->{output}->output_add(long_msg => "'" . $display_value . "' [size = " . $result->{$oid_hrStorageSize . "." . $_} * $result->{$oid_hrStorageAllocationUnits . "." . $_} . "B] [id = $_]");
}
$self->{output}->output_add(severity => 'OK',
short_msg => 'List storage:');
$self->{output}->output_add(
severity => 'OK',
short_msg => 'List storage:'
);
$self->{output}->display(nolabel => 1, force_ignore_perfdata => 1, force_long_output => 1);
$self->{output}->exit();
}
@ -144,13 +150,18 @@ sub get_additional_information {
sub get_display_value {
my ($self, %options) = @_;
my $value = $self->{datas}->{$self->{option_results}->{oid_display} . "_" . $options{id}};
our $assign_var = $self->{datas}->{$self->{option_results}->{oid_display} . "_" . $options{id}};
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}", 1);
if ($@) {
die 'Unsafe code evaluation: ' . $@;
}
}
return $value;
return $assign_var;
}
sub manage_selection {
@ -262,9 +273,11 @@ sub disco_show {
next if (!defined($storage_type) ||
($storage_types_manage{$storage_type} !~ /$self->{option_results}->{filter_storage_type}/i));
$self->{output}->add_disco_entry(name => $display_value,
total => $result->{$oid_hrStorageSize . "." . $_} * $result->{$oid_hrStorageAllocationUnits . "." . $_},
storageid => $_);
$self->{output}->add_disco_entry(
name => $display_value,
total => $result->{$oid_hrStorageSize . "." . $_} * $result->{$oid_hrStorageAllocationUnits . "." . $_},
storageid => $_
);
}
}
@ -300,13 +313,11 @@ Choose OID used to filter storage (default: hrStorageDescr) (values: hrStorageDe
Choose OID used to display storage (default: hrStorageDescr) (values: hrStorageDescr, hrFSMountPoint).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the storage name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='dev' --display-transform-dst='run' will replace all occurrences of 'dev' with 'run'
=item B<--filter-storage-type>

View File

@ -26,6 +26,7 @@ use strict;
use warnings;
use centreon::plugins::statefile;
use Digest::MD5 qw(md5_hex);
use Safe;
my %oids_hrStorageTable = (
'hrstoragedescr' => '.1.3.6.1.2.1.25.2.3.1.3',
@ -270,6 +271,9 @@ sub new {
$self->{storage_id_selected} = [];
$self->{statefile_cache} = centreon::plugins::statefile->new(%options);
$self->{safe} = Safe->new();
$self->{safe}->share('$assign_var');
return $self;
}
@ -577,13 +581,18 @@ sub get_selection {
sub get_display_value {
my ($self, %options) = @_;
my $value = $self->{statefile_cache}->get(name => $self->{option_results}->{oid_display} . "_" . $options{id});
our $assign_var = $self->{statefile_cache}->get(name => $self->{option_results}->{oid_display} . "_" . $options{id});
if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));
eval "\$value =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}";
$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}", 1);
if ($@) {
die 'Unsafe code evaluation: ' . $@;
}
}
return $value;
return $assign_var;
}
1;
@ -655,13 +664,11 @@ Choose OID used to filter storage (default: hrStorageDescr) (values: hrStorageDe
Choose OID used to display storage (default: hrStorageDescr) (values: hrStorageDescr, hrFSMountPoint).
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value. (security risk!!!)
Modify the storage name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value. (security risk!!!)
Eg: adding --display-transform-src='dev' --display-transform-dst='run' will replace all occurrences of 'dev' with 'run'
=item B<--show-cache>

View File

@ -166,13 +166,11 @@ Define the OID that will be used to name the interfaces (default: ifDesc) (value
Add an OID to display.
=item B<--display-transform-src>
=item B<--display-transform-src> B<--display-transform-dst>
Regexp src to transform display value.
Modify the interface name displayed by using a regular expression.
=item B<--display-transform-dst>
Regexp dst to transform display value.
Eg: adding --display-transform-src='eth' --display-transform-dst='ens' will replace all occurrences of 'eth' with 'ens'
=item B<--show-cache>