#!/bin/sh

version="1.0"
toolDir="/usr/local/sbin"

echo "Content-type: text/html"
echo
echo "<HEAD><title>Accounting summary from $1/*acct.$2</title></head><body>"
echo "<h1>Accounting summary for $3</h1>"

if [ $# != 0 ]
then
	echo "<h2>Program Summary</h2>"
	echo "<pre>"
	echo "   Calls Real [min]  CPU [min]   Program"
	echo "----------------------------------------"
	$toolDir/sa -a /dev/null \
		--other-savacct-file "$1/savacct.$2" \
		--other-usracct-file "$1/usracct.$2" | \
		sed -e "s/\.\(..\)cp/.\1/g" -e "s/\.\(..\)re/.\1/g"
	echo "</pre>"

	echo "<h2>User Summary</h2>"
	echo "<pre>"
	echo "User    Processes Real [min]  CPU [min]"
	echo "---------------------------------------"
	$toolDir/sa -am /dev/null \
		--other-savacct-file "$1/savacct.$2" \
		--other-usracct-file "$1/usracct.$2" | \
		sed -e "s/\.\(..\)cp/.\1/g" -e "s/\.\(..\)re/.\1/g"
	echo "</pre>"
fi

echo "<hr><address>Created by acctsum $version</address>"

