2011-07-14 Ramon Novoa <rnovoa@artica.es>

* modules/pandora_module.h,
	  modules/pandora_module_factory.cc,
	  modules/pandora_module.cc: Set additional module configuration
	  parameters from the XML.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4572 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2011-07-14 16:45:12 +00:00
parent f05f9e36bd
commit d320f55981
4 changed files with 180 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2011-07-14 Ramon Novoa <rnovoa@artica.es>
* 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 <vanessa.gil@artica.es>
* win32/pandora.cc: Fixed: Windows agent log and system time are unsynchronized.

View File

@ -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 += "]]></post_process>\n";
}
/* Min critical */
if (this->min_critical != "") {
module_xml += "\t<min_critical><![CDATA[";
module_xml += this->min_critical;
module_xml += "]]></min_critical>\n";
}
/* Max critical */
if (this->max_critical != "") {
module_xml += "\t<max_critical><![CDATA[";
module_xml += this->max_critical;
module_xml += "]]></max_critical>\n";
}
/* Min warning */
if (this->min_warning != "") {
module_xml += "\t<min_warning><![CDATA[";
module_xml += this->min_warning;
module_xml += "]]></min_warning>\n";
}
/* Max warning */
if (this->max_warning != "") {
module_xml += "\t<max_warning><![CDATA[";
module_xml += this->max_warning;
module_xml += "]]></max_warning>\n";
}
/* Disabled */
if (this->disabled != "") {
module_xml += "\t<disabled><![CDATA[";
module_xml += this->disabled;
module_xml += "]]></disabled>\n";
}
/* Min ff event */
if (this->min_ff_event != "") {
module_xml += "\t<min_ff_event><![CDATA[";
module_xml += this->min_ff_event;
module_xml += "]]></min_ff_event>\n";
}
/* Write module data */
if (this->data_list && this->data_list->size () > 1) {
list<Pandora_Data *>::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.
*

View File

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

View File

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