]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/media.cgi
52d9337eb857caf8482e39bc52df64593e6977ba
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2013 IPFire Team <info@ipfire.org> #
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";
34 my %mainsettings = ();
35 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
36 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
38 #workaround to suppress a warning when a variable is used only once
39 my @dummy = ( ${Header
::colourred
} );
44 my @querry = split(/\?/,$ENV{'QUERY_STRING'});
45 $querry[0] = '' unless defined $querry[0];
46 $querry[1] = 'hour' unless defined $querry[1];
48 my @devices = `ls -1 /sys/block | grep -E '^sd|^mmcblk|^xvd|^vd|^md' | sort | uniq`;
50 if ( $querry[0] =~ "sd?" || $querry[0] =~ "mmcblk?" || $querry[0] =~ "xvd??" || $querry[0] =~ "vd?" || $querry[0] =~ "md*" ){
51 print "Content-type: image/png\n\n";
54 &Graphs
::updatediskgraph
($querry[0],$querry[1]);
56 &Header
::showhttpheaders
();
57 &Header
::openpage
($Lang::tr
{'media information'}, 1, '');
58 &Header
::openbigbox
('100%', 'left');
63 my @array = split(/\//,$device);
64 &Header
::openbox
('100%', 'center', "$array[$#array] $Lang::tr{'graph'}");
65 diskbox
($array[$#array]);
66 &Graphs
::makegraphbox
("media.cgi",$array[$#array],"day");
71 &Header
::openbox
('100%', 'center', $Lang::tr
{'disk usage'});
72 print "<table width='95%' cellspacing='5'>\n";
73 open(DF
,'/bin/df -P -B M -x rootfs|');
75 if ($_ =~ m/^Filesystem/ ){
78 <td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td>
79 <td align='center' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
80 <td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
81 <td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
82 <td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
83 <td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
88 my ($device,$size,$used,$free,$percent,$mount) = split;
91 <td align='center'>$device</td>
92 <td align='center'>$mount</td>
93 <td align='center'>$size</td>
94 <td align='center'>$used</td>
95 <td align='center'>$free</td>
99 &percentbar
($percent);
102 <td align='left'>$percent</td>
109 print "<tr><td colspan='7'> \n<tr><td colspan='7'><h3>Inodes</h3>\n";
111 open(DF
,'/bin/df -P -i -x rootfs|');
113 if ($_ =~ m/^Filesystem/ ){
116 <td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td>
117 <td align='center' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
118 <td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
119 <td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
120 <td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
121 <td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
126 my ($device,$size,$used,$free,$percent,$mount) = split;
129 <td align='center'>$device</td>
130 <td align='center'>$mount</td>
131 <td align='center'>$size</td>
132 <td align='center'>$used</td>
133 <td align='center'>$free</td>
137 &percentbar
($percent);
140 <td align='left'>$percent</td>
147 my @iostat1 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$1}');
148 my @iostat2 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$5}');
149 my @iostat3 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$6}');
150 print "<tr><td colspan='3'> \n<tr><td colspan='3'><h3>transfers</h3></td></tr>";
153 for(my $i = 1; $i <= $#iostat1; $i++){
155 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>";
157 print "<tr><td align='center'>$iostat1[$i]</td><td align='center'>$iostat2[$i]</td><td align='center'>$iostat3[$i]</td></tr>";
163 &Header
::closebigbox
();
164 &Header
::closepage
();
173 if ($percent =~ m/^(\d+)%$/ )
176 <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
180 if ($percent eq "100%") {
181 print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
182 } elsif ($percent eq "0%") {
183 print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
185 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'>"
188 <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>
198 if (-e
"/var/run/hddstatus"){
199 open(DATEI
, "</var/run/hddstatus") || die "Datei nicht gefunden";
200 my @diskstate = <DATEI
>;
203 foreach (@diskstate){
204 if ( $_ =~/$disk/ ){@status = split(/-/,$_);}
207 if ( $status[1]=~/standby/){
208 my $ftime = localtime((stat("/var/run/hddshutdown-$disk"))[9]);
209 print"<B>Disk $disk status:<font color=#FF0000>".$status[1]."</font></B> (since $ftime)";
211 print"<B>Disk $disk status:<font color=#00FF00>".$status[1]."</font></B>";
215 my $smart = `/usr/local/bin/smartctrl $disk`;
216 $smart = &Header
::cleanhtml
($smart);
218 <br /><input type="button" onClick="swapVisibility('smart_$disk')" value="$Lang::tr{'smart information'}" />
219 <div id='smart_$disk' style='display: none'>
220 <hr /><table border=0><tr><td align=left><pre>$smart</pre></table>