Skip to content

Commit

Permalink
fix: Update ESX & RemoteInventory timeout to a safe value after first…
Browse files Browse the repository at this point in the history
… connection attempt
  • Loading branch information
g-bougard committed Nov 28, 2023
1 parent aa33b4a commit bad9c65
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Revision history for GLPI agent

core:
* Make alt2canonical() always return a mac address in lower case if found one
* Fix HTTP::Client API to support timeout update

inventory:
* PR #531: Add SentinelOne Antivirus support on Linux, thanks to @MarcSamD
Expand All @@ -17,16 +18,22 @@ inventory:
* Feature: Make assetname-support option also works to compute agent deviceid when
unknown

remoteinventory:
* Fix connection timeout API to support timeout update

netdiscovery/netinventory:
* Enhanced Toshiba printers support
* Fix LLDP support
* Update timeout to backend-collect-timeout configuration when scanning ESX or
RemoteInventory after a successful scan requested by ToolBox

esx:
* Fix first connection timeout support
* Added --timeout option support to glpi-esx

toolbox:
* fix #533: Fix Toolbox export buttons in inventory results
* Fix wrong remote inventory results when using a short timeout for quickier detection

injector:
* fix #537: Make -x, --xml-ua & --json-ua options equivalent and update help text
Expand Down
7 changes: 7 additions & 0 deletions lib/GLPI/Agent/HTTP/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ sub new {
return $self;
}

sub timeout {
my ($self, $timeout) = @_;

# Get/set LWP::UserAgent timeout as required
return $self->{ua}->timeout($timeout);
}

sub request {
my ($self, $request, $file, $no_proxy_host, $timeout, %skiperror) = @_;

Expand Down
5 changes: 5 additions & 0 deletions lib/GLPI/Agent/Task/NetDiscovery.pm
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,11 @@ sub run {
};
my $credentials = first { $_->{ID} eq $authremote } @{$jobaddress->{remote_credentials}};
if ($credentials && $found) {

# Reset timeout to backend-collect-timeout as first set one is only for discovery
$timeout = $self->{config}->{"backend-collect-timeout"};
$found->timeout($timeout);

my $path;
$path = $self->{target}->getPath() if $self->{target}->isType('local');
# When target path is agent folder, inventory should be saved in inventory subfolder
Expand Down
9 changes: 9 additions & 0 deletions lib/GLPI/Agent/Task/RemoteInventory/Remote/Ssh.pm
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ sub _ssh2_exec_status {
return $ret;
}

sub timeout {
my ($self, $timeout) = @_;

# Reset Net::SSH2 current client timeout if required
$self->{_ssh2}->timeout($timeout * 1000) if $timeout && $self->{_ssh2};

$self->SUPER::timeout($timeout);
}

sub checking_error {
my ($self) = @_;

Expand Down
9 changes: 9 additions & 0 deletions lib/GLPI/Agent/Task/RemoteInventory/Remote/Winrm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ sub prepare {
);
}

sub timeout {
my ($self, $timeout) = @_;

# Reset http client timeout if required
$self->{_winrm}->timeout($timeout) if $timeout && $self->{_winrm};

$self->SUPER::timeout($timeout);
}

sub checking_error {
my ($self) = @_;

Expand Down

0 comments on commit bad9c65

Please sign in to comment.