mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
added module_interval feature to broker agents
This commit is contained in:
parent
afe730d4c4
commit
3be05cf385
@ -1422,48 +1422,48 @@ Pandora_Module::evaluatePreconditions () {
|
|||||||
buffer[read] = '\0';
|
buffer[read] = '\0';
|
||||||
output += (char *) buffer;
|
output += (char *) buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
double_output = Pandora_Strutils::strtodouble (output);
|
double_output = Pandora_Strutils::strtodouble (output);
|
||||||
} catch (Pandora_Strutils::Invalid_Conversion e) {
|
} catch (Pandora_Strutils::Invalid_Conversion e) {
|
||||||
double_output = 0;
|
double_output = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dwRet == WAIT_OBJECT_0) {
|
||||||
|
break;
|
||||||
|
} else if(this->getTimeout() < GetTickCount() - tickbase) {
|
||||||
|
/* STILL_ACTIVE */
|
||||||
|
TerminateProcess(pi.hThread, STILL_ACTIVE);
|
||||||
|
pandoraLog ("evaluatePreconditions: %s timed out (retcode: %d)", this->module_name.c_str (), STILL_ACTIVE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dwRet == WAIT_OBJECT_0) {
|
GetExitCodeProcess (pi.hProcess, &retval);
|
||||||
break;
|
|
||||||
} else if(this->getTimeout() < GetTickCount() - tickbase) {
|
if (retval != 0) {
|
||||||
/* STILL_ACTIVE */
|
if (! TerminateJobObject (job, 0)) {
|
||||||
TerminateProcess(pi.hThread, STILL_ACTIVE);
|
pandoraLog ("evaluatePreconditions: TerminateJobObject failed. (error %d)",
|
||||||
pandoraLog ("evaluatePreconditions: %s timed out (retcode: %d)", this->module_name.c_str (), STILL_ACTIVE);
|
GetLastError ());
|
||||||
break;
|
}
|
||||||
|
if (retval != STILL_ACTIVE) {
|
||||||
|
pandoraLog ("evaluatePreconditions: %s did not executed well (retcode: %d)",
|
||||||
|
this->module_name.c_str (), retval);
|
||||||
|
}
|
||||||
|
/* Close job, process and thread handles. */
|
||||||
|
CloseHandle (job);
|
||||||
|
CloseHandle (pi.hProcess);
|
||||||
|
CloseHandle (pi.hThread);
|
||||||
|
CloseHandle (new_stdout);
|
||||||
|
CloseHandle (out_read);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
GetExitCodeProcess (pi.hProcess, &retval);
|
|
||||||
|
|
||||||
if (retval != 0) {
|
|
||||||
if (! TerminateJobObject (job, 0)) {
|
|
||||||
pandoraLog ("evaluatePreconditions: TerminateJobObject failed. (error %d)",
|
|
||||||
GetLastError ());
|
|
||||||
}
|
|
||||||
if (retval != STILL_ACTIVE) {
|
|
||||||
pandoraLog ("evaluatePreconditions: %s did not executed well (retcode: %d)",
|
|
||||||
this->module_name.c_str (), retval);
|
|
||||||
}
|
|
||||||
/* Close job, process and thread handles. */
|
/* Close job, process and thread handles. */
|
||||||
CloseHandle (job);
|
CloseHandle (job);
|
||||||
CloseHandle (pi.hProcess);
|
CloseHandle (pi.hProcess);
|
||||||
CloseHandle (pi.hThread);
|
CloseHandle (pi.hThread);
|
||||||
CloseHandle (new_stdout);
|
|
||||||
CloseHandle (out_read);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close job, process and thread handles. */
|
|
||||||
CloseHandle (job);
|
|
||||||
CloseHandle (pi.hProcess);
|
|
||||||
CloseHandle (pi.hThread);
|
|
||||||
}
|
|
||||||
|
|
||||||
CloseHandle (new_stdout);
|
CloseHandle (new_stdout);
|
||||||
CloseHandle (out_read);
|
CloseHandle (out_read);
|
||||||
@ -1693,4 +1693,18 @@ Pandora_Module::getAsync () {
|
|||||||
return this->async;
|
return this->async;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current exections
|
||||||
|
*/
|
||||||
|
long
|
||||||
|
Pandora_Module::getExecutions () {
|
||||||
|
return this->executions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set current execution (global) used for brokers.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
Pandora_Module::setExecutions (long executions) {
|
||||||
|
this->executions = executions;
|
||||||
|
}
|
||||||
|
@ -234,6 +234,8 @@ namespace Pandora_Modules {
|
|||||||
int getTimeout ();
|
int getTimeout ();
|
||||||
string getSave ();
|
string getSave ();
|
||||||
bool getAsync ();
|
bool getAsync ();
|
||||||
|
void setExecutions(long executions=0);
|
||||||
|
long getExecutions();
|
||||||
|
|
||||||
virtual string getXml ();
|
virtual string getXml ();
|
||||||
|
|
||||||
|
@ -1849,7 +1849,7 @@ Pandora_Windows_Service::sendBufferedXml (string path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Pandora_Windows_Service::pandora_run_broker (string config) {
|
Pandora_Windows_Service::pandora_run_broker (string config, long executions) {
|
||||||
Pandora_Agent_Conf *conf = NULL;
|
Pandora_Agent_Conf *conf = NULL;
|
||||||
string server_addr;
|
string server_addr;
|
||||||
unsigned char data_flag = 0;
|
unsigned char data_flag = 0;
|
||||||
@ -1876,7 +1876,10 @@ Pandora_Windows_Service::pandora_run_broker (string config) {
|
|||||||
Pandora_Module *module;
|
Pandora_Module *module;
|
||||||
|
|
||||||
module = this->broker_modules->getCurrentValue ();
|
module = this->broker_modules->getCurrentValue ();
|
||||||
|
|
||||||
|
/* Keep executions matching main agent */
|
||||||
|
module->setExecutions(executions);
|
||||||
|
|
||||||
/* Check preconditions */
|
/* Check preconditions */
|
||||||
if (module->evaluatePreconditions () == 0) {
|
if (module->evaluatePreconditions () == 0) {
|
||||||
pandoraDebug ("Preconditions not matched for module %s", module->getName ().c_str ());
|
pandoraDebug ("Preconditions not matched for module %s", module->getName ().c_str ());
|
||||||
@ -2074,7 +2077,7 @@ Pandora_Windows_Service::pandora_run (int forced_run) {
|
|||||||
check_broker_agents(all_conf);
|
check_broker_agents(all_conf);
|
||||||
for (i=0;i<num;i++){
|
for (i=0;i<num;i++){
|
||||||
pandora_init_broker(all_conf[i]);
|
pandora_init_broker(all_conf[i]);
|
||||||
pandora_run_broker(all_conf[i]);
|
pandora_run_broker(all_conf[i], execution_number);
|
||||||
}
|
}
|
||||||
delete []all_conf;
|
delete []all_conf;
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ namespace Pandora {
|
|||||||
int checkConfig (string file);
|
int checkConfig (string file);
|
||||||
void purgeDiskCollections ();
|
void purgeDiskCollections ();
|
||||||
void pandora_init_broker (string file_conf);
|
void pandora_init_broker (string file_conf);
|
||||||
void pandora_run_broker (string config);
|
void pandora_run_broker (string config, long executions=0);
|
||||||
int count_broker_agents();
|
int count_broker_agents();
|
||||||
void check_broker_agents(string *all_conf);
|
void check_broker_agents(string *all_conf);
|
||||||
int launchTentacleProxy();
|
int launchTentacleProxy();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user