]>
git.ipfire.org Git - people/pmueller/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 %mbmonsettings = ();
37 &Header
::showhttpheaders
();
39 my $graphdir = "/srv/web/ipfire/html/graphs";
41 $ENV{'QUERY_STRING'} =~ s/&//g;
42 @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
43 $cgigraphs[1] = '' unless defined $cgigraphs[1];
46 if ( -e
"/var/log/rrd/collectd/localhost/mbmon" ){@mbmongraphs = `ls /var/log/rrd/collectd/localhost/mbmon/`;}
48 &Header
::getcgihash
(\
%mbmonsettings);
50 if ( $mbmonsettings{'ACTION'} eq $Lang::tr
{'save'} ) {
51 foreach (@mbmongraphs){
53 my @name=split(/\./,$_);
54 if ( $mbmonsettings{'LINE-'.$name[0]} ne "on" ){$mbmonsettings{'LINE-'.$name[0]} = 'off';}
55 elsif ( $mbmonsettings{'LINE-'.$name[0]} eq "on" ){$mbmonsettings{'LINE-'.$name[0]} = 'checked';}
57 &General
::writehash
("${General::swroot}/mbmon/settings", \
%mbmonsettings);
60 my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
62 &Header
::openpage
($Lang::tr
{'harddisk temperature graphs'}, 1, '');
63 &Header
::openbigbox
('100%', 'left');
65 if ($cgigraphs[1] =~ /hwtemp/) {&Graphs
::updatehwtempgraph
("hour");&Graphs
::updatehwtempgraph
("week");&Graphs
::updatehwtempgraph
("month");&Graphs
::updatehwtempgraph
("year");graphbox
("hwtemp");}
66 elsif ($cgigraphs[1] =~ /hwfan/) {&Graphs
::updatehwfangraph
("hour");&Graphs
::updatehwfangraph
("week");&Graphs
::updatehwfangraph
("month");&Graphs
::updatehwfangraph
("year");graphbox
("hwfan");}
67 elsif ($cgigraphs[1] =~ /hwvolt/) {&Graphs
::updatehwvoltgraph
("hour");&Graphs
::updatehwvoltgraph
("week");&Graphs
::updatehwvoltgraph
("month");&Graphs
::updatehwvoltgraph
("year");graphbox
("hwvolt");}
68 elsif ($cgigraphs[1] =~ /hddtemp/) {
72 my @array = split(/\//,$disk);
73 &Graphs
::updatehddgraph
($array[$#array],"week");&Graphs
::updatehddgraph
($array[$#array],"month");&Graphs
::updatehddgraph
($array[$#array],"year");
74 hddtempbox
($array[$#array]);
79 &Graphs
::updatehwtempgraph
("day");&Graphs
::updatehwfangraph
("day");&Graphs
::updatehwvoltgraph
("day");
83 my @array = split(/\//,$disk);
84 &Graphs
::updatehddgraph
($array[$#array],"day");
85 if (-e
"$graphdir/hddtemp-$disk-day.png") {
87 &Header
::openbox
('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
88 my $ftime = localtime((stat("$graphdir/hddtemp-$disk-day.png"))[9]);
89 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
90 print "<a href='/cgi-bin/hardwaregraphs.cgi?graph=hddtemp'>";
91 print "<img src='/graphs/hddtemp-$disk-day.png' border='0' />";
98 my @graphs = ("hwtemp","hwfan","hwvolt");
100 &Header
::openbox
('100%', 'center', "$_ $Lang::tr{'graph'}");
101 if (-e
"$graphdir/mbmon-$_-day.png"){
102 my $ftime = localtime((stat("$graphdir/mbmon-$_-day.png"))[9]);
104 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
105 print "<a href='/cgi-bin/hardwaregraphs.cgi?graph=$_'>";
106 print "<img src='/graphs/mbmon-$_-day.png' border='0' />";
109 else{print $Lang::tr
{'no information available'};}
112 if ( -e
"/var/log/rrd/collectd/localhost/mbmon" ){mbmonbox
();}
115 &Header
::closebigbox
();
116 &Header
::closepage
();
120 if (-e
"$graphdir/hddtemp-$disk-week.png") {
122 &Header
::openbox
('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
123 my $ftime = localtime((stat("$graphdir/hddtemp-$disk-week.png"))[9]);
124 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
125 print "<img src='/graphs/hddtemp-$disk-week.png' border='0' />";
129 if (-e
"$graphdir/hddtemp-$disk-month.png") {
131 &Header
::openbox
('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
132 my $ftime = localtime((stat("$graphdir/hddtemp-$disk-month.png"))[9]);
133 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
134 print "<img src='/graphs/hddtemp-$disk-month.png' border='0' />";
138 if (-e
"$graphdir/hddtemp-$disk-year.png") {
140 &Header
::openbox
('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
141 my $ftime = localtime((stat("$graphdir/hddtemp-$disk-year.png"))[9]);
142 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
143 print "<img src='/graphs/hddtemp-$disk-year.png' border='0' />";
152 &Header
::openbox
('100%', 'center', "$graph $Lang::tr{'graph'}");
153 if (-e
"$graphdir/mbmon-$graph-week.png"){
154 my $ftime = localtime((stat("$graphdir/mbmon-$graph-week.png"))[9]);
156 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
157 print "<img src='/graphs/mbmon-$graph-week.png' border='0' /><hr />";
159 else{print $Lang::tr
{'no information available'};}
161 &Header
::openbox
('100%', 'center', "$graph $Lang::tr{'graph'}");
162 if (-e
"$graphdir/mbmon-$graph-month.png"){
163 my $ftime = localtime((stat("$graphdir/mbmon-$graph-month.png"))[9]);
165 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
166 print "<img src='/graphs/mbmon-$graph-month.png' border='0' /><hr />";
168 else{print $Lang::tr
{'no information available'};}
170 &Header
::openbox
('100%', 'center', "$graph $Lang::tr{'graph'}");
171 if (-e
"$graphdir/mbmon-$graph-year.png"){
172 my $ftime = localtime((stat("$graphdir/mbmon-$graph-year.png"))[9]);
174 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
175 print "<img src='/graphs/mbmon-$graph-year.png' border='0' /><hr />";
177 else{print $Lang::tr
{'no information available'};}
183 foreach (@mbmongraphs){
185 my @name=split(/\./,$_);my $label = $name[0]; $label=~ s/-//;
186 $mbmonsettings{'LABEL-'.$name[0]}="$label";
187 $mbmonsettings{'LINE-'.$name[0]}="checked";
189 &General
::readhash
("${General::swroot}/mbmon/settings", \
%mbmonsettings);
191 &Header
::openbox
('100%', 'center', "$Lang::tr{'mbmon settings'}");
192 if ( $cgiparams{'ACTION'} eq $Lang::tr
{'save'} ){print "Test";}
195 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
196 <table width='100%' border='0' cellspacing='5' cellpadding='0' align='center'>
197 <tr><td align='right' width='40%'><b>$Lang::tr{'mbmon display'}</b></td>
198 <td align='left'><b>$Lang::tr{'mbmon label'}</b></td>
202 foreach (@mbmongraphs){
203 chomp($_);my @name=split(/\./,$_);
204 print("<tr><td align='right'><input type='checkbox' name='LINE-$name[0]' $mbmonsettings{'LINE-'.$name[0]} /></td>");
205 print("<td><input type='text' name='LABEL-$name[0]' value='$mbmonsettings{'LABEL-'.$name[0]}' size='25' /></td></tr>\n");
208 <tr><td align='center' colspan='2' ><input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td></tr>