[ UP ] cgi
[archserver.git] / cgi / raid / disk_status.sh
blobff94717621720b412c3fa528ac1974282fe11804
1 #!/bin/sh
4 function one_disk() {
5 size=`df $1 | grep '^/' | awk '{print $2" "$3" "$NF}'`
6 usage=`df $1 -h | grep '^/' | awk '{print $3" / "$2}'`
7 _t=$(echo $size|cut -d" " -f1)
8 _u=$(echo $size|cut -d" " -f2)
9 _d=$(echo $size|cut -d" " -f3)
11 totalsize=300
12 let redsize=$_u*$totalsize/$_t
13 let bluesize=300-$redsize
15 echo "<tr bgcolor=\"#c6d5a8\"><td width=250 align=center>$1</td><td>$_d</td><td>($usage)<br>
16 <img src=images/red.gif width=$redsize height=10><img src=images/blue.gif width=$bluesize height=10></td></tr>"
20 echo '<h3><font color=blue>Harddisk Status</color></h3>'
21 echo '<table cellspacing="2" cellpadding="8" border="0" width="90%">'
22 echo '<tr align="center"><td bgcolor="#ebebeb"><strong>Device</strong></td><td bgcolor="#ebebeb"><strong>Mounted_on</strong></td><td bgcolor="#ebebeb"><strong>Size</strong></td></tr>'
23 tmpfile="/tmp/.xxx_mtab.tmp"
24 rm $tmpfile
25 cat /etc/mtab|grep '^/'|cut -d" " -f 1 >> $tmpfile
26 while read dev
28 one_disk $dev
29 done < $tmpfile
30 rm $tmpfile
32 echo "</table>"