From patchwork Sun Mar 7 14:49:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo-Andres Hofmann X-Patchwork-Id: 3933 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4DtksX4zRsz3xCc for ; Sun, 7 Mar 2021 14:50:08 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4DtksW4FClzZR; Sun, 7 Mar 2021 14:50:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4DtksW2xV4z2xNt; Sun, 7 Mar 2021 14:50:07 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4DtksT6fV6z2xJj for ; Sun, 7 Mar 2021 14:50:05 +0000 (UTC) Received: from arche.uberspace.de (arche.uberspace.de [185.26.156.147]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4DtksQ2Yb4zYH for ; Sun, 7 Mar 2021 14:50:02 +0000 (UTC) Received: (qmail 30784 invoked from network); 7 Mar 2021 14:50:00 -0000 Received: from localhost (HELO localhost) (127.0.0.1) by arche.uberspace.de with SMTP; 7 Mar 2021 14:50:00 -0000 From: Leo-Andres Hofmann To: development@lists.ipfire.org Subject: [PATCH] QoS graphs: Add color mapping table Date: Sun, 7 Mar 2021 15:49:50 +0100 Message-Id: <20210307144950.486-1-hofmann@leo-andres.de> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1615128602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=0wmLko1yIEmmjJRjdFE9rgu3N74n5oyPcL6UnKYKfNk=; b=ofAt2Ye+h06wb2HKho7SSQO7mv4ffnB4PwWDrwe28vgFYbLOFAjZ9cF7106yEqWec2hHeC 4pPCBZgvfGMuKvrsazgAQnQrm3lHkc4T0dZX3DgwP7nJCG1m91jItPqyTgX3EOKsTpJvop D7mabZuv3GmHNiq9nHs8xbuLSu3EsQBx8YQlOARPOez49QvXPib3JqO+j0H9a8MOapgNTH ZvHr1j8R60NM2uAi82nXPlnGqqydQw3O1oOg09ZuSSkCWz5zwB3xtJqJ4xUaMgfdvQpv3S 2txxixJc54vF/7h8qFw8WqB8rs1k9k0rema2CGj77AeLBBYME3RIpHwmW8re6g== ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1615128602; a=rsa-sha256; cv=none; b=jF9OU76fOajd7zdbXqCTC+XotwUspDX1PlX+m9zhYR0EFKLvKF985WvaE6erdskgo7EEJV mgh6aADXh1pUteOsvrsNoLsJDIX8wiFfdx1EuHBxlzLDq0ArFFGwWpL408tRB/4YhlPpcO 8NwNcCvckdc7yXCaQX+RkOyaeplRI8vBEsU2uxguIY34nqcxnChRUHAXHs6RBIq0Di2I93 s3cdju+b4om+S3NTNxIM5Unx6fXAYZfxPV7bqz4XmBPTTSPD+QMcvUMT08/ZAweHDSny3P b50VV9Rei+hJE3FBiJrbMYSFe5kn2PfVy0mr4Rcd2gWxf4ZhCZ8sa/uQiQq8PQ== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-0.33 / 11.00]; RCVD_TLS_LAST(0.00)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_ONE(0.00)[1]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; IP_REPUTATION_HAM(-2.03)[asn: 205766(-0.29), country: DE(-0.01), ip: 185.26.156.147(-0.72)]; MID_CONTAINS_FROM(1.00)[]; R_SPF_ALLOW(-0.20)[+mx]; DMARC_NA(0.00)[leo-andres.de]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:205766, ipnet:185.26.156.0/24, country:DE]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-3.00)[99.99%] X-Rspamd-Queue-Id: 4DtksQ2Yb4zYH Authentication-Results: mail01.ipfire.org; dkim=none; dmarc=none; spf=pass (mail01.ipfire.org: domain of hofmann@leo-andres.de designates 185.26.156.147 as permitted sender) smtp.mailfrom=hofmann@leo-andres.de X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Use the traffic class description field to identify similar classes. This ensures that a class used in both the up- and down-link is printed with matching colors in both graphs. Signed-off-by: Leo-Andres Hofmann --- config/cfgroot/graphs.pl | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/config/cfgroot/graphs.pl b/config/cfgroot/graphs.pl index aced99125..e4c3613fb 100644 --- a/config/cfgroot/graphs.pl +++ b/config/cfgroot/graphs.pl @@ -989,7 +989,7 @@ sub updateqosgraph { my $ERROR=""; my $count="1"; - my $color="#000000"; + my %colorMap = (); # maps traffic classes to graph colors my @command = ( @GRAPH_ARGS, @@ -1013,18 +1013,27 @@ sub updateqosgraph { @classes = ; close FILE; - my $colorIndex = 0; foreach $classentry (sort @classes){ @classline = split( /\;/, $classentry ); + + # create class <-> color mapping + my $colorKey = uc $classline[8]; # upper case class name as key + if(! exists $colorMap{$colorKey}) { + # add missing color to table, use colors 11-25 + my $colorIndex = 11 + ((scalar keys %colorMap) % 15); + $colorMap{$colorKey} = "$color{\"color$colorIndex\"}"; + } + if ( $classline[0] eq $qossettings{'DEV'} ){ - 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"); + # get color to be used for this graph + my $graphColor = $colorMap{$colorKey}; + if ($count eq "1") { - push(@command, "AREA:$classline[1]$color:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8])); + push(@command, "AREA:$classline[1]$graphColor:$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, "STACK:$classline[1]$graphColor:$Lang::tr{'Class'} $classline[1] -".sprintf("%15s",$classline[8])); } push(@command, "GPRINT:$classline[1]:MAX:%8.1lf %sBps"