]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/media.cgi
5 # This code is distributed under the terms of the GPL
7 # (c) The SmoothWall Team
13 # enable only the following on debugging purpose
15 use CGI
::Carp
'fatalsToBrowser';
17 require '/var/ipfire/general-functions.pl';
18 require "${General::swroot}/lang.pl";
19 require "${General::swroot}/header.pl";
20 require "${General::swroot}/graphs.pl";
22 #workaround to suppress a warning when a variable is used only once
23 my @dummy = ( ${Header
::colourred
} );
28 &Header
::showhttpheaders
();
30 &Header
::getcgihash
(\
%cgiparams);
32 &Header
::openpage
($Lang::tr
{'media information'}, 1, '');
34 &Header
::openbigbox
('100%', 'left');
36 my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
41 &Graphs
::updatediskgraph
("day",$device);
45 &Header
::openbox
('100%', 'center', $Lang::tr
{'disk usage'});
46 print "<table width='95%' cellspacing='5'>\n";
47 open(DF
,'/bin/df -B M -x rootfs|');
50 if ($_ =~ m/^Filesystem/ )
54 <td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td>
55 <td align='center' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
56 <td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
57 <td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
58 <td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
59 <td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
66 my ($device,$size,$used,$free,$percent,$mount) = split;
69 <td align='center'>$device</td>
70 <td align='center'>$mount</td>
71 <td align='center'>$size</td>
72 <td align='center'>$used</td>
73 <td align='center'>$free</td>
77 &percentbar
($percent);
80 <td align='left'>$percent</td>
87 print "<tr><td colspan='7'> \n<tr><td colspan='7'><h3>Inodes</h3>\n";
89 open(DF
,'/bin/df -i -x rootfs|');
92 if ($_ =~ m/^Filesystem/ )
96 <td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td>
97 <td align='center' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
98 <td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
99 <td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
100 <td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
101 <td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
108 my ($device,$size,$used,$free,$percent,$mount) = split;
111 <td align='center'>$device</td>
112 <td align='center'>$mount</td>
113 <td align='center'>$size</td>
114 <td align='center'>$used</td>
115 <td align='center'>$free</td>
119 &percentbar
($percent);
122 <td align='left'>$percent</td>
129 my @iostat1 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$1}');
130 my @iostat2 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$5}');
131 my @iostat3 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$6}');
132 print "<tr><td colspan='3'> \n<tr><td colspan='3'><h3>transfers</h3></td></tr>";
135 for(my $i = 1; $i <= $#iostat1; $i++)
137 if ( $i eq '1' ){print "<tr><td align='center' class='boldbase'><b>Device</b></td><td align='center' class='boldbase'><b>MB read</b></td><td align='center' class='boldbase'><b>MB writen</b></td></tr>";}
138 else {print "<tr><td align='center'>$iostat1[$i]</td><td align='center'>$iostat2[$i]</td><td align='center'>$iostat3[$i]</td></tr>";}
143 &Header
::closebigbox
();
145 &Header
::closepage
();
153 if ($percent =~ m/^(\d+)%$/ )
156 <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
160 if ($percent eq "100%") {
161 print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
162 } elsif ($percent eq "0%") {
163 print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
165 print "<td width='$percent' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'></td><td width='" . (100-$1) . "%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
168 <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>
176 if (-e
"$Header::graphdir/disk-$disk-day.png") {
177 &Header
::openbox
('100%', 'center', "Disk /dev/$disk $Lang::tr{'graph'}");
178 my $ftime = localtime((stat("$Header::graphdir/disk-$disk-day.png"))[9]);
179 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
180 print "<a href='/cgi-bin/graphs.cgi?graph=disk-$disk'>";
181 print "<img alt='' src='/graphs/disk-$disk-day.png' border='0' />";
184 if (-e
"/usr/local/bin/hddshutdown-state") {
185 system("/usr/local/bin/hddshutdown-state $disk");
187 my $smart = `/usr/local/bin/smartctrl $disk`;
188 $smart = &Header
::cleanhtml
($smart);
190 <br /><input type="button" onClick="swapVisibility('smart_$disk')" value="$Lang::tr{'smart information'}" />
191 <div id='smart_$disk' style='display: none'>
192 <hr /><table border=0><tr><td align=left><pre>$smart</pre></table>