]>
Commit | Line | Data |
---|---|---|
3961e831 AF |
1 | #!/usr/bin/perl |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
1e18d32b | 5 | # Copyright (C) 2005-2011 IPFire Team # |
3961e831 AF |
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 | |
bcad0fd0 CS |
25 | #use warnings; |
26 | #use CGI::Carp 'fatalsToBrowser'; | |
3961e831 AF |
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 | ||
2d281532 CS |
33 | my %color = (); |
34 | my %mainsettings = (); | |
35 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
36 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
37 | ||
3961e831 | 38 | my %sensorsettings = (); |
3961e831 | 39 | |
3961e831 | 40 | my @sensorsgraphs = (); |
bcad0fd0 | 41 | my @sensorsdir = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/`; |
2d281532 | 42 | foreach (@sensorsdir){ |
3961e831 AF |
43 | chomp($_);chop($_); |
44 | foreach (`ls $_/*`){ | |
45 | chomp($_); | |
46 | push(@sensorsgraphs,$_); | |
47 | } | |
48 | } | |
49 | ||
2d281532 CS |
50 | my @querry = split(/\?/,$ENV{'QUERY_STRING'}); |
51 | $querry[0] = '' unless defined $querry[0]; | |
52 | $querry[1] = 'hour' unless defined $querry[1]; | |
53 | ||
54 | if ( $querry[0] =~ "hwtemp"){ | |
55 | print "Content-type: image/png\n\n"; | |
56 | binmode(STDOUT); | |
57 | &Graphs::updatehwtempgraph($querry[1]); | |
58 | }elsif ( $querry[0] =~ "hwfan"){ | |
59 | print "Content-type: image/png\n\n"; | |
60 | binmode(STDOUT); | |
61 | &Graphs::updatehwfangraph($querry[1]); | |
62 | }elsif ( $querry[0] =~ "hwvolt"){ | |
63 | print "Content-type: image/png\n\n"; | |
64 | binmode(STDOUT); | |
65 | &Graphs::updatehwvoltgraph($querry[1]); | |
30189c50 AF |
66 | }elsif ( $querry[0] =~ "thermaltemp"){ |
67 | print "Content-type: image/png\n\n"; | |
68 | binmode(STDOUT); | |
69 | &Graphs::updatethermaltempgraph($querry[1]); | |
269e21c6 | 70 | }elsif ( $querry[0] =~ "sd?" ){ |
2d281532 CS |
71 | print "Content-type: image/png\n\n"; |
72 | binmode(STDOUT); | |
73 | &Graphs::updatehddgraph($querry[0],$querry[1]); | |
74 | }else{ | |
75 | &Header::showhttpheaders(); | |
76 | &Header::openpage($Lang::tr{'harddisk temperature graphs'}, 1, ''); | |
77 | &Header::openbigbox('100%', 'left'); | |
78 | ||
79 | &Header::getcgihash(\%sensorsettings); | |
80 | ||
81 | if ( $sensorsettings{'ACTION'} eq $Lang::tr{'save'} ) { | |
82 | foreach(@sensorsgraphs){ | |
83 | chomp($_); | |
84 | $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; | |
85 | my $label = $2.$3;$label=~ s/-//g; | |
e4e74858 CS |
86 | if ( $sensorsettings{'LINE-'.$label} ne "on" ){ |
87 | $sensorsettings{'LINE-'.$label} = 'off'; | |
88 | } elsif ($sensorsettings{'LINE-'.$label} eq "on" ){ | |
89 | $sensorsettings{'LINE-'.$label} = 'checked'; | |
90 | } | |
91 | $sensorsettings{'LABEL-'.$label} =~ s/\W//g; | |
2d281532 CS |
92 | } |
93 | &General::writehash("${General::swroot}/sensors/settings", \%sensorsettings); | |
3961e831 | 94 | } |
3961e831 | 95 | |
269e21c6 | 96 | my @disks = `ls -1 /sys/block | grep -E '^sd' | sort | uniq`; |
2d281532 CS |
97 | |
98 | foreach (@disks){ | |
99 | my $disk = $_; | |
100 | chomp $disk; | |
101 | my @array = split(/\//,$disk); | |
102 | ||
103 | &Header::openbox('100%', 'center', "$array[$#array] $Lang::tr{'graph'}"); | |
104 | &Graphs::makegraphbox("hardwaregraphs.cgi",$array[$#array],"day"); | |
105 | &Header::closebox(); | |
3961e831 | 106 | } |
2d281532 | 107 | |
0d08de33 | 108 | if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/thermal-thermal_zone* 2>/dev/null` ) { |
e4e74858 CS |
109 | &Header::openbox('100%', 'center', "ACPI Thermal-Zone Temp $Lang::tr{'graph'}"); |
110 | &Graphs::makegraphbox("hardwaregraphs.cgi","thermaltemp","day"); | |
111 | &Header::closebox(); | |
30189c50 AF |
112 | } |
113 | ||
0d08de33 | 114 | if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/temperature-* 2>/dev/null` ) { |
e4e74858 | 115 | &Header::openbox('100%', 'center', "hwtemp $Lang::tr{'graph'}"); |
e682323b | 116 | &Graphs::makegraphbox("hardwaregraphs.cgi","hwtemp","day","375"); |
e4e74858 | 117 | Header::closebox(); |
30114625 | 118 | } |
2d281532 | 119 | |
0d08de33 | 120 | if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/fanspeed-* 2>/dev/null` ) { |
e4e74858 CS |
121 | &Header::openbox('100%', 'center', "hwfan $Lang::tr{'graph'}"); |
122 | &Graphs::makegraphbox("hardwaregraphs.cgi","hwfan","day"); | |
123 | &Header::closebox(); | |
30114625 | 124 | } |
2d281532 | 125 | |
0d08de33 | 126 | if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/voltage-* 2>/dev/null` ) { |
e4e74858 | 127 | &Header::openbox('100%', 'center', "hwvolt $Lang::tr{'graph'}"); |
e682323b | 128 | &Graphs::makegraphbox("hardwaregraphs.cgi","hwvolt","day","435"); |
e4e74858 | 129 | &Header::closebox(); |
30114625 | 130 | } |
3961e831 | 131 | |
0d08de33 | 132 | if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-* 2>/dev/null` ) { |
e4e74858 | 133 | sensorsbox(); |
30189c50 | 134 | } |
2d281532 CS |
135 | &Header::closebigbox(); |
136 | &Header::closepage(); | |
3961e831 | 137 | |
3961e831 AF |
138 | } |
139 | ||
3961e831 | 140 | |
2d281532 CS |
141 | sub sensorsbox { |
142 | &Header::openbox('100%', 'center', "$Lang::tr{'mbmon settings'}"); | |
3961e831 | 143 | |
2d281532 CS |
144 | print <<END |
145 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
146 | <table width='100%' border='0' cellspacing='5' cellpadding='0' align='center'> | |
147 | <tr> | |
148 | <td align='right' width='40%'><b>$Lang::tr{'mbmon display'}</b></td> | |
149 | <td align='left'><b>$Lang::tr{'mbmon label'}</b></td> | |
150 | </tr> | |
3961e831 AF |
151 | END |
152 | ; | |
2d281532 CS |
153 | |
154 | foreach (@sensorsgraphs){ | |
155 | $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; | |
156 | my $label = $2.$3;$label=~ s/-//g; | |
157 | $sensorsettings{'LABEL-'.$label}="$label"; | |
158 | $sensorsettings{'LINE-'.$label}="checked"; | |
159 | &General::readhash("${General::swroot}/sensors/settings", \%sensorsettings); | |
160 | print("<tr><td align='right'><input type='checkbox' name='LINE-$label' $sensorsettings{'LINE-'.$label} /></td>"); | |
161 | print("<td><input type='text' name='LABEL-$label' value='$sensorsettings{'LABEL-'.$label}' size='25' /></td></tr>\n"); | |
162 | } | |
163 | ||
164 | print <<END | |
165 | <tr> | |
166 | <td align='center' colspan='2' ><input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td> | |
167 | </tr> | |
168 | </table> | |
169 | </form> | |
3961e831 AF |
170 | END |
171 | ; | |
2d281532 | 172 | &Header::closebox(); |
3961e831 | 173 | } |