+ add system to convert args and use with nrpe
This commit is contained in:
parent
8bb6cf95e9
commit
7c4e28bb1d
|
@ -102,6 +102,7 @@ sub get_plugin {
|
|||
'version' => { name => 'version' },
|
||||
'runas:s' => { name => 'runas' },
|
||||
'environment:s%' => { name => 'environment' },
|
||||
'convert-args:s' => { name => 'convert_args' },
|
||||
} );
|
||||
|
||||
$self->{options}->parse_options();
|
||||
|
@ -113,6 +114,7 @@ sub get_plugin {
|
|||
$self->{runas} = $self->{options}->get_option(argument => 'runas' );
|
||||
$self->{environment} = $self->{options}->get_option(argument => 'environment' );
|
||||
$self->{ignore_warn_msg} = $self->{options}->get_option(argument => 'ignore_warn_msg' );
|
||||
$self->{convert_args} = $self->{options}->get_option(argument => 'convert_args' );
|
||||
|
||||
$self->{output}->mode(name => $self->{mode});
|
||||
$self->{output}->plugin(name => $self->{plugin});
|
||||
|
@ -121,6 +123,17 @@ sub get_plugin {
|
|||
$self->{options}->clean();
|
||||
}
|
||||
|
||||
sub convert_args {
|
||||
my ($self) = @_;
|
||||
|
||||
if ($self->{convert_args} =~ /^(.+?),(.*)/) {
|
||||
my ($search, $replace) = ($1, $2);
|
||||
for (my $i = 0; $i < $#ARGV; $i++) {
|
||||
$ARGV[$i] =~ s/$search/$replace/g;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub display_local_help {
|
||||
my ($self) = @_;
|
||||
|
||||
|
@ -325,12 +338,11 @@ sub run {
|
|||
$self->display_list_plugin();
|
||||
$self->{output}->option_exit();
|
||||
}
|
||||
if (!defined($self->{plugin}) || $self->{plugin} eq '') {
|
||||
$self->check_plugin_option();
|
||||
}
|
||||
$self->check_plugin_option() if (!defined($self->{plugin}) || $self->{plugin} eq '');
|
||||
if (defined($self->{ignore_warn_msg})) {
|
||||
$SIG{__WARN__} = sub {};
|
||||
}
|
||||
$self->convert_args() if (defined($self->{convert_args}));
|
||||
|
||||
$self->check_relaunch();
|
||||
|
||||
|
@ -387,6 +399,11 @@ Run the script as a different user (prefer to use directly the good user).
|
|||
|
||||
Set environment variables for the script (prefer to set it before running it for better performance).
|
||||
|
||||
=item B<--convert-args>
|
||||
|
||||
Change strings of arguments. Useful to use '!' in nrpe protocol.
|
||||
Example: --convert-args='##,!'
|
||||
|
||||
=back
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
|
Loading…
Reference in New Issue