From c46f2bba9bfb1603c958bfafe3c83e61ef8e5977 Mon Sep 17 00:00:00 2001 From: garnier-quentin Date: Mon, 16 Jan 2017 18:38:37 +0100 Subject: [PATCH] + add an option in trap mode --- apps/centreon/local/mode/downtimetrap.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/centreon/local/mode/downtimetrap.pm b/apps/centreon/local/mode/downtimetrap.pm index 25ec3bfa8..360ac9991 100644 --- a/apps/centreon/local/mode/downtimetrap.pm +++ b/apps/centreon/local/mode/downtimetrap.pm @@ -61,6 +61,7 @@ sub new { "duration:s" => { name => 'duration', default => 300 }, "wait:s" => { name => 'wait' }, "snmptrap-command:s" => { name => 'snmptrap_command', default => 'snmptrap' }, + "display-options" => { name => 'display_options' }, }); return $self; } @@ -131,6 +132,13 @@ sub send_trap_cmd { $options .= ' ' . $self->{snmp_args}->{author}->{oid} . '.' . $self->{snmp_args}->{author}->{instance} . ' ' . $self->{snmp_args}->{author}->{type_cmd} . ' "' . $self->{snmp_args}->{author}->{val} . '"'; $options .= ' ' . $self->{snmp_args}->{comment}->{oid} . '.' . $self->{snmp_args}->{comment}->{instance} . ' ' . $self->{snmp_args}->{comment}->{type_cmd} . ' "' . $self->{snmp_args}->{comment}->{val} . '"'; $options .= ' ' . $self->{snmp_args}->{duration}->{oid} . '.' . $self->{snmp_args}->{duration}->{instance} . ' ' . $self->{snmp_args}->{duration}->{type_cmd} . ' "' . $self->{snmp_args}->{duration}->{val} . '"'; + + if (defined($self->{option_results}->{display_options})) { + $self->{output}->output_add(severity => 'OK', + short_msg => $options); + $self->{output}->display(force_ignore_perfdata => 1, nolabel => 1); + $self->{output}->exit(); + } $self->{option_results}->{timeout} = 10; centreon::plugins::misc::execute(output => $self->{output}, options => $self->{option_results}, @@ -141,7 +149,7 @@ sub send_trap_cmd { sub run { my ($self, %options) = @_; - if ($use_module_snmp == 1) { + if ($use_module_snmp == 1 && !defined($self->{option_results}->{display_options})) { $self->send_trap_module(); } else { $self->send_trap_cmd(); @@ -220,6 +228,10 @@ Time in seconds to wait snmptrap command used (Default: 'snmptrap'). Use if the SNMP perl module is not installed. +=item B<--display-options> + +Only display snmptrap command options. + =back =cut