#! /bin/csh
# $Header: dailystats,v 4.300 91/06/09 00:59:28 root Rel41 $ 
#	Copyright 1990 Sony Corp.
#	Copyright 1990 Performance Systems International Inc.
#       copyright 1988 NYSERNet, Inc.
#	All Rights Reserved.

# called by dailystats.main
# uses dailystats.awk on per-interface snmppoll files
# to generate Daily.Stats report
# does some attempt to make two ifc reports to a page. -hmt
# recent alterations in dailystats.awk may have ruined this feature. -wpc

source ../../config/report-env
if (-e $ROOT/config/daily-env) then
  source $ROOT/config/daily-env
else
  echo "$0 : daily-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	DIR	= $DATA/$ext
chdir	$DIR

# to do page formating
# yes we wanting pageformating
set pageformat

# number of table in one page
# you are welcome to change it.
# BUT BE CAREFUL!!!!!!! Csh is very weak at numeric expressions syntax parsing
# It is always safe to insert spaces.
@ tableperpage = 1
@ table = 0
@ Page = 1

echo	"$Date           SNMP Daily Statistics              page  $Page"
echo ""

set nonomatch
set temp = (*-*)
@ count = $#temp
unset temp
foreach link (*-*)
	if ("$link" == '*-*') then
	  break
	endif
	@ table ++

	awk -f $SEDAWK/dailystats.awk $link

	@ count --
	if ($count <= 0) then
	  break
	endif
	if ($?pageformat && $table >= $tableperpage) then
	  @ Page ++
	  @ table = 0
	  echo	"$Date           SNMP  Daily Statistics               page  $Page"
	  echo ""
	else
	  echo ""
	  echo '---------------------------------------------------------------------------'
	endif
end
unset nonomatch
