]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/hardwaregraphs.cgi
a25d511ff3ed1cb04181db7d95a09e42d7eb701d
3 # This code is based on hddGraph and mbmongraph
4 # written by weizen_42 and distributed under the
6 # http://www.ban-solms.de/t/IPCop-mbmongraph.html
7 # http://www.ban-solms.de/t/IPCop-hddgraph.html
12 # enable only the following on debugging purpose
14 # use CGI::Carp 'fatalsToBrowser';
16 require '/var/ipfire/general-functions.pl';
17 require "${General::swroot}/lang.pl";
18 require "${General::swroot}/header.pl";
24 &Header
::showhttpheaders
();
26 my $graphdir = "/srv/web/ipfire/html/graphs";
28 &Header
::getcgihash
(\
%cgiparams);
30 $ENV{'QUERY_STRING'} =~ s/&//g;
31 @cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
32 $cgigraphs[1] = '' unless defined $cgigraphs[1];
34 my %mbmon_settings = ();
35 my %mbmon_values = ();
36 &General
::readhash
("/var/log/mbmon-values", \
%mbmon_values);
39 if ( $cgiparams{'ACTION'} eq $Lang::tr
{'save'} )
41 $mbmon_settings{'GRAPH_TEMP'} = ($cgiparams{'TEMP'} eq 'on');
42 $mbmon_settings{'GRAPH_FAN'} = ($cgiparams{'FAN'} eq 'on');
43 $mbmon_settings{'GRAPH_VOLT'} = ($cgiparams{'VOLT'} eq 'on');
44 $mbmon_settings{'GRAPH_HDD'} = ($cgiparams{'HDD'} eq 'on');
46 foreach my $line (sort keys %cgiparams)
48 if ( index($line, "LINE-") != -1 )
50 $mbmon_settings{$line} = 'on';
53 if ( index($line, "LABEL-") != -1 )
55 $mbmon_settings{$line} = $cgiparams{$line};
59 &General
::writehash
("${General::swroot}/mbmon/settings", \
%mbmon_settings);
63 &General
::readhash
("${General::swroot}/mbmon/settings", \
%mbmon_settings);
66 my $selected_temp = '';
67 my $selected_fan = '';
68 my $selected_volt = '';
69 my $selected_hdd = '';
71 $selected_temp = "checked='checked'" if ( $mbmon_settings{'GRAPH_TEMP'} == 1 );
72 $selected_fan = "checked='checked'" if ( $mbmon_settings{'GRAPH_FAN'} == 1 );
73 $selected_volt = "checked='checked'" if ( $mbmon_settings{'GRAPH_VOLT'} == 1 );
74 $selected_hdd = "checked='checked'" if ( $mbmon_settings{'GRAPH_HDD'} == 1 );
76 my %mbmon_graphs = ();
77 foreach $key ( sort(keys %mbmon_values) )
79 $mbmon_graphs{$key} = "checked='checked'" if ( $mbmon_settings{'LINE-'.$key} eq 'on' );
80 if ( !defined($mbmon_settings{'LABEL-'.$key}) )
82 $mbmon_settings{'LABEL-'.$key} = $key;
86 &Header
::openpage
($Lang::tr
{'harddisk temperature graphs'}, 1, '');
88 &Header
::openbigbox
('100%', 'left');
92 #&Header::openbox('100%', 'left', 'DEBUG');
94 #foreach my $line (sort keys %cgiparams) {
95 # print "$line = $cgiparams{$line}<br />\n";
98 #print " Count: $debugCount\n";
103 if ($cgigraphs[1] =~ /(temp|fan|volt)/)
105 my $graph = $cgigraphs[1];
106 my $graphname = $Lang::tr
{"mbmon $cgigraphs[1]"};
107 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
109 if (-e
"$graphdir/mbmon-${graph}-day.png")
111 my $ftime = localtime((stat("$graphdir/mbmon-${graph}-day.png"))[9]);
113 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n";
114 print "<img src='/graphs/mbmon-${graph}-day.png' border='0' /><hr />";
115 print "<img src='/graphs/mbmon-${graph}-week.png' border='0' /><hr />";
116 print "<img src='/graphs/mbmon-${graph}-month.png' border='0' /><hr />";
117 print "<img src='/graphs/mbmon-${graph}-year.png' border='0' />";
121 print $Lang::tr
{'no information available'};
124 print "<div align='center'><table width='80%'><tr><td align='center'>";
125 print "<a href='/cgi-bin/mbmongraph.cgi'>";
126 print "$Lang::tr{'back'}</a></td></tr></table></div>\n";
128 elsif ($cgigraphs[1] =~ /(hdd)/)
130 my $graph = $cgigraphs[1];
131 my $graphname = $Lang::tr
{"harddisk temperature"};
132 &Header
::openbox
('100%', 'center', "$graphname $Lang::tr{'graph'}");
134 if (-e
"$graphdir/hddtemp-day.png")
136 my $ftime = localtime((stat("$graphdir/hddtemp-day.png"))[9]);
138 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n";
139 print "<img src='/graphs/hddtemp-day.png' border='0' /><hr />";
140 print "<img src='/graphs/hddtemp-week.png' border='0' /><hr />";
141 print "<img src='/graphs/hddtemp-month.png' border='0' /><hr />";
142 print "<img src='/graphs/hddtemp-year.png' border='0' />";
143 if ( -e
"/var/log/hddgraph_smartctl_out" )
145 my $output = `/bin/cat /var/log/hddgraph_smartctl_out`;
146 $output = &Header
::cleanhtml
($output);
147 print "<hr><pre>$output</pre>\n";
152 print $Lang::tr
{'no information available'};
155 print "<div align='center'><table width='80%'><tr><td align='center'>";
156 print "<a href='/cgi-bin/mbmongraph.cgi'>";
157 print "$Lang::tr{'back'}</a></td></tr></table></div>\n";
161 if ( $mbmon_settings{'GRAPH_TEMP'} == 1 )
163 &Header
::openbox
('100%', 'center', "$Lang::tr{'mbmon temp'} $Lang::tr{'graph'}");
164 if (-e
"$graphdir/mbmon-temp-day.png")
166 my $ftime = localtime((stat("$graphdir/mbmon-temp-day.png"))[9]);
167 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
168 print "<a href='/cgi-bin/mbmongraph.cgi?graph=temp'>";
169 print "<img src='/graphs/mbmon-temp-day.png' border='0' />";
174 print $Lang::tr
{'no information available'};
180 if ( $mbmon_settings{'GRAPH_FAN'} == 1 )
182 &Header
::openbox
('100%', 'center', "$Lang::tr{'mbmon fan'} $Lang::tr{'graph'}");
183 if (-e
"$graphdir/mbmon-fan-day.png")
185 my $ftime = localtime((stat("$graphdir/mbmon-fan-day.png"))[9]);
186 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
187 print "<a href='/cgi-bin/mbmongraph.cgi?graph=fan'>";
188 print "<img src='/graphs/mbmon-fan-day.png' border='0' />";
193 print $Lang::tr
{'no information available'};
199 if ( $mbmon_settings{'GRAPH_VOLT'} == 1 )
201 &Header
::openbox
('100%', 'center', "$Lang::tr{'mbmon volt'} $Lang::tr{'graph'}");
202 if (-e
"$graphdir/mbmon-volt-day.png")
204 my $ftime = localtime((stat("$graphdir/mbmon-volt-day.png"))[9]);
205 print "<center><b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br />\n";
206 print "<a href='/cgi-bin/mbmongraph.cgi?graph=volt'>";
207 print "<img src='/graphs/mbmon-volt-day.png' border='0' />";
212 print $Lang::tr
{'no information available'};
218 if ( $mbmon_settings{'GRAPH_HDD'} == 1 )
220 &Header
::openbox
('100%', 'center', $Lang::tr
{'harddisk temperature'});
221 if (-e
"$graphdir/hddtemp-day.png")
223 my $ftime = localtime((stat("$graphdir/hddtemp-day.png"))[9]);
225 print "<b>$Lang::tr{'the statistics were last updated at'}: $ftime</b></center><br /><hr />\n";
226 print "<a href='/cgi-bin/hddgraph.cgi?graph=hdd'>";
227 print "<img src='/graphs/hddtemp-day.png' border='0' /><hr />";
232 print $Lang::tr
{'no information available'};
238 &Header
::openbox
('100%', 'center', $Lang::tr
{'settings'});
240 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
242 <tr><td colspan='2'><input type='checkbox' name='TEMP' $selected_temp /> $Lang::tr{'mbmon temp'} $Lang::tr{'graph'}</td></tr>
243 <tr><td colspan='2'><input type='checkbox' name='FAN' $selected_fan /> $Lang::tr{'mbmon fan'} $Lang::tr{'graph'}</td></tr>
244 <tr><td colspan='2'><input type='checkbox' name='VOLT' $selected_volt /> $Lang::tr{'mbmon volt'} $Lang::tr{'graph'}</td></tr>
245 <tr><td colspan='2'><input type='checkbox' name='HDD' $selected_hdd /> $Lang::tr{'harddisk temperature'}-$Lang::tr{'graph'}</td></tr>
248 <table width='100%' border='0' cellspacing='1' cellpadding='0'>
249 <tr><td align='center' width='10%'><b>$Lang::tr{'mbmon display'}</b></td><td align='center' width='15%'> </td><td align='center' width='15%'><b>$Lang::tr{'mbmon value'}</b></td><td align='left'><b>$Lang::tr{'mbmon label'}</b></td></tr>
254 foreach $key ( sort(keys %mbmon_values) )
258 print("<tr bgcolor='$Header::table2colour'>");
262 print("<tr bgcolor='$Header::table1colour'>");
264 $mbmon_settings{'LABEL-'.$key} = &Header
::cleanhtml
($mbmon_settings{'LABEL-'.$key});
265 print("<td align='center'><input type='checkbox' name='LINE-$key' $mbmon_graphs{$key}/></td>");
266 print("<td>$key</td><td align='center'>$mbmon_values{$key}</td>\n");
267 print("<td> <input type='text' name='LABEL-$key' value='$mbmon_settings{'LABEL-'.$key}' size='25' /></td></tr>\n");
275 <tr><td class='base' valign='top'> </td><td width='40%' align='center'><input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td></tr>
286 &Header
::closebigbox
();
287 &Header
::closepage
();