X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fhardwaregraphs.cgi;h=0c8881877289058cdb02bdea9a200dad207cb0fd;hp=b2c9408d84e294828ac0d89a1aa3726a146f291f;hb=e1e3dbe5a88eb6bdc0f2b13579bc7c3157eb2a84;hpb=5db10f476c90304d2c5fcaf453d63e5b4693ee55
diff --git a/html/cgi-bin/hardwaregraphs.cgi b/html/cgi-bin/hardwaregraphs.cgi
index b2c9408d84..0c88818772 100644
--- a/html/cgi-bin/hardwaregraphs.cgi
+++ b/html/cgi-bin/hardwaregraphs.cgi
@@ -22,19 +22,15 @@
use strict;
# enable only the following on debugging purpose
-# use warnings;
-# use CGI::Carp 'fatalsToBrowser';
+#use warnings;
+#use CGI::Carp 'fatalsToBrowser';
require '/var/ipfire/general-functions.pl';
require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
require "${General::swroot}/graphs.pl";
-my %color = ();
-my %mainsettings = ();
-&General::readhash("${General::swroot}/main/settings", \%mainsettings);
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
-
+my %mbmonsettings = ();
my %cgiparams=();
my @cgigraphs=();
@@ -42,269 +38,78 @@ my @cgigraphs=();
my $graphdir = "/srv/web/ipfire/html/graphs";
-my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
-foreach (@disks){
- my $disk = $_;
- chomp $disk;
- my @array = split(/\//,$disk);
- &Graphs::updatehddgraph ($array[$#array],"day");&Graphs::updatehddgraph ($array[$#array],"week");&Graphs::updatehddgraph ($array[$#array],"month");&Graphs::updatehddgraph ($array[$#array],"year");
-}
-
- &Graphs::updatetempgraph ("day");
- &Graphs::updatefangraph ("day");
- &Graphs::updatevoltgraph ("day");
-
-my @graphs=();
-
-&Header::getcgihash(\%cgiparams);
-
$ENV{'QUERY_STRING'} =~ s/&//g;
@cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
$cgigraphs[1] = '' unless defined $cgigraphs[1];
-my %mbmon_settings = ();
-my %mbmon_values = ();
-&General::readhash("/var/log/mbmon-values", \%mbmon_values);
-my $key;
-
-if ( $cgiparams{'ACTION'} eq $Lang::tr{'save'} )
-{
- $mbmon_settings{'GRAPH_TEMP'} = ($cgiparams{'TEMP'} eq 'on');
- $mbmon_settings{'GRAPH_FAN'} = ($cgiparams{'FAN'} eq 'on');
- $mbmon_settings{'GRAPH_VOLT'} = ($cgiparams{'VOLT'} eq 'on');
- $mbmon_settings{'GRAPH_HDD'} = ($cgiparams{'HDD'} eq 'on');
-
- foreach my $line (sort keys %cgiparams)
- {
- if ( index($line, "LINE-") != -1 )
- {
- $mbmon_settings{$line} = 'on';
- }
+my @mbmongraphs = ();
+if ( -e "/var/log/rrd/collectd/localhost/mbmon" ){@mbmongraphs = `ls /var/log/rrd/collectd/localhost/mbmon/`;}
- if ( index($line, "LABEL-") != -1 )
- {
- $mbmon_settings{$line} = $cgiparams{$line};
- }
- }
+&Header::getcgihash(\%mbmonsettings);
- &General::writehash("${General::swroot}/mbmon/settings", \%mbmon_settings);
-}
-else
-{
- &General::readhash("${General::swroot}/mbmon/settings", \%mbmon_settings);
+if ( $mbmonsettings{'ACTION'} eq $Lang::tr{'save'} ) {
+ foreach (@mbmongraphs){
+ chomp($_);
+ my @name=split(/\./,$_);
+ if ( $mbmonsettings{'LINE-'.$name[0]} ne "on" ){$mbmonsettings{'LINE-'.$name[0]} = 'off';}
+ elsif ( $mbmonsettings{'LINE-'.$name[0]} eq "on" ){$mbmonsettings{'LINE-'.$name[0]} = 'checked';}
+ }
+ &General::writehash("${General::swroot}/mbmon/settings", \%mbmonsettings);
}
-my $selected_temp = '';
-my $selected_fan = '';
-my $selected_volt = '';
-my $selected_hdd = '';
-
-$selected_temp = "checked='checked'" if ( $mbmon_settings{'GRAPH_TEMP'} == 1 );
-$selected_fan = "checked='checked'" if ( $mbmon_settings{'GRAPH_FAN'} == 1 );
-$selected_volt = "checked='checked'" if ( $mbmon_settings{'GRAPH_VOLT'} == 1 );
-$selected_hdd = "checked='checked'" if ( $mbmon_settings{'GRAPH_HDD'} == 1 );
-
-my %mbmon_graphs = ();
-foreach $key ( sort(keys %mbmon_values) )
-{
- $mbmon_graphs{$key} = "checked='checked'" if ( $mbmon_settings{'LINE-'.$key} eq 'on' );
- if ( !defined($mbmon_settings{'LABEL-'.$key}) )
- {
- $mbmon_settings{'LABEL-'.$key} = $key;
- }
-}
+my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
&Header::openpage($Lang::tr{'harddisk temperature graphs'}, 1, '');
-
&Header::openbigbox('100%', 'left');
-###############
-# DEBUG DEBUG
-#&Header::openbox('100%', 'left', 'DEBUG');
-#my $debugCount = 0;
-#foreach my $line (sort keys %cgiparams) {
-# print "$line = $cgiparams{$line}
\n";
-# $debugCount++;
-#}
-#print " Count: $debugCount
\n";
-#print " CGIParams: $cgigraphs[1]\n";
-#&Header::closebox();
-# DEBUG DEBUG
-###############
-
-if ($cgigraphs[1] =~ /hddtemp/)
-{
- my $graph = $cgigraphs[1];
- my $graphname = $Lang::tr{"harddisk temperature"};
- &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
-
- if (-e "$graphdir/${graph}-day.png")
- {
- my $ftime = localtime((stat("$graphdir/${graph}-day.png"))[9]);
- print "
";
- print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
- print "
";
- print "
";
- print "
";
- print "";
- if ( -e "/var/log/smartctl_out_${graph}" )
- {
- my $output = `/bin/cat /var/log/smartctl_out_${graph}`;
- $output = &Header::cleanhtml($output);
- print "
\n";
- }
- }
- else
- {
- print $Lang::tr{'no information available'};
- }
- &Header::closebox();
- print "\n";
-}
-elsif ($cgigraphs[1] =~ /(temp|fan|volt)/)
-{
-if ($cgigraphs[1] =~ /temp/) {&Graphs::updatetempgraph ("week");&Graphs::updatetempgraph ("month");&Graphs::updatetempgraph ("year");}
-if ($cgigraphs[1] =~ /fan/) {&Graphs::updatefangraph ("week");&Graphs::updatefangraph ("month");&Graphs::updatefangraph ("year");}
-if ($cgigraphs[1] =~ /volt/) {&Graphs::updatevoltgraph ("week");&Graphs::updatevoltgraph ("month");&Graphs::updatevoltgraph ("year");}
-
- my $graph = $cgigraphs[1];
- my $graphname = $Lang::tr{"mbmon $cgigraphs[1]"};
- &Header::openbox('100%', 'center', "$graphname $Lang::tr{'graph'}");
-
- if (-e "$graphdir/mbmon-${graph}-day.png")
- {
- my $ftime = localtime((stat("$graphdir/mbmon-${graph}-day.png"))[9]);
- print "";
- print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
- print "
";
- print "
";
- print "
";
- print "";
- }
- else
- {
- print $Lang::tr{'no information available'};
- }
- &Header::closebox();
- print "\n";
+if ($cgigraphs[1] =~ /hwtemp/) {&Graphs::updatehwtempgraph ("hour");&Graphs::updatehwtempgraph ("week");&Graphs::updatehwtempgraph ("month");&Graphs::updatehwtempgraph ("year");graphbox("hwtemp");}
+elsif ($cgigraphs[1] =~ /hwfan/) {&Graphs::updatehwfangraph ("hour");&Graphs::updatehwfangraph ("week");&Graphs::updatehwfangraph ("month");&Graphs::updatehwfangraph ("year");graphbox("hwfan");}
+elsif ($cgigraphs[1] =~ /hwvolt/) {&Graphs::updatehwvoltgraph ("hour");&Graphs::updatehwvoltgraph ("week");&Graphs::updatehwvoltgraph ("month");&Graphs::updatehwvoltgraph ("year");graphbox("hwvolt");}
+elsif ($cgigraphs[1] =~ /hddtemp/) {
+ foreach (@disks){
+ my $disk = $_;
+ chomp $disk;
+ my @array = split(/\//,$disk);
+ &Graphs::updatehddgraph ($array[$#array],"week");&Graphs::updatehddgraph ($array[$#array],"month");&Graphs::updatehddgraph ($array[$#array],"year");
+ hddtempbox($array[$#array]);
+ }
}
-else
+else
{
- if ( $mbmon_settings{'GRAPH_TEMP'} == 1 )
- {
- &Header::openbox('100%', 'center', "$Lang::tr{'mbmon temp'} $Lang::tr{'graph'}");
- if (-e "$graphdir/mbmon-temp-day.png")
- {
- my $ftime = localtime((stat("$graphdir/mbmon-temp-day.png"))[9]);
- print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
- print "";
- print "";
- print "";
- }
- else
- {
- print $Lang::tr{'no information available'};
- }
- print "
\n";
- &Header::closebox();
- }
-
- if ( $mbmon_settings{'GRAPH_FAN'} == 1 )
- {
- &Header::openbox('100%', 'center', "$Lang::tr{'mbmon fan'} $Lang::tr{'graph'}");
- if (-e "$graphdir/mbmon-fan-day.png")
- {
- my $ftime = localtime((stat("$graphdir/mbmon-fan-day.png"))[9]);
- print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
- print "";
- print "";
- print "";
- }
- else
- {
- print $Lang::tr{'no information available'};
- }
- print "
\n";
- &Header::closebox();
- }
-
- if ( $mbmon_settings{'GRAPH_VOLT'} == 1 )
- {
- &Header::openbox('100%', 'center', "$Lang::tr{'mbmon volt'} $Lang::tr{'graph'}");
- if (-e "$graphdir/mbmon-volt-day.png")
- {
- my $ftime = localtime((stat("$graphdir/mbmon-volt-day.png"))[9]);
- print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
- print "";
- print "";
- print "";
- }
- else
- {
- print $Lang::tr{'no information available'};
- }
- print "
\n";
- &Header::closebox();
- }
-
- if ( $mbmon_settings{'GRAPH_HDD'} == 1 )
- {
- my @devices = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
- foreach (@devices) {
- my $device = $_;
- chomp($device);
- my @array = split(/\//,$device);
- hddtempbox($array[$#array]);}
- }
-
- &Header::openbox('100%', 'center', $Lang::tr{'settings'});
-print <
-
-
-
-$Lang::tr{'mbmon display'} | | $Lang::tr{'mbmon value'} | $Lang::tr{'mbmon label'} |
-END
-;
+ &Graphs::updatehwtempgraph ("day");&Graphs::updatehwfangraph ("day");&Graphs::updatehwvoltgraph ("day");
+ foreach (@disks){
+ my $disk = $_;
+ chomp $disk;
+ my @array = split(/\//,$disk);
+ &Graphs::updatehddgraph ($array[$#array],"day");
+ if (-e "$graphdir/hddtemp-$disk-day.png") {
-my $i = 0;
-foreach $key ( sort(keys %mbmon_values) )
-{
- if ( $i % 2 )
- {
- print("");
- }
- else
- {
- print("
");
+ &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
+ my $ftime = localtime((stat("$graphdir/hddtemp-$disk-day.png"))[9]);
+ print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
+ print "";
+ print "";
+ print "";
+ print "
\n";
+ &Header::closebox();
+ }
}
- $mbmon_settings{'LABEL-'.$key} = &Header::cleanhtml($mbmon_settings{'LABEL-'.$key});
- print(" | ");
- print("$key | $mbmon_values{$key} | \n");
- print(" |
\n");
- $i++;
-}
-
-print <
-
-
-
-END
-;
- &Header::closebox();
+ my @graphs = ("hwtemp","hwfan","hwvolt");
+ foreach (@graphs){
+ &Header::openbox('100%', 'center', "$_ $Lang::tr{'graph'}");
+ if (-e "$graphdir/mbmon-$_-day.png"){
+ my $ftime = localtime((stat("$graphdir/mbmon-$_-day.png"))[9]);
+ print "";
+ print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
+ print "";
+ print "";
+ print "
";
+ }
+ else{print $Lang::tr{'no information available'};}
+ &Header::closebox();
+ }
+ if ( -e "/var/log/rrd/collectd/localhost/mbmon" ){mbmonbox();}
}
&Header::closebigbox();
@@ -312,15 +117,98 @@ END
sub hddtempbox {
my $disk = $_[0];
- if (-e "$graphdir/hddtemp-$disk-day.png") {
-
+ if (-e "$graphdir/hddtemp-$disk-week.png") {
+
&Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
- my $ftime = localtime((stat("$graphdir/hddtemp-$disk-day.png"))[9]);
+ my $ftime = localtime((stat("$graphdir/hddtemp-$disk-week.png"))[9]);
print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
- print "";
print "";
- print "";
print "
\n";
&Header::closebox();
}
+ if (-e "$graphdir/hddtemp-$disk-month.png") {
+
+ &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
+ my $ftime = localtime((stat("$graphdir/hddtemp-$disk-month.png"))[9]);
+ print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
+ print "";
+ print "
\n";
+ &Header::closebox();
+ }
+ if (-e "$graphdir/hddtemp-$disk-year.png") {
+
+ &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
+ my $ftime = localtime((stat("$graphdir/hddtemp-$disk-year.png"))[9]);
+ print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
+ print "";
+ print "
\n";
+ &Header::closebox();
+ }
+}
+
+sub graphbox {
+ my $graph = $_[0];
+
+ &Header::openbox('100%', 'center', "$graph $Lang::tr{'graph'}");
+ if (-e "$graphdir/mbmon-$graph-week.png"){
+ my $ftime = localtime((stat("$graphdir/mbmon-$graph-day.png"))[9]);
+ print "";
+ print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
+ print "
";
+ }
+ else{print $Lang::tr{'no information available'};}
+ &Header::closebox();
+ &Header::openbox('100%', 'center', "$graph $Lang::tr{'graph'}");
+ if (-e "$graphdir/mbmon-$graph-month.png"){
+ my $ftime = localtime((stat("$graphdir/mbmon-$graph-month.png"))[9]);
+ print "";
+ print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
+ print "
";
+ }
+ else{print $Lang::tr{'no information available'};}
+ &Header::closebox();
+ &Header::openbox('100%', 'center', "$graph $Lang::tr{'graph'}");
+ if (-e "$graphdir/mbmon-$graph-year.png"){
+ my $ftime = localtime((stat("$graphdir/mbmon-$graph-year.png"))[9]);
+ print "";
+ print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
+ print "
";
+ }
+ else{print $Lang::tr{'no information available'};}
+ &Header::closebox();
+}
+
+sub mbmonbox{
+
+ foreach (@mbmongraphs){
+ chomp($_);
+ my @name=split(/\./,$_);my $label = $name[0]; $label=~ s/-//;
+ $mbmonsettings{'LABEL-'.$name[0]}="$label";
+ $mbmonsettings{'LINE-'.$name[0]}="checked";
+ }
+ &General::readhash("${General::swroot}/mbmon/settings", \%mbmonsettings);
+
+ &Header::openbox('100%', 'center', "$Lang::tr{'mbmon settings'}");
+ if ( $cgiparams{'ACTION'} eq $Lang::tr{'save'} ){print "Test";}
+
+ print <
+
+
+END
+;
+ &Header::closebox();
}