#!/bin/ash
export GET
cat <<EOT
Content-type: text/html
<html><head><title>System-Info</title><style>body{font:11px Arial;}
legend{font-weight:bold;color:#15428b}fieldset{border:1px solid #bbb}</style></head><body>
$(/opt/sbin/diskstatsd)
<fieldset><legend title="/opt/sbin/diskstats hd[abcd];/opt/sbin/smartctl -d marvell -A /dev/hd[abcd]">Average Temperatures</legend>
<div style="font:11px monospace;position:absolute;top:30px;left:34px;z-index:5">
<span style="color:#333333">?</span>
hda Temperatur $(</var/log/hdastats tail -1|awk '{print $5}')°C
<span style="color:#333333">?</span>
hdb Temperatur $(</var/log/hdbstats tail -1|awk '{print $5}')°C
<span style="color:#333333">?</span>
hdc Temperatur $(</var/log/hdcstats tail -1|awk '{print $5}')°C
<span style="color:#333333">?</span>
hdd Temperatur $(</var/log/hddstats tail -1|awk '{print $5}')°C
</div>
<div style="padding-top:150px;line-height:10px">
<pre>
Aver. Mini Maxi Lifetime Hibernate Power on/off Reallocated
hda $(/opt/sbin/diskstats hda|awk '{printf("%s",$1)}';/opt/sbin/smartctl -d marvell -A /dev/hda | awk '/^194/{t1=$10}/^190/{t6=substr($13,1,2),t7=substr($13,4,2)}
/^ 9/{t2=$10}/^ 4/{t3=$10}/^ 12/{t4=$10}/^ 5/{t5=$10}
END{printf(" %2d.0°C %2d.0°C %7d h %5d cycles %6d cycles %4d sectors\n",t6,t7,t2,t3-t4,t4,t5)}')
hdb $(/opt/sbin/diskstats hdb|awk '{printf("%s",$1)}';/opt/sbin/smartctl -d marvell -A /dev/hdb | awk '/^194/{t1=$10}/^190/{t6=substr($13,1,2),t7=substr($13,4,2)}
/^ 9/{t2=$10}/^ 4/{t3=$10}/^ 12/{t4=$10}/^ 5/{t5=$10}
END{printf(" %2d.0°C %2d.0°C %7d h %5d cycles %6d cycles %4d sectors\n",t6,t7,t2,t3-t4,t4,t5)}')
hdc $(/opt/sbin/diskstats hdc|awk '{printf("%s",$1)}';/opt/sbin/smartctl -d marvell -A /dev/hdc | awk '/^194/{t1=$10}/^190/{t6=substr($13,1,2),t7=substr($13,4,2)}
/^ 9/{t2=$10}/^ 4/{t3=$10}/^ 12/{t4=$10}/^ 5/{t5=$10}
END{printf(" %2d.0°C %2d.0°C %7d h %5d cycles %6d cycles %4d sectors\n",t6,t7,t2,t3-t4,t4,t5)}')
hdd $(/opt/sbin/diskstats hdd|awk '{printf("%s",$1)}';/opt/sbin/smartctl -d marvell -A /dev/hdd | awk '/^194/{t1=$10}/^190/{t6=substr($13,1,2),t7=substr($13,4,2)}
/^ 9/{t2=$10}/^ 4/{t3=$10}/^ 12/{t4=$10}/^ 5/{t5=$10}
END{printf(" %2d.0°C %2d.0°C %7d h %5d cycles %6d cycles %4d sectors\n",t6,t7,t2,t3-t4,t4,t5)}')
EOT
year=$(date "+%Y")
month=$(date "+%m")
day=$(date "+%d"); day1=$(expr $day - 1); day1=$(printf %02d $day1);
hour=$(date "+%H"); hour1=$(expr $hour + 1);
T1="";T2="";T3="";T4="";L="";
G=`date -d"$month${day1}0000$year" "+%m %d "`;for t in $(seq $hour1 23);do
t=$(printf %02d $t);GET=$G$t;if [ "$L" == "" ] ;then L=$t; else L=$L'|'$t; fi
T=$(/opt/sbin/diskstats hda); if [ "$T" == "" ] ;then S=0; else S=`echo $T|sed 's/\(..\).\(.\).*/\1\2/'`; fi
if [ "$T1" == "" ] ;then T1=$S; else T1=$T1,$S; fi
echo -e "$t: \c";
if [ "$T" != "" ] ;then echo -e "$T\c"; else echo -e "n/a\c"; fi; echo
T=$(/opt/sbin/diskstats hdb); if [ "$T" == "" ] ;then S=0; else S=`echo $T|sed 's/\(..\).\(.\).*/\1\2/'`; fi
if [ "$T2" == "" ] ;then T2=$S; else T2=$T2,$S; fi
echo -e "$t: \c";
if [ "$T" != "" ] ;then echo -e "$T\c"; else echo -e "n/a\c"; fi; echo
T=$(/opt/sbin/diskstats hdc); if [ "$T" == "" ] ;then S=0; else S=`echo $T|sed 's/\(..\).\(.\).*/\1\2/'`; fi
if [ "$T3" == "" ] ;then T3=$S; else T3=$T3,$S; fi
echo -e "$t: \c";
if [ "$T" != "" ] ;then echo -e "$T\c"; else echo -e "n/a\c"; fi; echo
T=$(/opt/sbin/diskstats hdd); if [ "$T" == "" ] ;then S=0; else S=`echo $T|sed 's/\(..\).\(.\).*/\1\2/'`; fi
if [ "$T4" == "" ] ;then T4=$S; else T4=$T4,$S; fi
if [ "$T" != "" ] ;then echo -e "$T\c"; else echo -e "n/a\c"; fi; echo
done
G=`date "+%m %d "`;for t in $(seq 00 $hour);do
t=$(printf %02d $t);GET=$G$t;if [ "$L" == "" ] ;then L=$t; else L=$L'|'$t; fi
T=$(/opt/sbin/diskstats hda); if [ "$T" == "" ] ;then S=0; else S=`echo $T|sed 's/\(..\).\(.\).*/\1\2/'`; fi
if [ "$T1" == "" ] ;then T1=$S; else T1=$T1,$S; fi
echo -e "$t: \c";if [ "$T" != "" ] ;then echo -e "$T\c"; else echo -e "n/a\c"; fi; echo
T=$(/opt/sbin/diskstats hdb); if [ "$T" == "" ] ;then S=0; else S=`echo $T|sed 's/\(..\).\(.\).*/\1\2/'`; fi
if [ "$T2" == "" ] ;then T2=$S; else T2=$T2,$S; fi
echo -e "$t: \c";if [ "$T" != "" ] ;then echo -e "$T\c"; else echo -e "n/a\c"; fi; echo
T=$(/opt/sbin/diskstats hdc); if [ "$T" == "" ] ;then S=0; else S=`echo $T|sed 's/\(..\).\(.\).*/\1\2/'`; fi
if [ "$T3" == "" ] ;then T3=$S; else T3=$T3,$S; fi
echo -e "$t: \c";if [ "$T" != "" ] ;then echo -e "$T\c"; else echo -e "n/a\c"; fi; echo
T=$(/opt/sbin/diskstats hdd); if [ "$T" == "" ] ;then S=0; else S=`echo $T|sed 's/\(..\).\(.\).*/\1\2/'`; fi
if [ "$T4" == "" ] ;then T4=$S; else T4=$T4,$S; fi
if [ "$T" != "" ] ;then echo -e " $T\c"; else echo -e " n/a\c"; fi; echo
done
cat <<EOT
</pre>
</div>
<img style="position:absolute;top:20px;margin-left:-2px"
src="http://chart.apis.google.com/chart?cht=bvg&chds=200,500&&chbh=11,0,0
&chf=c,lg,90,dd0000,1,ffff77,0|bg,s,efefef00&chg=8.33,33.33&chco=333333,666666&chs=680x150
&chxt=x,r&chxl=0:|$L|1:|20|30|40|50
&chd=t:$T1|$T2"></fieldset><br/>
EOT
for d in $(ls /dev/hd[abcd]); do
cat <<EOT
<fieldset><legend title="/opt/sbin/smartctl -d marvell -iAH $d">$d</legend>
<pre>$(/opt/sbin/smartctl -d marvell -iAH $d|sed '1,3d')</pre></fieldset><br/>
EOT
done
cat <<EOT
</body></html>
EOT