diff --git a/pandora_agents/win32/ChangeLog b/pandora_agents/win32/ChangeLog index c4df615324..696851c7c4 100644 --- a/pandora_agents/win32/ChangeLog +++ b/pandora_agents/win32/ChangeLog @@ -1,3 +1,10 @@ +2012-11-19 Sergio Martin + + * modules/pandora_module.h + modules/pandora_module_factory.cc + modules/pandora_module.cc: Added several new module fields + to the XML + 2012-04-19 Ramon Novoa * modules/pandora_module.cc: Default to generic_data if no module_type diff --git a/pandora_agents/win32/modules/pandora_module.cc b/pandora_agents/win32/modules/pandora_module.cc index cef5e47351..f2fda80d0f 100644 --- a/pandora_agents/win32/modules/pandora_module.cc +++ b/pandora_agents/win32/modules/pandora_module.cc @@ -65,6 +65,19 @@ Pandora_Module::Pandora_Module (string name) { this->intensive_interval = 1; this->timestamp = 0; this->intensive_match = 0; + this->unit = ""; + this->module_group = 0; + this->custom_id = ""; + this->str_warning = ""; + this->str_critical = ""; + this->critical_instructions = ""; + this->warning_instructions = ""; + this->unknown_instructions = ""; + this->tags = ""; + this->critical_inverse = 0; + this->warning_inverse = 0; + this->quiet = 0; + this->module_ff_interval = 0; } /** @@ -580,6 +593,97 @@ Pandora_Module::getXml () { module_xml += "]]>\n"; } + /* Unit */ + if (this->unit != "") { + module_xml += "\tunit; + module_xml += "]]>\n"; + } + + /* Module group */ + if (this->module_group != 0) { + module_xml += "\t"; + module_xml += this->module_group; + module_xml += "\n"; + } + + /* Custom ID */ + if (this->custom_id != "") { + module_xml += "\t"; + module_xml += this->custom_id; + module_xml += "\n"; + } + + /* Str warning */ + if (this->str_warning != "") { + module_xml += "\t"; + module_xml += this->str_warning; + module_xml += "\n"; + } + + /* Str critical */ + if (this->str_critical != "") { + module_xml += "\t"; + module_xml += this->str_critical; + module_xml += "\n"; + } + + /* Critical instructions */ + if (this->critical_instructions != "") { + module_xml += "\t"; + module_xml += this->critical_instructions; + module_xml += "\n"; + } + + /* Warning instructions */ + if (this->warning_instructions != "") { + module_xml += "\t"; + module_xml += this->warning_instructions; + module_xml += "\n"; + } + + /* Unknown instructions */ + if (this->unknown_instructions != "") { + module_xml += "\t"; + module_xml += this->unknown_instructions; + module_xml += "\n"; + } + + /* Tags */ + if (this->tags != "") { + module_xml += "\t"; + module_xml += this->tags; + module_xml += "\n"; + } + + /* Critical inverse */ + if (this->critical_inverse != 0) { + module_xml += "\t"; + module_xml += this->critical_inverse; + module_xml += "\n"; + } + + /* Warning inverse */ + if (this->warning_inverse != 0) { + module_xml += "\t"; + module_xml += this->warning_inverse; + module_xml += "\n"; + } + + /* Quiet */ + if (this->quiet != 0) { + module_xml += "\t"; + module_xml += this->quiet; + module_xml += "\n"; + } + + /* Module FF interval */ + if (this->module_ff_interval != 0) { + module_xml += "\t"; + module_xml += this->module_ff_interval; + module_xml += "\n"; + } + /* Write module data */ if (this->data_list && this->data_list->size () > 1) { list::iterator iter; @@ -659,7 +763,7 @@ Pandora_Module::setMin (int value) { /** * Set the post process value for the module. * - * @param value Post process value . + * @param value Post process value to set. */ void Pandora_Module::setPostProcess (string value) { @@ -669,7 +773,7 @@ Pandora_Module::setPostProcess (string value) { /** * Set the min critical value for the module. * - * @param value Min critical value . + * @param value Min critical value to set. */ void Pandora_Module::setMinCritical (string value) { @@ -679,7 +783,7 @@ Pandora_Module::setMinCritical (string value) { /** * Set the max critical value for the module. * - * @param value Max critical value . + * @param value Max critical value to set. */ void Pandora_Module::setMaxCritical (string value) { @@ -689,7 +793,7 @@ Pandora_Module::setMaxCritical (string value) { /** * Set the min warning value for the module. * - * @param value Min warning value . + * @param value Min warning value to set. */ void Pandora_Module::setMinWarning (string value) { @@ -699,7 +803,7 @@ Pandora_Module::setMinWarning (string value) { /** * Set the max warning value for the module. * - * @param value Max warning value . + * @param value Max warning value to set. */ void Pandora_Module::setMaxWarning (string value) { @@ -709,7 +813,7 @@ Pandora_Module::setMaxWarning (string value) { /** * Set the disabled value for the module. * - * @param value Disabled value . + * @param value Disabled value to set. */ void Pandora_Module::setDisabled (string value) { @@ -719,13 +823,143 @@ Pandora_Module::setDisabled (string value) { /** * Set the min ff event value for the module. * - * @param value Min ff event value . + * @param value Min ff event value to set. */ void Pandora_Module::setMinFFEvent (string value) { this->min_ff_event = value; } +/** + * Set the unit value for the module. + * + * @param value unit value to set. + */ +void +Pandora_Module::setUnit (string value) { + this->unit = value; +} + +/** + * Set the module group for the module. + * + * @param value module group value to set. + */ +void +Pandora_Module::setModuleGroup (string value) { + this->module_group = value; +} + +/** + * Set the custom id for the module. + * + * @param value custom id value to set. + */ +void +Pandora_Module::setCustomId (string value) { + this->custom_id = value; +} + +/** + * Set the str warning for the module. + * + * @param value str warning value to set. + */ +void +Pandora_Module::setStrWarning (string value) { + this->str_warning = value; +} + +/** + * Set the str critical for the module. + * + * @param value str critical value to set. + */ +void +Pandora_Module::setStrCritical (string value) { + this->str_critical = value; +} + +/** + * Set the critical instructions for the module. + * + * @param value critical instructions value to set. + */ +void +Pandora_Module::setCriticalInstructions (string value) { + this->critical_instructions = value; +} + +/** + * Set the warning instructions for the module. + * + * @param value warning instructions value to set. + */ +void +Pandora_Module::setWarningInstructions (string value) { + this->warning_instructions = value; +} + +/** + * Set the unknown instructions for the module. + * + * @param value unknown instructions value to set. + */ +void +Pandora_Module::setUnknownInstructions (string value) { + this->unknown_instructions = value; +} + +/** + * Set the tags for the module. + * + * @param value tags value to set. + */ +void +Pandora_Module::setTags (string value) { + this->tags = value; +} + +/** + * Set the critical inverse for the module. + * + * @param value critical inverse value to set. + */ +void +Pandora_Module::setCriticalInverse (string value) { + this->critical_inverse = value; +} + +/** + * Set the warning inverse for the module. + * + * @param value warning inverse value to set. + */ +void +Pandora_Module::setWarningInverse (string value) { + this->warning_inverse = value; +} + +/** + * Set the quiet for the module. + * + * @param value quiet value to set. + */ +void +Pandora_Module::setQuiet (string value) { + this->quiet = value; +} + +/** + * Set the module FF interval for the module. + * + * @param value module FF interval value to set. + */ +void +Pandora_Module::setModuleFFInterval (string value) { + this->module_ff_interval = 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 af573596de..c6da1115be 100644 --- a/pandora_agents/win32/modules/pandora_module.h +++ b/pandora_agents/win32/modules/pandora_module.h @@ -176,7 +176,9 @@ namespace Pandora_Modules { time_t timestamp; unsigned char intensive_match; int intensive_interval; - + string unit, custom_id, str_warning, str_critical; + int module_group, warning_inverse, critical_inverse, quiet, module_ff_interval; + string critical_instructions, warning_instructions, unknown_instructions, tags; protected: @@ -263,6 +265,19 @@ namespace Pandora_Modules { void setMaxWarning (string value); void setDisabled (string value); void setMinFFEvent (string value); + void setUnit (string value); + void setModuleGroup (string value); + void setCustomId (string value); + void setStrWarning (string value); + void setStrCritical (string value); + void setCriticalInstructions (string value); + void setWarningInstructions (string value); + void setUnknownInstructions (string value); + void setTags (string value); + void setCriticalInverse (string value); + void setWarningInverse (string value); + void setQuiet (string value); + void setModuleFFInterval (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 4520ad1b85..a1437d116b 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -106,8 +106,21 @@ using namespace Pandora_Strutils; #define TOKEN_SNMPAGENT ("module_snmp_agent ") #define TOKEN_SNMPOID ("module_snmp_oid ") #define TOKEN_ADVANCEDOPTIONS ("module_advanced_options ") -#define TOKEN_INTENSIVECONDITION ("module_intensive_condition ") - +#define TOKEN_INTENSIVECONDITION ("module_intensive_condition ") +#define TOKEN_UNIT ("module_unit ") +#define TOKEN_MODULE_GROUP ("module_group ") +#define TOKEN_CUSTOM_ID ("module_custom_id ") +#define TOKEN_STR_WARNING ("module_str_warning ") +#define TOKEN_STR_CRITICAL ("module_str_critical ") +#define TOKEN_CRITICAL_INSTRUCTIONS ("module_critical_instructions ") +#define TOKEN_WARNING_INSTRUCTIONS ("module_warning_instructions ") +#define TOKEN_UNKNOWN_INSTRUCTIONS ("module_unknown_instructions ") +#define TOKEN_TAGS ("module_tags ") +#define TOKEN_CRITICAL_INVERSE ("module_critical_inverse ") +#define TOKEN_WARNING_INVERSE ("module_warning_inverse ") +#define TOKEN_QUIET ("module_quiet ") +#define TOKEN_MODULE_FF_INTERVAL ("module_ff_interval ") + string parseLine (string line, string token) { unsigned int pos; @@ -156,6 +169,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { string module_ping, module_ping_count, module_ping_timeout; string module_snmpget, module_snmp_version, module_snmp_community, module_snmp_agent, module_snmp_oid; string module_advanced_options, module_cooked, module_intensive_condition; + string module_unit, module_group, module_custom_id, module_str_warning, module_str_critical; + string module_critical_instructions, module_warning_instructions, module_unknown_instructions, module_tags; + string module_critical_inverse, module_warning_inverse, module_quiet, module_ff_interval; Pandora_Module *module; bool numeric; Module_Type type; @@ -219,6 +235,19 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_advanced_options = ""; module_cooked = ""; module_intensive_condition = ""; + module_unit = ""; + module_group = ""; + module_custom_id = ""; + module_str_warning = ""; + module_str_critical = ""; + module_critical_instructions = ""; + module_warning_instructions = ""; + module_unknown_instructions = ""; + module_tags = ""; + module_critical_inverse = ""; + module_warning_inverse = ""; + module_quiet = ""; + module_ff_interval = ""; stringtok (tokens, definition, "\n"); @@ -430,6 +459,46 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { module_intensive_condition = ""; } } + if (module_unit == "") { + module_unit = parseLine (line, TOKEN_UNIT); + } + if (module_group == "") { + module_group = parseLine (line, TOKEN_MODULE_GROUP); + } + if (module_custom_id == "") { + module_custom_id = parseLine (line, TOKEN_CUSTOM_ID); + } + if (module_str_warning == "") { + module_str_warning = parseLine (line, TOKEN_STR_WARNING); + } + if (module_str_critical == "") { + module_str_critical = parseLine (line, TOKEN_STR_CRITICAL); + } + if (module_critical_instructions == "") { + module_critical_instructions = parseLine (line, TOKEN_CRITICAL_INSTRUCTIONS); + } + if (module_warning_instructions == "") { + module_warning_instructions = parseLine (line, TOKEN_WARNING_INSTRUCTIONS); + } + if (module_unknown_instructions == "") { + module_unknown_instructions = parseLine (line, TOKEN_UNKNOWN_INSTRUCTIONS); + } + if (module_tags == "") { + module_tags = parseLine (line, TOKEN_TAGS); + } + if (module_critical_inverse == "") { + module_critical_inverse = parseLine (line, TOKEN_CRITICAL_INVERSE); + } + if (module_warning_inverse == "") { + module_warning_inverse = parseLine (line, TOKEN_WARNING_INVERSE); + } + if (module_quiet == "") { + module_quiet = parseLine (line, TOKEN_QUIET); + } + if (module_ff_interval == "") { + module_ff_interval = parseLine (line, TOKEN_MODULE_FF_INTERVAL); + } + iter++; } @@ -710,6 +779,58 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) { if (module_min_ff_event != "") { module->setMinFFEvent (module_min_ff_event); } - + + if (module_unit != "") { + module->setUnit (module_unit); + } + + if (module_group != "") { + module->setModuleGroup (module_group); + } + + if (module_custom_id != "") { + module->setCustomId (module_custom_id); + } + + if (module_str_warning != "") { + module->setStrWarning (module_str_warning); + } + + if (module_str_critical != "") { + module->setStrCritical (module_str_critical); + } + + if (module_critical_instructions != "") { + module->setCriticalInstructions (module_critical_instructions); + } + + if (module_warning_instructions != "") { + module->setWarningInstructions (module_warning_instructions); + } + + if (module_unknown_instructions != "") { + module->setUnknownInstructions (module_unknown_instructions); + } + + if (module_tags != "") { + module->setTags (module_tags); + } + + if (module_critical_inverse != "") { + module->setCriticalInverse (module_critical_inverse); + } + + if (module_warning_inverse != "") { + module->setWarningInverse (module_warning_inverse); + } + + if (module_quiet != "") { + module->setQuiet (module_quiet); + } + + if (module_ff_interval != "") { + module->setModuleFFInterval (module_ff_interval); + } + return module; }