X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Fstatus.cgi;h=4aa226334d0b1b9305061ee895c3325a624d25ef;hb=32e2d042f155146017ef012b9bad566f89802305;hp=ac560f84eb4cb3ae436ecb9b74f74d3cb59ff2f2;hpb=ca35618d116ce539bd9ebe850c7aa2d137f7c786;p=people%2Fpmueller%2Fipfire-2.x.git diff --git a/html/cgi-bin/status.cgi b/html/cgi-bin/status.cgi index ac560f84eb..4aa226334d 100644 --- a/html/cgi-bin/status.cgi +++ b/html/cgi-bin/status.cgi @@ -6,16 +6,15 @@ # # (c) The SmoothWall Team # -# $Id: status.cgi,v 1.6.2.7 2005/02/24 07:44:35 gespinasse Exp $ # use strict; # enable only the following on debugging purpose -#use warnings; -#use CGI::Carp 'fatalsToBrowser'; +use warnings; +use CGI::Carp 'fatalsToBrowser'; -require 'CONFIG_ROOT/general-functions.pl'; +require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; @@ -31,35 +30,45 @@ my %cgiparams=(); # is also the name of the program my %servicenames = ( - $Lang::tr{'dhcp server'} => 'dhcpd', - $Lang::tr{'web server'} => 'httpd', - $Lang::tr{'cron server'} => 'fcron', - $Lang::tr{'dns proxy server'} => 'dnsmasq', - $Lang::tr{'logging server'} => 'syslogd', - $Lang::tr{'kernel logging server'} => 'klogd', - $Lang::tr{'ntp server'} => 'ntpd', - $Lang::tr{'secure shell server'} => 'sshd', - $Lang::tr{'vpn'} => 'pluto', - $Lang::tr{'web proxy'} => 'squid', - $Lang::tr{'openvpn'} => 'openvpn' + $Lang::tr{'dhcp server'} => 'dhcpd', + $Lang::tr{'web server'} => 'httpd', + $Lang::tr{'cron server'} => 'fcron', + $Lang::tr{'dns proxy server'} => 'dnsmasq', + $Lang::tr{'logging server'} => 'syslogd', + $Lang::tr{'kernel logging server'} => 'klogd', + $Lang::tr{'ntp server'} => 'ntpd', + $Lang::tr{'secure shell server'} => 'sshd', + $Lang::tr{'vpn'} => 'pluto', + $Lang::tr{'web proxy'} => 'squid', + 'OpenVPN' => 'openvpn' ); my $iface = ''; if (open(FILE, "${General::swroot}/red/iface")) { - $iface = ; - close FILE; - chomp $iface; + $iface = ; + close FILE; + chomp $iface; } $servicenames{"$Lang::tr{'intrusion detection system'} (RED)"} = "snort_${iface}"; $servicenames{"$Lang::tr{'intrusion detection system'} (GREEN)"} = "snort_$netsettings{'GREEN_DEV'}"; if ($netsettings{'ORANGE_DEV'} ne '') { - $servicenames{"$Lang::tr{'intrusion detection system'} (ORANGE)"} = "snort_$netsettings{'ORANGE_DEV'}"; + $servicenames{"$Lang::tr{'intrusion detection system'} (ORANGE)"} = "snort_$netsettings{'ORANGE_DEV'}"; } if ($netsettings{'BLUE_DEV'} ne '') { - $servicenames{"$Lang::tr{'intrusion detection system'} (BLUE)"} = "snort_$netsettings{'BLUE_DEV'}"; + $servicenames{"$Lang::tr{'intrusion detection system'} (BLUE)"} = "snort_$netsettings{'BLUE_DEV'}"; } +my %dhcpsettings=(); +my %netsettings=(); +my %dhcpinfo=(); +my %pppsettings=(); +my $output=''; + +&General::readhash("${General::swroot}/dhcp/settings", \%dhcpsettings); +&General::readhash("${General::swroot}/ethernet/settings", \%netsettings); +&General::readhash("${General::swroot}/ppp/settings", \%pppsettings); + &Header::showhttpheaders(); &Header::getcgihash(\%cgiparams); @@ -68,20 +77,6 @@ if ($netsettings{'BLUE_DEV'} ne '') { &Header::openbigbox('100%', 'left'); -print < - - $Lang::tr{'services'} | - $Lang::tr{'memory'} | - $Lang::tr{'disk usage'} | - $Lang::tr{'uptime and users'} | - $Lang::tr{'loaded modules'} | - $Lang::tr{'kernel version'} - -END -; - -print "\n"; &Header::openbox('100%', 'left', $Lang::tr{'services'}); print <\n"; } - else { - print "\n"; } - print "$key\n"; - my $shortname = $servicenames{$key}; - my $status = &isrunning($shortname); - print "$status\n"; - print "\n"; - $lines++; + if ($lines % 2) { + print "\n"; } + else { + print "\n"; } + print "$key\n"; + my $shortname = $servicenames{$key}; + my $status = &isrunning($shortname); + print "$status\n"; + print "\n"; + $lines++; } @@ -111,8 +106,7 @@ print "\n"; &Header::closebox(); -print "\n"; -&Header::openbox('100%', 'left', $Lang::tr{'memory'}); +&Header::openbox('100%', 'center', $Lang::tr{'memory'}); print " + + + + +
"; my $ram=0; my $size=0; @@ -125,8 +119,8 @@ my $cached=0; open(FREE,'/usr/bin/free |'); while() { - if ($_ =~ m/^\s+total\s+used\s+free\s+shared\s+buffers\s+cached$/ ) - { + if ($_ =~ m/^\s+total\s+used\s+free\s+shared\s+buffers\s+cached$/ ) + { print < @@ -194,15 +188,14 @@ END ; &Header::closebox(); -print "\n"; -&Header::openbox('100%', 'left', $Lang::tr{'disk usage'}); -print "
 
