]> git.ipfire.org Git - ipfire-2.x.git/blame - html/cgi-bin/entropy.cgi
BUG 11786 - squid: Remove setting for filter processes the number of Squid processes
[ipfire-2.x.git] / html / cgi-bin / entropy.cgi
CommitLineData
15b023b9
MT
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2005-2010 IPFire Team #
6# #
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. #
11# #
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. #
16# #
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/>. #
19# #
20###############################################################################
21
22use strict;
23
24# enable only the following on debugging purpose
25#use warnings;
26#use CGI::Carp 'fatalsToBrowser';
27
28require '/var/ipfire/general-functions.pl';
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
31require "${General::swroot}/graphs.pl";
32
33my @querry = split(/\?/,$ENV{'QUERY_STRING'});
34$querry[0] = '' unless defined $querry[0];
35$querry[1] = 'hour' unless defined $querry[1];
36
37if ( $querry[0] ne~ "") {
38 print "Content-type: image/png\n\n";
39 binmode(STDOUT);
40 &Graphs::updateentropygraph($querry[1]);
41
42} else {
43 &Header::showhttpheaders();
44 &Header::openpage($Lang::tr{'entropy'}, 1, '');
45 &Header::openbigbox('100%', 'left');
46
47 &Header::openbox('100%', 'center', $Lang::tr{'entropy'});
a249ccd2 48 &Graphs::makegraphbox("entropy.cgi", "day");
15b023b9
MT
49 &Header::closebox();
50
84004f05
MT
51 # Check for hardware support.
52 my $message;
53 my $message_colour = $Header::colourred;
9b656e7f 54 if (&has_rdrand()) {
84004f05
MT
55 $message = $Lang::tr{'system has rdrand'};
56 $message_colour = $Header::colourgreen;
84004f05
MT
57 }
58
742c334a
MT
59 my $rngd_status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
60 if (&rngd_is_running()) {
61 $rngd_status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
62 }
63
84004f05 64 &Header::openbox('100%', 'center', $Lang::tr{'hardware support'});
9b656e7f
MT
65 if ($message) {
66 print <<EOF;
67 <p style="color: $message_colour; text-align: center;">$message</p>
68EOF
69 }
742c334a 70
9b656e7f 71 print <<EOF;
742c334a
MT
72 <table width='80%' cellspacing='1' class='tbl'>
73 <tr>
74 <th align='center'><b>$Lang::tr{'service'}</b></th>
75 <th align='center'><b>$Lang::tr{'status'}</b></th>
76 </tr>
77 <tr>
78 <td align='center'>
79 $Lang::tr{'random number generator daemon'}
80 </td>
81 $rngd_status
82 </tr>
83 </table>
84004f05
MT
84EOF
85 &Header::closebox();
86
15b023b9
MT
87 &Header::closebigbox();
88 &Header::closepage();
89}
84004f05 90
84004f05
MT
91sub has_rdrand() {
92 open(FILE, "/proc/cpuinfo") or return 0;
93 my @cpuinfo = <FILE>;
94 close(FILE);
95
96 my @result = grep(/rdrand/, @cpuinfo);
97 if (@result) {
98 return 1;
99 }
100
101 return 0;
102}
742c334a
MT
103
104sub rngd_is_running() {
105 return (-e "/var/run/rngd.pid");
106}