From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: Re: [PATCH] graphs.pl: Make canvas fixed size and limit cpufreq color index Date: Mon, 13 Mar 2023 09:23:20 +0000 Message-ID: <358CBBDE-3C7F-48AF-8994-94316DB07FE7@ipfire.org> In-Reply-To: <20230313073544.753-1-hofmann@leo-andres.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3990405616578865461==" List-Id: --===============3990405616578865461== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello, Reviewed-by: Michael Tremer > On 13 Mar 2023, at 07:35, Leo-Andres Hofmann wrot= e: >=20 > This fixes an issue where systems with many CPU cores > run out of usable graph colors and canvas area. > It also unifies the canvas size for all graphs. >=20 > Discussion: https://community.ipfire.org/t/cpu-freq-graph-not-working-with-= i5-1235u/9396 >=20 > Fixes: #12890 >=20 > Signed-off-by: Leo-Andres Hofmann > --- > config/cfgroot/graphs.pl | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-) >=20 > diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl > index 3368e5aad..cefe0b90d 100644 > --- a/config/cfgroot/graphs.pl > +++ b/config/cfgroot/graphs.pl > @@ -30,8 +30,11 @@ require '/var/ipfire/general-functions.pl'; > require "${General::swroot}/lang.pl"; > require "${General::swroot}/header.pl"; >=20 > -# Graph image size in pixel > -our %image_size =3D ('width' =3D> 910, 'height' =3D> 300); > +# Approximate size of the final graph image including canvas and labeling = (in pixels, mainly used for placeholders) > +our %image_size =3D ('width' =3D> 900, 'height' =3D> 300); > + > +# Size of the actual data area within the image, without labeling (in pixe= ls) > +our %canvas_size =3D ('width' =3D> 800, 'height' =3D> 190); >=20 > # List of all available time ranges > our @time_ranges =3D ("hour", "day", "week", "month", "year"); > @@ -48,15 +51,12 @@ my @GRAPH_ARGS =3D ( > # For a more 'organic' look > "--slope-mode", >=20 > - # HxW define the size of the output image > - "--full-size-mode", > - > # Watermark > "-W www.ipfire.org", >=20 > - # Default size > - "-w $image_size{'width'}", > - "-h $image_size{'height'}", > + # Canvas width/height > + "-w $canvas_size{'width'}", > + "-h $canvas_size{'height'}", >=20 > # Use alternative grid > "--alt-y-grid", > @@ -1090,18 +1090,19 @@ sub updatecpufreqgraph { > "--color=3DSHADEA".$color{"color19"}, > "--color=3DSHADEB".$color{"color19"}, > "--color=3DBACK".$color{"color21"}, > - "COMMENT:".sprintf("%-10s",$Lang::tr{'caption'}), > + "COMMENT:".sprintf("%-15s",$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" > ); >=20 > + my $j =3D 11; > for(my $i =3D 0; $i < $cpucount; $i++) { > - my $j=3D$i+1; > + $j++; $j =3D 1 if $j > 20; I think you could have written this slightly shorter by taking the modulus of= j like so: $j =3D $i % 20; But since this is not changing the behaviour, I am happy to see this merged. -Michael > push(@command,"DEF:cpu".$i."_=3D".$mainsettings{'RRDLOG'}."/collectd/localh= ost/cpufreq/cpufreq-".$i.".rrd:value:AVERAGE" > ,"CDEF:cpu".$i."=3Dcpu".$i."_,1000000,/" > - ,"LINE1:cpu".$i.$color{"color1$j"}."A0:cpu ".$i." " > + ,"LINE1:cpu".$i.$color{"color$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" > --=20 > 2.37.1.windows.1 >=20 --===============3990405616578865461==--