#! /bin/csh
# $Header: genweekly,v 4.300 91/06/09 01:00:31 root Rel41 $
# Script to produce statistics for NYSERNet nodes
#
#
# Copyright 1990, Performance Systems International Inc.
# Copyright 1988,1989 NYSERNet Inc.
# Copyright 1990, Sony Corp.
# All Rights Reserved
#
# Written 4/21/88 by Wengyik Yeong
#
source ../../config/report-env
if (-e $ROOT/config/weekly-env) then
  source $ROOT/config/weekly-env
else
  echo "$0 : weekly-env missing. Can't continue. Exit."
  exit(1)
endif

if ($#argv >= 1) then
	set ext=$argv[1]
	set Date=(`prsdate $argv[1]`)
else
	echo "Usage: $0 mmddyy"
	exit(1)
endif
set workplace = /tmp/snmp.$ext

# deciding page format
# 
# no page formating. If you want page formating, change it to "set pageformat".
set pageformat

# you are welcome to change this variable, tableperpage.
# BUT BE CAREFUL!!!!! Csh is very weak at numeric expression syntax parsing.
# It is always safe to fill in spaces.
@ tableperpage = 2

@ table = 0
@ Page = 1
if ($?pageformat) then
  echo "Page $Page"
else
  echo " "
endif
#echo "  "
#echo "(The statistics reported here are weekly averages for each hour of"
#echo "		a 24 hour day, displayed in units/hour)"
echo " "

cd $workplace
set nonomatch
set temp = (*)
@ count = $#temp
unset temp
foreach link (*)
    if ( $link != '*' ) then
	@ table ++
	echo " "
	echo "link " $link
	echo " "
	echo "time	    incoming		    outgoing		 failures"
	echo "	(KB) (pkts) (errs)	(KB) (pkts) (errs)	maint slftst"
	awk -f $SEDAWK/stats.awk ${link}
	@ count --
	if ($count <= 0) then
	  break
	endif
	if ($?pageformat && $table >= $tableperpage) then
		@ Page ++
		@ table = 0
		echo "  $Date   SNMP Weekly Statistic Report                   Page $Page"
		echo ""
	else
  		echo '---------------------------------------------------------------------------'
	endif
    endif
end
unset nonomatch
