From 3ff05ca7ad86ba82aafe530e9fe9320d7d8fd8f5 Mon Sep 17 00:00:00 2001 From: Fabien Rendu Date: Tue, 5 Nov 2019 13:23:56 +0100 Subject: [PATCH] add separator option for --manage-returns --- centreon-plugins/os/aix/local/mode/cmdreturn.pm | 7 ++++++- centreon-plugins/os/linux/local/mode/cmdreturn.pm | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/centreon-plugins/os/aix/local/mode/cmdreturn.pm b/centreon-plugins/os/aix/local/mode/cmdreturn.pm index 47e3703a3..6bd5816a0 100644 --- a/centreon-plugins/os/aix/local/mode/cmdreturn.pm +++ b/centreon-plugins/os/aix/local/mode/cmdreturn.pm @@ -44,6 +44,7 @@ sub new { "command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options' }, "manage-returns:s" => { name => 'manage_returns', default => '' }, + "separator:s" => { name => 'separator', default => '#' }, }); $self->{manage_returns} = {}; return $self; @@ -58,7 +59,7 @@ sub check_options { $self->{output}->option_exit(); } - foreach my $entry (split(/#/, $self->{option_results}->{manage_returns})) { + foreach my $entry (split(/$self->{option_results}->{separator}/, $self->{option_results}->{manage_returns})) { next if (!($entry =~ /(.*?),(.*?),(.*)/)); next if (!$self->{output}->is_litteral_status(status => $2)); if ($1 ne '') { @@ -122,6 +123,10 @@ Check command returns. Set action according command exit code. Example: 0,OK,File xxx exist#1,CRITICAL,File xxx not exist#,UNKNOWN,Command problem +=item B<--separator> + +Set the separator used in --manage-returns (default : #) + =item B<--remote> Execute command remotely in 'ssh'. diff --git a/centreon-plugins/os/linux/local/mode/cmdreturn.pm b/centreon-plugins/os/linux/local/mode/cmdreturn.pm index c0d587058..7841b7c10 100644 --- a/centreon-plugins/os/linux/local/mode/cmdreturn.pm +++ b/centreon-plugins/os/linux/local/mode/cmdreturn.pm @@ -44,6 +44,7 @@ sub new { "command-path:s" => { name => 'command_path' }, "command-options:s" => { name => 'command_options' }, "manage-returns:s" => { name => 'manage_returns', default => '' }, + "separator:s" => { name => 'separator', default => '#' }, }); $self->{manage_returns} = {}; return $self; @@ -58,7 +59,7 @@ sub check_options { $self->{output}->option_exit(); } - foreach my $entry (split(/#/, $self->{option_results}->{manage_returns})) { + foreach my $entry (split(/$self->{option_results}->{separator}/, $self->{option_results}->{manage_returns})) { next if (!($entry =~ /(.*?),(.*?),(.*)/)); next if (!$self->{output}->is_litteral_status(status => $2)); if ($1 ne '') { @@ -122,6 +123,10 @@ Check command returns. Set action according command exit code. Example: 0,OK,File xxx exist#1,CRITICAL,File xxx not exist#,UNKNOWN,Command problem +=item B<--separator> + +Set the separator used in --manage-returns (default : #) + =item B<--remote> Execute command remotely in 'ssh'.