diff --git a/pandora_agents/win32/ChangeLog b/pandora_agents/win32/ChangeLog index 410342d489..831b873f5f 100644 --- a/pandora_agents/win32/ChangeLog +++ b/pandora_agents/win32/ChangeLog @@ -1,3 +1,10 @@ +2011-07-14 Ramon Novoa + + * modules/pandora_module.h, + modules/pandora_module_factory.cc, + modules/pandora_module.cc: Set additional module configuration + parameters from the XML. + 2011-05-06 Vanessa Gil * win32/pandora.cc: Fixed: Windows agent log and system time are unsynchronized. diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index ab2379f60b..a1a84820c6 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -55,6 +55,12 @@ Pandora_Module::Pandora_Module (string name) { this->precondition_list = NULL; this->condition_list = NULL; this->cron = NULL; + this->min_critical = ""; + this->max_critical = ""; + this->min_warning = ""; + this->max_warning = ""; + this->disabled = ""; + this->min_ff_event = ""; } /** @@ -498,6 +504,48 @@ Pandora_Module::getXml () { module_xml += "]]>\n"; } + /* Min critical */ + if (this->min_critical != "") { + module_xml += "\tmin_critical; + module_xml += "]]>\n"; + } + + /* Max critical */ + if (this->max_critical != "") { + module_xml += "\tmax_critical; + module_xml += "]]>\n"; + } + + /* Min warning */ + if (this->min_warning != "") { + module_xml += "\tmin_warning; + module_xml += "]]>\n"; + } + + /* Max warning */ + if (this->max_warning != "") { + module_xml += "\tmax_warning; + module_xml += "]]>\n"; + } + + /* Disabled */ + if (this->disabled != "") { + module_xml += "\tdisabled; + module_xml += "]]>\n"; + } + + /* Min ff event */ + if (this->min_ff_event != "") { + module_xml += "\tmin_ff_event; + module_xml += "]]>\n"; + } + /* Write module data */ if (this->data_list && this->data_list->size () > 1) { list::iterator iter; @@ -584,6 +632,66 @@ Pandora_Module::setPostProcess (string value) { this->post_process = value; } +/** + * Set the min critical value for the module. + * + * @param value Min critical value . + */ +void +Pandora_Module::setMinCritical (string value) { + this->min_critical = value; +} + +/** + * Set the max critical value for the module. + * + * @param value Max critical value . + */ +void +Pandora_Module::setMaxCritical (string value) { + this->max_critical = value; +} + +/** + * Set the min warning value for the module. + * + * @param value Min warning value . + */ +void +Pandora_Module::setMinWarning (string value) { + this->min_warning = value; +} + +/** + * Set the max warning value for the module. + * + * @param value Max warning value . + */ +void +Pandora_Module::setMaxWarning (string value) { + this->max_warning = value; +} + +/** + * Set the disabled value for the module. + * + * @param value Disabled value . + */ +void +Pandora_Module::setDisabled (string value) { + this->disabled = value; +} + +/** + * Set the min ff event value for the module. + * + * @param value Min ff event value . + */ +void +Pandora_Module::setMinFFEvent (string value) { + this->min_ff_event = value; +} + /** * Set the async flag to the module. * diff --git a/pandora_agents/win32/modules/pandora_module.h b/pandora_agents/win32/modules/pandora_module.h index d8e617e655..eadb262411 100644 --- a/pandora_agents/win32/modules/pandora_module.h +++ b/pandora_agents/win32/modules/pandora_module.h @@ -170,7 +170,8 @@ namespace Pandora_Modules { int module_timeout; int executions; int max, min; - string post_process; + string min_critical, max_critical, min_warning, max_warning; + string post_process, disabled, min_ff_event; bool has_limits, has_min, has_max; Module_Type module_type; string module_kind_str; @@ -257,6 +258,13 @@ namespace Pandora_Modules { void setMax (int value); void setMin (int value); void setPostProcess (string value); + void setMinCritical (string value); + void setMaxCritical (string value); + void setMinWarning (string value); + void setMaxWarning (string value); + void setDisabled (string value); + void setMinFFEvent (string value); + void setAsync (bool async); void setSave (string save); diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index c20770b05a..a60ba7dc91 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -59,6 +59,12 @@ using namespace Pandora_Strutils; #define TOKEN_MAX ("module_max ") #define TOKEN_MIN ("module_min ") #define TOKEN_POST_PROCESS ("module_postprocess ") +#define TOKEN_MIN_CRITICAL ("module_min_critical ") +#define TOKEN_MAX_CRITICAL ("module_max_critical ") +#define TOKEN_MIN_WARNING ("module_min_warning ") +#define TOKEN_MAX_WARNING ("module_max_warning ") +#define TOKEN_DISABLED ("module_disabled ") +#define TOKEN_MIN_FF_EVENT ("module_min_ff_event ") #define TOKEN_DESCRIPTION ("module_description ") #define TOKEN_ODBC_QUERY ("module_odbc_query ") #define TOKEN_LOGEVENT ("module_logevent") @@ -130,6 +136,8 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { string module_port, module_timeout, module_regexp; string module_plugin, module_save, module_condition, module_precondition; string module_crontab, module_cron_interval, module_post_process; + string module_min_critical, module_max_critical, module_min_warning, module_max_warning; + string module_disabled, module_min_ff_event; Pandora_Module *module; bool numeric; Module_Type type; @@ -176,6 +184,12 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_cron_interval = ""; module_post_process = ""; module_precondition = ""; + module_min_critical = ""; + module_max_critical = ""; + module_min_warning = ""; + module_max_warning = ""; + module_disabled = ""; + module_min_ff_event = ""; stringtok (tokens, definition, "\n"); @@ -243,6 +257,24 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { if (module_post_process == "") { module_post_process = parseLine (line, TOKEN_POST_PROCESS); } + if (module_min_critical == "") { + module_post_process = parseLine (line, TOKEN_MIN_CRITICAL); + } + if (module_max_critical == "") { + module_post_process = parseLine (line, TOKEN_MAX_CRITICAL); + } + if (module_min_warning == "") { + module_post_process = parseLine (line, TOKEN_MIN_WARNING); + } + if (module_max_warning == "") { + module_post_process = parseLine (line, TOKEN_MAX_WARNING); + } + if (module_disabled == "") { + module_post_process = parseLine (line, TOKEN_DISABLED); + } + if (module_min_ff_event == "") { + module_post_process = parseLine (line, TOKEN_MIN_FF_EVENT); + } if (module_description == "") { module_description = parseLine (line, TOKEN_DESCRIPTION); } @@ -541,5 +573,29 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module->setPostProcess (module_post_process); } + if (module_min_critical != "") { + module->setMinCritical (module_min_critical); + } + + if (module_max_critical != "") { + module->setMaxCritical (module_max_critical); + } + + if (module_min_warning != "") { + module->setMinWarning (module_min_warning); + } + + if (module_max_warning != "") { + module->setMaxWarning (module_max_warning); + } + + if (module_disabled != "") { + module->setDisabled (module_disabled); + } + + if (module_min_ff_event != "") { + module->setMinFFEvent (module_min_ff_event); + } + return module; }