2009-02-24 Ramon Novoa <rnovoa@artica.es>

* win32/modules/pandora_module_proc.cc,
          win32/modules/pandora_module_proc.h,
          win32/modules/pandora_module_factory.cc,
          win32/pandora_windows_service.cc: Fixed some 'work in progress'
          code from previous commit.

        * win32/pandora.cc: Updated version string.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1482 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2009-02-24 18:50:16 +00:00
parent 148769b57c
commit 2c6d6d5954
6 changed files with 56 additions and 32 deletions

View File

@ -1,3 +1,13 @@
2009-02-24 Ramon Novoa <rnovoa@artica.es>
* win32/modules/pandora_module_proc.cc,
win32/modules/pandora_module_proc.h,
win32/modules/pandora_module_factory.cc,
win32/pandora_windows_service.cc: Fixed some 'work in progress'
code from previous commit.
* win32/pandora.cc: Updated version string.
2009-02-24 Jorge Gonzalez <jorgegonz@svn.gnome.org>
* linux/pandora_agent.conf: fixed typo.

View File

@ -101,6 +101,7 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
string module_pattern, module_async;
string module_watchdog, module_start_command;
string module_wmiquery, module_wmicolumn;
string module_retries, module_startdelay, module_retrydelay;
Pandora_Module *module;
bool numeric;
Module_Type type;
@ -250,9 +251,9 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
module_proc = (Pandora_Module_Proc *) module;
module_proc->setWatchdog (true);
module_proc->setStartCommand (module_start_command);
module_proc->setRetries (atoi(module_retries));
module_proc->setStartDelay (atoi(module_startdelay));
module_proc->setRetryDelay (atoi(module_retrydelay));
module_proc->setRetries (atoi(module_retries.c_str ()));
module_proc->setStartDelay (atoi(module_startdelay.c_str ()));
module_proc->setRetryDelay (atoi(module_retrydelay.c_str ()));
}
}
} else if (module_service != "") {

View File

@ -80,8 +80,8 @@ Pandora_Module_Proc::getStartDelay () const {
}
int
Pandora_Module_Proc::getStopDelay () const {
return this->stop_delay;
Pandora_Module_Proc::getRetryDelay () const {
return this->retry_delay;
}
void
@ -107,7 +107,8 @@ Pandora_Module_Proc::setStartDelay (int mseconds) {
if (mseconds < MIN_DELAY) {
return;
}
this->start_delay = start_delay;
this->start_delay = mseconds;
}
void
@ -115,7 +116,8 @@ Pandora_Module_Proc::setRetryDelay (int mseconds) {
if (mseconds < MIN_DELAY) {
return;
}
this->retry_delay = retry_delay;
this->retry_delay = mseconds;
}
void
@ -131,20 +133,27 @@ async_run (Pandora_Module_Proc *module) {
prev_res = module->getLatestOutput ();
modules = new Pandora_Module_List ();
modules->addModule (module);
Sleep (this->getStartDelay ());
Sleep (module->getStartDelay ());
while (1) {
Sleep (module->getStartDelay ());
processes = getProcessHandles (module->getProcessName ());
if (processes == NULL) {
if (module->isWatchdog ()) {
if (counter >= this->getRetries ()) {
this->setWatchdog (false);
} else {
Pandora_Wmi::runProgram (module->getStartCommand ());
counter++;
if (counter >= module->getRetries ()) {
module->setWatchdog (false);
continue;
}
/* Retrying... */
if (counter > 0) {
Sleep (module->getRetryDelay ());
}
Pandora_Wmi::runProgram (module->getStartCommand ());
counter++;
}
Sleep (this->getStartDelay ());
Sleep (module->getRetryDelay ());
continue;
}
@ -185,8 +194,6 @@ async_run (Pandora_Module_Proc *module) {
for (i = 0; i < nprocess; i++)
CloseHandle (processes[i]);
pandoraFree (processes);
Sleep (this->getRetryDelay ());
}
delete modules;

View File

@ -31,24 +31,24 @@ namespace Pandora_Modules {
*/
class Pandora_Module_Proc : public Pandora_Module {
private:
string process_name;
HANDLE thread;
bool watchdog;
string process_name;
HANDLE thread;
bool watchdog;
string start_command;
int retries;
int start_delay;
int stop_delay;
int retry_delay;
public:
Pandora_Module_Proc (string name, string process_name);
string getProcessName () const;
string getStartCommand () const;
string getProcessName () const;
string getStartCommand () const;
bool isWatchdog () const;
int getRetries () const;
int getStartDelay () const;
void getRetryDelay () const;
void setWatchdog (bool watchdog);
int getRetryDelay () const;
void setWatchdog (bool watchdog);
void setStartCommand (string command);
void setRetries (int retries);
void setStartDelay (int mseconds);

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("2.0(Build 080610)")
#define PANDORA_VERSION ("3.0(Build 090224)")
string pandora_path;
string pandora_dir;

View File

@ -209,8 +209,10 @@ Pandora_Windows_Service::copyTentacleDataFile (string host,
{
bool rc = false;
string var, filepath;
string tentacle_cmd;
string tentacle_cmd, working_dir;
PROCESS_INFORMATION pi;
STARTUPINFO si;
var = conf->getValue ("temporal");
if (var[var.length () - 1] != '\\') {
var += "\\";
@ -244,11 +246,15 @@ Pandora_Windows_Service::copyTentacleDataFile (string host,
filepath.c_str (), host.c_str ());
pandoraDebug ("Command %s", tentacle_cmd.c_str());
rc = Pandora_Wmi::runProgram (tentacle_cmd.c_str(), CREATE_NO_WINDOW);
ZeroMemory (&si, sizeof (si));
ZeroMemory (&pi, sizeof (pi));
rc = CreateProcess (NULL , (CHAR *)tentacle_cmd.c_str (), NULL, NULL, FALSE, CREATE_NO_WINDOW,
NULL, NULL, &si, &pi);
WaitForSingleObject(pi.hProcess, INFINITE);
if (rc == true) {
return 0;
}
pandoraDebug ("Tentacle client was unable to copy %s",
filename.c_str ());
return -1;