#!/bin/sh
# $Id$

# This script looks for discrepancies in all of the stats files for the
# current machine type, by running the checkstats program for each
# stats file against the master tree (/os, or /install/oscheck/mach/...).

libdir=/install/oscheck
globalexceptions=$libdir/exceptions.all
mach=$libdir/mach
srvdstats=/srvd/usr/athena/lib/stats/sys_rvd
configfiles=/srvd/usr/athena/lib/update/configfiles
exceptions=/tmp/exceptions$$

case `machtype` in
sgi)
  platforms="46xl 46xz 50cr 50xl 50xz"
  ;;
sun4)
  platforms="sun4m sun4u"
  ;;
esac

# Generate the exception list.  Start with the known global exceptions,
# if any.
rm -f $exceptions
if [ -r $globalexceptions ]; then
  cp $globalexceptions $exceptions
else
  cp /dev/null $exceptions
fi

# We don't want to bother with anything tracked from the srvd, so
# extract all srvd paths from the srvd stats file, to add them to
# the exception list.
awk '{ print substr($1, 2, length($1) - 1); }' $srvdstats >> $exceptions
sed -e 's,^/,,' $configfiles >> $exceptions
rm -f $exceptions.sorted
sort -u $exceptions > $exceptions.sorted

# First check the "common" stats file.
echo "Checking $libdir/stats.common against /os..."
./checkstats -x $exceptions.sorted $libdir/stats.common

# Now check the machine-dependent files
for platform in $platforms ; do
  echo "Checking $libdir/stats.$platform against /os..."
  ./checkstats -x $exceptions.sorted $libdir/stats.$platform
  echo "Checking $libdir/stats.$platform.dup against $mach/$platform..."
  ./checkstats -o $mach/$platform -x $exceptions.sorted \
      $libdir/stats.$platform.dup
done
