]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/services.cgi
Merge branch 'master' into core61
[people/teissler/ipfire-2.x.git] / html / cgi-bin / services.cgi
index c24b4601c8fcd85256f9d30191bbae8a9008fcce..123c3258792ddab8da3350c2c9600dca3132d483 100644 (file)
@@ -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";
@@ -59,6 +59,24 @@ my %servicenames =(
        'OpenVPN' => 'openvpn'
 );
 
+my %link =(
+       $Lang::tr{'dhcp server'} => "<a href=\'dhcp.cgi\'>$Lang::tr{'dhcp server'}</a>",
+       $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'} => "<a href=\'time.cgi\'>$Lang::tr{'ntp server'}</a>",
+       $Lang::tr{'secure shell server'} => "<a href=\'remote.cgi\'>$Lang::tr{'secure shell server'}</a>",
+       $Lang::tr{'vpn'} => "<a href=\'vpnmain.cgi\'>$Lang::tr{'vpn'}</a>",
+       $Lang::tr{'web proxy'} => "<a href=\'proxy.cgi\'>$Lang::tr{'web proxy'}</a>",
+       'OpenVPN' => "<a href=\'ovpnmain.cgi\'>OpenVPN</a>",
+       "$Lang::tr{'intrusion detection system'} (GREEN)" => "<a href=\'ids.cgi\'>$Lang::tr{'intrusion detection system'} (GREEN)</a>",
+       "$Lang::tr{'intrusion detection system'} (RED)" => "<a href=\'ids.cgi\'>$Lang::tr{'intrusion detection system'} (RED)</a>",
+       "$Lang::tr{'intrusion detection system'} (ORANGE)" => "<a href=\'ids.cgi\'>$Lang::tr{'intrusion detection system'} (ORANGE)</a>",
+       "$Lang::tr{'intrusion detection system'} (BLUE)" => "<a href=\'ids.cgi\'>$Lang::tr{'intrusion detection system'} (BLUE)</a>"
+);
+
 my $lines=0; # Used to count the outputlines to make different bgcolor
 
 my $iface = '';
@@ -106,9 +124,13 @@ END
        foreach $key (sort keys %servicenames){
                $lines++;
                if ($lines % 2){
-                       print "<tr bgcolor='$color{'color22'}'>\n<td align='left'>$key</td>\n";
+                       print "<tr bgcolor='$color{'color22'}'>\n<td align='left'>";
+                       print %link->{$key};
+                       print "</td>\n";
                }else{
-                       print "<tr bgcolor='$color{'color20'}'>\n<td align='left'>$key</td>\n";
+                       print "<tr bgcolor='$color{'color20'}'>\n<td align='left'>";
+                       print %link->{$key};
+                       print "</td>\n";
                }
 
                my $shortname = $servicenames{$key};
@@ -155,9 +177,10 @@ 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 ( ($_ ne "alsa") && ($_ ne "mdadm") ) {
                                $lines++;
                                if ($lines % 2){
                                        print "<tr bgcolor='$color{'color22'}'>";
@@ -217,7 +240,7 @@ sub isrunning{
        my $pid = '';
        my $testcmd = '';
        my $exename;
-       my @memory;
+       my $memory;
 
        $cmd =~ /(^[a-z]+)/;
        $exename = $1;
@@ -233,13 +256,18 @@ sub isrunning{
                        }
                        close FILE;
                }
-               if (open(FILE, "/proc/${pid}/statm")){
-                               my $temp = <FILE>;
-                               @memory = split(/ /,$temp);
+               if (open(FILE, "/proc/${pid}/status")) {
+                       while (<FILE>) {
+                               my ($key, $val) = split(":", $_, 2);
+                               if ($key eq 'VmRSS') {
+                                       $memory = $val;
+                                       last;
+                               }
+                       }
+                       close(FILE);
                }
-               close FILE;
                if ($testcmd =~ /$exename/){
-                       $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td><td align='center'>$pid</td><td align='center'>$memory[0] KB</td>";
+                       $status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td><td align='center'>$pid</td><td align='center'>$memory</td>";
                }
        }
        return $status;
@@ -253,10 +281,11 @@ sub isrunningaddon{
        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 = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
+               $testcmd =~ s/.* //gi;
                $testcmd =~ s/[a-z_]//gi;
                $testcmd =~ s/\[[0-1]\;[0-9]+//gi;
                $testcmd =~ s/[\(\)\.]//gi;