2011-03-01 Ramon Novoa <rnovoa@artica.es>

* win32/modules/pandora_module.h,
	  win32/modules/pandora_module_factory.cc,
	  win32/modules/pandora_module.cc,
	  unix/pandora_agent,
	  shellscript/linux/pandora_agent: Set the module min, max and
	  post_process in the XML data file.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4036 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2011-03-01 14:45:32 +00:00
parent fa9d3363bd
commit 6c2489b4c7
6 changed files with 85 additions and 13 deletions

View File

@ -1,3 +1,12 @@
2011-03-01 Ramon Novoa <rnovoa@artica.es>
* win32/modules/pandora_module.h,
win32/modules/pandora_module_factory.cc,
win32/modules/pandora_module.cc,
unix/pandora_agent,
shellscript/linux/pandora_agent: Set the module min, max and
post_process in the XML data file.
2011-02-14 Ramon Novoa <rnovoa@artica.es>
* embedded/INSTALL: Added instructions to cross-compile for

View File

@ -618,7 +618,7 @@ do
if [ ! -z "`echo $a | grep -e '^module_postprocess'`" ]
then
pprocess=`echo $a | cut -d" " -f2-`
echo "<postprocess><![CDATA[$pprocess]]></postprocess>" >> $DATA2
echo "<post_process><![CDATA[$pprocess]]></post_process>" >> $DATA2
fi
# If module ends, and execute for this module is enabled

View File

