]>
git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/media.cgi
1eacb34286496410bdd0602c45be3a827daeaf51
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31 require "${General::swroot}/graphs.pl";
33 #workaround to suppress a warning when a variable is used only once
34 my @dummy = ( ${Header
::colourred
} );
39 &Header
::showhttpheaders
();
41 &Header
::getcgihash
(\
%cgiparams);
43 &Header
::openpage
($Lang::tr
{'media information'}, 1, '');
45 &Header
::openbigbox
('100%', 'left');
47 my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
52 my @array = split(/\//,$device);
53 &Graphs
::updatediskgraph
("day",$array[$#array]);
54 diskbox
($array[$#array]);
57 &Header
::openbox
('100%', 'center', $Lang::tr
{'disk usage'});
58 print "<table width='95%' cellspacing='5'>\n";
59 open(DF
,'/bin/df -B M -x rootfs|');
62 if ($_ =~ m/^Filesystem/ )
66 <td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td>
67 <td align='center' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
68 <td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
69 <td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
70 <td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
71 <td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
78 my ($device,$size,$used,$free,$percent,$mount) = split;
81 <td align='center'>$device</td>
82 <td align='center'>$mount</td>
83 <td align='center'>$size</td>
84 <td align='center'>$used</td>
85 <td align='center'>$free</td>
89 &percentbar
($percent);
92 <td align='left'>$percent</td>
99 print "<tr><td colspan='7'> \n<tr><td colspan='7'><h3>Inodes</h3>\n";
101 open(DF
,'/bin/df -i -x rootfs|');
104 if ($_ =~ m/^Filesystem/ )
108 <td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td>
109 <td align='center' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
110 <td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
111 <td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
112 <td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
113 <td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
120 my ($device,$size,$used,$free,$percent,$mount) = split;
123 <td align='center'>$device</td>
124 <td align='center'>$mount</td>
125 <td align='center'>$size</td>
126 <td align='center'>$used</td>
127 <td align='center'>$free</td>
131 &percentbar
($percent);
134 <td align='left'>$percent</td>
141 my @iostat1 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$1}');
142 my @iostat2 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$5}');
143 my @iostat3 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$6}');
144 print "<tr><td colspan='3'> \n<tr><td colspan='3'><h3>transfers</h3></td></tr>";
147 for(my $i = 1; $i <= $#iostat1; $i++)
149 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>";}
150 else {print "<tr><td align='center'>$iostat1[$i]</td><td align='center'>$iostat2[$i]</td><td align='center'>$iostat3[$i]</td></tr>";}
155 &Header
::closebigbox
();
157 &Header
::closepage
();
165 if ($percent =~ m/^(\d+)%$/ )
168 <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
172 if ($percent eq "100%") {
173 print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
174 } elsif ($percent eq "0%") {
175 print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
177 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'>"
180 <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>
190 if (-e
"$Header::graphdir/disk-$disk-day.png") {
191 &Header
::openbox
('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
192 my $ftime = localtime((stat("$Header::graphdir/disk-$disk-day.png"))[9]);
193 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
194 print "<a href='/cgi-bin/graphs.cgi?graph=disk-$disk'>";
195 print "<img alt='' src='/graphs/disk-$disk-day.png' border='0' />";
199 if (-e
"/tmp/hddstatus") {
200 open(DATEI
, "</tmp/hddstatus") || die "Datei nicht gefunden";
201 my @diskstate = <DATEI
>;
204 foreach (@diskstate){
205 if ( $_ =~/$disk/ ){@status = split(/-/,$_);}
208 if ( $status[1]=~/standby/){
209 my $ftime = localtime((stat("/tmp/hddshutdown-$disk"))[9]);
210 print"<B>Disk $disk status:<font color=#FF0000>".$status[1]."</font></B> (since $ftime)";
213 print"<B>Disk $disk status:<font color=#00FF00>".$status[1]."</font></B>";
216 my $smart = `/usr/local/bin/smartctrl $disk`;
217 $smart = &Header
::cleanhtml
($smart);
219 <br /><input type="button" onClick="swapVisibility('smart_$disk')" value="$Lang::tr{'smart information'}" />
220 <div id='smart_$disk' style='display: none'>
221 <hr /><table border=0><tr><td align=left><pre>$smart</pre></table>