mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Change SFTP/SCP log rotators to use 4-digit year in filenames (fixes #745).
This commit is contained in:
parent
048516c605
commit
f921a4d5db
2 changed files with 18 additions and 2 deletions
|
@ -25,6 +25,10 @@ export {
|
|||
## function queries this table upon log rotation and performs a secure
|
||||
## copy of the rotated-log to each destination in the set.
|
||||
global scp_destinations: table[Writer, string] of set[SCPDestination];
|
||||
|
||||
## Default naming format for timestamps embedded into log filenames
|
||||
## that use the SCP rotator.
|
||||
const scp_rotation_date_format = "%Y-%m-%d-%H-%M-%S" &redef;
|
||||
}
|
||||
|
||||
function scp_postprocessor(info: Log::RotationInfo): bool
|
||||
|
@ -34,7 +38,11 @@ function scp_postprocessor(info: Log::RotationInfo): bool
|
|||
|
||||
local command = "";
|
||||
for ( d in scp_destinations[info$writer, info$path] )
|
||||
command += fmt("scp %s %s@%s:%s;", info$fname, d$user, d$host, d$path);
|
||||
{
|
||||
local dst = fmt("%s/%s.%s.log", d$path, info$path,
|
||||
strftime(Log::scp_rotation_date_format, info$open));
|
||||
command += fmt("scp %s %s@%s:%s;", info$fname, d$user, d$host, dst);
|
||||
}
|
||||
|
||||
command += fmt("/bin/rm %s", info$fname);
|
||||
system(command);
|
||||
|
|
|
@ -47,6 +47,10 @@ export {
|
|||
## transfer of the rotated-log to each destination in the set. This
|
||||
## table can be modified at run-time.
|
||||
global sftp_destinations: table[Writer, string] of set[SFTPDestination];
|
||||
|
||||
## Default naming format for timestamps embedded into log filenames
|
||||
## that use the SFTP rotator.
|
||||
const sftp_rotation_date_format = "%Y-%m-%d-%H-%M-%S" &redef;
|
||||
}
|
||||
|
||||
function sftp_postprocessor(info: Log::RotationInfo): bool
|
||||
|
@ -56,8 +60,12 @@ function sftp_postprocessor(info: Log::RotationInfo): bool
|
|||
|
||||
local command = "";
|
||||
for ( d in sftp_destinations[info$writer, info$path] )
|
||||
command += fmt("echo put %s %s | sftp -b - %s@%s;", info$fname, d$path,
|
||||
{
|
||||
local dst = fmt("%s/%s.%s.log", d$path, info$path,
|
||||
strftime(Log::sftp_rotation_date_format, info$open));
|
||||
command += fmt("echo put %s %s | sftp -b - %s@%s;", info$fname, dst,
|
||||
d$user, d$host);
|
||||
}
|
||||
|
||||
command += fmt("/bin/rm %s", info$fname);
|
||||
system(command);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue