Extended Debug mode. Now, agents report allways to server

This commit is contained in:
fermin831 2015-10-06 16:09:46 +02:00
parent bea8170120
commit 388e1ff533
2 changed files with 41 additions and 13 deletions

16
pandora_agents/unix/pandora_agent Normal file → Executable file
View File

@ -883,7 +883,14 @@ sub send_buffered_xml_files () {
next if ($xml_file !~ m/^$Conf{'agent_name'}\.[0-9]+\.data$/ || -l "$Conf{'temporal'}/$xml_file");
my $rc = send_file ("$Conf{'temporal'}/$xml_file", 1);
unlink ("$Conf{'temporal'}/$xml_file") if ($rc == 0);
if ($rc == 0) {
if ($Conf{'debug'} eq '1') {
rename "$Conf{'temporal'}/$xml_file", "$Conf{'temporal'}/$xml_file". "sent";
} else {
unlink ("$Conf{'temporal'}/$xml_file");
}
}
}
}
@ -2350,13 +2357,16 @@ while (1) {
if ($Conf{'debug'} eq '1') {
log_message ('debug', "Wrote XML data file '$temp_file'");
log_message ('debug', "Wrote XML data file '$temp_file'", *STDOUT);
last;
}
# Send the XML data file
my $rc = send_file ($temp_file, 1);
if ($rc == 0 || $Conf{'xml_buffer'} == 0 || temporal_freedisk () < $Conf{'temporal_min_size'}) {
unlink ($temp_file);
if ($Conf{'debug'} eq '1') {
rename $temp_file, $temp_file . "sent";
} else {
unlink ($temp_file);
}
}
# Send buffered XML data files

View File

@ -1699,19 +1699,23 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
fprintf (conf_fh, "%s", data_xml.c_str ());
fclose (conf_fh);
/* Only send if debug is not activated */
if (getPandoraDebug () == false) {
rc = this->copyDataFile (tmp_filename);
/* Allways reports to Data Server*/
rc = this->copyDataFile (tmp_filename);
/* Delete the file if successfully copied, buffer disabled or not enough space available */
if (rc == 0 || xml_buffer == 0 || (GetDiskFreeSpaceEx (tmp_filepath.c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart < min_free_bytes)) {
Pandora_File::removeFile (tmp_filepath);
/* Delete the file if successfully copied, buffer disabled or not enough space available */
if (rc == 0 || xml_buffer == 0 || (GetDiskFreeSpaceEx (tmp_filepath.c_str (), &free_bytes, NULL, NULL) != 0 && free_bytes.QuadPart < min_free_bytes)) {
/* Rename the file if debug mode is enabled*/
if (getPandoraDebug ()) {
string tmp_filepath_sent = tmp_filepath;
tmp_filepath_sent.append("sent");
CopyFile (tmp_filepath.c_str(), tmp_filepath_sent.c_str(), false);
}
Pandora_File::removeFile (tmp_filepath);
}
/* Send any buffered data files */
if (xml_buffer == 1) {
this->sendBufferedXml (conf->getValue ("temporal"));
}
/* Send any buffered data files */
if (xml_buffer == 1) {
this->sendBufferedXml (conf->getValue ("temporal"));
}
ReleaseMutex (mutex);
@ -1739,6 +1743,14 @@ Pandora_Windows_Service::sendBufferedXml (string path) {
FindClose(find);
return;
}
if (getPandoraDebug ()){
string file_data_path = base_path + file_data.cFileName;
string file_data_sent = file_data_path;
file_data_sent.append("sent");
CopyFile (file_data_path.c_str(), file_data_sent.c_str(), false);
}
Pandora_File::removeFile (base_path + file_data.cFileName);
while (FindNextFile(find, &file_data) != 0) {
@ -1746,6 +1758,12 @@ Pandora_Windows_Service::sendBufferedXml (string path) {
FindClose(find);
return;
}
if (getPandoraDebug ()){
string file_data_path = base_path + file_data.cFileName;
string file_data_sent = file_data_path;
file_data_sent.append("sent");
CopyFile (file_data_path.c_str(), file_data_sent.c_str(), false);
}
Pandora_File::removeFile (base_path + file_data.cFileName);
}