]>
git.ipfire.org Git - people/ms/ipfire-2.x.git/blob - html/cgi-bin/system.cgi
5 # This code is distributed under the terms of the GPL
7 # (c) The SmoothWall Team
13 # enable only the following on debugging purpose
15 use CGI
::Carp
'fatalsToBrowser';
17 require '/var/ipfire/general-functions.pl';
18 require "${General::swroot}/lang.pl";
19 require "${General::swroot}/header.pl";
20 require "${General::swroot}/graphs.pl";
22 #workaround to suppress a warning when a variable is used only once
23 my @dummy = ( ${Header
::colourred
} );
27 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
30 my %mainsettings = ();
31 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
32 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
35 # Maps a nice printable name to the changing part of the pid file, which
36 # is also the name of the program
39 $Lang::tr
{'dhcp server'} => 'dhcpd',
40 $Lang::tr
{'web server'} => 'httpd',
41 $Lang::tr
{'cron server'} => 'fcron',
42 $Lang::tr
{'dns proxy server'} => 'dnsmasq',
43 $Lang::tr
{'logging server'} => 'syslogd',
44 $Lang::tr
{'kernel logging server'} => 'klogd',
45 $Lang::tr
{'ntp server'} => 'ntpd',
46 $Lang::tr
{'secure shell server'} => 'sshd',
47 $Lang::tr
{'vpn'} => 'pluto',
48 $Lang::tr
{'web proxy'} => 'squid',
49 'OpenVPN' => 'openvpn'
53 if (open(FILE
, "${General::swroot}/red/iface"))
59 $servicenames{"$Lang::tr{'intrusion detection system'} (RED)"} = "snort_${iface}";
60 $servicenames{"$Lang::tr{'intrusion detection system'} (GREEN)"} = "snort_$netsettings{'GREEN_DEV'}";
61 if ($netsettings{'ORANGE_DEV'} ne '') {
62 $servicenames{"$Lang::tr{'intrusion detection system'} (ORANGE)"} = "snort_$netsettings{'ORANGE_DEV'}";
64 if ($netsettings{'BLUE_DEV'} ne '') {
65 $servicenames{"$Lang::tr{'intrusion detection system'} (BLUE)"} = "snort_$netsettings{'BLUE_DEV'}";
68 # Generate Graphs from rrd Data
69 &Graphs
::updatecpugraph
("day");
70 &Graphs
::updatecpugraph
("week");
71 &Graphs
::updatecpugraph
("month");
72 &Graphs
::updatecpugraph
("year");
73 &Graphs
::updateloadgraph
("day");
74 &Graphs
::updateloadgraph
("week");
75 &Graphs
::updateloadgraph
("month");
76 &Graphs
::updateloadgraph
("year");
78 &Header
::showhttpheaders
();
79 &Header
::getcgihash
(\
%cgiparams);
80 &Header
::openpage
($Lang::tr
{'status information'}, 1, '');
81 &Header
::openbigbox
('100%', 'left');
83 &Header
::openbox
('100%', 'center', "CPU $Lang::tr{'graph'}");
84 if (-e
"$Header::graphdir/cpu-day.png") {
85 my $ftime = localtime((stat("$Header::graphdir/cpu-day.png"))[9]);
86 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
87 print "<a href='/cgi-bin/graphs.cgi?graph=cpu'>";
88 print "<img alt='' src='/graphs/cpu-day.png' border='0' />";
91 print $Lang::tr
{'no information available'};
96 &Header
::openbox
('100%', 'center', "Load $Lang::tr{'graph'}");
97 if (-e
"$Header::graphdir/load-day.png") {
98 my $ftime = localtime((stat("$Header::graphdir/load-day.png"))[9]);
99 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
100 print "<a href='/cgi-bin/graphs.cgi?graph=load'>";
101 print "<img alt='' src='/graphs/load-day.png' border='0' />";
104 print $Lang::tr
{'no information available'};
109 &Header
::openbox
('100%', 'left', $Lang::tr
{'services'});
113 <table width='60%' cellspacing='0' border='0'>
118 foreach $key (sort keys %servicenames)
120 print "<tr>\n<td align='left'>$key</td>\n";
121 my $shortname = $servicenames{$key};
122 my $status = &isrunning
($shortname);
128 print "</table></div>\n";
131 &Header
::closebigbox
();
132 &Header
::closepage
();
137 my $status = "<td bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
145 if (open(FILE
, "/var/run/${cmd}.pid"))
147 $pid = <FILE
>; chomp $pid;
149 if (open(FILE
, "/proc/${pid}/status"))
153 if (/^Name:\W+(.*)/) {
157 if ($testcmd =~ /$exename/)
159 $status = "<td bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
173 if ($percent =~ m/^(\d+)%$/ )
176 <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
180 if ($percent eq "100%") {
181 print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
182 } elsif ($percent eq "0%") {
183 print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
185 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'>"
188 <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>