]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/system.cgi
e7a8e513622bbfc1c23d6a7defef206637cc9452
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";
21 #workaround to suppress a warning when a variable is used only once
22 my @dummy = ( ${Header
::colourred
} );
26 &General
::readhash
("${General::swroot}/ethernet/settings", \
%netsettings);
29 # Maps a nice printable name to the changing part of the pid file, which
30 # is also the name of the program
33 $Lang::tr
{'dhcp server'} => 'dhcpd',
34 $Lang::tr
{'web server'} => 'httpd',
35 $Lang::tr
{'cron server'} => 'fcron',
36 $Lang::tr
{'dns proxy server'} => 'dnsmasq',
37 $Lang::tr
{'logging server'} => 'syslogd',
38 $Lang::tr
{'kernel logging server'} => 'klogd',
39 $Lang::tr
{'ntp server'} => 'ntpd',
40 $Lang::tr
{'secure shell server'} => 'sshd',
41 $Lang::tr
{'vpn'} => 'pluto',
42 $Lang::tr
{'web proxy'} => 'squid',
43 'OpenVPN' => 'openvpn'
47 if (open(FILE
, "${General::swroot}/red/iface"))
53 $servicenames{"$Lang::tr{'intrusion detection system'} (RED)"} = "snort_${iface}";
54 $servicenames{"$Lang::tr{'intrusion detection system'} (GREEN)"} = "snort_$netsettings{'GREEN_DEV'}";
55 if ($netsettings{'ORANGE_DEV'} ne '') {
56 $servicenames{"$Lang::tr{'intrusion detection system'} (ORANGE)"} = "snort_$netsettings{'ORANGE_DEV'}";
58 if ($netsettings{'BLUE_DEV'} ne '') {
59 $servicenames{"$Lang::tr{'intrusion detection system'} (BLUE)"} = "snort_$netsettings{'BLUE_DEV'}";
62 &Header
::showhttpheaders
();
64 &Header
::getcgihash
(\
%cgiparams);
66 &Header
::openpage
($Lang::tr
{'status information'}, 1, '');
68 &Header
::openbigbox
('100%', 'left');
70 &Header
::openbox
('100%', 'center', "CPU $Lang::tr{'graph'}");
71 if (-e
"$Header::graphdir/cpu-day.png") {
72 my $ftime = localtime((stat("$Header::graphdir/cpu-day.png"))[9]);
73 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
74 print "<a href='/cgi-bin/graphs.cgi?graph=cpu'>";
75 print "<img alt='' src='/graphs/cpu-day.png' border='0' />";
78 print $Lang::tr
{'no information available'};
83 &Header
::openbox
('100%', 'center', "Load $Lang::tr{'graph'}");
84 if (-e
"$Header::graphdir/load-day.png") {
85 my $ftime = localtime((stat("$Header::graphdir/load-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=load'>";
88 print "<img alt='' src='/graphs/load-day.png' border='0' />";
91 print $Lang::tr
{'no information available'};
96 &Header
::openbox
('100%', 'left', $Lang::tr
{'services'});
100 <table width='60%' cellspacing='0' border='0'>
106 foreach $key (sort keys %servicenames)
109 print "<tr bgcolor='${Header::table1colour}'>\n"; }
111 print "<tr bgcolor='${Header::table2colour}'>\n"; }
112 print "<td align='left'>$key</td>\n";
113 my $shortname = $servicenames{$key};
114 my $status = &isrunning
($shortname);
121 print "</table></div>\n";
124 &Header
::closebigbox
();
125 &Header
::closepage
();
130 my $status = "<td bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
138 if (open(FILE
, "/var/run/${cmd}.pid"))
140 $pid = <FILE
>; chomp $pid;
142 if (open(FILE
, "/proc/${pid}/status"))
146 if (/^Name:\W+(.*)/) {
150 if ($testcmd =~ /$exename/)
152 $status = "<td bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
166 if ($percent =~ m/^(\d+)%$/ )
169 <table width='100' border='1' cellspacing='0' cellpadding='0' style='border-width:1px;border-style:solid;border-color:$fg;width:100px;height:10px;'>
173 if ($percent eq "100%") {
174 print "<td width='100%' bgcolor='$fg' style='background-color:$fg;border-style:solid;border-width:1px;border-color:$bg'>"
175 } elsif ($percent eq "0%") {
176 print "<td width='100%' bgcolor='$bg' style='background-color:$bg;border-style:solid;border-width:1px;border-color:$bg'>"
178 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'>"
181 <img src='/images/null.gif' width='1' height='1' alt='' /></td></tr></table>