Force modules that run once to async types.

This commit is contained in:
Ramon Novoa 2023-07-17 22:05:40 +09:00
parent 1b3a12a8f0
commit a29e504e2c
2 changed files with 23 additions and 0 deletions

View File

@ -1671,6 +1671,17 @@ sub parse_conf_modules($) {
# Convert from seconds to actual agent intervals.
$module->{'interval'} = ceil($module->{'absoluteinterval'} / $Conf{'interval'});
# Make sure modules that run once are asynchronous.
if ($module->{'interval'} == 0) {
if ($module->{'type'} eq 'generic_data') {
$module->{'type'} = 'async_data';
} elsif ($module->{'type'} eq 'generic_proc') {
$module->{'type'} = 'async_proc';
} elsif ($module->{'type'} eq 'generic_data_string') {
$module->{'type'} = 'async_string';
}
}
# This file will be used for persistence.
$module->{'timestamp_file'} = $ConfDir . '/' . $Conf{'server_path_ref'} . '/' . md5($module->{'name'}) . '.ref';
}

View File

@ -1448,6 +1448,18 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
numeric = false;
}
// Make sure modules that run once are asynchronous.
if (module->getInterval() == 0) {
type = module->getTypeInt();
if (type == TYPE_GENERIC_DATA) {
module->setType("async_data");
} else if (type == TYPE_GENERIC_PROC) {
module->setType("async_proc");
} else if (type == TYPE_GENERIC_DATA_STRING) {
module->setType("async_string");
}
}
if (numeric) {
if (module_max != "") {
try {