Added max_log_generation config
This commit is contained in:
parent
a203d3beb7
commit
b20c81143d
|
@ -274,10 +274,13 @@ braa_retries 3
|
|||
autocreate 1
|
||||
|
||||
# max_log_size: Specify max size of Pandora FMS server log file (1MB by default). If
|
||||
# log file grows above this limit, is renamed to "pandora_server.log.old".
|
||||
# log file grows above this limit, is renamed to "pandora_server.log.0".
|
||||
|
||||
max_log_size 1048576
|
||||
|
||||
# max_log_generation: Specify max generation count (between 1 and 9) of Pandora FMS server log files.
|
||||
max_log_generation 1
|
||||
|
||||
# max_queue_files (500 by default)
|
||||
# When server have more than max_queue_files in incoming directory, skips the read
|
||||
# the directory to avoid filesystem overhead.
|
||||
|
|
|
@ -286,6 +286,9 @@ sub pandora_load_config {
|
|||
# max log size (bytes)
|
||||
$pa_config->{'max_log_size'} = 1048576;
|
||||
|
||||
# max log generation
|
||||
$pa_config->{'max_log_generation'} = 1;
|
||||
|
||||
# Ignore the timestamp in the XML and use the file timestamp instead
|
||||
$pa_config->{'use_xml_timestamp'} = 0;
|
||||
|
||||
|
@ -639,6 +642,9 @@ sub pandora_load_config {
|
|||
elsif ($parametro =~ m/^max_log_size\s([0-9]*)/i) {
|
||||
$pa_config->{'max_log_size'}= clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^max_log_generation\s([1-9])/i) {
|
||||
$pa_config->{'max_log_generation'}= clean_blank($1);
|
||||
}
|
||||
elsif ($parametro =~ m/^wmi_threads\s([0-9]*)/i) {
|
||||
$pa_config->{'wmi_threads'}= clean_blank($1);
|
||||
}
|
||||
|
|
|
@ -466,7 +466,12 @@ sub logger ($$;$) {
|
|||
closelog();
|
||||
} else {
|
||||
# Log rotation
|
||||
rename ($file, $file.'.old') if (-e $file && (stat($file))[7] > $pa_config->{'max_log_size'});
|
||||
if (-e $file && (stat($file))[7] > $pa_config->{'max_log_size'}) {
|
||||
foreach my $i (reverse 1..$pa_config->{'max_log_generation'}) {
|
||||
rename ($file . "." . ($i - 1), $file . "." . $i);
|
||||
}
|
||||
rename ($file, "$file.0");
|
||||
}
|
||||
|
||||
open (FILE, ">> $file") or die "[FATAL] Could not open logfile '$file'";
|
||||
print FILE strftime ("%Y-%m-%d %H:%M:%S", localtime()) . " " . $pa_config->{'servername'} . $pa_config->{'servermode'} . " [V". $level ."] " . $message . "\n";
|
||||
|
|
Loading…
Reference in New Issue