# [rrd-users] Creating a XmR control chart.

John P. Rouillard rouilj at cs.umb.edu
Tue Jan 20 22:06:37 CET 2009

```Hi folks:

I am trying to get rrdtool to produce an XmR control chart.
For example:

http://gunston.gmu.edu/708/XmR.asp

The data is throughput data measured in Kbits/sec that is gathered
once per hour. So given:

bw1
bw2
bw3
bw4
bw5
bw6

I need to calculate:

the mean of the bw data (bw1+...+bwN)/N

the mean of the absolute values of the pairwise differences:
(|bw1-bw2|, |bw2-bw3|...,|bwN-1 - bwN|)/(N-1)

I was trying to use:

rrdtool create test.rrd  --step 3600 \
DS:bandwidth:GAUGE:7200:0:U \
DS:mR:COMPUTE:PREV(bandwidth),bandwidth,-,DUP,0,LT,-1,1,IF,* \
RRA:LAST:0.5:1:712

to record the bandwidth, and the absolute value of the pairwise
differences in bandwidth. I am using rrdtool 1.2, so I don't have the
ABS function hence the '-1, 1, IF *'.  Then an "rrdtool update
N:bandwidth" would generate all the values so I can graph them using:

rrdtool DEF=bandwidth=test.rrd:bandwidth:LAST \
VDEF=centerline=bandwidth,AVERAGE \
VDEF=mRbar=mR,AVERAGE \
CDEF=UCL=centerline,2.66,mRbar,*,+ \
CDEF=LCL=centerline,2.66,mRbar,*,- \
LINE:UCL:UCL \
LINE:LCL:LCL \
LINE:bandwidth:bandwidth

to get the bandwidth data points graphed between it's control limits.
(For the sticklers, LCL needs to be set to 0 if it is < 0 and that can
be done with a DUP,0,GT,1,0,if,*.)

But this method doesn't work because you can't use PREV() in a compute
DS 8-(.

So I was thinking of using:

rrdtool create test.rrd  --step 3600 \
DS:bandwidth:GAUGE:7200:0:U \
DS:mR:DERIVE:7200:0:U \
RRA:AVERAGE:0.5:1:712

and using 'rrdtool update N:bandwidth:bandwidth'. But this gives me
positive and negative values in mR, and I need only positive values.

So does anybody have a recipe for a standard XmR chart using rrdtool?

--
-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.

```