From 6236c21858f31085641256648d2d41e3fc338784 Mon Sep 17 00:00:00 2001 From: CPbN <40244829+CPbN@users.noreply.github.com> Date: Fri, 1 Nov 2019 23:27:39 +0100 Subject: [PATCH] Add option --use-perl-mod --- snmp_standard/mode/stringvalue.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/snmp_standard/mode/stringvalue.pm b/snmp_standard/mode/stringvalue.pm index 79c5dfb46..e555f5a9d 100644 --- a/snmp_standard/mode/stringvalue.pm +++ b/snmp_standard/mode/stringvalue.pm @@ -25,7 +25,6 @@ use base qw(centreon::plugins::mode); use strict; use warnings; use centreon::plugins::misc; -use Date::Parse; sub new { my ($class, %options) = @_; @@ -71,6 +70,8 @@ sub new { 'map-value-other:s' => { name => 'map_value_other' }, 'map-values-separator:s' => { name => 'map_values_separator', default => ',' }, 'convert-custom-values:s' => { name => 'convert_custom_values' }, + + "use-perl-mod:s@" => { name => 'use_perl_mod' }, }); $self->{macros} = { ok => {}, warning => {}, critical => {}, unknown => {} }; @@ -81,6 +82,11 @@ sub check_options { my ($self, %options) = @_; $self->SUPER::init(%options); + foreach my $mod (@{$self->{option_results}->{use_perl_mod}}) { + centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $mod, + error_msg => "Cannot load module '" . $mod . "'."); + } + $self->{option_results}->{oid_leef} = $self->{option_results}->{oid} if (defined($self->{option_results}->{oid}) && $self->{option_results}->{oid} ne ''); if ((!defined($self->{option_results}->{oid_leef}) || $self->{option_results}->{oid_leef} eq '') && (!defined($self->{option_results}->{oid_table}) || $self->{option_results}->{oid_table} eq '')) { @@ -387,6 +393,11 @@ Separator uses between values (default: coma). Custom code to convert values. Example to convert octetstring to macaddress: --convert-custom-values='join(":", unpack("(H2)*", $value))' +=item B<--use-perl-mod> + +Load additional Perl module (Can be multiple) +Example : --use-perl-mod='Date::Parse' + =back =cut