mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
Merge pull request #8 from uchida/remember-agent_name_cmd-result-in-xml-header
Remember agent_name_cmd result in xml header
This commit is contained in:
commit
7357216155
@ -370,7 +370,7 @@ Pandora_Windows_Service::launchTentacleProxy() {
|
|||||||
string
|
string
|
||||||
Pandora_Windows_Service::getXmlHeader () {
|
Pandora_Windows_Service::getXmlHeader () {
|
||||||
char timestamp[20];
|
char timestamp[20];
|
||||||
string agent_name, os_name, os_version, encoding, value, xml, address, parent_agent_name, agent_name_cmd, temp_agent_name;
|
string agent_name, os_name, os_version, encoding, value, xml, address, parent_agent_name, agent_name_cmd;
|
||||||
string custom_id, url_address, latitude, longitude, altitude, position_description, gis_exec, gis_result;
|
string custom_id, url_address, latitude, longitude, altitude, position_description, gis_exec, gis_result;
|
||||||
time_t ctime;
|
time_t ctime;
|
||||||
struct tm *ctime_tm = NULL;
|
struct tm *ctime_tm = NULL;
|
||||||
@ -385,7 +385,7 @@ Pandora_Windows_Service::getXmlHeader () {
|
|||||||
agent_name_cmd = conf->getValue ("agent_name_cmd");
|
agent_name_cmd = conf->getValue ("agent_name_cmd");
|
||||||
if (agent_name_cmd != "") {
|
if (agent_name_cmd != "") {
|
||||||
agent_name_cmd = "cmd.exe /c \"" + agent_name_cmd + "\"";
|
agent_name_cmd = "cmd.exe /c \"" + agent_name_cmd + "\"";
|
||||||
temp_agent_name = getCoordinatesFromCmdExec(agent_name_cmd);
|
static string temp_agent_name = getAgentNameFromCmdExec(agent_name_cmd);
|
||||||
// Delete carriage return if is provided
|
// Delete carriage return if is provided
|
||||||
pos = temp_agent_name.find("\n");
|
pos = temp_agent_name.find("\n");
|
||||||
if(pos != string::npos) {
|
if(pos != string::npos) {
|
||||||
@ -536,7 +536,7 @@ Pandora_Windows_Service::getXmlHeader () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
Pandora_Windows_Service::getCoordinatesFromCmdExec (string cmd_exec)
|
Pandora_Windows_Service::getValueFromCmdExec (string cmd_exec, int timeout)
|
||||||
{
|
{
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
STARTUPINFO si;
|
STARTUPINFO si;
|
||||||
@ -546,7 +546,6 @@ Pandora_Windows_Service::getCoordinatesFromCmdExec (string cmd_exec)
|
|||||||
HANDLE out, new_stdout, out_read, job;
|
HANDLE out, new_stdout, out_read, job;
|
||||||
string working_dir;
|
string working_dir;
|
||||||
string output = "";
|
string output = "";
|
||||||
int timeout = 30;
|
|
||||||
|
|
||||||
/* Set the bInheritHandle flag so pipe handles are inherited. */
|
/* Set the bInheritHandle flag so pipe handles are inherited. */
|
||||||
attributes.nLength = sizeof (SECURITY_ATTRIBUTES);
|
attributes.nLength = sizeof (SECURITY_ATTRIBUTES);
|
||||||
@ -660,6 +659,18 @@ Pandora_Windows_Service::getCoordinatesFromCmdExec (string cmd_exec)
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
Pandora_Windows_Service::getAgentNameFromCmdExec (string cmd_exec)
|
||||||
|
{
|
||||||
|
return getValueFromCmdExec(cmd_exec, 10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
Pandora_Windows_Service::getCoordinatesFromCmdExec (string cmd_exec)
|
||||||
|
{
|
||||||
|
return getValueFromCmdExec(cmd_exec, 500);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Pandora_Windows_Service::copyTentacleDataFile (string host,
|
Pandora_Windows_Service::copyTentacleDataFile (string host,
|
||||||
string filename,
|
string filename,
|
||||||
|
@ -53,6 +53,8 @@ namespace Pandora {
|
|||||||
|
|
||||||
string getXmlHeader ();
|
string getXmlHeader ();
|
||||||
int copyDataFile (string filename);
|
int copyDataFile (string filename);
|
||||||
|
string getValueFromCmdExec (string cmd_exec, int timeout);
|
||||||
|
string getAgentNameFromCmdExec (string cmd_exec);
|
||||||
string getCoordinatesFromCmdExec (string cmd_exec);
|
string getCoordinatesFromCmdExec (string cmd_exec);
|
||||||
int copyTentacleDataFile (string host,
|
int copyTentacleDataFile (string host,
|
||||||
string filename,
|
string filename,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user