X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Fservices.cgi;h=64fdbba05a4ee6afcaceae2caa1dbee12f485782;hb=87ea30ff5669c0174af3a481f31aba9f868101c6;hp=c24b4601c8fcd85256f9d30191bbae8a9008fcce;hpb=4e481c3a517c27fae6b8e7056fb8a5fdd05c9188;p=people%2Fpmueller%2Fipfire-2.x.git diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index c24b4601c8..64fdbba05a 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2008 Michael Tremer & Christian Schmidt # +# Copyright (C) 2005-2010 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 # @@ -22,8 +22,8 @@ use strict; # enable only the following on debugging purpose -use warnings; -use CGI::Carp 'fatalsToBrowser'; +#use warnings; +#use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; @@ -49,16 +49,34 @@ 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{'dns proxy server'} => 'unbound', $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{'vpn'} => 'charon', $Lang::tr{'web proxy'} => 'squid', 'OpenVPN' => 'openvpn' ); +my %link =( + $Lang::tr{'dhcp server'} => "$Lang::tr{'dhcp server'}", + $Lang::tr{'web server'} => $Lang::tr{'web server'}, + $Lang::tr{'cron server'} => $Lang::tr{'cron server'}, + $Lang::tr{'dns proxy server'} => $Lang::tr{'dns proxy server'}, + $Lang::tr{'logging server'} => $Lang::tr{'logging server'}, + $Lang::tr{'kernel logging server'} => $Lang::tr{'kernel logging server'}, + $Lang::tr{'ntp server'} => "$Lang::tr{'ntp server'}", + $Lang::tr{'secure shell server'} => "$Lang::tr{'secure shell server'}", + $Lang::tr{'vpn'} => "$Lang::tr{'vpn'}", + $Lang::tr{'web proxy'} => "$Lang::tr{'web proxy'}", + 'OpenVPN' => "OpenVPN", + "$Lang::tr{'intrusion detection system'} (GREEN)" => "$Lang::tr{'intrusion detection system'} (GREEN)", + "$Lang::tr{'intrusion detection system'} (RED)" => "$Lang::tr{'intrusion detection system'} (RED)", + "$Lang::tr{'intrusion detection system'} (ORANGE)" => "$Lang::tr{'intrusion detection system'} (ORANGE)", + "$Lang::tr{'intrusion detection system'} (BLUE)" => "$Lang::tr{'intrusion detection system'} (BLUE)" +); + my $lines=0; # Used to count the outputlines to make different bgcolor my $iface = ''; @@ -98,21 +116,33 @@ if ( $querry[0] =~ "processescpu"){ &Header::openbox('100%', 'left', $Lang::tr{'services'}); print < - - +
$Lang::tr{'services'}$Lang::tr{'status'}PID$Lang::tr{'memory'}
+ + + + + + END ; my $key = ''; + my $col=""; foreach $key (sort keys %servicenames){ $lines++; if ($lines % 2){ - print "\n\n"; + $col="bgcolor='$color{'color22'}'"; + print ""; }else{ - print "\n\n"; + $col="bgcolor='$color{'color20'}'"; + print ""; } my $shortname = $servicenames{$key}; - my $status = &isrunning($shortname); + my $status = &isrunning($shortname,$col); print "$status\n"; print "\n"; @@ -130,14 +160,14 @@ END print < -
$Lang::tr{'services'}$Lang::tr{'status'}PID$Lang::tr{'memory'}
$key
"; + print $link{$key}; + print "
$key
"; + print $link{$key}; + print "
- - - - - - - +
AddonBoot$Lang::tr{'action'}$Lang::tr{'status'}PID$Lang::tr{'memory'}
+ + + + + + + END ; @@ -155,21 +185,27 @@ END # blacklist some packages # # alsa has trouble with the volume saving and was not really stopped + # mdadm should not stopped with webif because this could crash the system # chomp($_); - if ($_ ne "alsa"){ + if ( $_ eq 'squid' ) { + next; + } + if ( ($_ ne "alsa") && ($_ ne "mdadm") ) { $lines++; if ($lines % 2){ - print ""; + print ""; + $col="bgcolor='$color{'color22'}'"; }else{ - print ""; + print ""; + $col="bgcolor='$color{'color20'}'"; } - print " "; - my $status = isautorun($_); + print " "; + my $status = isautorun($_,$col); print "$status "; - print ""; - print " "; - my $status = &isrunningaddon($_); + print ""; + print " "; + my $status = &isrunningaddon($_,$col); $status =~ s/\\[[0-1]\;[0-9]+m//g; chomp($status); @@ -196,16 +232,17 @@ END sub isautorun{ my $cmd = $_[0]; - my $status = ""; + my $col = $_[1]; + my $status = ""; my $init = `find /etc/rc.d/rc3.d/S??${cmd} 2>/dev/null`; chomp ($init); if ($init ne ''){ - $status = ""; + $status = ""; } $init = `find /etc/rc.d/rc3.d/off/S??${cmd} 2>/dev/null`; chomp ($init); if ($init ne ''){ - $status = ""; + $status = ""; } return $status; @@ -213,11 +250,12 @@ sub isautorun{ sub isrunning{ my $cmd = $_[0]; - my $status = ""; + my $col = $_[1]; + my $status = ""; my $pid = ''; my $testcmd = ''; my $exename; - my @memory; + my $memory; $cmd =~ /(^[a-z]+)/; $exename = $1; @@ -233,13 +271,18 @@ sub isrunning{ } close FILE; } - if (open(FILE, "/proc/${pid}/statm")){ - my $temp = ; - @memory = split(/ /,$temp); + if (open(FILE, "/proc/${pid}/status")) { + while () { + my ($key, $val) = split(":", $_, 2); + if ($key eq 'VmRSS') { + $memory = $val; + last; + } + } + close(FILE); } - close FILE; if ($testcmd =~ /$exename/){ - $status = ""; + $status = ""; } } return $status; @@ -247,16 +290,18 @@ sub isrunning{ sub isrunningaddon{ my $cmd = $_[0]; - my $status = ""; + my $col = $_[1]; + my $status = ""; my $pid = ''; my $testcmd = ''; my $exename; my @memory; - my $testcmd = `/usr/local/bin/addonctrl $_ status`; + my $testcmd = `/usr/local/bin/addonctrl $_ status 2>/dev/null`; if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){ $status = ""; + $testcmd =~ s/.* //gi; $testcmd =~ s/[a-z_]//gi; $testcmd =~ s/\[[0-1]\;[0-9]+//gi; $testcmd =~ s/[\(\)\.]//gi; @@ -264,7 +309,7 @@ sub isrunningaddon{ $testcmd =~ s///gi; my @pid = split(/\s/,$testcmd); - $status .=""; + $status .=""; my $memory = 0; @@ -276,9 +321,9 @@ sub isrunningaddon{ } $memory+=$memory[0]; } - $status .=""; + $status .=""; }else{ - $status = ""; + $status = ""; } return $status; }
AddonBoot$Lang::tr{'action'}$Lang::tr{'status'}PID$Lang::tr{'memory'}
$_$_$Lang::tr{$Lang::tr{$Lang::tr{$Lang::tr{$Lang::tr{$Lang::tr{$Lang::tr{$Lang::tr{$Lang::tr{'stopped'}$Lang::tr{'stopped'}$Lang::tr{'running'}$pid$memory[0] KB$Lang::tr{'running'}$pid$memory$Lang::tr{'stopped'}$Lang::tr{'stopped'}$Lang::tr{'running'}$pid[0]$pid[0]$memory KB$memory KB$Lang::tr{'stopped'}$Lang::tr{'stopped'}