Added disable_logfile token to Windows Agent

This commit is contained in:
fermin831 2015-09-22 18:35:19 +02:00
parent 161921be3d
commit d30ad049c8
4 changed files with 30 additions and 10 deletions

View File

@ -65,6 +65,9 @@ server_port 41121
# In case of using FTP or tentacle with password. User is always "pandora"
#server_pwd pandora
# If set to 1 disables log writing into pandora_agent.log
#disable_logfile 1
# Debug mode do not copy XML data files to server.
# debug 1
@ -75,9 +78,6 @@ remote_config 0
# XML encoding (ISO-8859-1 by default). Most windows servers experience problems when you set to UTF-8. Other special codepages may be specified here.
#encoding ISO-8859-1
# Config file encoding. Some windows text editors has ANSI default and others UTF-8
#config_file_encoding UTF-8
# If set to 1 start Drone Agent's Proxy Mode
# proxy_mode 1

View File

@ -35,6 +35,7 @@ using namespace Pandora_Strutils;
string pandora_path;
string pandora_dir;
bool pandora_debug;
bool pandora_log_disable;
string pandora_version = PANDORA_VERSION;
/**
@ -143,14 +144,17 @@ pandoraWriteLog (string filename, string line) {
*/
void
Pandora::pandoraLog (const char *format, ...) {
va_list args;
char msg[5000];
if (!pandora_log_disable) {
va_list args;
char msg[5000];
va_start (args, format);
vsprintf (msg, format, args);
va_end (args);
va_start (args, format);
vsprintf (msg, format, args);
va_end (args);
pandoraWriteLog ("pandora_agent.log", (char *) msg);
pandoraWriteLog ("pandora_agent.log", (char *) msg);
}
return;
}
/**
@ -275,6 +279,18 @@ Pandora::getPandoraDebug () {
return pandora_debug;
}
/**
* Set the disable logfile flag.
*
* If the flag is true no logs will be written.
*
* @param dbg Turns the debug flag on/off.
*
*/
void
Pandora::setPandoraLogDisable (bool dbg) {
pandora_log_disable = dbg;
}
/**
* Get the version of the agent.

View File

@ -76,6 +76,7 @@ namespace Pandora {
string getPandoraInstallPath ();
void setPandoraDebug (bool dbg);
bool getPandoraDebug ();
void setPandoraLogDisable (bool dbg);
string getPandoraAgentVersion ();
void pandoraDebug (const char *format, ...);

View File

@ -205,7 +205,7 @@ Pandora_Windows_Service::check_broker_agents(string *all_conf){
void
Pandora_Windows_Service::pandora_init () {
string conf_file, interval, debug, intensive_interval, util_dir, path, env;
string conf_file, interval, debug, disable_logfile, intensive_interval, util_dir, path, env;
string udp_server_enabled, udp_server_port, udp_server_addr, udp_server_auth_addr;
string name_agent, name;
string proxy_mode, server_ip;
@ -264,6 +264,9 @@ Pandora_Windows_Service::pandora_init () {
debug = conf->getValue ("debug");
setPandoraDebug (is_enabled (debug));
disable_logfile = conf->getValue ("disable_logfile");
setPandoraLogDisable (is_enabled(disable_logfile));
if (first_run == 1) {
first_run = 0;