]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/media.cgi
2dfc3a02ce80d722f6568a7f1b0d1115b8607bb5
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);
42 &Graphs
::updatediskgraph
("week",$device);
43 &Graphs
::updatediskgraph
("month",$device);
47 &Header
::openbox
('100%', 'center', $Lang::tr
{'disk usage'});
48 print "<table width='95%' cellspacing='5'>\n";
49 open(DF
,'/bin/df -B M -x rootfs|');
52 if ($_ =~ m/^Filesystem/ )
56 <td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td>
57 <td align='center' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
58 <td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
59 <td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
60 <td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
61 <td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
68 my ($device,$size,$used,$free,$percent,$mount) = split;
71 <td align='center'>$device</td>
72 <td align='center'>$mount</td>
73 <td align='center'>$size</td>
74 <td align='center'>$used</td>
75 <td align='center'>$free</td>
79 &percentbar
($percent);
82 <td align='left'>$percent</td>
89 print "<tr><td colspan='7'> \n<tr><td colspan='7'><h3>Inodes</h3>\n";
91 open(DF
,'/bin/df -i -x rootfs|');
94 if ($_ =~ m/^Filesystem/ )
98 <td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td>
99 <td align='center' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
100 <td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
101 <td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
102 <td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
103 <td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
110 my ($device,$size,$used,$free,$percent,$mount) = split;
113 <td align='center'>$device</td>
114 <td align='center'>$mount</td>
115 <td align='center'>$size</td>
116 <td align='center'>$used</td>
117 <td align='center'>$free</td>
121 &percentbar
($percent);
124 <td align='left'>$percent</td>
131 my @iostat1 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$1}');
132 my @iostat2 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$5}');
133 my @iostat3 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$6}');
134 print "<tr><td colspan='3'> \n<tr><td colspan='3'><h3>transfers</h3></td></tr>";
137 for(my $i = 1; $i <= $#iostat1; $i++)
139 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>";}
140 else {print "<tr><td align='center'>@iostat1[$i]</td><td align='center'>@iostat2[$i]</td><td align='center'>@iostat3[$i]</td></tr>";}
145 &Header
::closebigbox
();
147 &Header
::closepage
();
155 if ($percent =~ m/^(\d+)%$/ )
158 <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
162 if ($percent eq "100%") {
163 print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
164 } elsif ($percent eq "0%") {
165 print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
167 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'>"
170 <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>
178 if (-e
"$Header::graphdir/disk-$disk-day.png") {
179 &Header
::openbox
('100%', 'center', "Disk /dev/$disk $Lang::tr{'graph'}");
180 my $ftime = localtime((stat("$Header::graphdir/disk-$disk-day.png"))[9]);
181 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
182 print "<a href='/cgi-bin/graphs.cgi?graph=disk-$disk'>";
183 print "<img alt='' src='/graphs/disk-$disk-day.png' border='0' />";
186 if (-e
"/usr/local/bin/hddshutdown-state") {
187 system("/usr/local/bin/hddshutdown-state $disk");
189 my $smart = `/usr/local/bin/smartctrl $disk`;
190 $smart = &Header
::cleanhtml
($smart);
192 <br /><input type="button" onClick="swapVisibility('smart_$disk')" value="$Lang::tr{'smart information'}" />
193 <div id='smart_$disk' style='display: none'>
194 <hr /><table border=0><tr><td align=left><pre>$smart</pre></table>