]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/hardwaregraphs.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
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. #
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. #
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/>. #
20 ###############################################################################
24 # enable only the following on debugging purpose
26 #use CGI::Carp 'fatalsToBrowser';
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";
33 my %sensorsettings = ();
36 my $rrdlog = "/var/log/rrd";
38 &Header
::showhttpheaders
();
40 my $graphdir = "/srv/web/ipfire/html/graphs";
42 $ENV{'QUERY_STRING'} =~ s/&//g;
43 @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
44 $cgigraphs[1] = '' unless defined $cgigraphs[1];
46 my @sensorsgraphs = ();
47 my @sensorsdir = `ls -dA $rrdlog/collectd/localhost/sensors-*/`;
53 push(@sensorsgraphs,$_);
57 &Header
::getcgihash
(\
%sensorsettings);
59 if ( $sensorsettings{'ACTION'} eq $Lang::tr
{'save'} ) {
60 foreach(@sensorsgraphs){
62 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
63 my $label = $2.$3;$label=~ s/-//g;
64 if ( $sensorsettings{'LINE-'.$label} ne "on" ){$sensorsettings{'LINE-'.$label} = 'off';}
65 elsif ( $sensorsettings{'LINE-'.$label} eq "on" ){$sensorsettings{'LINE-'.$label} = 'checked';}
67 &General
::writehash
("${General::swroot}/sensors/settings", \
%sensorsettings);
70 my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
72 &Header
::openpage
($Lang::tr
{'harddisk temperature graphs'}, 1, '');
73 &Header
::openbigbox
('100%', 'left');
75 if ($cgigraphs[1] =~ /hwtemp/) {&Graphs
::updatehwtempgraph
("hour");&Graphs
::updatehwtempgraph
("week");&Graphs
::updatehwtempgraph
("month");&Graphs
::updatehwtempgraph
("year");graphbox
("hwtemp");}
76 elsif ($cgigraphs[1] =~ /hwfan/) {&Graphs
::updatehwfangraph
("hour");&Graphs
::updatehwfangraph
("week");&Graphs
::updatehwfangraph
("month");&Graphs
::updatehwfangraph
("year");graphbox
("hwfan");}
77 elsif ($cgigraphs[1] =~ /hwvolt/) {&Graphs
::updatehwvoltgraph
("hour");&Graphs
::updatehwvoltgraph
("week");&Graphs
::updatehwvoltgraph
("month");&Graphs
::updatehwvoltgraph
("year");graphbox
("hwvolt");}
78 elsif ($cgigraphs[1] =~ /hddtemp/) {
82 my @array = split(/\//,$disk);
83 &Graphs
::updatehddgraph
($array[$#array],"week");&Graphs
::updatehddgraph
($array[$#array],"month");&Graphs
::updatehddgraph
($array[$#array],"year");
84 hddtempbox
($array[$#array]);
89 &Graphs
::updatehwtempgraph
("day");&Graphs
::updatehwfangraph
("day");&Graphs
::updatehwvoltgraph
("day");
93 my @array = split(/\//,$disk);
94 &Graphs
::updatehddgraph
($array[$#array],"day");
95 if (-e
"$graphdir/hddtemp-$disk-day.png") {
97 &Header
::openbox
('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
98 my $ftime = localtime((stat("$graphdir/hddtemp-$disk-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/hardwaregraphs.cgi?graph=hddtemp'>";
101 print "<img src='/graphs/hddtemp-$disk-day.png' border='0' />";
108 my @graphs = ("hwtemp","hwfan","hwvolt");
110 &Header
::openbox
('100%', 'center', "$_ $Lang::tr{'graph'}");
111 if (-e
"$graphdir/sensors-$_-day.png"){
112 my $ftime = localtime((stat("$graphdir/sensors-$_-day.png"))[9]);
114 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
115 print "<a href='/cgi-bin/hardwaregraphs.cgi?graph=$_'>";
116 print "<img src='/graphs/sensors-$_-day.png' border='0' />";
119 else{print $Lang::tr
{'no information available'};}
125 &Header
::closebigbox
();
126 &Header
::closepage
();
130 if (-e
"$graphdir/hddtemp-$disk-week.png") {
132 &Header
::openbox
('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
133 my $ftime = localtime((stat("$graphdir/hddtemp-$disk-week.png"))[9]);
134 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
135 print "<img src='/graphs/hddtemp-$disk-week.png' border='0' />";
139 if (-e
"$graphdir/hddtemp-$disk-month.png") {
141 &Header
::openbox
('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
142 my $ftime = localtime((stat("$graphdir/hddtemp-$disk-month.png"))[9]);
143 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
144 print "<img src='/graphs/hddtemp-$disk-month.png' border='0' />";
148 if (-e
"$graphdir/hddtemp-$disk-year.png") {
150 &Header
::openbox
('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
151 my $ftime = localtime((stat("$graphdir/hddtemp-$disk-year.png"))[9]);
152 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
153 print "<img src='/graphs/hddtemp-$disk-year.png' border='0' />";
162 &Header
::openbox
('100%', 'center', "$graph $Lang::tr{'graph'}");
163 if (-e
"$graphdir/sensors-$graph-week.png"){
164 my $ftime = localtime((stat("$graphdir/sensors-$graph-week.png"))[9]);
166 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
167 print "<img src='/graphs/sensors-$graph-week.png' border='0' /><hr />";
169 else{print $Lang::tr
{'no information available'};}
171 &Header
::openbox
('100%', 'center', "$graph $Lang::tr{'graph'}");
172 if (-e
"$graphdir/sensors-$graph-month.png"){
173 my $ftime = localtime((stat("$graphdir/sensors-$graph-month.png"))[9]);
175 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
176 print "<img src='/graphs/sensors-$graph-month.png' border='0' /><hr />";
178 else{print $Lang::tr
{'no information available'};}
180 &Header
::openbox
('100%', 'center', "$graph $Lang::tr{'graph'}");
181 if (-e
"$graphdir/sensors-$graph-year.png"){
182 my $ftime = localtime((stat("$graphdir/sensors-$graph-year.png"))[9]);
184 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
185 print "<img src='/graphs/sensors-$graph-year.png' border='0' /><hr />";
187 else{print $Lang::tr
{'no information available'};}
193 &Header
::openbox
('100%', 'center', "$Lang::tr{'mbmon settings'}");
194 if ( $cgiparams{'ACTION'} eq $Lang::tr
{'save'} ){print "Test";}
197 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
198 <table width='100%' border='0' cellspacing='5' cellpadding='0' align='center'>
199 <tr><td align='right' width='40%'><b>$Lang::tr{'mbmon display'}</b></td>
200 <td align='left'><b>$Lang::tr{'mbmon label'}</b></td>
204 foreach (@sensorsgraphs){
205 $_ =~ /\/(.*)sensors
-(.*)\
/(.*)\.rrd/;
206 my $label = $2.$3;$label=~ s/-//g;
207 $sensorsettings{'LABEL-'.$label}="$label";
208 $sensorsettings{'LINE-'.$label}="checked";
209 &General
::readhash
("${General::swroot}/sensors/settings", \
%sensorsettings);
210 print("<tr><td align='right'><input type='checkbox' name='LINE-$label' $sensorsettings{'LINE-'.$label} /></td>");
211 print("<td><input type='text' name='LABEL-$label' value='$sensorsettings{'LABEL-'.$label}' size='25' /></td></tr>\n");
214 <tr><td align='center' colspan='2' ><input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td></tr>