]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/entropy.cgi
rrd graphs: Remove unused individual graph output
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / entropy.cgi
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
22 use strict;
23
24 # enable only the following on debugging purpose
25 #use warnings;
26 #use CGI::Carp 'fatalsToBrowser';
27
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";
32
33 &Header::showhttpheaders();
34 &Header::openpage($Lang::tr{'entropy'}, 1, '');
35 &Header::openbigbox('100%', 'left');
36
37 &Header::openbox('100%', 'center', $Lang::tr{'entropy'});
38 &Graphs::makegraphbox("entropy.cgi", "entropy", "day");
39 &Header::closebox();
40
41 # Check for hardware support.
42 my $message;
43 my $message_colour = $Header::colourred;
44 if (&has_rdrand()) {
45 $message = $Lang::tr{'system has rdrand'};
46 $message_colour = $Header::colourgreen;
47 }
48
49 my $rngd_status = "<td align='center' bgcolor='${Header::colourred}'><font color='white'><b>$Lang::tr{'stopped'}</b></font></td>";
50 if (&rngd_is_running()) {
51 $rngd_status = "<td align='center' bgcolor='${Header::colourgreen}'><font color='white'><b>$Lang::tr{'running'}</b></font></td>";
52 }
53
54 &Header::openbox('100%', 'center', $Lang::tr{'hardware support'});
55 if ($message) {
56 print <<EOF;
57 <p style="color: $message_colour; text-align: center;">$message</p>
58 EOF
59 }
60
61 print <<EOF;
62 <table width='80%' cellspacing='1' class='tbl'>
63 <tr>
64 <th align='center'><b>$Lang::tr{'service'}</b></th>
65 <th align='center'><b>$Lang::tr{'status'}</b></th>
66 </tr>
67 <tr>
68 <td align='center'>
69 $Lang::tr{'random number generator daemon'}
70 </td>
71 $rngd_status
72 </tr>
73 </table>
74 EOF
75 &Header::closebox();
76
77 &Header::closebigbox();
78 &Header::closepage();
79
80 sub has_rdrand() {
81 open(FILE, "/proc/cpuinfo") or return 0;
82 my @cpuinfo = <FILE>;
83 close(FILE);
84
85 my @result = grep(/rdrand/, @cpuinfo);
86 if (@result) {
87 return 1;
88 }
89
90 return 0;
91 }
92
93 sub rngd_is_running() {
94 return (-e "/var/run/rngd.pid");
95 }