@ -311,9 +311,9 @@ sub read_config (;$) {
'interval' => 1,
'timeout' => 0,
'counter' => 0,
'max' => 0,
'min' => 0,
'postprocess' => 0,
'max' => undef,
'min' => undef,
'post_process' => undef,
'save' => '',
'conditions' => [],
'cron' => '',
@ -353,10 +353,12 @@ sub read_config (;$) {
} elsif ($line =~ /^\s*module_freepercentdisk\s+(.*)$/) {
$module->{'func'} = \&module_freepercentdisk;
$module->{'params'} = $1;
} elsif ($line =~ /^\s*module_max\s+(\d+)\s*$/) {
$module->{'max'} = $1;
} elsif ($line =~ /^\s*module_min\s+(\d+)\s*$/) {
} elsif ($line =~ /^\s*module_max\s+(.*)\s*$/) {
$module->{'max'} = $1;
} elsif ($line =~ /^\s*module_min\s+(.*)\s*$/) {
$module->{'min'} = $1;
} elsif ($line =~ /^\s*module_post_process\s+(.*)\s*$/) {
$module->{'post_process'} = $1;
} elsif ($line =~ /^\s*module_interval\s+(\d+)\s*$/) {
$module->{'interval'} = $1;
@ -1211,9 +1213,17 @@ sub write_module_xml ($@) {
" <description><![CDATA[" . $module->{'description'} . "]]></description>\n" .
" <type>" . $module->{'type'} . "</type>\n";
if ($module->{'interval'} > 1) {
$Xml .= " <module_interval>" . $module->{'interval'} . "</module_interval>\n";
}
# Interval
$Xml .= " <module_interval>" . $module->{'interval'} . "</module_interval>\n" if ($module->{'interval'} > 1);
# Min
$Xml .= " <min>" . $module->{'min'} . "</min>\n" if (defined ($module->{'min'}));
# Max
$Xml .= " <max>" . $module->{'max'} . "</max>\n" if (defined ($module->{'max'}));
# Post process
$Xml .= " <post_process>" . $module->{'post_process'} . "</post_process>\n" if (defined ($module->{'post_process'}));
# Data list
if ($#data > 0) {

View File

@ -43,7 +43,10 @@ Pandora_Module::Pandora_Module (string name) {
this->module_timeout = 15000;
this->max = 0;
this->min = 0;
this->post_process = "";
this->has_limits = false;
this->has_min = false;
this->has_max = false;
this->async = false;
this->data_list = NULL;
this->inventory_list = NULL;
@ -418,7 +421,7 @@ Pandora_Module::run () {
*/
string
Pandora_Module::getXml () {
ostringstream module_interval;
ostringstream module_interval, min, max;
string module_xml, data_clean, interval_str;
Pandora_Data *data;
@ -435,17 +438,44 @@ Pandora_Module::getXml () {
module_xml += "]]></name>\n\t<type><![CDATA[";
module_xml += this->module_type_str;
module_xml += "]]></type>\n";
/* Description */
if (this->module_description != "") {
module_xml += "\t<description><![CDATA[";
module_xml += this->module_description;
module_xml += "]]></description>\n";
}
/* Interval */
if (this->module_interval > 1) {
module_interval << this->module_interval;
module_xml += "\t<module_interval><![CDATA[";
module_xml += module_interval.str ();
module_xml += "]]></module_interval>\n";
}
/* Min */
if (this->has_min) {
min << this->min;
module_xml += "\t<min><![CDATA[";
module_xml += min.str ();
module_xml += "]]></min>\n";
}
/* Max */
if (this->has_max) {
max << this->max;
module_xml += "\t<max><![CDATA[";
module_xml += max.str ();
module_xml += "]]></max>\n";
}
/* Post process */
if (this->post_process != "") {
module_xml += "\t<post_process><![CDATA[";
module_xml += this->post_process;
module_xml += "]]></post_process>\n";
}
/* Write module data */
if (this->data_list && this->data_list->size () > 1) {
@ -505,6 +535,7 @@ Pandora_Module::getXml () {
void
Pandora_Module::setMax (int value) {
this->has_limits = true;
this->has_max = true;
this->max = value;
}
@ -518,9 +549,20 @@ Pandora_Module::setMax (int value) {
void
Pandora_Module::setMin (int value) {
this->has_limits = true;
this->has_min = true;
this->min = value;
}
/**
* Set the post process value for the module.
*
* @param value Post process value .
*/
void
Pandora_Module::setPostProcess (string value) {
this->post_process = value;
}
/**
* Set the async flag to the module.
*

View File

@ -158,7 +158,8 @@ namespace Pandora_Modules {
int module_timeout;
int executions;
int max, min;
bool has_limits;
string post_process;
bool has_limits, has_min, has_max;
Module_Type module_type;
string module_kind_str;
Module_Kind module_kind;
@ -242,6 +243,7 @@ namespace Pandora_Modules {
void setDescription (string description);
void setMax (int value);
void setMin (int value);
void setPostProcess (string value);
void setAsync (bool async);
void setSave (string save);

View File

@ -58,6 +58,7 @@ using namespace Pandora_Strutils;
#define TOKEN_ODBC ("module_odbc ")
#define TOKEN_MAX ("module_max ")
#define TOKEN_MIN ("module_min ")
#define TOKEN_POST_PROCESS ("module_post_process ")
#define TOKEN_DESCRIPTION ("module_description ")
#define TOKEN_ODBC_QUERY ("module_odbc_query ")
#define TOKEN_LOGEVENT ("module_logevent")
@ -127,7 +128,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
string module_perfcounter, module_tcpcheck;
string module_port, module_timeout, module_regexp;
string module_plugin, module_save, module_condition;
string module_crontab, module_cron_interval;
string module_crontab, module_cron_interval, module_post_process;
Pandora_Module *module;
bool numeric;
Module_Type type;
@ -170,6 +171,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_condition = "";
module_crontab = "";
module_cron_interval = "";
module_post_process = "";
stringtok (tokens, definition, "\n");
@ -225,6 +227,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
if (module_min == "") {
module_min = parseLine (line, TOKEN_MIN);
}
if (module_post_process == "") {
module_post_process = parseLine (line, TOKEN_POST_PROCESS);
}
if (module_description == "") {
module_description = parseLine (line, TOKEN_DESCRIPTION);
}
@ -509,5 +514,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
}
}
if (module_post_process != "") {
module->setPostProcess (module_post_process);
}
return module;
}