#!/usr/bin/bash

#remove any old data
rm -f /var/apache2/htdocs/test.html 2>/dev/null
rm -f ./collect

#get projects
set `ssh root@192.168.73.141 shares list`
counter=0
while test $# -gt 0
do
 let counter=$counter+1
 shares[$counter]=$1
 shift
done

#count projects
count=`echo ${#shares[@]}` > /dev/null

#get data
item=1
while test $item -le $count
do
 echo "project ${shares[$item]}"
 ssh root@192.168.73.141 "shares select ${shares[$item]}  show" |egrep "canonical|space_total|space_available|space_snapshots">>collect
 let item=$item+1
 echo "" >>collect
done

#create html
echo "creating html"

#!/usr/bin/bash
htmldir=/var/apache2/htdocs/
echo "<table border=1>" >> $htmldir/test.html
text=gray
echo "<tr><td bgcolor=$text>property</td><td bgcolor=$text></td><td bgcolor=$text>value</td></tr>" >> $htmldir/test.html

while read line
do
pr0=`echo $line | awk {'print $1'}`
pr1=`echo $line | awk {'print $2'}`
pr2=`echo $line | awk {'print $3'}`

echo "<tr><td>$pr0</td><td>$pr1</td><td>$pr2</td></tr>" >> $htmldir/test.html
done <<< "`cat collect`"
echo "</table>" >> $htmldir/test.html

echo "done"
echo "go to http://localhost/test.html"

