From 0ed0b40b89a6383a480290c65e6f985d02580566 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Tue, 9 May 2023 10:22:27 +0200 Subject: [PATCH] Retry WMI modules when None is returned. --- pandora_server/lib/PandoraFMS/WMIServer.pm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pandora_server/lib/PandoraFMS/WMIServer.pm b/pandora_server/lib/PandoraFMS/WMIServer.pm index 018d7e86ac..d47470829c 100644 --- a/pandora_server/lib/PandoraFMS/WMIServer.pm +++ b/pandora_server/lib/PandoraFMS/WMIServer.pm @@ -135,8 +135,9 @@ sub data_producer ($) { ############################################################################### # Data consumer. ############################################################################### -sub data_consumer ($$) { - my ($self, $module_id) = @_; +#sub data_consumer ($$;$) { +sub data_consumer { + my ($self, $module_id, $none) = @_; my ($pa_config, $dbh) = ($self->getConfig (), $self->getDBH ()); my $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente_modulo = ?', $module_id); @@ -247,6 +248,14 @@ sub data_consumer ($$) { }; } + # Every once in a while a WMI module seems to return None and we don't know the + # cause yet. Calling data_consumer again is not the most efficient way to retry the module, + # but it reduces the complexity of the function and this should only happen on rare occasions. + if ($module_data eq 'None' && !defined($none)) { + data_consumer($self, $module_id, 'None'); + return; + } + my $utimestamp = time (); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime($utimestamp));