head 1.2; access; symbols; locks; strict; comment @# @; 1.2 date 97.11.25.20.42.47; author alexis; state Exp; branches; next 1.1; 1.1 date 97.08.27.18.13.40; author alexis; state Exp; branches; next ; desc @@ 1.2 log @*** empty log message *** @ text @#!/usr/bin/ksh PROGNAME=`basename $0` # $Id$ VERSION="PATCHLEVEL_MARKER" # This command should be called by cron shortly *after* midnight. # # General config. There should be no need to change any of this. Use options instead. # COMPRESS="compress -f" YESTFILE=/usr/local/admin/etc/$PROGNAME.yest # By default just show errors and warnings - don't change this, use '-v' or '-d' if you want something else VERBOSELEVEL=2 SARDIR=/usr/adm/sa SARARCDIR=/usr/adm/sa PRI_ALERT="local1.alert" # # Some mickey mouse functions for displaying messages # message() { [ ! -t 2 ] && logger -t $PROGNAME -i "$@@" || echo "$@@" } # # Don't even bother removing lock files if we get an internal error; the more information left intact # the better. # internal() { echo "$PROGNAME: INTERNAL ERROR: $@@" > /dev/tty exit 3 } error() { [ $VERBOSELEVEL -ge 1 ] && { [ ! -t 2 ] && logger -p $PRI_ALERT -t $PROGNAME -i "ERROR: $@@" || echo "$PROGNAME: ERROR: $@@" >&2; } exit 2 } warning() { [ $VERBOSELEVEL -lt 2 ] && return [ ! -t 2 ] && logger -p $PRI_ALERT -t $PROGNAME -i "WARNING: $@@" || echo "$PROGNAME: WARNING: $@@" >&2 } info() { [ $VERBOSELEVEL -lt 3 ] && return [ ! -t 2 ] && logger -t $PROGNAME -i "INFO: $@@" || echo "$PROGNAME: INFO: $@@" >&2 } debug() { L_LEVEL=$1 shift [ $VERBOSELEVEL -lt $L_LEVEL ] && return { [ ! -t 2 ] && logger -t $PROGNAME -i "DEBUG: $@@"; } || { echo "$PROGNAME: DEBUG: $@@" >&2; } } # # Tell the user how to use this program # usage() { # Printer version number and exit message "Usage: $PROGNAME -V" message " $PROGNAME" exit 1 } # This is where it all happens. First read the file we wrote yesterday. [ ! -r $YESTFILE ] && error "no record of when $PROGNAME last ran, please sort this out" cat $YESTFILE | read YESTDATESTAMP YESTDATENUM expr "$YESTDATESTAMP" : '^[0-9]\{6\}$' > /dev/null || error "badly formatted datestamp in config file '$YESTFILE'" expr "$YESTDATENUM" : '^[0-9]\{2\}$' > /dev/null || error "badly formatted date number in config file '$YESTFILE'" # Now prepare the information we will write to that file today and check it hasn't been run today TODAYDATESTAMP=`date +%y%m%d` TODAYDATENUM=`date +%d` [ $YESTDATESTAMP = $TODAYDATESTAMP ] && error "already run today" # Now rename and compress the yesterday's sar output file. if [ -f $SARDIR/sa$YESTDATENUM ]; then # mv'ing assumes same filesystem for SARDIR and SARARCDIR HOSTNAME=`hostname` mv $SARDIR/sa$YESTDATENUM $SARARCDIR/sa-$HOSTNAME-$YESTDATESTAMP $COMPRESS $SARARCDIR/sa-$HOSTNAME-$YESTDATESTAMP else warning "yesterday's sar file '$SARDIR/sa$YESTDATENUM' not found" fi # And finally write information about today that we can use tomorrow echo $TODAYDATESTAMP $TODAYDATENUM > $YESTFILE @ 1.1 log @Initial revision @ text @d1 1 a1 14 From alexis@@danae.demon.co.uk Fri Aug 8 08:16:33 1997 Received: from danae.myth.net by web3.hq.eso.org with ESMTP (8.8.5/ eso-5.3) id IAA11131; Fri, 8 Aug 1997 08:16:31 +0200 (MET DST) Received: (from alexis@@localhost) by danae.myth.net (8.8.5/8.8.5) id HAA02478 for ahuxley@@eso.org; Fri, 8 Aug 1997 07:17:13 +0100 From: Alexis Huxley Message-Id: <199708080617.HAA02478@@danae.myth.net> Subject: no subject (file transmission) To: ahuxley@@eso.org Date: Fri, 8 Aug 1997 07:17:12 +0100 (BST) Content-Type: text Status: O #!/bin/ksh d3 2 a4 1 VERSION="Thu May 11 10:27:27 BST 1995" a102 1 @