From 8e9b1ddc4b23a7c006a86b12caf1a35b94e09b83 Mon Sep 17 00:00:00 2001
From: Colin Gagnaire <cgagnaire@centreon.com>
Date: Wed, 12 Aug 2020 20:36:15 +0200
Subject: [PATCH] enh(linux/local): add timeout and sudo as options for nmap
 discovery (#2148)

---
 os/linux/local/mode/discoverynmap.pm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/os/linux/local/mode/discoverynmap.pm b/os/linux/local/mode/discoverynmap.pm
index a932b1a2a..c8e4cfc96 100644
--- a/os/linux/local/mode/discoverynmap.pm
+++ b/os/linux/local/mode/discoverynmap.pm
@@ -35,6 +35,8 @@ sub new {
     
     $options{options}->add_options(arguments => {
         'subnet:s'              => { name => 'subnet' },
+        'timeout:s'             => { name => 'timeout', default => 120 },
+        'sudo'                  => { name => 'sudo' },
         'prettify'              => { name => 'prettify' }
     });
                                     
@@ -112,7 +114,8 @@ sub run {
         command => 'nmap',
         command_options => '-sS -sU -R -O --osscan-limit --osscan-guess -p U:161,162,T:21-25,80,139,443,3306,8080,8443 -oX - ',
         command_options_suffix => $self->{option_results}->{subnet},
-        timeout => 120
+        sudo => $self->{option_results}->{sudo},
+        timeout => $self->{option_results}->{timeout}
     );
 
     my $results = $self->decode_xml_response(
@@ -190,6 +193,14 @@ Command used: nmap -sS -sU -R -O --osscan-limit --osscan-guess -p U:161,162,T:21
 Specify subnet from which discover
 resources (Must be <ip>/<cidr> format) (Mandatory).
 
+=item B<--timeout>
+
+Timeout in seconds (Default: 120).
+
+=item B<--sudo>
+
+Defines if 'sudo' must be used to execute the 'nmap' command.
+
 =item B<--prettify>
 
 Prettify JSON output.