* logrotate?
@ 2001-09-11 8:47 Axel K�ster
2001-09-12 6:33 ` logrotate? Jonas Furrer
2001-09-12 23:16 ` logrotate? Mike Robinson
0 siblings, 2 replies; 3+ messages in thread
From: Axel K�ster @ 2001-09-11 8:47 UTC (permalink / raw)
Hello to all,
does anyone know of a logrotate tool running on True64 (4.0..), preferrable a
binary?
Thanks in advance
Axel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: logrotate?
2001-09-11 8:47 logrotate? Axel K�ster
@ 2001-09-12 6:33 ` Jonas Furrer
2001-09-12 23:16 ` logrotate? Mike Robinson
1 sibling, 0 replies; 3+ messages in thread
From: Jonas Furrer @ 2001-09-12 6:33 UTC (permalink / raw)
"Axel K�ster" wrote:
> Hello to all,
>
> does anyone know of a logrotate tool running on True64 (4.0..), preferrable a
> binary?
>
> Thanks in advance
>
> Axel
Hi Axel
Maybe this Perl-Script helps. It is designed to use with Tru64 V4 / V5 Unix, that
meens CDSL's are handeld hopefully correctly. No Warranty.
Bye Jonas
-----------------------------8x ----------x8 --------------------------------
#!/bin/perl -w
#
# $Id: rotate_log.pl,v 1.3 2001/07/02 09:41:54 t750t Exp $
#
# ------------------------------------------------------------------------------
# Filename: rotate_log.pl
#
# Usage: see subroutine 'print_usage'
#
# Author: Jonas Furrer, RealStuff Informatik AG (http://www.realstuff.ch)
#
# Abstract: Rotates Files. /var/adm/messages and /var/adm/binary.errlog
# are rotated only if they contain a boot record.
# CDSL-Links are handeld correctly. Compression can be enabled.
#
# Requirements: - Digital UNIX 3.2 or higher
# - Perl 5.004 or higher
#
# Output-files: rotated files
#
# ------------------------------------------------------------------------------
# Edition history:
#
# 13.06.2001 jfu Initial version
# 02.07.2001 jfu Bug-Fix: dealing context-dependent symbolic link
use vars qw($opt_d $opt_c $opt_v $opt_m);
use Getopt::Std;
use File::stat qw(:FIELDS);
sub print_usage
{
print "\nUsage: rotate_log.pl [-dm] [-v [count]] [-c method] [-f input
file] filename\n";
print " -d\t\t -> debug\n";
print " -m\t\t -> sends no mail\n";
print " -c method\t -> compress\n";
print " Z\t = Unix standard compression\n";
print " gz\t = gzip compression\n";
print " -v count\t -> versions\n";
print " -f input file\t -> File containing files to rotate\n";
print " filenames\t -> Files to rotates, wildcards allowed\n";
print "\n";
exit;
}
# ----------------------------- Global declarations ----------------------------
chomp(($OSVERSION) = (`uname -r | cut -d. -f1`));
# ----------------------------- Parse Command line -----------------------------
if ( ! getopts("dmc:f:v:")) # d/m = Boolean;
{
print_usage;
}
if ( defined ($opt_d) ) {$DEBUG = "TRUE";} else {$DEBUG = "FALSE";}
if ( defined ($opt_m) ) {$NOMAIL = "TRUE";} else {$NOMAIL = "FALSE";}
if ( defined ($opt_v) ) {$VERSIONS = $opt_v;} else {$VERSIONS = 1;}
# --- Compression ---
if ( defined ($opt_c) )
{
$COMPRESS = "TRUE";
$EXT=".".$opt_c;
if ($opt_c =~ /Z/ )
{ $COMPRESS_CMD = "/usr/bin/compress"; }
elsif ( $opt_c =~ /gz/ )
{ $COMPRESS_CMD = "/usr/bin/gzip";}
else
{ print "Unknown compression method\n"; print_usage; exit;}
} else
{
$COMPRESS = "FALSE";$EXT="";
}
# --- Files to rotate ---
if ( defined ($opt_f) )
{
open(FH, $opt_f) or die("Can't open $opt_f: $!\n");
while (defined ($line = <FH>))
{
chomp($line);
if ( $DEBUG =~ /TRUE/i ) { print "File list: $line\n";}
push(@FILES,$line);
}
close(FH);
}
if ( defined ($ARGV[0]))
{
push(@FILES , @ARGV);
} else
{
if ( ! defined ($opt_f))
{
print "No Files to rotate\n";
print_usage;
exit;
}
}
# --- Print Debug info ---
if ( $DEBUG =~ /TRUE/i )
{
print "We are a $OSVERSION system\n";
print "\nOption d\t= $DEBUG\n";
print "Option m\t= $NOMAIL\n";
print "Option c\t= $COMPRESS \t\tMethod = $EXT\n";
print "Option v\t= $VERSIONS\n";
print "Count Files\t= $#ARGV\n";
print "File list\t= @FILES\n";
}
# ---------------------------------- Sub Routines ------------------------------
sub mkcdsl
{
my $file = shift;
chomp($tmp_file = `basename $file`);
`/usr/sbin/mkcdsl -f $tmp_file`;
}
sub print_detail_info
{
$msg = "-> /var/adm/binary.errlog contains no startup message.\n";
$msg .= "-> binary.errlog and messages will not be switched.\n\n";
$msg .= "Output of 'ls -al /var/adm/binary.errlog*':\n";
$msg .= `/sbin/ls -al /var/adm/binary.errlog*`."\n";
$msg .= "Output of 'ls -al /var/adm/messages*:\n";
$msg .= `/sbin/ls -al /var/adm/messages*`."\n";
$msg .= "Output of 'df -k /var/adm':\n";
$msg .= `/sbin/df -k /var/adm`."\n";
$msg .= "Output of 'uptime':\n";
$msg .= `/usr/bin/uptime`."\n";
if ( $NOMAIL =~ /TRUE/i )
{
print $msg;
} else
{
`echo $msg | /usr/bin/mailx -s "No log switch" root`;
}
}
sub rotate
{
my $file = shift;
my $count= shift;
if ( $DEBUG =~ /TRUE/i ) { print "\n\$file = $file\n" ;}
stat($file) or die "No $file: $!"; # gets all inode informations
# --- Rotate from 1 to n ---
for ($i=$count-1; $i > 0; $i--)
{
$ii = $i+1;
if ( -e "$file.$i$EXT" )
{
if ( $DEBUG =~ /TRUE/i ) { print "mv $file.$i$EXT
$file.$ii$EXT\n";}
`mv $file.$i$EXT $file.$ii$EXT`;
`chown $st_uid.$st_gid $file.$ii$EXT`;
if ($OSVERSION =~ /V5/) { mkcdsl("$file.$ii$EXT"); }
}
}
if ( $DEBUG =~ /TRUE/i ) { print "cp $file $file.1\n";}
# --- Rotate actual file ---
`cp $file $file.1`;
`cp /dev/null $file`;
if ($OSVERSION =~ /V5/) { mkcdsl("$file.1"); }
# --- Compress if desired ---
if ( $COMPRESS =~ /TRUE/i )
{
if ( -s "$file.1" )
{ `$COMPRESS_CMD -f $file.1`; } else
{ `mv $file.1 $file.1$EXT`; } # Zero-Files would not
compressed
}
`chown $st_uid.$st_gid $file.1$EXT`;
}
# ------------------------ MAIN-LOOP: Read in files to rotate ------------------
if ( defined( $FILES[0] ))
{
foreach $file (@FILES)
{
if ( -e $file )
{
if ( -l $file )
{
chomp($tmp_dir = `dirname $file`);
chdir($tmp_dir); # --- due to relativ
referenced links
if ( $DEBUG =~ /TRUE/i ) { print "Changing
Directory to $tmp_dir \n";}
chomp($line = `ls -l $file`);
($file = $line) =~ (s/.*->\s+(.*)$/$1/);
}
} else
{
print "File : $file does not exist\n";
exit;
}
if (( $file =~ /binary.errlog$/ ) || ($file =~ /messages$/))
{
$startup_count = `/usr/sbin/uerf -R | /sbin/grep STARTUP |
/usr/bin/wc -l` ;
if ( $startup_count == 0 )
{
print_detail_info;
exit;
}
}
rotate("$file", $VERSIONS);
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: logrotate?
2001-09-11 8:47 logrotate? Axel K�ster
2001-09-12 6:33 ` logrotate? Jonas Furrer
@ 2001-09-12 23:16 ` Mike Robinson
1 sibling, 0 replies; 3+ messages in thread
From: Mike Robinson @ 2001-09-12 23:16 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]
Assuming you're logging to /var/adm/syslog.dated, which was the default in
my installation of Tru64, an entry such as: 0 0 * * * /sbin/kill -1
'/sbin/cat /var/run/syslog.pid' in root's crontab would restart syslog
nightly at midnight.
"Axel K�ster" <a.kuester@ostalb.netsurf.de> wrote in message
news:0rjrptka1jvsapv2nk1b2170ihec87s58c@4ax.com...
> Hello to all,
>
> does anyone know of a logrotate tool running on True64 (4.0..),
preferrable a
> binary?
>
> Thanks in advance
>
> Axel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-09-12 23:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-09-11 8:47 logrotate? Axel K�ster
2001-09-12 6:33 ` logrotate? Jonas Furrer
2001-09-12 23:16 ` logrotate? Mike Robinson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox