###############################################################################
# #
# 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 #
# 3 if given is the height of the iframe default if nothing is given
sub makegraphbox {
- my $height = 275;
+ my $height = 285;
my $width = 700;
if ( $_[3] ne "" ){ $height = $_[3]; }
print "<center>";
- print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'>Hour</a>";
+ print "<a href='".$_[0]."?".$_[1]."?hour' target='".$_[1]."box'><b>".$Lang::tr{'hour'}."</b></a>";
print " - ";
- print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'>Day</a>";
+ print "<a href='".$_[0]."?".$_[1]."?day' target='".$_[1]."box'><b>".$Lang::tr{'day'}."</b></a>";
print " - ";
- print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'>Week</a>";
+ print "<a href='".$_[0]."?".$_[1]."?week' target='".$_[1]."box'><b>".$Lang::tr{'week'}."</b></a>";
print " - ";
- print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'>Month</a>";
+ print "<a href='".$_[0]."?".$_[1]."?month' target='".$_[1]."box'><b>".$Lang::tr{'month'}."</b></a>";
print " - ";
- print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'>Year</a>";
+ print "<a href='".$_[0]."?".$_[1]."?year' target='".$_[1]."box'><b>".$Lang::tr{'year'}."</b></a>";
print "<iframe src='".$_[0]."?".$_[1]."?".$_[2]."' width='".$width."' height='".$height."' scrolling='no' frameborder='no' marginheight='0' name='".$_[1]."box'></iframe>";
print "</center>";
}
$addstring .= "+,";
}
- $addstring .= "+";
-
- push(@command,$nice.$addstring
- ,$interrupt.$addstring
- ,$steal.$addstring
- ,$user.$addstring
- ,$system.$addstring
- ,$idle.$addstring
- ,$iowait.$addstring
- ,$irq.$addstring);
+ if ( $cpucount > 1){
+ $addstring .= "+";
+ push(@command,$nice.$addstring
+ ,$interrupt.$addstring
+ ,$steal.$addstring
+ ,$user.$addstring
+ ,$system.$addstring
+ ,$idle.$addstring
+ ,$iowait.$addstring
+ ,$irq.$addstring);
+ }else{
+ chop($nice),chop($interrupt),chop($steal),chop($user),chop($system),chop($idle),chop($iowait),chop($irq);
+ push(@command,$nice,$interrupt,$steal,$user,$system,$idle,$iowait,$irq);
+ }
push(@command,"CDEF:total=user,system,idle,iowait,irq,nice,interrupt,steal,+,+,+,+,+,+,+"
,"CDEF:userpct=100,user,total,/,*"
"-w 600",
"-h 125",
"-l 0",
- "-u 100",
"-r",
"-t ".$Lang::tr{'cpu frequency per'}." ".$Lang::tr{$period},
"-v MHz",
"--color=SHADEA".$color{"color19"},
"--color=SHADEB".$color{"color19"},
"--color=BACK".$color{"color21"},
- "COMMENT:".sprintf("%-29s",$Lang::tr{'caption'}),
+ "COMMENT:".sprintf("%-10s",$Lang::tr{'caption'}),
"COMMENT:".sprintf("%15s",$Lang::tr{'maximal'}),
"COMMENT:".sprintf("%15s",$Lang::tr{'average'}),
"COMMENT:".sprintf("%15s",$Lang::tr{'minimal'}),
);
for(my $i = 0; $i < $cpucount; $i++) {
+ my $j=$i+1;
push(@command,"DEF:cpu".$i."_=".$mainsettings{'RRDLOG'}."/collectd/localhost/cpufreq/cpufreq-".$i.".rrd:value:AVERAGE"
,"CDEF:cpu".$i."=cpu".$i."_,1000000,/"
- ,"LINE3:cpu".$i.$color{"color12"}."A0:1"
+ ,"LINE1:cpu".$i.$color{"color1$j"}."A0:cpu ".$i." "
,"GPRINT:cpu".$i.":MAX:%3.0lf Mhz"
,"GPRINT:cpu".$i.":AVERAGE:%3.0lf Mhz"
,"GPRINT:cpu".$i.":MIN:%3.0lf Mhz"
print "Error in RRD::graph for cpu freq: ".$ERROR."\n" if $ERROR;
}
+# Generate the Thermal Zone Temp CPU Graph
+
+sub updatethermaltempgraph {
+ my $thermalcount = `ls -dA $mainsettings{'RRDLOG'}/collectd/localhost/thermal-thermal_zone* | wc -l`;
+ my $period = $_[0];
+ my @command = (
+ "-",
+ "--start",
+ "-1".$period,
+ "-aPNG",
+ "-i",
+ "-z",
+ "-W www.ipfire.org",
+ "--alt-y-grid",
+ "-w 600",
+ "-h 125",
+ "-r",
+ "-t "."ACPI Thermal-Zone Temperature"." - ".$Lang::tr{$period},
+ "-v Grad Celsius",
+ "--color=SHADEA".$color{"color19"},
+ "--color=SHADEB".$color{"color19"},
+ "--color=BACK".$color{"color21"},
+ "COMMENT:".sprintf("%-10s",$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"
+ );
+
+ for(my $i = 0; $i < $thermalcount; $i++) {
+ my $j=$i+1;
+ push(@command,"DEF:temp".$i."_=".$mainsettings{'RRDLOG'}."/collectd/localhost/thermal-thermal_zone".$i."/temperature-temperature.rrd:value:AVERAGE"
+ ,"CDEF:temp".$i."=temp".$i."_,1,/"
+ ,"LINE3:temp".$i.$color{"color1$j"}."A0:Temp ".$i." "
+ ,"GPRINT:temp".$i.":MAX:%3.0lf Grad C"
+ ,"GPRINT:temp".$i.":AVERAGE:%3.0lf Grad C"
+ ,"GPRINT:temp".$i.":MIN:%3.0lf Grad C"
+ ,"GPRINT:temp".$i.":LAST:%3.0lf Grad C\\j");
+ }
+
+ RRDs::graph (@command);
+ $ERROR = RRDs::error;
+ print "Error in RRD::graph for thermal temp: ".$ERROR."\n" if $ERROR;
+}
+
+
# Generate a random color, used by Qos Graph to be independent from the amount of values
sub random_hex_color {