From 2d281532a66266c6eb476cb7301414e61dc7f331 Mon Sep 17 00:00:00 2001 From: Maniacikarus Date: Sat, 27 Sep 2008 18:32:54 +0200 Subject: [PATCH] 2nd step for 2.3 tuning --- config/cfgroot/graphs.pl | 374 ++++++++++++----------- config/rootfiles/updater/filelists/files | 3 + html/cgi-bin/hardwaregraphs.cgi | 259 ++++++---------- html/cgi-bin/services.cgi | 4 +- html/cgi-bin/system.cgi | 2 +- make.sh | 2 +- 6 files changed, 304 insertions(+), 340 deletions(-) diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index 08dc6d3d96..e386009152 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -30,7 +30,7 @@ require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; my $ERROR; -my $rrdlog = "/var/log/rrd/"; +my $rrdlog = "/var/log/rrd"; my $graphs = "/srv/web/ipfire/html/graphs"; $ENV{PATH}="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"; @@ -46,8 +46,8 @@ my %sensorsettings = (); # If the collection deamon is working and collecting lm_sensors data there will be # some data source named after a common scheme, with the sensorssettingsfile # the user is able to deactivate some of this parameters, in case not to show -# false collected value´s may be disable. The user has the ability to ente -# custom graph names in order to change temp0 to cpu or motherboad +# false collected values may be disable. The user has the ability to enter +# custom graph names in order to change temp0 to cpu or motherboard my $key; my $value; @@ -85,9 +85,9 @@ if ((${Lang::language} eq 'el') || } else {%tr=%Lang::tr;} # Generate a nice box for selection of time range in graphs -# this will generate a nice iframe for the cgi requesting every klick for +# this will generate a nice iframe for the cgi every klick for # the graph will be handled inside the iframe -# 0 is the cgi revering to +# 0 is the cgi refering to # 1 is the graph name # 2 is the time range for the graph # 3 if given is the height of the iframe default if nothing is given @@ -135,7 +135,12 @@ sub updatecpugraph { "-v ".$Lang::tr{'percentage'}, "--color=SHADEA".$color{"color19"}, "--color=SHADEB".$color{"color19"}, - "--color=BACK".$color{"color21"} + "--color=BACK".$color{"color21"}, + "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" ); my $nice = "CDEF:nice="; @@ -692,7 +697,6 @@ sub updatewirelessgraph { "--alt-y-grid", "-w 600", "-h 125", - "-r", "-t Wireless ".$interface." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period}, "-v dBm", "--color=SHADEA".$color{"color19"}, @@ -720,14 +724,204 @@ sub updatewirelessgraph { print "Error in RRD::graph for wireless: ".$ERROR."\n" if $ERROR; } +# Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors +sub updatehddgraph { + my $disk = $_[0]; + my $period = $_[1]; + RRDs::graph( + "-", + "--start", + "-1".$period, + "-aPNG", + "-i", + "-z", + "-W www.ipfire.org", + "--alt-y-grid", + "-w 600", + "-h 125", + "-r", + "-t ".$disk." ".$Lang::tr{'harddisk temperature'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period}, + "-v Celsius", + "--color=SHADEA".$color{"color19"}, + "--color=SHADEB".$color{"color19"}, + "--color=BACK".$color{"color21"}, + "DEF:temperature=".$rrdlog."/hddtemp-$disk.rrd:temperature:AVERAGE", + "DEF:standby=".$rrdlog."/hddshutdown-$disk.rrd:standby:AVERAGE", + "CDEF:st=standby,INF,*", + "AREA:st".$color{"color20"}."A0:standby", + "LINE3:temperature".$color{"color11"}."A0:$Lang::tr{'hdd temperature in'} C\\j", + "COMMENT:$Lang::tr{'maximal'}", + "COMMENT:$Lang::tr{'average'}", + "COMMENT:$Lang::tr{'minimal'}", + "COMMENT:$Lang::tr{'current'}\\j", + "GPRINT:temperature:MAX:%3.0lf Grad C", + "GPRINT:temperature:AVERAGE:%3.0lf Grad C", + "GPRINT:temperature:MIN:%3.0lf Grad C", + "GPRINT:temperature:LAST:%3.0lf Grad C\\j", + ); + $ERROR = RRDs::error; + print "Error in RRD::graph for hdd-".$disk.": ".$ERROR."\n" if $ERROR; +} +# Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors +sub updatehwtempgraph { + my $period = $_[0]; + my @command = ( + "-", + "--start", + "-1".$period, + "-aPNG", + "-i", + "-z", + "-W www.ipfire.org", + "--alt-y-grid", + "-w 600", + "-h 125", + "-r", + "-t ".$Lang::tr{'sensors temp'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period}, + "--color=SHADEA".$color{"color19"}, + "--color=SHADEB".$color{"color19"}, + "--color=BACK".$color{"color21"}, + "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" + ); + foreach(@sensorsgraphs){ + chomp($_); + if ( $_ =~ /temperature/ ) { + $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; + my $label = $2.$3;$label=~ s/-//g; + if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} + push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE"); + } + } + foreach(@sensorsgraphs){ + chomp($_); + if ( $_ =~ /temperature/ ){ + $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; + my $label = $2.$3;$label=~ s/-//g; + if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} + push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf C\\j",); + } + } + RRDs::graph (@command); + $ERROR = RRDs::error; + print "Error in RRD::graph for HDD Temp: ".$ERROR."\n" if $ERROR; +} +# Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors + +sub updatehwfangraph { + my $period = $_[0]; + + my @command = ( + "-", + "--start", + "-1".$period, + "-aPNG", + "-i", + "-z", + "-W www.ipfire.org", + "--alt-y-grid", + "-w 600", + "-h 125", + "-r", + "-t ".$Lang::tr{'mbmon fan'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period}, + "--color=SHADEA".$color{"color19"}, + "--color=SHADEB".$color{"color19"}, + "--color=BACK".$color{"color21"}, + "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" + ); + + foreach(@sensorsgraphs){ + chomp($_); + if ( $_ =~ /fanspeed/ ) { + $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; + my $label = $2.$3;$label=~ s/-//g; + if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} + push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE"); + } + } + + foreach(@sensorsgraphs){ + chomp($_); + if ( $_ =~ /fanspeed/ ){ + $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; + my $label = $2.$3;$label=~ s/-//g; + if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} + push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf RPM\\j",); + } + } + + RRDs::graph (@command); + $ERROR = RRDs::error; + print "Error in RRD::graph for Fan Speed: ".$ERROR."\n" if $ERROR; +} + +# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors + +sub updatehwvoltgraph { + my $period = $_[0]; + + my @command = ( + "-", + "--start", + "-1".$period, + "-aPNG", + "-i", + "-z", + "-W www.ipfire.org", + "--alt-y-grid", + "-w 600", + "-h 125", + "-r", + "-t ".$Lang::tr{'mbmon volt'}." ".$Lang::tr{'graph per'}." ".$Lang::tr{$period}, + "--color=SHADEA".$color{"color19"}, + "--color=SHADEB".$color{"color19"}, + "--color=BACK".$color{"color21"}, + "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'average'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}), + "COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j" + ); + + foreach(@sensorsgraphs){ + chomp($_); + if ( $_ =~ /voltage/ ) { + $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; + my $label = $2.$3;$label=~ s/-//g; + if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} + push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE"); + } + } + + foreach(@sensorsgraphs){ + chomp($_); + if ( $_ =~ /voltage/ ){ + $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; + my $label = $2.$3;$label=~ s/-//g; + if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} + push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf V\\j",); + } + } + + RRDs::graph (@command); + $ERROR = RRDs::error; + print "Error in RRD::graph for Voltage: ".$ERROR."\n" if $ERROR; +} @@ -793,24 +987,6 @@ sub updatecpufreqgraph { } } - - - - - - - - - - - - - - - - - - # Generate the QoS Graph for the current period of time sub updateqosgraph { @@ -880,154 +1056,6 @@ sub updateqosgraph { print "$ERROR"; } -# Generate the HDD Temp Graph for the current period of time for values given by collecd and lm_sensors - -sub updatehddgraph { - - my $disk = $_[0]; - my $period = $_[1]; - - RRDs::graph ("$graphs/hddtemp-$disk-$period.png", - "--start", "-1$period", "-aPNG", "-i", "-z", "-W www.ipfire.org", - "--alt-y-grid", "-w 600", "-h 125", - "--color", "SHADEA".$color{"color19"}, - "--color", "SHADEB".$color{"color19"}, - "--color", "BACK".$color{"color21"}, - "-t $disk $Lang::tr{'harddisk temperature'} $Lang::tr{'graph per'} $Lang::tr{$period}", - "DEF:temperature=$rrdlog/hddtemp-$disk.rrd:temperature:AVERAGE", - "DEF:standby=$rrdlog/hddshutdown-$disk.rrd:standby:AVERAGE", - "CDEF:st=standby,INF,*", - "AREA:st".$color{"color20"}."A0:standby", - "LINE3:temperature".$color{"color11"}."A0:$Lang::tr{'hdd temperature in'} C\\j", - "COMMENT:$Lang::tr{'maximal'}", - "COMMENT:$Lang::tr{'average'}", - "COMMENT:$Lang::tr{'minimal'}", - "COMMENT:$Lang::tr{'current'}\\j", - "GPRINT:temperature:MAX:%3.0lf Grad C", - "GPRINT:temperature:AVERAGE:%3.0lf Grad C", - "GPRINT:temperature:MIN:%3.0lf Grad C", - "GPRINT:temperature:LAST:%3.0lf Grad C\\j", - ); - $ERROR = RRDs::error; - print "Error in RRD::graph for hdd-$disk: $ERROR\n" if $ERROR; -} - -# Generate the Temp Graph for the current period of time for values given by collecd and lm_sensors - -sub updatehwtempgraph { - - my $period = $_[0]; - - my @command = ("$graphs/sensors-hwtemp-$period.png", - "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", - "--alt-y-grid", "-w 600", "-h 125", - "--color", "SHADEA".$color{"color19"},"--color", - "SHADEB".$color{"color19"},"--color", - "BACK".$color{"color21"}, - "-t $Lang::tr{'sensors temp'} $Lang::tr{'graph per'} $Lang::tr{$period}"); - - foreach(@sensorsgraphs){ - chomp($_); - if ( $_ =~ /temperature/ ) { - $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; - my $label = $2.$3;$label=~ s/-//g; - if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} - push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE"); - } - } - push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j"); - foreach(@sensorsgraphs){ - chomp($_); - if ( $_ =~ /temperature/ ){ - $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; - my $label = $2.$3;$label=~ s/-//g; - if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} - push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf C","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf C\\j",); - } - } - RRDs::graph (@command); - $ERROR = RRDs::error; - print "$ERROR"; -} - -# Generate the Voltage Graph for the current period of time for values given by collecd and lm_sensors - -sub updatehwvoltgraph { - - my $period = $_[0]; - - my @command = ("$graphs/sensors-hwvolt-$period.png", - "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", - "--alt-y-grid", "-w 600", "-h 125", - "--color", "SHADEA".$color{"color19"},"--color", - "SHADEB".$color{"color19"},"--color", - "BACK".$color{"color21"}, - "-t $Lang::tr{'mbmon volt'} $Lang::tr{'graph per'} $Lang::tr{$period}"); - - foreach(@sensorsgraphs){ - chomp($_); - if ( $_ =~ /voltage/ ) { - $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; - my $label = $2.$3;$label=~ s/-//g; - if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} - push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE"); - } - } - push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j"); - foreach(@sensorsgraphs){ - chomp($_); - if ( $_ =~ /voltage/ ){ - $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; - my $label = $2.$3;$label=~ s/-//g; - if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} - push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf V","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf V\\j",); - } - } - RRDs::graph (@command); - $ERROR = RRDs::error; - print "$ERROR"; -} - -# Generate the Fan Graph for the current period of time for values given by collecd and lm_sensors - -sub updatehwfangraph { - - my $period = $_[0]; - - my @command = ("$graphs/sensors-hwfan-$period.png", - "--start", "-1$period", "-aPNG", "-i", "-W www.ipfire.org", - "--alt-y-grid", "-w 600", "-h 125", - "--color", "SHADEA".$color{"color19"},"--color", - "SHADEB".$color{"color19"},"--color", - "BACK".$color{"color21"}, - "-t $Lang::tr{'mbmon fan'} $Lang::tr{'graph per'} $Lang::tr{$period}"); - - foreach(@sensorsgraphs){ - chomp($_); - if ( $_ =~ /fanspeed/ ) { - $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; - my $label = $2.$3;$label=~ s/-//g; - if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} - push(@command,"DEF:".$sensorsettings{'LABEL-'.$label}."=".$_.":value:AVERAGE"); - } - } - push(@command,"COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),"COMMENT:".sprintf("%15s",$Lang::tr{'current'})."\\j"); - foreach(@sensorsgraphs){ - chomp($_); - if ( $_ =~ /fanspeed/ ){ - $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; - my $label = $2.$3;$label=~ s/-//g; - if ( $sensorsettings{'LINE-'.$label} eq "off" ){next;} - push(@command,"LINE3:".$sensorsettings{'LABEL-'.$label}.random_hex_color(6)."A0:".sprintf("%-25s",$sensorsettings{'LABEL-'.$label}),"GPRINT:".$sensorsettings{'LABEL-'.$label}.":MAX:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":AVERAGE:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":MIN:%3.2lf RPM","GPRINT:".$sensorsettings{'LABEL-'.$label}.":LAST:%3.2lf RPM\\j",); - } - } - RRDs::graph (@command); - $ERROR = RRDs::error; - print "$ERROR"; -} - - - # Generate a random color, used by Qos Graph to be independent from the amount of values sub random_hex_color { diff --git a/config/rootfiles/updater/filelists/files b/config/rootfiles/updater/filelists/files index 0a697ea4a1..ea76db77b1 100644 --- a/config/rootfiles/updater/filelists/files +++ b/config/rootfiles/updater/filelists/files @@ -31,6 +31,9 @@ srv/web/ipfire/cgi-bin/netexternal.cgi srv/web/ipfire/cgi-bin/netinternal.cgi srv/web/ipfire/cgi-bin/netother.cgi srv/web/ipfire/cgi-bin/system.cgi +srv/web/ipfire/cgi-bin/services.cgi +srv/web/ipfire/cgi-bin/media.cgi +srv/web/ipfire/cgi-bin/memory.cgi srv/web/ipfire/cgi-bin/ids.cgi var/ipfire/sensors/ var/ipfire/graphs.pl diff --git a/html/cgi-bin/hardwaregraphs.cgi b/html/cgi-bin/hardwaregraphs.cgi index 911a63281f..3bdad64041 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 # @@ -22,31 +22,25 @@ 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 %sensorsettings = (); -my %cgiparams=(); -my @cgigraphs=(); my $rrdlog = "/var/log/rrd"; -&Header::showhttpheaders(); - -my $graphdir = "/srv/web/ipfire/html/graphs"; - -$ENV{'QUERY_STRING'} =~ s/&//g; -@cgigraphs = split(/graph=/,$ENV{'QUERY_STRING'}); -$cgigraphs[1] = '' unless defined $cgigraphs[1]; - my @sensorsgraphs = (); my @sensorsdir = `ls -dA $rrdlog/collectd/localhost/sensors-*/`; -foreach (@sensorsdir) -{ +foreach (@sensorsdir){ chomp($_);chop($_); foreach (`ls $_/*`){ chomp($_); @@ -54,167 +48,106 @@ foreach (@sensorsdir) } } -&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';} +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] =~ "sd?" || $querry[0] =~ "hd?" ){ + 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';} + } + &General::writehash("${General::swroot}/sensors/settings", \%sensorsettings); } - &General::writehash("${General::swroot}/sensors/settings", \%sensorsettings); -} -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]); + my @disks = `kudzu -qps -c HD | grep device: | cut -d" " -f2 | sort | uniq`; + + foreach (@disks){ + my $disk = $_; + chomp $disk; + my @array = split(/\//,$disk); + + &Header::openbox('100%', 'center', "$array[$#array] $Lang::tr{'graph'}"); + &Graphs::makegraphbox("hardwaregraphs.cgi",$array[$#array],"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/sensors-$_-day.png"){ - my $ftime = localtime((stat("$graphdir/sensors-$_-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::openbox('100%', 'center', "hwtemp $Lang::tr{'graph'}"); + &Graphs::makegraphbox("hardwaregraphs.cgi","hwtemp","day"); &Header::closebox(); - } + + &Header::openbox('100%', 'center', "hwfan $Lang::tr{'graph'}"); + &Graphs::makegraphbox("hardwaregraphs.cgi","hwfan","day"); + &Header::closebox(); + + &Header::openbox('100%', 'center', "hwvolt $Lang::tr{'graph'}"); + &Graphs::makegraphbox("hardwaregraphs.cgi","hwvolt","day","375"); + &Header::closebox(); + sensorsbox(); -} -&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(); - } -} + &Header::closebigbox(); + &Header::closepage(); -sub graphbox { - my $graph = $_[0]; - - &Header::openbox('100%', 'center', "$graph $Lang::tr{'graph'}"); - if (-e "$graphdir/sensors-$graph-week.png"){ - my $ftime = localtime((stat("$graphdir/sensors-$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/sensors-$graph-month.png"){ - my $ftime = localtime((stat("$graphdir/sensors-$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/sensors-$graph-year.png"){ - my $ftime = localtime((stat("$graphdir/sensors-$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 sensorsbox{ - &Header::openbox('100%', 'center', "$Lang::tr{'mbmon settings'}"); - if ( $cgiparams{'ACTION'} eq $Lang::tr{'save'} ){print "Test";} +sub sensorsbox { + &Header::openbox('100%', 'center', "$Lang::tr{'mbmon settings'}"); - print < - - - - + print < +
$Lang::tr{'mbmon display'}$Lang::tr{'mbmon label'}
+ + + + END ; -foreach (@sensorsgraphs){ - $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; - my $label = $2.$3;$label=~ s/-//g; - $sensorsettings{'LABEL-'.$label}="$label"; - $sensorsettings{'LINE-'.$label}="checked"; - &General::readhash("${General::swroot}/sensors/settings", \%sensorsettings); - print(""); - print("\n"); -} - print < -
$Lang::tr{'mbmon display'}$Lang::tr{'mbmon label'}
- + + foreach (@sensorsgraphs){ + $_ =~ /\/(.*)sensors-(.*)\/(.*)\.rrd/; + my $label = $2.$3;$label=~ s/-//g; + $sensorsettings{'LABEL-'.$label}="$label"; + $sensorsettings{'LINE-'.$label}="checked"; + &General::readhash("${General::swroot}/sensors/settings", \%sensorsettings); + print(""); + print("\n"); + } + + print < + + + + END ; - &Header::closebox(); + &Header::closebox(); } diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index c24b4601c8..dcd306ef79 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -22,8 +22,8 @@ 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"; diff --git a/html/cgi-bin/system.cgi b/html/cgi-bin/system.cgi index 171bdbd4b6..6c85e38238 100644 --- a/html/cgi-bin/system.cgi +++ b/html/cgi-bin/system.cgi @@ -53,7 +53,7 @@ if ( $querry[0] =~ "cpu"){ &Header::openbigbox('100%', 'left'); &Header::openbox('100%', 'center', "CPU $Lang::tr{'graph'}"); - &Graphs::makegraphbox("system.cgi","cpu","day","315"); + &Graphs::makegraphbox("system.cgi","cpu","day","325"); &Header::closebox(); &Header::openbox('100%', 'center', "Load $Lang::tr{'graph'}"); diff --git a/make.sh b/make.sh index 7f62482ece..38fc7c645c 100755 --- a/make.sh +++ b/make.sh @@ -177,7 +177,7 @@ prepareenv() { # Setup environment set +h LC_ALL=POSIX - MAKETUNING="-j6" + MAKETUNING="-j8" export LFS LC_ALL CFLAGS CXXFLAGS MAKETUNING unset CC CXX CPP LD_LIBRARY_PATH LD_PRELOAD -- 2.39.2