]>
git.ipfire.org Git - people/stevee/ipfire-2.x.git/blob - html/cgi-bin/system.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
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";
33 #workaround to suppress a warning when a variable is used only once
34 my @dummy = ( ${Header
::colourred
} );
38 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
41 my %mainsettings = ();
42 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
43 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
46 # Maps a nice printable name to the changing part of the pid file, which
47 # is also the name of the program
50 $Lang::tr
{'dhcp server'} => 'dhcpd',
51 $Lang::tr
{'web server'} => 'httpd',
52 $Lang::tr
{'cron server'} => 'fcron',
53 $Lang::tr
{'dns proxy server'} => 'dnsmasq',
54 $Lang::tr
{'logging server'} => 'syslogd',
55 $Lang::tr
{'kernel logging server'} => 'klogd',
56 $Lang::tr
{'ntp server'} => 'ntpd',
57 $Lang::tr
{'secure shell server'} => 'sshd',
58 $Lang::tr
{'vpn'} => 'pluto',
59 $Lang::tr
{'web proxy'} => 'squid',
60 'OpenVPN' => 'openvpn'
64 if (open(FILE
, "${General::swroot}/red/iface"))
70 $servicenames{"$Lang::tr{'intrusion detection system'} (RED)"} = "snort_${iface}";
71 $servicenames{"$Lang::tr{'intrusion detection system'} (GREEN)"} = "snort_$netsettings{'GREEN_DEV'}";
72 if ($netsettings{'ORANGE_DEV'} ne '') {
73 $servicenames{"$Lang::tr{'intrusion detection system'} (ORANGE)"} = "snort_$netsettings{'ORANGE_DEV'}";
75 if ($netsettings{'BLUE_DEV'} ne '') {
76 $servicenames{"$Lang::tr{'intrusion detection system'} (BLUE)"} = "snort_$netsettings{'BLUE_DEV'}";
79 # Generate Graphs from rrd Data
80 &Graphs
::updatecpugraph
("day");
81 &Graphs
::updateloadgraph
("day");
83 &Header
::showhttpheaders
();
84 &Header
::getcgihash
(\
%cgiparams);
85 &Header
::openpage
($Lang::tr
{'status information'}, 1, '');
86 &Header
::openbigbox
('100%', 'left');
88 &Header
::openbox
('100%', 'center', "CPU $Lang::tr{'graph'}");
89 if (-e
"$Header::graphdir/cpu-day.png") {
90 my $ftime = localtime((stat("$Header::graphdir/cpu-day.png"))[9]);
91 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
92 print "<a href='/cgi-bin/graphs.cgi?graph=cpu'>";
93 print "<img alt='' src='/graphs/cpu-day.png' border='0' />";
96 print $Lang::tr
{'no information available'};
101 &Header
::openbox
('100%', 'center', "Load $Lang::tr{'graph'}");
102 if (-e
"$Header::graphdir/load-day.png") {
103 my $ftime = localtime((stat("$Header::graphdir/load-day.png"))[9]);
104 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
105 print "<a href='/cgi-bin/graphs.cgi?graph=load'>";
106 print "<img alt='' src='/graphs/load-day.png' border='0' />";
109 print $Lang::tr
{'no information available'};
114 &Header
::openbox
('100%', 'left', $Lang::tr
{'services'});
118 <table width='60%' cellspacing='0' border='0'>
123 foreach $key (sort keys %servicenames)
125 print "<tr>\n<td align='left'>$key</td>\n";
126 my $shortname = $servicenames{$key};
127 my $status = &isrunning
($shortname);
133 print "</table></div>\n";
136 &Header
::closebigbox
();
137 &Header
::closepage
();
142 my $status = "<td bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
150 if (open(FILE
, "/var/run/${cmd}.pid"))
152 $pid = <FILE
>; chomp $pid;
154 if (open(FILE
, "/proc/${pid}/status"))
158 if (/^Name:\W+(.*)/) {
162 if ($testcmd =~ /$exename/)
164 $status = "<td bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
178 if ($percent =~ m/^(\d+)%$/ )
181 <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
185 if ($percent eq "100%") {
186 print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
187 } elsif ($percent eq "0%") {
188 print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
190 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'>"
193 <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>