X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fhardwaregraphs.cgi;h=dabdfd1aeeeed3af82f9f4c384890de0b622e1d0;hp=22b20485f706d4e3cdfc84b84965d52bf40b49f6;hb=fac92c6d25038f61430a4e872e720ba00b539385;hpb=4a52eae459b248456969c85b3421e1958bb521be
diff --git a/html/cgi-bin/hardwaregraphs.cgi b/html/cgi-bin/hardwaregraphs.cgi
index 22b20485f7..dabdfd1aee 100644
--- a/html/cgi-bin/hardwaregraphs.cgi
+++ b/html/cgi-bin/hardwaregraphs.cgi
@@ -2,7 +2,7 @@
###############################################################################
# #
# IPFire.org - A linux based firewall #
-# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
+# Copyright (C) 2008 Michael Tremer & Christian Schmidt #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
@@ -30,185 +30,144 @@ require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl";
require "${General::swroot}/graphs.pl";
-my %mbmonsettings = ();
-my %cgiparams=();
-my @cgigraphs=();
+my %color = ();
+my %mainsettings = ();
+&General::readhash("${General::swroot}/main/settings", \%mainsettings);
+&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
-&Header::showhttpheaders();
+my %sensorsettings = ();
-my $graphdir = "/srv/web/ipfire/html/graphs";
+my @sensorsgraphs = ();
+my @sensorsdir = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/`;
+foreach (@sensorsdir){
+ chomp($_);chop($_);
+ foreach (`ls $_/*`){
+ chomp($_);
+ push(@sensorsgraphs,$_);
+ }
+}
-$ENV{'QUERY_STRING'} =~ s/&//g;
-@cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'});
-$cgigraphs[1] = '' unless defined $cgigraphs[1];
+my @querry = split(/\?/,$ENV{'QUERY_STRING'});
+$querry[0] = '' unless defined $querry[0];
+$querry[1] = 'hour' unless defined $querry[1];
+
+if ( $querry[0] =~ "hwtemp"){
+ print "Content-type: image/png\n\n";
+ binmode(STDOUT);
+ &Graphs::updatehwtempgraph($querry[1]);
+}elsif ( $querry[0] =~ "hwfan"){
+ print "Content-type: image/png\n\n";
+ binmode(STDOUT);
+ &Graphs::updatehwfangraph($querry[1]);
+}elsif ( $querry[0] =~ "hwvolt"){
+ print "Content-type: image/png\n\n";
+ binmode(STDOUT);
+ &Graphs::updatehwvoltgraph($querry[1]);
+}elsif ( $querry[0] =~ "thermaltemp"){
+ print "Content-type: image/png\n\n";
+ binmode(STDOUT);
+ &Graphs::updatethermaltempgraph($querry[1]);
+}elsif ( $querry[0] =~ "sd?" || $querry[0] =~ "hd?" || $querry[0] =~ "xvd??" ){
+ print "Content-type: image/png\n\n";
+ binmode(STDOUT);
+ &Graphs::updatehddgraph($querry[0],$querry[1]);
+}else{
+ &Header::showhttpheaders();
+ &Header::openpage($Lang::tr{'harddisk temperature graphs'}, 1, '');
+ &Header::openbigbox('100%', 'left');
+
+ &Header::getcgihash(\%sensorsettings);
+
+ if ( $sensorsettings{'ACTION'} eq $Lang::tr{'save'} ) {
+ foreach(@sensorsgraphs){
+ chomp($_);
+ $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/;
+ my $label = $2.$3;$label=~ s/-//g;
+ if ( $sensorsettings{'LINE-'.$label} ne "on" ){
+ $sensorsettings{'LINE-'.$label} = 'off';
+ } elsif ($sensorsettings{'LINE-'.$label} eq "on" ){
+ $sensorsettings{'LINE-'.$label} = 'checked';
+ }
+ $sensorsettings{'LABEL-'.$label} =~ s/\W//g;
+ }
+ &General::writehash("${General::swroot}/sensors/settings", \%sensorsettings);
+ }
-my @mbmongraphs = ();
-if ( -e "/var/log/rrd/collectd/localhost/mbmon" ){@mbmongraphs = `ls /var/log/rrd/collectd/localhost/mbmon/`;}
+ my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`;
-&Header::getcgihash(\%mbmonsettings);
+ foreach (@disks){
+ my $disk = $_;
+ chomp $disk;
+ my @array = split(/\//,$disk);
-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);
-}
+ &Header::openbox('100%', 'center', "$array[$#array] $Lang::tr{'graph'}");
+ &Graphs::makegraphbox("hardwaregraphs.cgi",$array[$#array],"day");
+ &Header::closebox();
+ }
-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');
-
-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]);
+ if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/thermal-thermal_zone*` ) {
+ &Header::openbox('100%', 'center', "ACPI Thermal-Zone Temp $Lang::tr{'graph'}");
+ &Graphs::makegraphbox("hardwaregraphs.cgi","thermaltemp","day");
+ &Header::closebox();
}
-}
-else
-{
- &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") {
-
- &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();
- }
- }
-
- 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 ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/temperature-*` ) {
+ &Header::openbox('100%', 'center', "hwtemp $Lang::tr{'graph'}");
+ &Graphs::makegraphbox("hardwaregraphs.cgi","hwtemp","day","375");
+ Header::closebox();
}
- if ( -e "/var/log/rrd/collectd/localhost/mbmon" ){mbmonbox();}
-}
-&Header::closebigbox();
-&Header::closepage();
-
-sub hddtempbox {
- my $disk = $_[0];
- if (-e "$graphdir/hddtemp-$disk-week.png") {
-
- &Header::openbox('100%', 'center', "Disk $disk $Lang::tr{'graph'}");
- my $ftime = localtime((stat("$graphdir/hddtemp-$disk-week.png"))[9]);
- print "$Lang::tr{'the statistics were last updated at'}: $ftime
\n";
- 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();
- }
-}
+ if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/fanspeed-*` ) {
+ &Header::openbox('100%', 'center', "hwfan $Lang::tr{'graph'}");
+ &Graphs::makegraphbox("hardwaregraphs.cgi","hwfan","day");
+ &Header::closebox();
+ }
+
+ if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*/voltage-*` ) {
+ &Header::openbox('100%', 'center', "hwvolt $Lang::tr{'graph'}");
+ &Graphs::makegraphbox("hardwaregraphs.cgi","hwvolt","day","435");
+ &Header::closebox();
+ }
+
+ if ( `ls $mainsettings{'RRDLOG'}/collectd/localhost/sensors-*` ) {
+ sensorsbox();
+ }
+ &Header::closebigbox();
+ &Header::closepage();
-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-week.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();
+ &Header::closebox();
}