diff --git a/pandora_agents/ChangeLog b/pandora_agents/ChangeLog index 857ada31ac..cd08e5d8d7 100644 --- a/pandora_agents/ChangeLog +++ b/pandora_agents/ChangeLog @@ -1,3 +1,13 @@ +2009-02-24 Ramon Novoa + + * 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 * linux/pandora_agent.conf: fixed typo. diff --git a/pandora_agents/win32/modules/pandora_module_factory.cc b/pandora_agents/win32/modules/pandora_module_factory.cc index 30ec8dad64..09242bd0ca 100644 --- a/pandora_agents/win32/modules/pandora_module_factory.cc +++ b/pandora_agents/win32/modules/pandora_module_factory.cc @@ -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 != "") { diff --git a/pandora_agents/win32/modules/pandora_module_proc.cc b/pandora_agents/win32/modules/pandora_module_proc.cc index 2bdf8d59f9..1b76f7e77e 100644 --- a/pandora_agents/win32/modules/pandora_module_proc.cc +++ b/pandora_agents/win32/modules/pandora_module_proc.cc @@ -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; diff --git a/pandora_agents/win32/modules/pandora_module_proc.h b/pandora_agents/win32/modules/pandora_module_proc.h index 27c79911ae..6ca28ae84c 100644 --- a/pandora_agents/win32/modules/pandora_module_proc.h +++ b/pandora_agents/win32/modules/pandora_module_proc.h @@ -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); diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index b1b0cfaa36..86c2631f5c 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -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; diff --git a/pandora_agents/win32/pandora_windows_service.cc b/pandora_agents/win32/pandora_windows_service.cc index 0d368030c1..21bda86ffc 100644 --- a/pandora_agents/win32/pandora_windows_service.cc +++ b/pandora_agents/win32/pandora_windows_service.cc @@ -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;