Skip to content

Commit

Permalink
qos and process graphs: avoid random colors
Browse files Browse the repository at this point in the history
For the graphs for qos classes, and for process
count and memory usage, the colors change on
each page reload, since the colors are currently
totally random.

This change uses defined color indexes, 15 different
ones, that should be enough for qos at least, and is
enough for processes on my setup. This makes
the colors consistent between page loads, so it makes
it easier to monitor changes.

Perhaps one should define 30 different colors meant
to be used for graphing, then one could avoid random
colors also for the sensor graphs, and make it less
likely to get color collision for the process graphs
as well. Defining 30 such colors is not part of this
change.
  • Loading branch information
alfh committed Feb 26, 2014
1 parent 69776cc commit e06986e
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions config/cfgroot/graphs.pl
Original file line number Diff line number Diff line change
Expand Up @@ -422,12 +422,15 @@ sub updateprocessescpugraph {

push(@command,"COMMENT:".$Lang::tr{'caption'}."\\j");

my $colorIndex = 0;
foreach(@processesgraph){
my $colorIndex = 10 + $count % 15;
my $color="$color{\"color$colorIndex\"}";
chomp($_);my @name=split(/\-/,$_);chop($name[1]);
if ($count eq "0"){
push(@command,"AREA:".$name[1].random_hex_color(6)."A0:".$name[1]);
push(@command,"AREA:".$name[1].$color."A0:".$name[1]);
}else{
push(@command,"STACK:".$name[1].random_hex_color(6)."A0:".$name[1]);
push(@command,"STACK:".$name[1].$color."A0:".$name[1]);
}
$count++;
}
Expand Down Expand Up @@ -471,12 +474,15 @@ sub updateprocessesmemorygraph {

push(@command,"COMMENT:".$Lang::tr{'caption'}."\\j");

my $colorIndex = 0;
foreach(@processesgraph){
chomp($_);my @name=split(/\-/,$_);chop($name[1]);
my $colorIndex = 10 + $count % 15;
my $color="$color{\"color$colorIndex\"}";
if ($count eq "0"){
push(@command,"AREA:".$name[1].random_hex_color(6)."A0:".$name[1]);
push(@command,"AREA:".$name[1].$color."A0:".$name[1]);
}else{
push(@command,"STACK:".$name[1].random_hex_color(6)."A0:".$name[1]);
push(@command,"STACK:".$name[1].$color."A0:".$name[1]);
}
$count++;
}
Expand Down Expand Up @@ -983,17 +989,18 @@ sub updateqosgraph {
@classes = <FILE>;
close FILE;

my $colorIndex = 0;
foreach $classentry (sort @classes){
@classline = split( /\;/, $classentry );
if ( $classline[0] eq $qossettings{'DEV'} ){
$color=random_hex_color(6);
my $colorIndex = 10 + $count % 15;
$color="$color{\"color$colorIndex\"}";
push(@command, "DEF:$classline[1]=$mainsettings{'RRDLOG'}/class_$qossettings{'CLASSPRFX'}-$classline[1]_$qossettings{'DEV'}.rrd:bytes:AVERAGE");

if ($count eq "1") {
push(@command, "AREA:$classline[1]$color:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8]));
} else {
push(@command, "STACK:$classline[1]$color:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8]));

}

push(@command, "GPRINT:$classline[1]:MAX:%8.1lf %sBps"
Expand Down

0 comments on commit e06986e

Please sign in to comment.