\n"; +&Header::openbox('100%', 'center', $Lang::tr{'disk usage'}); +print "
\n"; open(DF,'/bin/df -B M -x rootfs|'); while() { - if ($_ =~ m/^Filesystem/ ) - { - print < @@ -213,11 +206,11 @@ while() END ; - } - else - { - my ($device,$size,$used,$free,$percent,$mount) = split; - print < @@ -227,38 +220,214 @@ END END ; - } + } +} +close DF; +print " + + + + + + +END +; + } + else + { + my ($device,$size,$used,$free,$percent,$mount) = split; + print < + + + + + + + +END +; + } } close DF; print "
$Lang::tr{'device'} $Lang::tr{'mounted on'}
$device $mount END ; - &percentbar($percent); - print < $percent
 \n

Inodes

\n"; + +open(DF,'/bin/df -i -x rootfs|'); +while() +{ + if ($_ =~ m/^Filesystem/ ) + { + print < +
$Lang::tr{'device'}$Lang::tr{'mounted on'}$Lang::tr{'size'}$Lang::tr{'used'}$Lang::tr{'free'}$Lang::tr{'percentage'}
$device$mount$size$used$free +END +; + &percentbar($percent); + print < +$percent
\n"; &Header::closebox(); -print "\n"; -&Header::openbox('100%', 'left', $Lang::tr{'uptime and users'}); -my $output = `/usr/bin/w`; +&Header::openbox('100%', 'left', $Lang::tr{'interfaces'}); +$output = `/sbin/ip link show`; +$output = &Header::cleanhtml($output,"y"); + +my @itfs = ('ORANGE','BLUE','GREEN'); +foreach my $itf (@itfs) { + my $ColorName=''; + my $lc_itf=lc($itf); + my $dev = $netsettings{"${itf}_DEV"}; + if ($dev){ + $ColorName = "${lc_itf}"; #dereference variable name... + $output =~ s/$dev/$dev<\/font><\/b>/ ; + } +} + +if (open(REDIFACE, "${General::swroot}/red/iface")) { + my $lc_itf='red'; + my $reddev = ; + close(REDIFACE); + chomp $reddev; + $output =~ s/$reddev/${reddev}<\/font><\/b>/; +} +print "
$output
\n"; +&Header::closebox(); + + +if ( $netsettings{'CONFIG_TYPE'} =~ /^(2|3|6|7)$/ && $netsettings{'RED_TYPE'} eq "DHCP") { + + &Header::openbox('100%', 'left', "RED $Lang::tr{'dhcp configuration'}"); + if (-s "${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info") { + + &General::readhash("${General::swroot}/dhcpc/dhcpcd-$netsettings{'RED_DEV'}.info", \%dhcpinfo); + + my $DNS1=`echo $dhcpinfo{'DNS'} | cut -f 1 -d ,`; + my $DNS2=`echo $dhcpinfo{'DNS'} | cut -f 2 -d ,`; + + my $lsetme=0; + my $leasetime=""; + if ($dhcpinfo{'LEASETIME'} ne "") { + $lsetme=$dhcpinfo{'LEASETIME'}; + $lsetme=($lsetme/60); + if ($lsetme > 59) { + $lsetme=($lsetme/60); $leasetime=$lsetme." Hour"; + } else { + $leasetime=$lsetme." Minute"; + } + if ($lsetme > 1) { + $leasetime=$leasetime."s"; + } + } + my $rentme=0; + my $rnwltime=""; + if ($dhcpinfo{'RENEWALTIME'} ne "") { + $rentme=$dhcpinfo{'RENEWALTIME'}; + $rentme=($rentme/60); + if ($rentme > 59){ + $rentme=($rentme/60); $rnwltime=$rentme." Hour"; + } else { + $rnwltime=$rentme." Minute"; + } + if ($rentme > 1){ + $rnwltime=$rnwltime."s"; + } + } + my $maxtme=0; + my $maxtime=""; + if ($dhcpinfo{'REBINDTIME'} ne "") { + $maxtme=$dhcpinfo{'REBINDTIME'}; + $maxtme=($maxtme/60); + if ($maxtme > 59){ + $maxtme=($maxtme/60); $maxtime=$maxtme." Hour"; + } else { + $maxtime=$maxtme." Minute"; + } + if ($maxtme > 1) { + $maxtime=$maxtime."s"; + } + } + + print ""; + if ($dhcpinfo{'HOSTNAME'}) { + print "\n"; + } else { + print "\n"; + } + print < + + + + + + +
$Lang::tr{'hostname'}$dhcpinfo{'HOSTNAME'}.$dhcpinfo{'DOMAIN'}
$Lang::tr{'domain'}$dhcpinfo{'DOMAIN'}
$Lang::tr{'gateway'}$dhcpinfo{'GATEWAY'}
$Lang::tr{'primary dns'}$DNS1
$Lang::tr{'secondary dns'}$DNS2
$Lang::tr{'dhcp server'}$dhcpinfo{'DHCPSIADDR'}
$Lang::tr{'def lease time'}$leasetime
$Lang::tr{'default renewal time'}$rnwltime
$Lang::tr{'max renewal time'}$maxtime
+END + ; + } + else + { + print "$Lang::tr{'no dhcp lease'}"; + } + &Header::closebox(); +} + +if ($dhcpsettings{'ENABLE_GREEN'} eq 'on' || $dhcpsettings{'ENABLE_BLUE'} eq 'on') { + &Header::CheckSortOrder; + &Header::PrintActualLeases; +} + +&Header::openbox('100%', 'left', $Lang::tr{'routing table entries'}); +$output = `/sbin/ip route show`; $output = &Header::cleanhtml($output,"y"); print "
$output
\n"; &Header::closebox(); -print "
\n"; -&Header::openbox('100%', 'left', $Lang::tr{'loaded modules'}); -$output = qx+/sbin/lsmod+; -($output = &Header::cleanhtml($output,"y")) =~ s/\[.*\]//g; -print "
\n$output\n
\n"; +&Header::openbox('100%', 'left', $Lang::tr{'arp table entries'}); +$output = `/sbin/ip neigh show`; +$output = &Header::cleanhtml($output,"y"); +print "
$output
\n"; &Header::closebox(); -print "
\n"; -&Header::openbox('100%', 'left', $Lang::tr{'kernel version'}); -print "
\n";
-print `/bin/uname -a`;
-print "
\n"; +&Header::openbox('100%', 'left', $Lang::tr{'loaded modules'}); +my $module = qx(/bin/lsmod | awk -F" " '{print \$1}'); +my $size = qx(/bin/lsmod | awk -F" " '{print \$2}'); +my $used = qx(/bin/lsmod | awk -F" " '{print \$3}'); +my @usedby = qx(/bin/lsmod | awk -F" " '{print \$4}'); +my @usedbyf; +my $usedbyline; + +foreach $usedbyline(@usedby) +{ +my $laenge = length($usedbyline); + +if ( $laenge > 30) + { + my $usedbylinef=substr($usedbyline,0,30); + $usedbyline="$usedbylinef ...\n"; + push(@usedbyf,$usedbyline); + } +else + {push(@usedbyf,$usedbyline);} +} +print <
$module
$size
$used
@usedbyf
+END +; + +print ""; &Header::closebox(); &Header::closebigbox(); @@ -267,35 +436,35 @@ print "\n"; sub isrunning { - my $cmd = $_[0]; - my $status = "$Lang::tr{'stopped'}"; - my $pid = ''; - my $testcmd = ''; - my $exename; + my $cmd = $_[0]; + my $status = "$Lang::tr{'stopped'}"; + my $pid = ''; + my $testcmd = ''; + my $exename; - $cmd =~ /(^[a-z]+)/; - $exename = $1; + $cmd =~ /(^[a-z]+)/; + $exename = $1; - if (open(FILE, "/var/run/${cmd}.pid")) - { - $pid = ; chomp $pid; - close FILE; - if (open(FILE, "/proc/${pid}/status")) - { - while () - { - if (/^Name:\W+(.*)/) { - $testcmd = $1; } - } - close FILE; - if ($testcmd =~ /$exename/) - { - $status = "$Lang::tr{'running'}"; - } - } - } + if (open(FILE, "/var/run/${cmd}.pid")) + { + $pid = ; chomp $pid; + close FILE; + if (open(FILE, "/proc/${pid}/status")) + { + while () + { + if (/^Name:\W+(.*)/) { + $testcmd = $1; } + } + close FILE; + if ($testcmd =~ /$exename/) + { + $status = "$Lang::tr{'running'}"; + } + } + } - return $status; + return $status; } sub percentbar