]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/media.cgi
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/ipfire/include/colors.txt", \
%color);
38 #workaround to suppress a warning when a variable is used only once
39 my @dummy = ( ${Header
::colourred
} );
44 my @devices = `ls -1 /sys/block | grep -E '^sd|^mmcblk|^nvme|^xvd|^vd|^md' | sort | uniq`;
46 &Header
::showhttpheaders
();
47 &Header
::openpage
($Lang::tr
{'media information'}, 1, '');
48 &Header
::openbigbox
('100%', 'left');
53 my @array = split(/\//,$device);
54 &Header
::openbox
('100%', 'center', "$array[$#array] $Lang::tr{'graph'}");
55 diskbox
($array[$#array]);
56 &Graphs
::makegraphbox
("media.cgi",$array[$#array],"day");
61 &Header
::openbox
('100%', 'center', $Lang::tr
{'disk usage'});
62 print "<table width='95%' cellspacing='5'>\n";
63 open(DF
,'/bin/df -P -B M -x rootfs|');
65 if ($_ =~ m/^Filesystem/ ){
68 <td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td>
69 <td align='center' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
70 <td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
71 <td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
72 <td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
73 <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 -P -i -x rootfs|');
103 if ($_ =~ m/^Filesystem/ ){
106 <td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td>
107 <td align='center' class='boldbase'><b>$Lang::tr{'mounted on'}</b></td>
108 <td align='center' class='boldbase'><b>$Lang::tr{'size'}</b></td>
109 <td align='center' class='boldbase'><b>$Lang::tr{'used'}</b></td>
110 <td align='center' class='boldbase'><b>$Lang::tr{'free'}</b></td>
111 <td align='left' class='boldbase' colspan='2'><b>$Lang::tr{'percentage'}</b></td>
116 my ($device,$size,$used,$free,$percent,$mount) = split;
119 <td align='center'>$device</td>
120 <td align='center'>$mount</td>
121 <td align='center'>$size</td>
122 <td align='center'>$used</td>
123 <td align='center'>$free</td>
127 &percentbar
($percent);
130 <td align='left'>$percent</td>
137 my @iostat1 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$1}');
138 my @iostat2 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$6}');
139 my @iostat3 = qx(/usr/bin
/iostat
-dm
-p
| grep -v
"Linux" | awk
'{print \$7}');
140 print "<tr><td colspan='3'> \n<tr><td colspan='3'><h3>transfers</h3></td></tr>";
143 for(my $i = 1; $i <= $#iostat1; $i++){
145 print "<tr><td align='center' class='boldbase'><b>$Lang::tr{'device'}</b></td><td align='center' class='boldbase'><b>$Lang::tr{'MB read'}</b></td><td align='center' class='boldbase'><b>$Lang::tr{'MB written'}</b></td></tr>";
147 print "<tr><td align='center'>$iostat1[$i]</td><td align='center'>$iostat2[$i]</td><td align='center'>$iostat3[$i]</td></tr>";
153 &Header
::closebigbox
();
154 &Header
::closepage
();
162 if ($percent =~ m/^(\d+)%$/ )
165 <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
169 if ($percent eq "100%") {
170 print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
171 } elsif ($percent eq "0%") {
172 print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
174 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'>"
177 <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>
187 if (-e
"/var/run/hddstatus"){
188 open(DATEI
, "</var/run/hddstatus") || die "Datei nicht gefunden";
189 my @diskstate = <DATEI
>;
192 foreach (@diskstate){
193 if ( $_ =~/$disk/ ){@status = split(/-/,$_);}
196 if ( $status[1]=~/standby/){
197 my $ftime = localtime((stat("/var/run/hddshutdown-$disk"))[9]);
198 print"<b>Disk $disk status:<span style='color:#FF0000'>".$status[1]."</b> ($Lang::tr{'since'} $ftime)";
200 print"<b>Disk $disk status:<span style='color:#00FF00'>".$status[1]."</b>";
204 my $smart = `/usr/local/bin/smartctrl $disk`;
205 $smart = &Header
::cleanhtml
($smart);
207 <br /><input type="button" onClick="swapVisibility('smart_$disk')" value="$Lang::tr{'smart information'}" />
208 <div id='smart_$disk' style='display: none'>
209 <hr /><table border='0'><tr><td align='left'><pre>$smart</pre></table>