diff --git a/pandora_agents/win32/ChangeLog b/pandora_agents/win32/ChangeLog index 967a0c3ec0..cecf594f52 100644 --- a/pandora_agents/win32/ChangeLog +++ b/pandora_agents/win32/ChangeLog @@ -1,3 +1,10 @@ +2009-09-11 Ramon Novoa + + * modules/pandora_module_inventory.h, + modules/pandora_module_inventory.cc, + modules/pandora_module_factory.cc: Fixed inventory module interval + calculation. + 2009-09-10 Ramon Novoa * windows/pandora_wmi.cc, diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index 88a35db592..cfb6b63e4a 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -123,7 +123,8 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { Pandora_Module *module; bool numeric; Module_Type type; - + long agent_interval; + module_name = ""; module_type = ""; module_min = ""; @@ -339,16 +340,6 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { } else if (module_inventory != "") { module = new Pandora_Module_Inventory (module_name, module_inventory); - if (module_interval != "") { - try { - // Convert the interval to seconds... - int interval = strtoint (module_interval) *60 *60 *24 ; - module->setInterval(interval); - } catch (Invalid_Conversion e) { - pandoraLog("Error in conversion of module_inventory_interval"); - } - - } } else if (module_odbc != "") { module = new Pandora_Module_Odbc (module_name, module_odbc, diff --git a/pandora_agents/win32/modules/pandora_module_inventory.cc b/pandora_agents/win32/modules/pandora_module_inventory.cc index 8560806bcd..c4711d03e9 100644 --- a/pandora_agents/win32/modules/pandora_module_inventory.cc +++ b/pandora_agents/win32/modules/pandora_module_inventory.cc @@ -22,6 +22,7 @@ the agent is instaled. #include "pandora_module_inventory.h" #include "../windows/pandora_wmi.h" #include "../windows/pandora_windows_info.h" +#include "../pandora_windows_service.h" #include "../pandora_strutils.h" using namespace Pandora; @@ -37,6 +38,7 @@ Pandora_Module_Inventory::Pandora_Module_Inventory (string name, string options) : Pandora_Module (name) { this->setKind (module_inventory_str); this->options = options; + this->interval_fixed = 0; } /** * Run the module and generates the output. @@ -52,13 +54,21 @@ Pandora_Module_Inventory::Pandora_Module_Inventory (string name, string options) */ void Pandora_Module_Inventory::run () { - list rows; list::iterator row; int num_results = 0; string res; size_t found; + // Agent interval unknown at module creation time, module interval cannot be + // set in constructor. + if (this->interval_fixed == 0) { + int agent_interval = Pandora_Windows_Service::getInstance ()->interval; + // Module interval specified in days for inventory modules (86400 = 60 * 60 * 24) + this->setInterval (this->getInterval () * 86400 / (agent_interval / 1000)); + this->interval_fixed = 1; + } + // Until no data data is gathered there will be no output this->has_output = false; diff --git a/pandora_agents/win32/modules/pandora_module_inventory.h b/pandora_agents/win32/modules/pandora_module_inventory.h index feb21f1bb0..01471e53e2 100644 --- a/pandora_agents/win32/modules/pandora_module_inventory.h +++ b/pandora_agents/win32/modules/pandora_module_inventory.h @@ -42,6 +42,7 @@ namespace Pandora_Modules { class Pandora_Module_Inventory : public Pandora_Module { private: string options; + unsigned char interval_fixed; public: Pandora_Module_Inventory (string name, string options);