Solved timeout problem in plugin modules

(cherry picked from commit 110b15e528)
This commit is contained in:
fermin831 2015-09-03 12:31:53 +02:00
parent e2a31bc538
commit cd27e2dc91
1 changed files with 22 additions and 19 deletions

View File

@ -36,7 +36,7 @@
#include "pandora_module_tcpcheck.h" #include "pandora_module_tcpcheck.h"
#include "pandora_module_regexp.h" #include "pandora_module_regexp.h"
#include "pandora_module_plugin.h" #include "pandora_module_plugin.h"
#include "pandora_module_ping.h" #include "pandora_module_ping.h"
#include "pandora_module_snmpget.h" #include "pandora_module_snmpget.h"
#include "../pandora_strutils.h" #include "../pandora_strutils.h"
#include <list> #include <list>
@ -97,14 +97,14 @@ using namespace Pandora_Strutils;
#define TOKEN_PING ("module_ping ") #define TOKEN_PING ("module_ping ")
#define TOKEN_PING_COUNT ("module_ping_count ") #define TOKEN_PING_COUNT ("module_ping_count ")
#define TOKEN_PING_TIMEOUT ("module_ping_timeout ") #define TOKEN_PING_TIMEOUT ("module_ping_timeout ")
#define TOKEN_SNMPGET ("module_snmpget") #define TOKEN_SNMPGET ("module_snmpget")
#define TOKEN_SNMPVERSION ("module_snmp_version ") #define TOKEN_SNMPVERSION ("module_snmp_version ")
#define TOKEN_SNMPCOMMUNITY ("module_snmp_community ") #define TOKEN_SNMPCOMMUNITY ("module_snmp_community ")
#define TOKEN_SNMPAGENT ("module_snmp_agent ") #define TOKEN_SNMPAGENT ("module_snmp_agent ")
#define TOKEN_SNMPOID ("module_snmp_oid ") #define TOKEN_SNMPOID ("module_snmp_oid ")
#define TOKEN_ADVANCEDOPTIONS ("module_advanced_options ") #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_UNIT ("module_unit ")
#define TOKEN_MODULE_GROUP ("module_group ") #define TOKEN_MODULE_GROUP ("module_group ")
#define TOKEN_CUSTOM_ID ("module_custom_id ") #define TOKEN_CUSTOM_ID ("module_custom_id ")
#define TOKEN_STR_WARNING ("module_str_warning ") #define TOKEN_STR_WARNING ("module_str_warning ")
@ -164,13 +164,13 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
string module_crontab, module_cron_interval, module_post_process; string module_crontab, module_cron_interval, module_post_process;
string module_min_critical, module_max_critical, module_min_warning, module_max_warning; string module_min_critical, module_max_critical, module_min_warning, module_max_warning;
string module_disabled, module_min_ff_event, module_noseekeof; string module_disabled, module_min_ff_event, module_noseekeof;
string module_ping, module_ping_count, module_ping_timeout; 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_snmpget, module_snmp_version, module_snmp_community, module_snmp_agent, module_snmp_oid;
string module_advanced_options, module_cooked, module_intensive_condition; 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_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_instructions, module_warning_instructions, module_unknown_instructions, module_tags;
string module_critical_inverse, module_warning_inverse, module_quiet, module_ff_interval; string module_critical_inverse, module_warning_inverse, module_quiet, module_ff_interval;
string macro; string macro;
Pandora_Module *module; Pandora_Module *module;
bool numeric; bool numeric;
Module_Type type; Module_Type type;
@ -226,11 +226,11 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_ping = ""; module_ping = "";
module_ping_count = ""; module_ping_count = "";
module_ping_timeout = ""; module_ping_timeout = "";
module_snmpget = ""; module_snmpget = "";
module_snmp_version = ""; module_snmp_version = "";
module_snmp_community = ""; module_snmp_community = "";
module_snmp_agent = ""; module_snmp_agent = "";
module_snmp_oid = ""; module_snmp_oid = "";
module_advanced_options = ""; module_advanced_options = "";
module_cooked = ""; module_cooked = "";
module_intensive_condition = ""; module_intensive_condition = "";
@ -428,7 +428,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
} }
if (module_snmp_version == "") { if (module_snmp_version == "") {
module_snmp_version = parseLine (line, TOKEN_SNMPVERSION); module_snmp_version = parseLine (line, TOKEN_SNMPVERSION);
} }
if (module_snmp_community == "") { if (module_snmp_community == "") {
module_snmp_community = parseLine (line, TOKEN_SNMPCOMMUNITY); module_snmp_community = parseLine (line, TOKEN_SNMPCOMMUNITY);
} }
@ -1143,6 +1143,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module = new Pandora_Module_Regexp (module_name, module_regexp, module_pattern, (unsigned char) atoi (module_noseekeof.c_str ())); module = new Pandora_Module_Regexp (module_name, module_regexp, module_pattern, (unsigned char) atoi (module_noseekeof.c_str ()));
} else if (module_plugin != "") { } else if (module_plugin != "") {
module = new Pandora_Module_Plugin (module_name, module_plugin); module = new Pandora_Module_Plugin (module_name, module_plugin);
if (module_timeout != ""){
module->setTimeout(atoi(module_timeout.c_str()));
}
} else if (module_ping != "") { } else if (module_ping != "") {
if (module_ping_count == "") { if (module_ping_count == "") {
module_ping_count = "1"; module_ping_count = "1";
@ -1154,17 +1157,17 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module = new Pandora_Module_Ping (module_name, module_ping, module_ping_count, module_ping_timeout, module_advanced_options); module = new Pandora_Module_Ping (module_name, module_ping, module_ping_count, module_ping_timeout, module_advanced_options);
if (module_timeout != "") { if (module_timeout != "") {
module->setTimeout (atoi (module_timeout.c_str ())); module->setTimeout (atoi (module_timeout.c_str ()));
} }
} else if (module_snmpget != "") { } else if (module_snmpget != "") {
if (module_snmp_version == "") { if (module_snmp_version == "") {
module_snmp_version = "1"; module_snmp_version = "1";
} }
if (module_snmp_community == "") { if (module_snmp_community == "") {
module_snmp_community = "public"; module_snmp_community = "public";
} }
if (module_snmp_agent == "") { if (module_snmp_agent == "") {
module_snmp_agent = "localhost"; module_snmp_agent = "localhost";
} }
module = new Pandora_Module_SNMPGet (module_name, module_snmp_version, module_snmp_community, module_snmp_agent, module_snmp_oid, module_advanced_options); module = new Pandora_Module_SNMPGet (module_name, module_snmp_version, module_snmp_community, module_snmp_agent, module_snmp_oid, module_advanced_options);
if (module_timeout != "") { if (module_timeout != "") {