mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-06 21:44:53 +02:00
2008-07-09 Esteban Sanchez <estebans@artica.es>
* pandora_strutils.[cc,h]: Added strUnicodeToAnsi(). * modules/pandora_module_logevent.cc, pandora_windows_service.[cc,h], windows/pandora_wmi.h: Tabs and blankspace style correction. * windows/pandora_wmi.cc: Convert result in getEventList() to ANSI, which was causing some BADXML errors on server. Tabs and blankspace style correction. * bin/PandoraAgent.exe: Updated to last commit. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@946 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
8e9b10cdc2
commit
654405d451
@ -1,3 +1,16 @@
|
|||||||
|
2008-07-09 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
|
* pandora_strutils.[cc,h]: Added strUnicodeToAnsi().
|
||||||
|
|
||||||
|
* modules/pandora_module_logevent.cc, pandora_windows_service.[cc,h],
|
||||||
|
windows/pandora_wmi.h: Tabs and blankspace style correction.
|
||||||
|
|
||||||
|
* windows/pandora_wmi.cc: Convert result in getEventList() to ANSI,
|
||||||
|
which was causing some BADXML errors on server. Tabs and blankspace
|
||||||
|
style correction.
|
||||||
|
|
||||||
|
* bin/PandoraAgent.exe: Updated to last commit.
|
||||||
|
|
||||||
2008-06-11 Esteban Sanchez <estebans@artica.es>
|
2008-06-11 Esteban Sanchez <estebans@artica.es>
|
||||||
|
|
||||||
* bin/PandoraAgent.exe: Updated to commit, fixed an error when
|
* bin/PandoraAgent.exe: Updated to commit, fixed an error when
|
||||||
|
Binary file not shown.
@ -43,50 +43,50 @@ Pandora_Module_Logevent::Pandora_Module_Logevent (string name, string source, st
|
|||||||
|
|
||||||
void
|
void
|
||||||
Pandora_Module_Logevent::run () {
|
Pandora_Module_Logevent::run () {
|
||||||
int interval, module_interval;
|
int interval, module_interval;
|
||||||
string value;
|
string value;
|
||||||
list<string> event_list;
|
list<string> event_list;
|
||||||
list<string>::iterator event;
|
list<string>::iterator event;
|
||||||
Pandora_Agent_Conf::Pandora_Agent_Conf *conf;
|
Pandora_Agent_Conf::Pandora_Agent_Conf *conf;
|
||||||
SYSTEMTIME system_time;
|
SYSTEMTIME system_time;
|
||||||
|
|
||||||
conf = Pandora_Agent_Conf::getInstance ();
|
conf = Pandora_Agent_Conf::getInstance ();
|
||||||
|
|
||||||
// Get execution interval
|
// Get execution interval
|
||||||
value = conf->getValue ("interval");
|
value = conf->getValue ("interval");
|
||||||
interval = atoi(value.c_str ());
|
interval = atoi(value.c_str ());
|
||||||
|
|
||||||
module_interval = this->getInterval ();
|
module_interval = this->getInterval ();
|
||||||
if (module_interval > 0) {
|
if (module_interval > 0) {
|
||||||
interval *= module_interval;
|
interval *= module_interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run
|
// Run
|
||||||
try {
|
try {
|
||||||
Pandora_Module::run ();
|
Pandora_Module::run ();
|
||||||
} catch (Interval_Not_Fulfilled e) {
|
} catch (Interval_Not_Fulfilled e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pandora_Wmi::getEventList (this->source, this->type, this->pattern, interval, event_list);
|
Pandora_Wmi::getEventList (this->source, this->type, this->pattern, interval, event_list);
|
||||||
|
|
||||||
// No data
|
// No data
|
||||||
if (event_list.size () < 1) {
|
if (event_list.size () < 1) {
|
||||||
this->setOutput ("");
|
this->setOutput ("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(event = event_list.begin (); event != event_list.end(); ++event) {
|
for (event = event_list.begin (); event != event_list.end(); ++event) {
|
||||||
// No WMI timestamp?
|
// No WMI timestamp?
|
||||||
if (event->size () < 26) {
|
if (event->size () < 26) {
|
||||||
this->setOutput (*event);
|
this->setOutput (*event);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the timestamp
|
// Get the timestamp
|
||||||
Pandora_Wmi::convertWMIDate(event->substr (0, 26), &system_time);
|
Pandora_Wmi::convertWMIDate (event->substr (0, 26), &system_time);
|
||||||
|
|
||||||
// Store the data
|
// Store the data
|
||||||
this->setOutput (event->substr (26), &system_time);
|
this->setOutput (event->substr (26), &system_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,12 @@ Pandora_Strutils::trim (const string str) {
|
|||||||
string result = str;
|
string result = str;
|
||||||
string::size_type index = result.find_last_not_of (delims);
|
string::size_type index = result.find_last_not_of (delims);
|
||||||
|
|
||||||
if(index != string::npos) {
|
if (index != string::npos) {
|
||||||
result.erase (++index);
|
result.erase (++index);
|
||||||
}
|
}
|
||||||
|
|
||||||
index = result.find_first_not_of (delims);
|
index = result.find_first_not_of (delims);
|
||||||
if(index != std::string::npos) {
|
if (index != std::string::npos) {
|
||||||
result.erase (0, index);
|
result.erase (0, index);
|
||||||
} else {
|
} else {
|
||||||
result.erase ();
|
result.erase ();
|
||||||
@ -56,6 +56,41 @@ Pandora_Strutils::trim (const string str) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an unicode string to a ANSI string.
|
||||||
|
*
|
||||||
|
* @param s String to convert
|
||||||
|
*
|
||||||
|
* @return String converted into ANSI code
|
||||||
|
*/
|
||||||
|
LPSTR
|
||||||
|
Pandora_Strutils::strUnicodeToAnsi (LPCWSTR s) {
|
||||||
|
if (s == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
int cw = lstrlenW (s);
|
||||||
|
if (cw == 0) {
|
||||||
|
CHAR *psz = new CHAR[1];
|
||||||
|
*psz='\0';
|
||||||
|
return psz;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cc = WideCharToMultiByte (CP_ACP,0, s, cw, NULL, 0, NULL, NULL);
|
||||||
|
if (cc==0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
CHAR *psz = new CHAR[cc+1];
|
||||||
|
cc = WideCharToMultiByte (CP_ACP, 0, s, cw, psz, cc, NULL, NULL);
|
||||||
|
|
||||||
|
if (cc == 0) {
|
||||||
|
delete[] psz;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
psz[cc]='\0';
|
||||||
|
|
||||||
|
return psz;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform an integer variable into a string.
|
* Transform an integer variable into a string.
|
||||||
*
|
*
|
||||||
|
@ -43,6 +43,8 @@ namespace Pandora_Strutils {
|
|||||||
|
|
||||||
string trim (const string str);
|
string trim (const string str);
|
||||||
|
|
||||||
|
LPSTR strUnicodeToAnsi (LPCWSTR s);
|
||||||
|
|
||||||
string inttostr (const int i);
|
string inttostr (const int i);
|
||||||
string longtostr (const long i);
|
string longtostr (const long i);
|
||||||
string longtohex (const long i);
|
string longtohex (const long i);
|
||||||
|
@ -51,16 +51,15 @@ string enabled_values[] = {"enabled", "1", "on", "yes", "si", "sí", "ok", ""};
|
|||||||
Pandora_Windows_Service::Pandora_Windows_Service (const char * svc_name,
|
Pandora_Windows_Service::Pandora_Windows_Service (const char * svc_name,
|
||||||
const char * svc_display_name,
|
const char * svc_display_name,
|
||||||
const char * svc_description)
|
const char * svc_description)
|
||||||
: Windows_Service (svc_name, svc_display_name, svc_description) {
|
: Windows_Service (svc_name, svc_display_name, svc_description) {
|
||||||
|
this->setInitFunction ((void (Windows_Service::*) ())
|
||||||
this->setInitFunction ((void (Windows_Service::*) ())
|
|
||||||
&Pandora_Windows_Service::pandora_init);
|
&Pandora_Windows_Service::pandora_init);
|
||||||
this->setRunFunction ((void (Windows_Service::*) ())
|
this->setRunFunction ((void (Windows_Service::*) ())
|
||||||
&Pandora_Windows_Service::pandora_run);
|
&Pandora_Windows_Service::pandora_run);
|
||||||
|
|
||||||
execution_number = 0;
|
execution_number = 0;
|
||||||
this->modules = NULL;
|
this->modules = NULL;
|
||||||
this->conf = NULL;
|
this->conf = NULL;
|
||||||
this->interval = 60000;
|
this->interval = 60000;
|
||||||
this->transfer_interval = this->interval;
|
this->transfer_interval = this->interval;
|
||||||
this->elapsed_transfer_time = 0;
|
this->elapsed_transfer_time = 0;
|
||||||
@ -70,60 +69,60 @@ Pandora_Windows_Service::Pandora_Windows_Service (const char * svc_name,
|
|||||||
* Destroys a Pandora_Windows_Service object.
|
* Destroys a Pandora_Windows_Service object.
|
||||||
*/
|
*/
|
||||||
Pandora_Windows_Service::~Pandora_Windows_Service () {
|
Pandora_Windows_Service::~Pandora_Windows_Service () {
|
||||||
if (this->conf != NULL) {
|
if (this->conf != NULL) {
|
||||||
delete this->conf;
|
delete this->conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->modules != NULL) {
|
if (this->modules != NULL) {
|
||||||
delete this->modules;
|
delete this->modules;
|
||||||
}
|
}
|
||||||
pandoraLog ("Pandora agent stopped");
|
pandoraLog ("Pandora agent stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
is_enabled (string value) {
|
is_enabled (string value) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (value == "") {
|
if (value == "") {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (enabled_values[i] != "") {
|
while (enabled_values[i] != "") {
|
||||||
if (enabled_values[i] == value) {
|
if (enabled_values[i] == value) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Pandora_Windows_Service::pandora_init () {
|
Pandora_Windows_Service::pandora_init () {
|
||||||
string conf_file, interval, debug, transfer_interval;
|
string conf_file, interval, debug, transfer_interval;
|
||||||
|
|
||||||
setPandoraDebug (true);
|
setPandoraDebug (true);
|
||||||
|
|
||||||
conf_file = Pandora::getPandoraInstallDir ();
|
conf_file = Pandora::getPandoraInstallDir ();
|
||||||
conf_file += "pandora_agent.conf";
|
conf_file += "pandora_agent.conf";
|
||||||
|
|
||||||
this->conf = Pandora::Pandora_Agent_Conf::getInstance ();
|
this->conf = Pandora::Pandora_Agent_Conf::getInstance ();
|
||||||
this->conf->setFile (conf_file);
|
this->conf->setFile (conf_file);
|
||||||
this->modules = new Pandora_Module_List (conf_file);
|
this->modules = new Pandora_Module_List (conf_file);
|
||||||
|
|
||||||
/* Get the interval value (in seconds) and set it to the service */
|
/* Get the interval value (in seconds) and set it to the service */
|
||||||
interval = conf->getValue ("interval");
|
interval = conf->getValue ("interval");
|
||||||
transfer_interval = conf->getValue ("transfer_interval");
|
transfer_interval = conf->getValue ("transfer_interval");
|
||||||
|
|
||||||
debug = conf->getValue ("debug");
|
debug = conf->getValue ("debug");
|
||||||
setPandoraDebug (is_enabled (debug));
|
setPandoraDebug (is_enabled (debug));
|
||||||
|
|
||||||
if (interval != "") {
|
if (interval != "") {
|
||||||
try {
|
try {
|
||||||
/* miliseconds */
|
/* miliseconds */
|
||||||
this->interval = strtoint (interval) * 1000;
|
this->interval = strtoint (interval) * 1000;
|
||||||
} catch (Invalid_Conversion e) {
|
} catch (Invalid_Conversion e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transfer_interval == "") {
|
if (transfer_interval == "") {
|
||||||
this->transfer_interval = this->interval;
|
this->transfer_interval = this->interval;
|
||||||
@ -136,50 +135,50 @@ Pandora_Windows_Service::pandora_init () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srand ((unsigned) time (0));
|
srand ((unsigned) time (0));
|
||||||
this->setSleepTime (this->interval);
|
this->setSleepTime (this->interval);
|
||||||
|
|
||||||
pandoraLog ("Pandora agent started");
|
pandoraLog ("Pandora agent started");
|
||||||
}
|
}
|
||||||
|
|
||||||
TiXmlElement *
|
TiXmlElement *
|
||||||
Pandora_Windows_Service::getXmlHeader () {
|
Pandora_Windows_Service::getXmlHeader () {
|
||||||
TiXmlElement *agent;
|
TiXmlElement *agent;
|
||||||
SYSTEMTIME st;
|
SYSTEMTIME st;
|
||||||
char timestamp[20];
|
char timestamp[20];
|
||||||
string value;
|
string value;
|
||||||
|
|
||||||
agent = new TiXmlElement ("agent_data");
|
agent = new TiXmlElement ("agent_data");
|
||||||
|
|
||||||
value = conf->getValue ("agent_name");
|
value = conf->getValue ("agent_name");
|
||||||
if (value == "") {
|
if (value == "") {
|
||||||
value = Pandora_Windows_Info::getSystemName ();
|
value = Pandora_Windows_Info::getSystemName ();
|
||||||
}
|
}
|
||||||
agent->SetAttribute ("agent_name", value);
|
agent->SetAttribute ("agent_name", value);
|
||||||
|
|
||||||
agent->SetAttribute ("version", getPandoraAgentVersion ());
|
agent->SetAttribute ("version", getPandoraAgentVersion ());
|
||||||
|
|
||||||
GetSystemTime(&st);
|
GetSystemTime(&st);
|
||||||
sprintf (timestamp, "%d-%02d-%02d %02d:%02d:%02d", st.wYear, st.wMonth, st.wDay,
|
sprintf (timestamp, "%d-%02d-%02d %02d:%02d:%02d", st.wYear, st.wMonth, st.wDay,
|
||||||
st.wHour, st.wMinute, st.wSecond);
|
st.wHour, st.wMinute, st.wSecond);
|
||||||
|
|
||||||
agent->SetAttribute ("timestamp", timestamp);
|
agent->SetAttribute ("timestamp", timestamp);
|
||||||
|
|
||||||
value = conf->getValue ("interval");
|
value = conf->getValue ("interval");
|
||||||
agent->SetAttribute ("interval", value);
|
agent->SetAttribute ("interval", value);
|
||||||
|
|
||||||
value = Pandora_Windows_Info::getOSName ();
|
value = Pandora_Windows_Info::getOSName ();
|
||||||
agent->SetAttribute ("os", value);
|
agent->SetAttribute ("os", value);
|
||||||
|
|
||||||
value = Pandora_Windows_Info::getOSVersion ();
|
value = Pandora_Windows_Info::getOSVersion ();
|
||||||
agent->SetAttribute ("os_version", value);
|
agent->SetAttribute ("os_version", value);
|
||||||
|
|
||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Pandora_Windows_Service::copyTentacleDataFile (string host,
|
Pandora_Windows_Service::copyTentacleDataFile (string host,
|
||||||
string filename)
|
string filename)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
string var, filepath;
|
string var, filepath;
|
||||||
@ -190,7 +189,7 @@ Pandora_Windows_Service::copyTentacleDataFile (string host,
|
|||||||
var += "\\";
|
var += "\\";
|
||||||
}
|
}
|
||||||
|
|
||||||
filepath = var + filename;
|
filepath = var + filename;
|
||||||
|
|
||||||
/* Build the command to launch the Tentacle client */
|
/* Build the command to launch the Tentacle client */
|
||||||
tentacle_cmd = "tentacle_client.exe -a " + host;
|
tentacle_cmd = "tentacle_client.exe -a " + host;
|
||||||
@ -219,26 +218,26 @@ Pandora_Windows_Service::copyTentacleDataFile (string host,
|
|||||||
|
|
||||||
/* Copy the file */
|
/* Copy the file */
|
||||||
pandoraDebug ("Remote copying XML %s on server %s",
|
pandoraDebug ("Remote copying XML %s on server %s",
|
||||||
filepath.c_str (), host.c_str ());
|
filepath.c_str (), host.c_str ());
|
||||||
pandoraDebug ("Command %s", tentacle_cmd.c_str());
|
pandoraDebug ("Command %s", tentacle_cmd.c_str());
|
||||||
|
|
||||||
rc = system (tentacle_cmd.c_str());
|
rc = system (tentacle_cmd.c_str());
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
|
|
||||||
/* system() error */
|
/* system() error */
|
||||||
case -1:
|
case -1:
|
||||||
pandoraLog ("Unable to copy %s", filename.c_str ());
|
pandoraLog ("Unable to copy %s", filename.c_str ());
|
||||||
throw Pandora_Exception ();
|
throw Pandora_Exception ();
|
||||||
|
|
||||||
/* tentacle_client.exe returned OK */
|
/* tentacle_client.exe returned OK */
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* tentacle_client.exe error */
|
/* tentacle_client.exe error */
|
||||||
default:
|
default:
|
||||||
pandoraDebug ("Tentacle client was unable to copy %s",
|
pandoraDebug ("Tentacle client was unable to copy %s",
|
||||||
filename.c_str ());
|
filename.c_str ());
|
||||||
throw Pandora_Exception ();
|
throw Pandora_Exception ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -254,47 +253,47 @@ Pandora_Windows_Service::copyScpDataFile (string host,
|
|||||||
string pubkey_file, privkey_file;
|
string pubkey_file, privkey_file;
|
||||||
|
|
||||||
tmp_dir = conf->getValue ("temporal");
|
tmp_dir = conf->getValue ("temporal");
|
||||||
if (tmp_dir[tmp_dir.length () - 1] != '\\') {
|
if (tmp_dir[tmp_dir.length () - 1] != '\\') {
|
||||||
tmp_dir += "\\";
|
tmp_dir += "\\";
|
||||||
}
|
}
|
||||||
filepath = tmp_dir + filename;
|
filepath = tmp_dir + filename;
|
||||||
|
|
||||||
pandoraDebug ("Connecting with %s", host.c_str ());
|
pandoraDebug ("Connecting with %s", host.c_str ());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pubkey_file = Pandora::getPandoraInstallDir ();
|
pubkey_file = Pandora::getPandoraInstallDir ();
|
||||||
pubkey_file += "key\\id_dsa.pub";
|
pubkey_file += "key\\id_dsa.pub";
|
||||||
privkey_file = Pandora::getPandoraInstallDir ();
|
privkey_file = Pandora::getPandoraInstallDir ();
|
||||||
privkey_file += "key\\id_dsa";
|
privkey_file += "key\\id_dsa";
|
||||||
|
|
||||||
ssh_client.connectWithPublicKey (host.c_str (), 22, "pandora",
|
ssh_client.connectWithPublicKey (host.c_str (), 22, "pandora",
|
||||||
pubkey_file, privkey_file, "");
|
pubkey_file, privkey_file, "");
|
||||||
} catch (SSH::Authentication_Failed e) {
|
} catch (SSH::Authentication_Failed e) {
|
||||||
pandoraLog ("Pandora Agent: Authentication Failed "
|
pandoraLog ("Pandora Agent: Authentication Failed "
|
||||||
"when connecting to %s",
|
"when connecting to %s",
|
||||||
host.c_str ());
|
host.c_str ());
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Pandora_Exception e) {
|
} catch (Pandora_Exception e) {
|
||||||
pandoraLog ("Pandora Agent: Failed when copying to %s",
|
pandoraLog ("Pandora Agent: Failed when copying to %s",
|
||||||
host.c_str ());
|
host.c_str ());
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
pandoraDebug ("Remote copying XML %s on server %s at %s%s",
|
pandoraDebug ("Remote copying XML %s on server %s at %s%s",
|
||||||
filepath.c_str (), host.c_str (),
|
filepath.c_str (), host.c_str (),
|
||||||
remote_path.c_str (), filename.c_str ());
|
remote_path.c_str (), filename.c_str ());
|
||||||
try {
|
try {
|
||||||
ssh_client.scpFileFilename (remote_path + filename,
|
ssh_client.scpFileFilename (remote_path + filename,
|
||||||
filepath);
|
filepath);
|
||||||
} catch (Pandora_Exception e) {
|
} catch (Pandora_Exception e) {
|
||||||
pandoraLog ("Unable to copy at %s%s", remote_path.c_str (),
|
pandoraLog ("Unable to copy at %s%s", remote_path.c_str (),
|
||||||
filename.c_str ());
|
filename.c_str ());
|
||||||
ssh_client.disconnect();
|
ssh_client.disconnect();
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_client.disconnect();
|
ssh_client.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -307,10 +306,10 @@ Pandora_Windows_Service::copyFtpDataFile (string host,
|
|||||||
string password;
|
string password;
|
||||||
|
|
||||||
filepath = conf->getValue ("temporal");
|
filepath = conf->getValue ("temporal");
|
||||||
if (filepath[filepath.length () - 1] != '\\') {
|
if (filepath[filepath.length () - 1] != '\\') {
|
||||||
filepath += "\\";
|
filepath += "\\";
|
||||||
}
|
}
|
||||||
filepath += filename;
|
filepath += filename;
|
||||||
|
|
||||||
password = conf->getValue ("server_pwd");
|
password = conf->getValue ("server_pwd");
|
||||||
|
|
||||||
@ -330,12 +329,12 @@ Pandora_Windows_Service::copyFtpDataFile (string host,
|
|||||||
} catch (FTP::Authentication_Failed e) {
|
} catch (FTP::Authentication_Failed e) {
|
||||||
pandoraLog ("Pandora Agent: Authentication Failed "
|
pandoraLog ("Pandora Agent: Authentication Failed "
|
||||||
"when connecting to %s (%s)",
|
"when connecting to %s (%s)",
|
||||||
host.c_str (), ftp_client.getError ().c_str ());
|
host.c_str (), ftp_client.getError ().c_str ());
|
||||||
ftp_client.disconnect ();
|
ftp_client.disconnect ();
|
||||||
throw e;
|
throw e;
|
||||||
} catch (FTP::FTP_Exception e) {
|
} catch (FTP::FTP_Exception e) {
|
||||||
pandoraLog ("Pandora Agent: Failed when copying to %s (%s)",
|
pandoraLog ("Pandora Agent: Failed when copying to %s (%s)",
|
||||||
host.c_str (), ftp_client.getError ().c_str ());
|
host.c_str (), ftp_client.getError ().c_str ());
|
||||||
ftp_client.disconnect ();
|
ftp_client.disconnect ();
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
@ -351,9 +350,9 @@ Pandora_Windows_Service::copyDataFile (string filename)
|
|||||||
mode = conf->getValue ("transfer_mode");
|
mode = conf->getValue ("transfer_mode");
|
||||||
host = conf->getValue ("server_ip");
|
host = conf->getValue ("server_ip");
|
||||||
remote_path = conf->getValue ("server_path");
|
remote_path = conf->getValue ("server_path");
|
||||||
if (remote_path[remote_path.length () - 1] != '/') {
|
if (remote_path[remote_path.length () - 1] != '/') {
|
||||||
remote_path += "/";
|
remote_path += "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mode == "ftp") {
|
if (mode == "ftp") {
|
||||||
@ -375,7 +374,7 @@ Pandora_Windows_Service::copyDataFile (string filename)
|
|||||||
|
|
||||||
void
|
void
|
||||||
Pandora_Windows_Service::recvTentacleDataFile (string host,
|
Pandora_Windows_Service::recvTentacleDataFile (string host,
|
||||||
string filename)
|
string filename)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
string var;
|
string var;
|
||||||
@ -415,26 +414,26 @@ Pandora_Windows_Service::recvTentacleDataFile (string host,
|
|||||||
|
|
||||||
/* Copy the file */
|
/* Copy the file */
|
||||||
pandoraDebug ("Requesting file %s from server %s",
|
pandoraDebug ("Requesting file %s from server %s",
|
||||||
filename.c_str (), host.c_str ());
|
filename.c_str (), host.c_str ());
|
||||||
pandoraDebug ("Command %s", tentacle_cmd.c_str());
|
pandoraDebug ("Command %s", tentacle_cmd.c_str());
|
||||||
|
|
||||||
rc = system (tentacle_cmd.c_str());
|
rc = system (tentacle_cmd.c_str());
|
||||||
switch (rc) {
|
switch (rc) {
|
||||||
|
|
||||||
/* system() error */
|
/* system() error */
|
||||||
case -1:
|
case -1:
|
||||||
pandoraLog ("Unable to receive file %s", filename.c_str ());
|
pandoraLog ("Unable to receive file %s", filename.c_str ());
|
||||||
throw Pandora_Exception ();
|
throw Pandora_Exception ();
|
||||||
|
|
||||||
/* tentacle_client.exe returned OK */
|
/* tentacle_client.exe returned OK */
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* tentacle_client.exe error */
|
/* tentacle_client.exe error */
|
||||||
default:
|
default:
|
||||||
pandoraDebug ("Tentacle client was unable to receive file %s",
|
pandoraDebug ("Tentacle client was unable to receive file %s",
|
||||||
filename.c_str ());
|
filename.c_str ());
|
||||||
throw Pandora_Exception ();
|
throw Pandora_Exception ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -468,12 +467,12 @@ void
|
|||||||
Pandora_Windows_Service::checkConfig () {
|
Pandora_Windows_Service::checkConfig () {
|
||||||
int i, conf_size;
|
int i, conf_size;
|
||||||
char *conf_str = NULL, *remote_conf_str = NULL, *remote_conf_md5 = NULL;
|
char *conf_str = NULL, *remote_conf_str = NULL, *remote_conf_md5 = NULL;
|
||||||
char agent_md5[33], conf_md5[33], flag;
|
char agent_md5[33], conf_md5[33], flag;
|
||||||
string conf_file, conf_tmp_file, md5_tmp_file, temp_dir, tmp;
|
string conf_file, conf_tmp_file, md5_tmp_file, temp_dir, tmp;
|
||||||
|
|
||||||
tmp = conf->getValue ("remote_config");
|
tmp = conf->getValue ("remote_config");
|
||||||
if (tmp != "1") {
|
if (tmp != "1") {
|
||||||
pandoraDebug ("Pandora_Windows_Service::checkConfig: Remote configuration disabled");
|
pandoraDebug ("Pandora_Windows_Service::checkConfig: Remote configuration disabled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +484,7 @@ Pandora_Windows_Service::checkConfig () {
|
|||||||
|
|
||||||
/* Get base install directory */
|
/* Get base install directory */
|
||||||
conf_file = Pandora::getPandoraInstallDir ();
|
conf_file = Pandora::getPandoraInstallDir ();
|
||||||
conf_file += "pandora_agent.conf";
|
conf_file += "pandora_agent.conf";
|
||||||
|
|
||||||
/* Get agent name */
|
/* Get agent name */
|
||||||
tmp = conf->getValue ("agent_name");
|
tmp = conf->getValue ("agent_name");
|
||||||
@ -495,23 +494,23 @@ Pandora_Windows_Service::checkConfig () {
|
|||||||
|
|
||||||
Pandora_File::md5 (tmp.c_str(), tmp.size(), agent_md5);
|
Pandora_File::md5 (tmp.c_str(), tmp.size(), agent_md5);
|
||||||
|
|
||||||
/* Calculate md5 hashes */
|
/* Calculate md5 hashes */
|
||||||
try {
|
try {
|
||||||
conf_size = Pandora_File::readBinFile (conf_file, &conf_str);
|
conf_size = Pandora_File::readBinFile (conf_file, &conf_str);
|
||||||
Pandora_File::md5 (conf_str, conf_size, conf_md5);
|
Pandora_File::md5 (conf_str, conf_size, conf_md5);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
pandoraDebug ("Pandora_Windows_Service::checkConfig: Error calculating configuration md5");
|
pandoraDebug ("Pandora_Windows_Service::checkConfig: Error calculating configuration md5");
|
||||||
if (conf_str != NULL) {
|
if (conf_str != NULL) {
|
||||||
delete[] conf_str;
|
delete[] conf_str;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compose file names from the agent name hash */
|
/* Compose file names from the agent name hash */
|
||||||
conf_tmp_file = agent_md5;
|
conf_tmp_file = agent_md5;
|
||||||
conf_tmp_file += ".conf";
|
conf_tmp_file += ".conf";
|
||||||
md5_tmp_file = agent_md5;
|
md5_tmp_file = agent_md5;
|
||||||
md5_tmp_file += ".md5";
|
md5_tmp_file += ".md5";
|
||||||
|
|
||||||
/* Get md5 file from server */
|
/* Get md5 file from server */
|
||||||
try {
|
try {
|
||||||
@ -547,24 +546,24 @@ Pandora_Windows_Service::checkConfig () {
|
|||||||
tmp += md5_tmp_file;
|
tmp += md5_tmp_file;
|
||||||
if (Pandora_File::readBinFile (tmp, &remote_conf_md5) < 32) {
|
if (Pandora_File::readBinFile (tmp, &remote_conf_md5) < 32) {
|
||||||
pandoraDebug ("Pandora_Windows_Service::checkConfig: Invalid remote md5", tmp.c_str());
|
pandoraDebug ("Pandora_Windows_Service::checkConfig: Invalid remote md5", tmp.c_str());
|
||||||
if (remote_conf_md5 != NULL) {
|
if (remote_conf_md5 != NULL) {
|
||||||
delete[] remote_conf_md5;
|
delete[] remote_conf_md5;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pandora_File::removeFile (tmp);
|
Pandora_File::removeFile (tmp);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
pandoraDebug ("Pandora_Windows_Service::checkConfig: Error checking remote configuration md5", tmp.c_str());
|
pandoraDebug ("Pandora_Windows_Service::checkConfig: Error checking remote configuration md5", tmp.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for configuration changes */
|
/* Check for configuration changes */
|
||||||
flag = 0;
|
flag = 0;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
if (remote_conf_md5[i] != conf_md5[i]) {
|
if (remote_conf_md5[i] != conf_md5[i]) {
|
||||||
flag = 1;
|
flag = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] remote_conf_md5;
|
delete[] remote_conf_md5;
|
||||||
@ -587,9 +586,9 @@ Pandora_Windows_Service::checkConfig () {
|
|||||||
Pandora_File::writeBinFile (conf_file, conf_str, conf_size);
|
Pandora_File::writeBinFile (conf_file, conf_str, conf_size);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
pandoraDebug("Pandora_Windows_Service::checkConfig: Error retrieving configuration file from server");
|
pandoraDebug("Pandora_Windows_Service::checkConfig: Error retrieving configuration file from server");
|
||||||
if (conf_str != NULL) {
|
if (conf_str != NULL) {
|
||||||
delete[] conf_str;
|
delete[] conf_str;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,37 +600,37 @@ Pandora_Windows_Service::checkConfig () {
|
|||||||
|
|
||||||
void
|
void
|
||||||
Pandora_Windows_Service::pandora_run () {
|
Pandora_Windows_Service::pandora_run () {
|
||||||
TiXmlDeclaration *decl;
|
TiXmlDeclaration *decl;
|
||||||
TiXmlDocument *doc;
|
TiXmlDocument *doc;
|
||||||
TiXmlElement *local_xml, *agent;
|
TiXmlElement *local_xml, *agent;
|
||||||
string xml_filename, random_integer;
|
string xml_filename, random_integer;
|
||||||
string tmp_filename, tmp_filepath;
|
string tmp_filename, tmp_filepath;
|
||||||
string encoding;
|
string encoding;
|
||||||
bool saved;
|
bool saved;
|
||||||
|
|
||||||
pandoraDebug ("Run begin");
|
pandoraDebug ("Run begin");
|
||||||
|
|
||||||
/* Check for configuration changes */
|
/* Check for configuration changes */
|
||||||
this->checkConfig ();
|
this->checkConfig ();
|
||||||
|
|
||||||
execution_number++;
|
execution_number++;
|
||||||
|
|
||||||
if (this->modules != NULL) {
|
if (this->modules != NULL) {
|
||||||
this->modules->goFirst ();
|
this->modules->goFirst ();
|
||||||
|
|
||||||
while (! this->modules->isLast ()) {
|
while (! this->modules->isLast ()) {
|
||||||
Pandora_Module *module;
|
Pandora_Module *module;
|
||||||
|
|
||||||
module = this->modules->getCurrentValue ();
|
module = this->modules->getCurrentValue ();
|
||||||
|
|
||||||
pandoraDebug ("Run %s", module->getName ().c_str ());
|
pandoraDebug ("Run %s", module->getName ().c_str ());
|
||||||
module->run ();
|
module->run ();
|
||||||
|
|
||||||
this->modules->goNext ();
|
this->modules->goNext ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this->elapsed_transfer_time += interval;
|
this->elapsed_transfer_time += interval;
|
||||||
|
|
||||||
if (this->elapsed_transfer_time >= this->transfer_interval) {
|
if (this->elapsed_transfer_time >= this->transfer_interval) {
|
||||||
agent = getXmlHeader ();
|
agent = getXmlHeader ();
|
||||||
@ -672,8 +671,8 @@ Pandora_Windows_Service::pandora_run () {
|
|||||||
/* Copy the XML to temporal file */
|
/* Copy the XML to temporal file */
|
||||||
encoding = conf->getValue ("encoding");
|
encoding = conf->getValue ("encoding");
|
||||||
if (encoding == "") {
|
if (encoding == "") {
|
||||||
encoding = "ISO-8859-1";
|
encoding = "ISO-8859-1";
|
||||||
}
|
}
|
||||||
|
|
||||||
pandoraDebug ("Copying XML on %s", tmp_filepath.c_str ());
|
pandoraDebug ("Copying XML on %s", tmp_filepath.c_str ());
|
||||||
decl = new TiXmlDeclaration( "1.0", encoding.c_str(), "" );
|
decl = new TiXmlDeclaration( "1.0", encoding.c_str(), "" );
|
||||||
@ -702,7 +701,7 @@ Pandora_Windows_Service::pandora_run () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the interval value (in minutes) */
|
/* Get the interval value (in minutes) */
|
||||||
pandoraDebug ("Next execution on %d seconds", this->interval / 1000);
|
pandoraDebug ("Next execution on %d seconds", this->interval / 1000);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -48,16 +48,16 @@ namespace Pandora {
|
|||||||
TiXmlElement *getXmlHeader ();
|
TiXmlElement *getXmlHeader ();
|
||||||
void copyDataFile (string filename);
|
void copyDataFile (string filename);
|
||||||
void copyTentacleDataFile (string host,
|
void copyTentacleDataFile (string host,
|
||||||
string filename);
|
string filename);
|
||||||
void copyScpDataFile (string host,
|
void copyScpDataFile (string host,
|
||||||
string remote_path,
|
string remote_path,
|
||||||
string filename);
|
string filename);
|
||||||
void copyFtpDataFile (string host,
|
void copyFtpDataFile (string host,
|
||||||
string remote_path,
|
string remote_path,
|
||||||
string filename);
|
string filename);
|
||||||
void recvDataFile (string filename);
|
void recvDataFile (string filename);
|
||||||
void recvTentacleDataFile (string host,
|
void recvTentacleDataFile (string host,
|
||||||
string filename);
|
string filename);
|
||||||
void checkConfig ();
|
void checkConfig ();
|
||||||
public:
|
public:
|
||||||
void pandora_run ();
|
void pandora_run ();
|
||||||
|
@ -392,22 +392,24 @@ Pandora_Wmi::getEventList (string source, string type, string pattern, int inter
|
|||||||
CDhInitialize init;
|
CDhInitialize init;
|
||||||
CDispPtr wmi_svc, quickfixes;
|
CDispPtr wmi_svc, quickfixes;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
|
WCHAR *unicode_value;
|
||||||
string event, limit, message, query, timestamp;
|
string event, limit, message, query, timestamp;
|
||||||
|
char *encode;
|
||||||
|
|
||||||
limit = getTimestampLimit(interval);
|
limit = getTimestampLimit (interval);
|
||||||
if (limit.empty()) {
|
if (limit.empty()) {
|
||||||
pandoraDebug ("Pandora_Wmi::getEventList: getTimestampLimit error");
|
pandoraDebug ("Pandora_Wmi::getEventList: getTimestampLimit error");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the WQL query
|
// Build the WQL query
|
||||||
query = "SELECT * FROM Win32_NTLogEvent WHERE TimeWritten >= '" + limit + "'";
|
query = "SELECT * FROM Win32_NTLogEvent WHERE TimeWritten >= '" + limit + "'";
|
||||||
if (! source.empty()) {
|
if (! source.empty()) {
|
||||||
query += " AND Logfile = '" + source + "'";
|
query += " AND Logfile = '" + source + "'";
|
||||||
}
|
}
|
||||||
if (! type.empty()) {
|
if (! type.empty()) {
|
||||||
query += " AND Type = '" + type + "'";
|
query += " AND Type = '" + type + "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
dhCheck (dhGetObject (getWmiStr (L"."), NULL, &wmi_svc));
|
||||||
@ -416,30 +418,29 @@ Pandora_Wmi::getEventList (string source, string type, string pattern, int inter
|
|||||||
query.c_str()));
|
query.c_str()));
|
||||||
|
|
||||||
FOR_EACH (quickfix, quickfixes, NULL) {
|
FOR_EACH (quickfix, quickfixes, NULL) {
|
||||||
// Timestamp
|
// Timestamp
|
||||||
dhGetValue (L"%s", &value, quickfix,
|
dhGetValue (L"%s", &value, quickfix,
|
||||||
L".TimeWritten");
|
L".TimeWritten");
|
||||||
timestamp = value;
|
timestamp = value;
|
||||||
dhFreeString (value);
|
dhFreeString (value);
|
||||||
|
|
||||||
// Message
|
// Message
|
||||||
dhGetValue (L"%s", &value, quickfix,
|
dhGetValue (L"%S", &unicode_value, quickfix,
|
||||||
L".Message");
|
L".Message");
|
||||||
message = value;
|
value = Pandora_Strutils::strUnicodeToAnsi (unicode_value);
|
||||||
|
message = Pandora_Strutils::trim (value);
|
||||||
dhFreeString (value);
|
dhFreeString (value);
|
||||||
|
|
||||||
// LIKE is not always available, we have to filter ourselves
|
// LIKE is not always available, we have to filter ourselves
|
||||||
if (pattern.empty() || (message.find(pattern) != string::npos)) {
|
if (pattern.empty () || (message.find (pattern) != string::npos)) {
|
||||||
event = timestamp + " " + message;
|
event = timestamp + " " + message;
|
||||||
event_list.push_back(event);
|
event_list.push_back(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
} NEXT_THROW (quickfix);
|
} NEXT_THROW (quickfix);
|
||||||
} catch (string errstr) {
|
} catch (string errstr) {
|
||||||
pandoraDebug ("Pandora_Wmi::getEventList: error: %s", errstr.c_str ());
|
pandoraDebug ("Pandora_Wmi::getEventList: error: %s", errstr.c_str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -449,59 +450,62 @@ Pandora_Wmi::getEventList (string source, string type, string pattern, int inter
|
|||||||
*/
|
*/
|
||||||
string
|
string
|
||||||
Pandora_Wmi::getTimestampLimit (int interval) {
|
Pandora_Wmi::getTimestampLimit (int interval) {
|
||||||
char limit_str[26], diff_sign;
|
char limit_str[26], diff_sign;
|
||||||
time_t limit_time, limit_time_utc, limit_diff;
|
time_t limit_time, limit_time_utc, limit_diff;
|
||||||
struct tm *limit_tm = NULL, *limit_tm_utc = NULL;
|
struct tm *limit_tm = NULL, *limit_tm_utc = NULL;
|
||||||
|
|
||||||
// Get current time
|
// Get current time
|
||||||
limit_time = time(0);
|
limit_time = time(0);
|
||||||
if (limit_time == (time_t)-1) {
|
if (limit_time == (time_t)-1) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get UTC time
|
// Get UTC time
|
||||||
limit_tm_utc = gmtime (&limit_time);
|
limit_tm_utc = gmtime (&limit_time);
|
||||||
limit_time_utc = mktime (limit_tm_utc);
|
limit_time_utc = mktime (limit_tm_utc);
|
||||||
|
|
||||||
// Calculate the difference in minutes
|
// Calculate the difference in minutes
|
||||||
limit_diff = limit_time - limit_time_utc;
|
limit_diff = limit_time - limit_time_utc;
|
||||||
if (limit_diff >= 0) {
|
if (limit_diff >= 0) {
|
||||||
diff_sign = '+';
|
diff_sign = '+';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
diff_sign = '-';
|
diff_sign = '-';
|
||||||
}
|
}
|
||||||
limit_diff = abs(limit_diff);
|
limit_diff = abs(limit_diff);
|
||||||
limit_diff /= 60;
|
limit_diff /= 60;
|
||||||
|
|
||||||
// Substract the agent interval
|
// Substract the agent interval
|
||||||
limit_time_utc -= interval;
|
limit_time_utc -= interval;
|
||||||
|
|
||||||
limit_tm = localtime (&limit_time_utc);
|
limit_tm = localtime (&limit_time_utc);
|
||||||
if (limit_tm == NULL) {
|
if (limit_tm == NULL) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// WMI date format: yyyymmddHHMMSS.xxxxxx+UUU
|
// WMI date format: yyyymmddHHMMSS.xxxxxx+UUU
|
||||||
snprintf (limit_str, 26, "%.4d%.2d%.2d%.2d%.2d%.2d.000000%c%.3d",
|
snprintf (limit_str, 26, "%.4d%.2d%.2d%.2d%.2d%.2d.000000%c%.3d",
|
||||||
limit_tm->tm_year + 1900, limit_tm->tm_mon + 1,
|
limit_tm->tm_year + 1900, limit_tm->tm_mon + 1,
|
||||||
limit_tm->tm_mday, limit_tm->tm_hour,
|
limit_tm->tm_mday, limit_tm->tm_hour,
|
||||||
limit_tm->tm_min, limit_tm->tm_sec, diff_sign, limit_diff);
|
limit_tm->tm_min, limit_tm->tm_sec, diff_sign, limit_diff);
|
||||||
limit_str[25] = '\0';
|
limit_str[25] = '\0';
|
||||||
|
|
||||||
return string (limit_str);
|
return string (limit_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Converts a date in WMI format to SYSTEMTIME format.
|
* Converts a date in WMI format to SYSTEMTIME format.
|
||||||
|
*
|
||||||
|
* @param wmi_date Date in WMI format
|
||||||
|
* @param system_time Output system time variable
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Pandora_Wmi::convertWMIDate (string wmi_date, SYSTEMTIME *system_time) {
|
Pandora_Wmi::convertWMIDate (string wmi_date, SYSTEMTIME *system_time)
|
||||||
|
{
|
||||||
system_time->wYear = atoi(wmi_date.substr (0, 4).c_str());
|
system_time->wYear = atoi (wmi_date.substr (0, 4).c_str());
|
||||||
system_time->wMonth = atoi(wmi_date.substr (4, 2).c_str());
|
system_time->wMonth = atoi (wmi_date.substr (4, 2).c_str());
|
||||||
system_time->wDay = atoi(wmi_date.substr (6, 2).c_str());
|
system_time->wDay = atoi (wmi_date.substr (6, 2).c_str());
|
||||||
system_time->wHour = atoi(wmi_date.substr (8, 2).c_str());
|
system_time->wHour = atoi (wmi_date.substr (8, 2).c_str());
|
||||||
system_time->wMinute = atoi(wmi_date.substr (10, 2).c_str());
|
system_time->wMinute = atoi (wmi_date.substr (10, 2).c_str());
|
||||||
system_time->wSecond = atoi(wmi_date.substr (12, 2).c_str());
|
system_time->wSecond = atoi (wmi_date.substr (12, 2).c_str());
|
||||||
}
|
}
|
||||||
|
@ -36,23 +36,20 @@ namespace Pandora_Wmi {
|
|||||||
/**
|
/**
|
||||||
* Exception super-class when doing a WMI operation.
|
* Exception super-class when doing a WMI operation.
|
||||||
*/
|
*/
|
||||||
class Pandora_Wmi_Exception : public Pandora_Exception { };
|
class Pandora_Wmi_Exception : public Pandora_Exception { };
|
||||||
|
|
||||||
int isProcessRunning (string process_name);
|
int isProcessRunning (string process_name);
|
||||||
int isServiceRunning (string service_name);
|
int isServiceRunning (string service_name);
|
||||||
unsigned long getDiskFreeSpace (string disk_id);
|
unsigned long getDiskFreeSpace (string disk_id);
|
||||||
int getCpuUsagePercentage (int cpu_id);
|
int getCpuUsagePercentage (int cpu_id);
|
||||||
long getFreememory ();
|
long getFreememory ();
|
||||||
string getOSName ();
|
string getOSName ();
|
||||||
string getOSVersion ();
|
string getOSVersion ();
|
||||||
string getOSBuild ();
|
string getOSBuild ();
|
||||||
string getSystemName ();
|
string getSystemName ();
|
||||||
void getEventList (string source, string type, string pattern, int interval, list<string> &event_list);
|
void getEventList (string source, string type, string pattern, int interval, list<string> &event_list);
|
||||||
string getTimestampLimit (int interval);
|
string getTimestampLimit (int interval);
|
||||||
void convertWMIDate (string wmi_date, SYSTEMTIME *system_time);
|
void convertWMIDate (string wmi_date, SYSTEMTIME *system_time);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user