diff --git a/centreon-plugins/centreon/plugins/script_custom.pm b/centreon-plugins/centreon/plugins/script_custom.pm index 9cd912d50..d4537427c 100644 --- a/centreon-plugins/centreon/plugins/script_custom.pm +++ b/centreon-plugins/centreon/plugins/script_custom.pm @@ -121,7 +121,7 @@ sub init { } elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') { centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, error_msg => "Cannot load module --dyn-mode."); - $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name}); + $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name}); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option."); $self->{output}->option_exit(); diff --git a/centreon-plugins/centreon/plugins/script_simple.pm b/centreon-plugins/centreon/plugins/script_simple.pm index 4abae8c32..8fe717cb7 100644 --- a/centreon-plugins/centreon/plugins/script_simple.pm +++ b/centreon-plugins/centreon/plugins/script_simple.pm @@ -100,7 +100,7 @@ sub init { } elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') { centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, error_msg => "Cannot load module --dyn-mode."); - $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name}); + $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name}); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option."); $self->{output}->option_exit(); diff --git a/centreon-plugins/centreon/plugins/script_snmp.pm b/centreon-plugins/centreon/plugins/script_snmp.pm index 26ece81f5..273e2aad3 100644 --- a/centreon-plugins/centreon/plugins/script_snmp.pm +++ b/centreon-plugins/centreon/plugins/script_snmp.pm @@ -52,7 +52,7 @@ sub new { $self->{options}->add_options( arguments => { - 'mode:s' => { name => 'mode' }, + 'mode:s' => { name => 'mode_name' }, 'dyn-mode:s' => { name => 'dynmode_name' }, 'list-mode' => { name => 'list_mode' }, 'mode-version:s' => { name => 'mode_version' }, @@ -63,9 +63,10 @@ sub new { $self->{default} = undef; $self->{options}->parse_options(); - $self->{mode_name} = $self->{options}->get_option(argument => 'mode'); - $self->{list_mode} = $self->{options}->get_option(argument => 'list_mode'); - $self->{mode_version} = $self->{options}->get_option(argument => 'mode_version'); + $self->{option_results} = $self->{options}->get_options(); + foreach (keys %{$self->{option_results}}) { + $self->{$_} = $self->{option_results}->{$_}; + } $self->{options}->clean(); $self->{options}->add_help(package => $options{package}, sections => 'PLUGIN DESCRIPTION'); @@ -105,7 +106,7 @@ sub init { } elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') { centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, error_msg => "Cannot load module --dyn-mode."); - $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name}); + $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name}); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option."); $self->{output}->option_exit(); diff --git a/centreon-plugins/centreon/plugins/script_sql.pm b/centreon-plugins/centreon/plugins/script_sql.pm index 6e6a324cb..c8be98bef 100644 --- a/centreon-plugins/centreon/plugins/script_sql.pm +++ b/centreon-plugins/centreon/plugins/script_sql.pm @@ -122,7 +122,7 @@ sub init { } elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') { centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, error_msg => "Cannot load module --dyn-mode."); - $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name}); + $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name}); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option."); $self->{output}->option_exit(); diff --git a/centreon-plugins/centreon/plugins/script_wsman.pm b/centreon-plugins/centreon/plugins/script_wsman.pm index 151f3ae01..651c9485e 100644 --- a/centreon-plugins/centreon/plugins/script_wsman.pm +++ b/centreon-plugins/centreon/plugins/script_wsman.pm @@ -105,7 +105,7 @@ sub init { } elsif (defined($self->{dynmode_name}) && $self->{dynmode_name} ne '') { centreon::plugins::misc::mymodule_load(output => $self->{output}, module => $self->{dynmode_name}, error_msg => "Cannot load module --dyn-mode."); - $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{mode_name}); + $self->{mode} = $self->{dynmode_name}->new(options => $self->{options}, output => $self->{output}, mode => $self->{dynmode_name}); } else { $self->{output}->add_option_msg(short_msg => "Need to specify '--mode' or '--dyn-mode' option."); $self->{output}->option_exit();