#!/bin/sh
##################################################################
#		I N V 2 H T M L
#		---------------
# Description:
# 	Produce a inventory report in html format. The report
#	contain information about The number of different OS-versions,
#	machine models and combination thereof.
#
# Created By:
#	Lars Olsson and Lars Berntzon.
#
##################################################################

ant_tot=0
datum=`date "+%y%m%d %H:%M"`
antal=`machines -exist true | wc -l | awk '{ print $1 }'`
machines -exist true -show osvers -show model > /tmp/whole.$$
os_versioner=`machines -u -exist true -show osvers`
models=`machines -exist true -show model -u `

echo "<HTML>"
echo "<HEAD>"
echo "<TITLE>UNIX machines</TITLE>"
echo "</HEAD>"
echo "<BODY BGCOLOR="#FFFFFF">"
echo "<h1>UNIX machines</h1>"
echo "<BR>"
echo "<FONT SIZE=-1>This page was updated $datum</FONT>"
echo "<P>"
echo "<HR SIZE="1" WIDTH="500" ALIGN="LEFT" NOSHADE="NOSHADE"></P>"
echo "Number of different OS-versions:"
echo "<TABLE BORDER=2>"
echo "<TR>"
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT SIZE=+1>Count</FONT></TD>"
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT SIZE=+2>OS Version</FONT></TD>"
echo "</TR>"
for ver in $os_versioner ; do
	ant=`grep "osvers=$ver " /tmp/whole.$$ | wc -l | awk '{ print $1 }'`
	if [ "$ant" != 0 ] ; then
	echo "<TR>"
		echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH="150"><B>$ant</B></TD>"
		echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH="150">$ver</TD>"
		ant_tot=`expr $ant_tot + $ant`
	echo "</TR>"
	fi
done
echo "</TABLE>"
echo "<P>"
echo "<HR SIZE="1" WIDTH="500" ALIGN="LEFT" NOSHADE="NOSHADE"></P>"
echo "Number of different models:"
echo "<TABLE BORDER=2>"
echo "<TR>"
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT SIZE=+2>Count</FONT></TD>"
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT SIZE=+2>Model</FONT></TD>"
echo "</TR>"
ant_tot=0

for mod in $models ; do
	model=`echo $mod | sed 's/*/ /g'`
	ant=`grep "model=$model" /tmp/whole.$$ | wc -l | awk '{ print $1 }'`
	if [ "$ant" != 0 ] ; then
	echo "<TR>"
		echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH="150"><B>$ant</B></TD>"
		echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH="150">$model</TD>"
		ant_tot=`expr $ant_tot + $ant`
	echo "</TR>"
	fi
done
echo "</TABLE>"
echo "<P>"
echo "<HR SIZE="1" WIDTH="500" ALIGN="LEFT" NOSHADE="NOSHADE"></P>"
echo "Number of combinations OS-version/model:"
echo "<TABLE BORDER=2>"
echo "<TR>"
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT SIZE=+2>Count</FONT></TD>"
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT SIZE=+2>OS Version</FONT></TD>"
echo "<TD ALIGN=LEFT VALIGN=TOP><FONT SIZE=+2>Model</FONT></TD>"
echo "</TR>"
ant_tot=0
for ver in $os_versioner ; do
	for mod in $models ; do
		model=`echo $mod | sed 's/*/ /g'`
		ant=`grep "osvers=$ver " /tmp/whole.$$ | grep "model=$model" | wc -l | \
			awk '{ print $1 }'`
		if [ "$ant" != 0 ] ; then
		echo "<TR>"
			echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH="150"><B>$ant</B></TD>"
			echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH="150">$ver</TD>"
			echo "<TD ALIGN=LEFT VALIGN=TOP WIDTH="150">$model</TD>"
			ant_tot=`expr $ant_tot + $ant`
		echo "</TR>"
		fi
	done
done
echo "</TABLE>"

echo "<P>"
echo "<HR SIZE="1" WIDTH="500" ALIGN="LEFT" NOSHADE="NOSHADE"></P>"

echo "</BODY>"
echo "</HTML>"
rm /tmp/whole.$$

exit 0

#
# History of changes:
# inv2html,v
# Revision 1.3  1997/01/09 20:21:24  lasse
# Backup
#
# Revision 1.2  1997/01/09 20:20:41  lasse
# My changes.
#
# Revision 1.1  1997/01/09 20:20:21  lasse
# Created by Lars Olsson
#
#
