From owner-freebsd-bugs Sat Mar 30 15:40:22 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 2D2D037B419 for ; Sat, 30 Mar 2002 15:40:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2UNe3C93411; Sat, 30 Mar 2002 15:40:03 -0800 (PST) (envelope-from gnats) Received: from mail.industrialcarriers.com (mail.industrialcarriers.com [195.138.73.178]) by hub.freebsd.org (Postfix) with ESMTP id AFD5537B405 for ; Sat, 30 Mar 2002 15:32:48 -0800 (PST) Received: (from mishka@localhost) by mail.industrialcarriers.com (8.11.6/8.11.6) id g2UNWdo85282; Sun, 31 Mar 2002 01:32:39 +0200 (EET) (envelope-from mishka) Message-Id: <200203302332.g2UNWdo85282@mail.industrialcarriers.com> Date: Sun, 31 Mar 2002 01:32:39 +0200 (EET) From: Mishka Reply-To: Mishka To: FreeBSD-gnats-submit@FreeBSD.org Cc: mishka@batraq.anything3d.com X-Send-Pr-Version: 3.113 Subject: bin/36553: Two new features in newsyslog(8) Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 36553 >Category: bin >Synopsis: Two new features in newsyslog(8) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Mar 30 15:40:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Mishka >Release: FreeBSD 4.5-STABLE i386 >Organization: Terabyte ACS >Environment: System: FreeBSD mail.industrialcarriers.com 4.5-STABLE FreeBSD 4.5-STABLE #0: Sun Mar 24 13:13:03 EET 2002 mishka@victor.terabyte.com.ua:/usr/src/sys/compile/HARLEY i386 >Description: Dear Sirs! I am very happy with FreeBSD built-in utilities. Such, in most cases i needn't any other software to solve my problems and task. Hovewer, there is posted some useful changes to newsyslog(8): 1. When time="*" and size="*" now it means that newsyslog must rotate log file with any size and at any time, when started. Early it just skip such logs. I think, if we always want to skip some logfiles, we can comment it out or just remove. 2. After all, newsyslog always tries to sent some signal (HUP by default) to some process (syslogd(8) by default) which can be not wanted sometimes. Now if path_to_pid_file="-" the newsyslog will not sent any signal to any process for this records. Few examples: /var/log/squid/access.log 644 31 * * - - /var/log/apache/access.log 644 3 8192 * Z - /var/log/maillog 644 7 * @T00 Z I take a look to ports collection before, but have not find any with such features, when my rotation scheme want to have such ones. For apply my changes please use patch provided. If you find my changes useful please inform me how can i fix it (move to ports collection or other way). -- Best regards, Mishka. >How-To-Repeat: 1. You can change time and size fields to asterisk (*) and see newer turned over logfiles. 2. You can't avoid sending signal. If you ignore path_to_pid_file field the newsyslog will sent SIGHUP to syslogd(8). Moreover, this field must be started with slash "/" character, so should be path to some pid-file. >Fix: Please use following patch: Note: This patchfile should be placed into /usr/src/usr.sbin directory. (cd /usr/sys/usr.sbin ; patch < newsyslog.patch) diff -ur /usr/src/usr.sbin/newsyslog/newsyslog.8 newsyslog/newsyslog.8 --- /usr/src/usr.sbin/newsyslog/newsyslog.8 Sun Mar 31 00:38:19 2002 +++ newsyslog/newsyslog.8 Sat Mar 30 06:34:07 2002 @@ -254,6 +254,16 @@ rotate on every 5th day of month at 6:00 hr .El .Pp +.Em Note: +if you place asterisk +.Pq Ql \&* +into both +.Ar size +and +.Ar when +fields the logfile will be turned over each time starting +.Nm . +.Pp .It Ar flags This optional field specifies if the archive should have any special processing done to the archived log files. @@ -284,9 +294,14 @@ the file name to read to find the daemon process id. If this field is present, a .Ar signal_number -is sent the process id contained in this -file. This field must start with "/" in order to be recognized -properly. +is sent the process id contained in this file; in other case +.Nm +will tries sent signal to +.Xr syslogd 8 . +Please note, all path must be absolute, (i.e. paths must start with "/" +in order to be recognized properly). Place the dash +.Ar - +here if you don't want sent any signals to any processes. .It Ar signal_number This optional field specifies the signal number will be sent to the daemon process. diff -ur /usr/src/usr.sbin/newsyslog/newsyslog.c newsyslog/newsyslog.c --- /usr/src/usr.sbin/newsyslog/newsyslog.c Sun Mar 31 00:38:21 2002 +++ newsyslog/newsyslog.c Sun Mar 31 01:03:25 2002 @@ -25,7 +25,7 @@ #ifndef lint static const char rcsid[] = -"$FreeBSD: src/usr.sbin/newsyslog/newsyslog.c,v 1.25.2.4 2001/11/14 16:58:58 obrien Exp $"; +"$Id$"; #endif /* not lint */ #define OSF @@ -67,6 +67,7 @@ #define CE_BZCOMPACT 8 /* Compact the achived log files with bzip2 */ /* status messages */ #define CE_TRIMAT 4 /* trim at a specific time */ +#define CE_SKIPNOTIFY 16 /* skip syslogd(8) notification */ #define NONE -1 @@ -167,17 +168,24 @@ ctime(&ent->trim_at)); return; } else if (verbose && ent->hours <= 0) { - printf("--> time is up\n"); + printf("time is up"); + if (ent->size < 0) + printf(" or "); + else + printf(", "); } } if (verbose && (ent->size > 0)) printf("size (Kb): %d [%d] ", size, ent->size); if (verbose && (ent->hours > 0)) printf(" age (hr): %d [%d] ", modtime, ent->hours); - if (force || ((ent->size > 0) && (size >= ent->size)) || + if (verbose && (ent->hours <= 0 && ent->size < 0)) + printf("always "); + if ( force || ((ent->size > 0) && (size >= ent->size)) || (ent->hours <= 0 && (ent->flags & CE_TRIMAT)) || - ((ent->hours > 0) && ((modtime >= ent->hours) - || (modtime < 0)))) { + ((ent->hours > 0) && ((modtime >= ent->hours) || + (modtime < 0) )) || + (ent->hours <= 0 && ent->size < 0) ) { if (verbose) printf("--> trimming log....\n"); if (noaction && !verbose) { @@ -460,6 +468,8 @@ if (q && *q) { if (*q == '/') working->pid_file = strdup(q); + else if (*q == '-') + working->flags |= CE_SKIPNOTIFY; else if (isdigit(*q)) goto got_sig; else @@ -666,7 +676,11 @@ pid = get_pid(pid_file); } if (pid) { - if (noaction) { + if (flags & CE_SKIPNOTIFY) { + notified = 1; + if (verbose) + printf("no syslogd(8) notification needed\n"); + } else if (noaction) { notified = 1; printf("kill -%d %d\n", sig, (int) pid); } else if (kill(pid, sig)) >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message