[smokeping-users] Re: Curl probe graph colors?
Tobias Oetiker
oetiker at ee.ethz.ch
Sat Jan 15 11:53:32 MET 2005
Yesterday Niko Tyni wrote:
> On Fri, Jan 14, 2005 at 10:46:56AM +0100, Sebastian Wiesinger wrote:
> > It works fine but the graph it outputs has some odd colors:
> >
> > http://alita.karotte.org/smokeping/cgi-bin/smokeping.cgi?target=World.USA.ISC
> >
> > What are these big green blocks (and the black ones in the Last 24
> > Hours)? I've never seen these in normal probes.
>
> Looks like you found a bug in Smokeping. With pings = 5, the smokecol()
> subroutine in Smokeping.pm breaks and calculates a wrong color for the
> ping deviating most from the median.
>
> Details: in the sub
>
> sub smokecol ($) {
> my $count = ( shift )- 2 ;
> my $half = int($count/2);
> my @items;
> for (my $i=$count; $i> $half; $i--){
> my $color = int(190/$half * ($i-$half))+50;
> push @items, "AREA:cp".($i+2)."#".(sprintf("%02x",$color) x 3);
> };
> for (my $i=$half; $i >= 0; $i--){
> my $color = int(190/$half * ($half - $i))+64;
> push @items, "AREA:cp".($i+2)."#".(sprintf("%02x",$color) x 3);
> };
> return \@items;
> }
>
> on the first round of the first for loop: $count = 3, $half = 1, $i = 3
> making $color = int(190/1 * (3-1))+50 = 430
>
> As this is >255, it's got more than two digits in hex (1AE).
> So the rrdtool graph line gets #1AE1AE1AE as the color. Apparently
> it takes just the firs six digits, resulting in RGB value 1A E1 AE,
> which seems to match the color you have.
>
> I'll let Tobi figure out the best fix. If you're in a hurry, I'd
> suggest changing the pings value to either 4 or 6.
I would suggest
--- Smokeping.pm~ Sat Jan 15 11:39:39 2005
+++ Smokeping.pm Sat Jan 15 11:51:57 2005
@@ -634,13 +634,14 @@
sub smokecol ($) {
my $count = ( shift )- 2 ;
- my $half = int($count/2);
+ return [] unless $count > 0
+ my $half = $count/2;
my @items;
- for (my $i=$count; $i> $half; $i--){
+ for (my $i=$count; $i > $half; $i--){
my $color = int(190/$half * ($i-$half))+50;
push @items, "AREA:cp".($i+2)."#".(sprintf("%02x",$color) x 3);
};
- for (my $i=$half; $i >= 0; $i--){
+ for (my $i=int($half); $i >= 0; $i--){
my $color = int(190/$half * ($half - $i))+64;
push @items, "AREA:cp".($i+2)."#".(sprintf("%02x",$color) x 3);
};
cheers
tobi
>
--
______ __ _
/_ __/_ / / (_) Oetiker @ ISG.EE, ETL F24.2, ETH, CH-8092 Zurich
/ // _ \/ _ \/ / System Manager, Time Lord, Coder, Designer, Coach
/_/ \.__/_.__/_/ http://people.ee.ethz.ch/oetiker +41(0)44-632-5286
--
Unsubscribe mailto:smokeping-users-request at list.ee.ethz.ch?subject=unsubscribe
Help mailto:smokeping-users-request at list.ee.ethz.ch?subject=help
Archive http://www.ee.ethz.ch/~slist/smokeping-users
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the smokeping-users
mailing list