X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fmedia.cgi;h=4c94d1c8dd8b3d6b4cf8bf111da885c109329e24;hp=57cd8cd33fd6db51dfe156ab582c347ed033abef;hb=dd73ef846e9b75c52da993044c0bbba67dc8f7f6;hpb=cb5e9c6c64d5281eba5c790f14c2e5f3066becbf diff --git a/html/cgi-bin/media.cgi b/html/cgi-bin/media.cgi index 57cd8cd33..4c94d1c8d 100644 --- a/html/cgi-bin/media.cgi +++ b/html/cgi-bin/media.cgi @@ -1,12 +1,23 @@ #!/usr/bin/perl -# -# SmoothWall CGIs -# -# This code is distributed under the terms of the GPL -# -# (c) The SmoothWall Team -# -# +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2013 IPFire Team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### use strict; @@ -19,37 +30,50 @@ require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; require "${General::swroot}/graphs.pl"; +my %color = (); +my %mainsettings = (); +&General::readhash("${General::swroot}/main/settings", \%mainsettings); +&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); + #workaround to suppress a warning when a variable is used only once my @dummy = ( ${Header::colourred} ); undef (@dummy); my %cgiparams=(); -&Header::showhttpheaders(); - -&Header::getcgihash(\%cgiparams); - -&Header::openpage($Lang::tr{'media information'}, 1, ''); - -&Header::openbigbox('100%', 'left'); - -my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`; - -foreach (@devices) { - my $device = $_; - chomp($device); - &Graphs::updatediskgraph ("day",$device); - diskbox("$device"); -} - -&Header::openbox('100%', 'center', $Lang::tr{'disk usage'}); -print "\n"; -open(DF,'/bin/df -B M -x rootfs|'); -while() -{ - if ($_ =~ m/^Filesystem/ ) - { - print <\n"; + open(DF,'/bin/df -P -B M -x rootfs|'); + while(){ + if ($_ =~ m/^Filesystem/ ){ + print < @@ -60,11 +84,9 @@ while() END ; - } - else - { - my ($device,$size,$used,$free,$percent,$mount) = split; - print < @@ -74,24 +96,22 @@ END END ; - } -} -close DF; -print " @@ -102,11 +122,9 @@ while() END ; - } - else - { - my ($device,$size,$used,$free,$percent,$mount) = split; - print < @@ -116,33 +134,35 @@ END END ; - } -} -close DF; -my @iostat1 = qx(/usr/bin/iostat -dm -p | grep -v "Linux" | awk '{print \$1}'); -my @iostat2 = qx(/usr/bin/iostat -dm -p | grep -v "Linux" | awk '{print \$5}'); -my @iostat3 = qx(/usr/bin/iostat -dm -p | grep -v "Linux" | awk '{print \$6}'); -print ""; -my $i=0; - -for(my $i = 1; $i <= $#iostat1; $i++) -{ -if ( $i eq '1' ){print "";} -else {print "";} -} -print "
$Lang::tr{'device'} $Lang::tr{'mounted on'}
$device $mount END ; - &percentbar($percent); - print < $percent
 \n

Inodes

\n"; + } + } + close DF; + print "
 \n

Inodes

\n"; -open(DF,'/bin/df -i -x rootfs|'); -while() -{ - if ($_ =~ m/^Filesystem/ ) - { - print <){ + if ($_ =~ m/^Filesystem/ ){ + print <
$Lang::tr{'device'} $Lang::tr{'mounted on'}
$device $mount END ; - &percentbar($percent); - print < $percent
 \n

transfers

DeviceMB readMB writen
$iostat1[$i]$iostat2[$i]$iostat3[$i]
\n"; -&Header::closebox(); - -&Header::closebigbox(); + } + } + close DF; + my @iostat1 = qx(/usr/bin/iostat -dm -p | grep -v "Linux" | awk '{print \$1}'); + my @iostat2 = qx(/usr/bin/iostat -dm -p | grep -v "Linux" | awk '{print \$5}'); + my @iostat3 = qx(/usr/bin/iostat -dm -p | grep -v "Linux" | awk '{print \$6}'); + print " \n

transfers

"; + my $i=0; + + for(my $i = 1; $i <= $#iostat1; $i++){ + if ( $i eq '1' ){ + print "$Lang::tr{'device'}$Lang::tr{'MB read'}$Lang::tr{'MB written'}"; + }else{ + print "$iostat1[$i]$iostat2[$i]$iostat3[$i]"; + } + } + print "\n"; + &Header::closebox(); -&Header::closepage(); + &Header::closebigbox(); + &Header::closepage(); +} sub percentbar { @@ -172,27 +192,33 @@ END } sub diskbox { - my $disk = $_[0]; - if (-e "$Header::graphdir/disk-$disk-day.png") { - &Header::openbox('100%', 'center', "Disk /dev/$disk $Lang::tr{'graph'}"); - my $ftime = localtime((stat("$Header::graphdir/disk-$disk-day.png"))[9]); - print "
$Lang::tr{'the statistics were last updated at'}: $ftime

\n"; - print ""; - print ""; - print ""; - print "
\n"; - if (-e "/usr/local/bin/hddshutdown-state") { - system("/usr/local/bin/hddshutdown-state $disk"); - } - my $smart = `/usr/local/bin/smartctrl $disk`; - $smart = &Header::cleanhtml($smart); - print < - + my $disk = $_[0]; + chomp $disk; + my @status; + if (-e "/var/run/hddstatus"){ + open(DATEI, "; + close(DATEI); + + foreach (@diskstate){ + if ( $_ =~/$disk/ ){@status = split(/-/,$_);} + } + + if ( $status[1]=~/standby/){ + my $ftime = localtime((stat("/var/run/hddshutdown-$disk"))[9]); + print"Disk $disk status:".$status[1]." ($Lang::tr{'since'} $ftime)"; + }else{ + print"Disk $disk status:".$status[1].""; + } + } + + my $smart = `/usr/local/bin/smartctrl $disk`; + $smart = &Header::cleanhtml($smart); + print < + END ; - &Header::closebox(); - } }