2006-07-05 Esteban Sanchez <esteban@steve-o.org>
* pandora.[cc,h]: Program name and display name of the application. Added pandora_version variable and getPandoraAgentVersion() * pandora_windows_service.[cc,h]: Added checking of debug flag when reading the configuration file. Get the agent name from the machine if it was not defined in the configuration file. Date format on getXmlHeader() corrected. Style correction. * bin/README.txt: Fixed a error. * bin/PandoraAgent.tar.gz: Updated to the new commit. * windows/pandora_wmi.cc: The errors are now shown using pandoraLog(). * modules/pandora_module.cc, modules/pandora_module_exec.cc, ChangeLog: Style correction. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@91 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
2666fe27b4
commit
38b25f1170
|
@ -1,54 +1,82 @@
|
|||
2006-07-05 Esteban Sanchez <esteban@steve-o.org>
|
||||
|
||||
* pandora.[cc,h]: Program name and display name of the application.
|
||||
Added pandora_version variable and getPandoraAgentVersion()
|
||||
|
||||
* pandora_windows_service.[cc,h]: Added checking of debug flag when
|
||||
reading the configuration file. Get the agent name from the machine if
|
||||
it was not defined in the configuration file. Date format on
|
||||
getXmlHeader() corrected. Style correction.
|
||||
|
||||
* bin/README.txt: Fixed a error.
|
||||
|
||||
* bin/PandoraAgent.tar.gz: Updated to the new commit.
|
||||
|
||||
* windows/pandora_wmi.cc: The errors are now shown using pandoraLog().
|
||||
|
||||
* modules/pandora_module.cc, modules/pandora_module_exec.cc,
|
||||
ChangeLog: Style correction.
|
||||
|
||||
2006-07-05 Esteban Sanchez <esteban@steve-o.org>
|
||||
* bin/README.txt: Added to repository.
|
||||
|
||||
* pandora.h: Service name renamed.
|
||||
|
||||
2006-07-05 Esteban Sanchez <esteban@steve-o.org>
|
||||
|
||||
* windows/pandora_wmi.cc: Removed unnecessary debug. Check the service state on isRunningService ()
|
||||
* windows/pandora_wmi.cc: Removed unnecessary debug. Check the service
|
||||
state on isRunningService ()
|
||||
|
||||
* pandora_agent_conf.cc, modules/pandora_module_factory.cc: Removed unnecessary debug.
|
||||
* pandora_agent_conf.cc, modules/pandora_module_factory.cc: Removed
|
||||
unnecessary debug.
|
||||
|
||||
* bin/PandoraAgent.tar.gz: Added to repository.
|
||||
|
||||
* ssh/pandora_ssh_client.cc: Debug converted into log.
|
||||
|
||||
* pandora_windows_service.cc: Get the interval value (in minutes) and set it to the service.
|
||||
Check if the XML of the module is NULL before adding it to the file. Added log output on error.
|
||||
Delete temporal file before finishing the run.
|
||||
* pandora_windows_service.cc: Get the interval value (in minutes)
|
||||
and set it to the service. Check if the XML of the module is NULL
|
||||
before adding it to the file. Added log output on error. Delete
|
||||
temporal file before finishing the run.
|
||||
|
||||
* pandora_windows_service.h: Macro modified.
|
||||
|
||||
* modules/pandora_module.h, modules/pandora_module.cc: Added new exception, raised when the interval
|
||||
is not fulfilled. Added code to the run funtion of the Pandora_Module class, to check the execution
|
||||
* modules/pandora_module.h, modules/pandora_module.cc: Added new
|
||||
exception, raised when the interval is not fulfilled. Added code to
|
||||
the run funtion of the Pandora_Module class, to check the execution
|
||||
interval.
|
||||
|
||||
* modules/pandora_module_proc.cc, modules/pandora_module_exec.cc, modules/pandora_module_service.cc:
|
||||
Call to the run() base class function before running the specific code.
|
||||
* modules/pandora_module_proc.cc, modules/pandora_module_exec.cc,
|
||||
modules/pandora_module_service.cc: Call to the run() base class
|
||||
function before running the specific code.
|
||||
|
||||
* modules/pandora_module_list.cc: Removed use of namespace and use a explicit specification.
|
||||
* modules/pandora_module_list.cc: Removed use of namespace and use a
|
||||
explicit specification.
|
||||
|
||||
2006-07-04 Esteban Sanchez <esteban@steve-o.org>
|
||||
|
||||
* windows/pandora_wmi.*, windows/pandora_windows_info.*, windows/wmi/disphelper.*,
|
||||
misc/pandora_file.*, ssh/*, ssh/libssh2/*, modules/pandora_module_service.*,
|
||||
modules/pandora_module_proc.*: Added to repository
|
||||
* windows/pandora_wmi.*, windows/pandora_windows_info.*,
|
||||
windows/wmi/disphelper.*, misc/pandora_file.*, ssh/*, ssh/libssh2/*,
|
||||
modules/pandora_module_service.*, modules/pandora_module_proc.*: Added
|
||||
to repository.
|
||||
|
||||
* pandora_windows_service.cc, pandora_windows_service.h: getXMLHeader renamed to getXmlHeader
|
||||
and modified its behavior. Updated to the Pandora XML specification. Add SSH and XML generation
|
||||
* pandora_windows_service.cc, pandora_windows_service.h: getXMLHeader
|
||||
renamed to getXmlHeader and modified its behavior. Updated to the
|
||||
Pandora XML specification. Add SSH and XML generation
|
||||
functionallity.
|
||||
|
||||
* modules/pandora_module_exec.cc: Added the execution to a job to prevent zombies process. Update
|
||||
the execution command.
|
||||
* modules/pandora_module_exec.cc: Added the execution to a job to
|
||||
prevent zombies process. Update the execution command.
|
||||
|
||||
* modules/pandora_module_factory.cc: Added Pandora_Module_Proc and Pandora_Module_Service. Added
|
||||
the interval parameter.
|
||||
|
||||
* modules/pandora_module_list.cc: Added support to Pandora_Module_Proc and Pandora_Module_Service.
|
||||
* modules/pandora_module_factory.cc: Added Pandora_Module_Proc and
|
||||
Pandora_Module_Service. Added the interval parameter.
|
||||
|
||||
* modules/pandora_module.h: Added new types of modules. Added execution times and module description
|
||||
to the Pandora_Module class. Added support to Pandora_Module_Proc and Pandora_Module_Service. Added
|
||||
* modules/pandora_module_list.cc: Added support to Pandora_Module_Proc
|
||||
and Pandora_Module_Service.
|
||||
|
||||
* modules/pandora_module.h: Added new types of modules. Added
|
||||
execution times and module description to the Pandora_Module class.
|
||||
Added support to Pandora_Module_Proc and Pandora_Module_Service. Added
|
||||
getXml, setInterval and setDescription functions.
|
||||
|
||||
* pandora.h: Commentary fixed.
|
||||
|
|
Binary file not shown.
|
@ -72,8 +72,8 @@ about the execution flow of the Agent.
|
|||
server_path /opt/pandora/data_in/
|
||||
# Local path to the temporal directory
|
||||
temporal "C:\temp files"
|
||||
# Interval between executions (in minutes)
|
||||
interval 5
|
||||
# Interval between executions (in seconds)
|
||||
interval 60
|
||||
# Name of the agent
|
||||
agent_name antiriad
|
||||
# End of pandora_agent.conf example
|
||||
|
|
|
@ -138,10 +138,14 @@ Pandora_Module::getXml () {
|
|||
try {
|
||||
data = this->getOutput ();
|
||||
} catch (Output_Error e) {
|
||||
pandoraLog ("Output error");
|
||||
pandoraLog ("Output error on module %s",
|
||||
this->module_name.c_str ());
|
||||
|
||||
return NULL;
|
||||
} catch (Interval_Error e) {
|
||||
pandoraLog ("The returned value was not in the interval");
|
||||
pandoraLog ("The returned value was not in the interval on module %s",
|
||||
this->module_name.c_str ());
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,8 @@ Pandora_Module_Exec::run () {
|
|||
unsigned long read, avail;
|
||||
|
||||
if (! AssignProcessToJobObject (job, pi.hProcess)) {
|
||||
pandoraLog ("Assign bad %d", GetLastError ());
|
||||
pandoraLog ("Could not assigned proccess to job (error %d)",
|
||||
GetLastError ());
|
||||
}
|
||||
ResumeThread (pi.hThread);
|
||||
|
||||
|
@ -116,7 +117,7 @@ Pandora_Module_Exec::run () {
|
|||
GetExitCodeProcess (pi.hProcess, &retval);
|
||||
if (retval != 0) {
|
||||
if (! TerminateJobObject (job, 0)) {
|
||||
pandoraLog ("TerminateJobObject failed. Err: %d",
|
||||
pandoraLog ("TerminateJobObject failed. (error %d)",
|
||||
GetLastError ());
|
||||
}
|
||||
|
||||
|
|
|
@ -30,9 +30,12 @@ using namespace Pandora;
|
|||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("1.2Beta")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
bool pandora_debug;
|
||||
string pandora_version = PANDORA_VERSION;
|
||||
|
||||
void
|
||||
Key_Value::parseLine (string str) {
|
||||
|
@ -160,3 +163,7 @@ Pandora::setPandoraDebug (bool dbg) {
|
|||
pandora_debug = dbg;
|
||||
}
|
||||
|
||||
string
|
||||
Pandora::getPandoraAgentVersion () {
|
||||
return pandora_version;
|
||||
}
|
||||
|
|
|
@ -42,19 +42,20 @@ namespace Pandora {
|
|||
};
|
||||
|
||||
static const HKEY hkey = HKEY_LOCAL_MACHINE;
|
||||
const char * const name = "PandoraService";
|
||||
const char * const display_name = "Pandora service";
|
||||
const char * const name = "PandoraAgent";
|
||||
const char * const display_name = "Pandora agent";
|
||||
const char * const description = "The Pandora Agent service";
|
||||
|
||||
void setPandoraInstallDir (string dir);
|
||||
string getPandoraInstallDir ();
|
||||
void setPandoraInstallPath (string path);
|
||||
string getPandoraInstallPath ();
|
||||
void setPandoraDebug (bool dbg);
|
||||
|
||||
void pandoraDebug (char *format, ...);
|
||||
void pandoraLog (char *format, ...);
|
||||
void pandoraFree (void * e);
|
||||
void setPandoraInstallDir (string dir);
|
||||
string getPandoraInstallDir ();
|
||||
void setPandoraInstallPath (string path);
|
||||
string getPandoraInstallPath ();
|
||||
void setPandoraDebug (bool dbg);
|
||||
string getPandoraAgentVersion ();
|
||||
|
||||
void pandoraDebug (char *format, ...);
|
||||
void pandoraLog (char *format, ...);
|
||||
void pandoraFree (void * e);
|
||||
|
||||
class Pandora_Exception { };
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ using namespace Pandora;
|
|||
using namespace Pandora_Modules;
|
||||
using namespace Pandora_Strutils;
|
||||
|
||||
string enabled_values[] = {"enabled", "1", "on", "yes", "si", "sí", "ok", ""};
|
||||
|
||||
Pandora_Windows_Service::Pandora_Windows_Service (const char * svc_name,
|
||||
const char * svc_display_name,
|
||||
const char * svc_description)
|
||||
|
@ -52,18 +54,35 @@ Pandora_Windows_Service::~Pandora_Windows_Service () {
|
|||
if (this->conf != NULL) {
|
||||
delete this->conf;
|
||||
}
|
||||
|
||||
if (this->modules != NULL) {
|
||||
delete this->modules;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
is_enabled (string value) {
|
||||
int i = 0;
|
||||
|
||||
if (value == "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
while (enabled_values[i] != "") {
|
||||
if (enabled_values[i] == value) {
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
Pandora_Windows_Service::pandora_init () {
|
||||
int interval_ms = 60000;
|
||||
string conf_file, interval;
|
||||
string conf_file, interval, debug;
|
||||
|
||||
setPandoraDebug (true);
|
||||
pandoraDebug ("Init begin");
|
||||
|
||||
conf_file = Pandora::getPandoraInstallDir ();
|
||||
conf_file += "pandora_agent.conf";
|
||||
|
@ -72,7 +91,10 @@ Pandora_Windows_Service::pandora_init () {
|
|||
|
||||
/* Get the interval value (in minutes) and set it to the service */
|
||||
interval = conf->getValue ("interval");
|
||||
|
||||
|
||||
debug = conf->getValue ("pandora_debug");
|
||||
setPandoraDebug (is_enabled (debug));
|
||||
|
||||
if (interval != "") {
|
||||
try {
|
||||
interval_ms = strtoint (interval)
|
||||
|
@ -96,16 +118,17 @@ Pandora_Windows_Service::getXmlHeader () {
|
|||
|
||||
agent = new TiXmlElement ("agent_data");
|
||||
|
||||
/* TODO: Get the name of the machine if there is no agent_name*/
|
||||
value = conf->getValue ("agent_name");
|
||||
agent->SetAttribute ("agent_name", value);
|
||||
|
||||
/* TODO: Get the real version of the agent */
|
||||
agent->SetAttribute ("version", "1.2Beta");
|
||||
if (value == "") {
|
||||
value = Pandora_Windows_Info::getSystemName ();
|
||||
}
|
||||
|
||||
agent->SetAttribute ("version", getPandoraAgentVersion ());
|
||||
|
||||
GetSystemTime(&st);
|
||||
sprintf (timestamp, "%d/%d/%d %d:%d:%d", st.wDay, st.wMonth,
|
||||
st.wYear, st.wHour, st.wMinute, st.wSecond);
|
||||
sprintf (timestamp, "%d-%d-%d %d:%d:%d", st.wYear, st.wMonth, st.wDay,
|
||||
st.wHour, st.wMinute, st.wSecond);
|
||||
agent->SetAttribute ("timestamp", timestamp);
|
||||
|
||||
value = conf->getValue ("interval");
|
||||
|
@ -205,7 +228,8 @@ Pandora_Windows_Service::pandora_run () {
|
|||
return;
|
||||
} catch (Pandora_Exception e) {
|
||||
delete ssh_client;
|
||||
pandoraLog ("Pandora Agent: Failed when copying to %s", remote_host.c_str ());
|
||||
pandoraLog ("Pandora Agent: Failed when copying to %s",
|
||||
remote_host.c_str ());
|
||||
try {
|
||||
Pandora_File::removeFile (tmp_filepath);
|
||||
} catch (Pandora_File::Delete_Error e) {
|
||||
|
@ -219,8 +243,8 @@ Pandora_Windows_Service::pandora_run () {
|
|||
}
|
||||
|
||||
pandoraDebug ("Remote copying XML %s on server %s at %s%s",
|
||||
tmp_filepath.c_str (), remote_host.c_str (),
|
||||
remote_filepath.c_str (), tmp_filename.c_str ());
|
||||
tmp_filepath.c_str (), remote_host.c_str (),
|
||||
remote_filepath.c_str (), tmp_filename.c_str ());
|
||||
try {
|
||||
ssh_client->scpFileFilename (remote_filepath + tmp_filename,
|
||||
tmp_filepath);
|
||||
|
|
|
@ -36,6 +36,7 @@ private:
|
|||
Pandora_Agent_Conf *conf;
|
||||
Pandora_Module_List *modules;
|
||||
long execution_number;
|
||||
string agent_name;
|
||||
|
||||
TiXmlElement * getXmlHeader ();
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ Pandora_Wmi::isProcessRunning (string process_name) {
|
|||
}
|
||||
} NEXT_THROW (quickfix);
|
||||
} catch (string errstr) {
|
||||
cerr << "Fatal error details:" << endl << errstr << endl;
|
||||
pandoraLog ("isProcessRunning error. %s", errstr.c_str ());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -126,7 +126,7 @@ Pandora_Wmi::isServiceRunning (string service_name) {
|
|||
}
|
||||
} NEXT_THROW (quickfix);
|
||||
} catch (string errstr) {
|
||||
cerr << "Fatal error details:" << endl << errstr << endl;
|
||||
pandoraLog ("isServiceRunning error. %s", errstr.c_str ());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -160,7 +160,7 @@ Pandora_Wmi::getOSName () {
|
|||
|
||||
} NEXT_THROW (quickfix);
|
||||
} catch (string errstr) {
|
||||
cerr << "Fatal error details:" << endl << errstr << endl;
|
||||
pandoraLog ("getOSName error. %s", errstr.c_str ());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -194,7 +194,7 @@ Pandora_Wmi::getOSVersion () {
|
|||
|
||||
} NEXT_THROW (quickfix);
|
||||
} catch (string errstr) {
|
||||
cerr << "Fatal error details:" << endl << errstr << endl;
|
||||
pandoraLog ("getOSVersion error. %s", errstr.c_str ());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -228,7 +228,7 @@ Pandora_Wmi::getOSBuild () {
|
|||
|
||||
} NEXT_THROW (quickfix);
|
||||
} catch (string errstr) {
|
||||
cerr << "Fatal error details:" << endl << errstr << endl;
|
||||
pandoraLog ("getOSBuild error. %s", errstr.c_str ());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -262,7 +262,7 @@ Pandora_Wmi::getSystemName () {
|
|||
|
||||
} NEXT_THROW (quickfix);
|
||||
} catch (string errstr) {
|
||||
cerr << "Fatal error details:" << endl << errstr << endl;
|
||||
pandoraLog ("getSystemName error. %s", errstr.c_str ());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue