Retry WMI modules when None is returned.

This commit is contained in:
Ramon Novoa 2023-05-09 10:22:27 +02:00
parent 782ee0e9ac
commit 0ed0b40b89
1 changed files with 11 additions and 2 deletions

View File

@ -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));