[smokeping-users] Standard Deviation in Smokeping
Rui Meireles
rmeireles at tec.dsr.telecom.pt
Thu Jan 22 17:27:02 CET 2009
Regarding (and closing) this subject, I'll send a little contribution, the
script I made to automatically store a weekly chart of values:
SYNOPSIS:
./smokeping_stats.pl -d <directory> -s <days> [ -e] [ -D]
PARAMETERS:
-e : Output in Microsoft EXCEL mode
-D : DEBUG
----------------------------------------
1 - Save the attached file into /opt/scripts/smokeping/smokeping_stats.pl
2 - Add this line in /etc/crontab:
1 2 * * 0 root /opt/scripts/smokeping/smokeping_stats.pl -d
/usr/smokeping/data/WAN/BBIP/ -s 7 > /opt/log/smokeping_stats/
`date "+%Y%m%d"`-BBIP-week.log 2>&1
----------------------------------------
Output:
2009/01/22 16:19:01 Estatisticas dos ultimos 7 dias.
Equipamento RTT Med(ms) RTT Max(ms) RTT Min(ms) Perdas
Med(%) STD Med(ms) RTT Med/STD Med
BE-ALM1 11.025 12.085 10.413 0.022321% 7.953 1.386309
BE-ARE1 10.293 12.527 9.013 0.027183% 11.803 0.872061
BE-AV1 5.759 6.129 5.579 0.027282% 5.38 1.070431
...
Some comments and variable names are in Portuguese, but it should be easy
enough to change them. Hope it helps someone in need... ;)
Regards,
Rui
-----Original Message-----
From: Rui Meireles [mailto:rmeireles at tec.dsr.telecom.pt]
Sent: quarta-feira, 21 de Janeiro de 2009 18:42
To: 'Tobias Oetiker'
Cc: smokeping-users at lists.oetiker.ch
Subject: Re: [smokeping-users] Standard Deviation in Smokeping
Thanks Tobi. Using that function (calc_stddev) and digging Smokeping.pm I
was able to make a script to calculate all the values shown in the Legend of
"Overview graphs".
Here's what I did, it might help someone:
(I cannot be a sponsor, but I'll look at your Amazon wishlist ;) )
Regards,
Rui
##################################################################
#!/usr/bin/perl -w
use strict;
my $rrd = "/usr/smokeping/data/WAN/MPLS/CR-PCS1.rrd";
my $i = 0; # No slaves
my $max = 100000;
my $interval_s = "-s -86400"; # 1 day
my @G = ();
# Determine number of datasources
my $pings = 0;
my $cmd1 = "/usr/bin/rrdtool info $rrd |grep \"ds\\[ping\"";
my @out = `$cmd1`;
foreach(@out) {
# Search last datasource. Ex: ds[ping20]
if(/^ds\[ping(\d+)\]/) {
$pings = $1 if($1 > $pings);
}
}
# Fetch info
push @G,
"/usr/bin/rrdtool graph $rrd $interval_s",
"DEF:median$i=${rrd}:median:AVERAGE",
"DEF:loss$i=${rrd}:loss:AVERAGE",
"CDEF:ploss$i=loss$i,$pings,/,100,*",
"CDEF:dm$i=median$i,0,$max,LIMIT",
calc_stddev($rrd,$i,$pings),
"CDEF:dmlow$i=dm$i,sdev$i,2,/,-",
"CDEF:s2d$i=sdev$i",
"VDEF:avmed$i=median$i,AVERAGE",
"VDEF:avsd$i=sdev$i,AVERAGE",
"CDEF:msr$i=median$i,POP,avmed$i,avsd$i,/",
"VDEF:avmsr$i=msr$i,AVERAGE",
"PRINT:avmed$i:%lf",
"PRINT:ploss$i:AVERAGE:%lf",
"PRINT:avsd$i:%lf",
"PRINT:avmsr$i:%lf";
my $cmd2 = join(" ", @G);
my $out = `$cmd2`;
print $out;
sub calc_stddev {
my $rrd = shift;
my $id = shift;
my $pings = shift;
my @G = map
{("DEF:pin${id}p${_}=${rrd}:ping${_}:AVERAGE","CDEF:p${id}p${_}=pin${id}p${_
},UN,0,pin${id}p${_},IF")} 1..$pings;
push @G, "CDEF:pings${id}="."$pings,p${id}p1,UN,".join(",",map
{"p${id}p$_,UN,+"} 2..$pings).",-";
push @G, "CDEF:m${id}="."p${id}p1,".join(",",map {"p${id}p$_,+"}
2..$pings).",pings${id},/";
push @G, "CDEF:sdev${id}=p${id}p1,m${id},-,DUP,*,".join(",",map
{"p${id}p$_,m${id},-,DUP,*,+"} 2..$pings).",pings${id},/,SQRT";
return @G;
}
##################################################################
-----Original Message-----
From: Tobias Oetiker [mailto:tobi at oetiker.ch]
Sent: quarta-feira, 21 de Janeiro de 2009 16:01
To: Rui Meireles
Cc: smokeping-users at lists.oetiker.ch
Subject: RE: [smokeping-users] Standard Deviation in Smokeping
Today Rui Meireles wrote:
> Tobi,
>
> Thanks a lot for the quick answer.
>
> I hadn't notice the difference between SD in Overview graphs and SD in
> Detail Graphs. Now I get it!
>
> What I need is exactly the value "av sd" that is being shown in the
Overview
> graphs. If you could help me with the rrdtool command that I should use to
> fetch that value, I would be most grateful, since I've already been
> "digging" smokeping.cgi but haven't found how to do it yet.
the heart of the operation is this function here:
sub calc_stddev {
my $rrd = shift;
my $id = shift;
my $pings = shift;
my @G = map
{("DEF:pin${id}p${_}=${rrd}:ping${_}:AVERAGE","CDEF:p${id}p${_}=pin${id}p${_
},UN,0,pin${id}p${_},IF")} 1..$pings;
push @G, "CDEF:pings${id}="."$pings,p${id}p1,UN,".join(",",map
{"p${id}p$_,UN,+"} 2..$pings).",-";
push @G, "CDEF:m${id}="."p${id}p1,".join(",",map {"p${id}p$_,+"}
2..$pings).",pings${id},/";
push @G, "CDEF:sdev${id}=p${id}p1,m${id},-,DUP,*,".join(",",map
{"p${id}p$_,m${id},-,DUP,*,+"} 2..$pings).",pings${id},/,SQRT";
return @G;
}
> Congratulations on this (and many other) projects, they sure are priceless
> tools!
well if you want to encurrage future development of the tools, you are
welcome to become a sponsor:
there are awfully few sponsors for the smokeping project
http://oss.oetiker.ch/smokeping/sponsors.en.html
cheers
tobi
--
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smokeping_stats.pl
Type: application/octet-stream
Size: 8064 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/smokeping-users/attachments/20090122/33d842a6/attachment.obj
More information about the smokeping-users
mailing list