Date created: Thursday, November 1, 2012 12:18:39 PM. Last modified: Tuesday, September 19, 2017 12:03:19 PM

## RRDTool 95th for Separate In & Out

An explenation of 95th percentile, mean, media and mode: /index.php?page=95th-percentile-and-mean-median-mode
Notes on 95th percentile accuracy with rrdtools: /index.php?page=95th-percentile-accuracy-with-rrdtools

Calculate separate in and out 95th values for the average data sampled:

```#!/bin/bash

datestart=`date -d "-1 month -\$((\$(date +%d)-1)) days 00:00" "+%s"`
dateend=`date -d "-\$(date +%d) days 23:59:59" "+%s"`

rrdtool graph -f '' -s \$datestart -e \$dateend /dev/null \
DEF:in="\$1":traffic_in:AVERAGE \
DEF:out="\$1":traffic_out:AVERAGE \
CDEF:inbits=in,8,* \
CDEF:outbits=out,8,* \
VDEF:95pct_in=inbits,95,PERCENT \
VDEF:95pct_out=outbits,95,PERCENT \
PRINT:95pct_in:"IN='%.2lf %Sb'" \
PRINT:95pct_out:"OUT='%.2lf %Sb'"

root@server:/tmp# ./rrd95th /var/lib/cacti/rra/my_data.rrd

IN='3.92 Mb'
OUT='5.33 Mb'```

Calculate separate in and out 95th values using the maximum data value sampled:

```#!/bin/bash

datestart=`date -d "-1 month -\$((\$(date +%d)-1)) days 00:00" "+%s"`
dateend=`date -d "-\$(date +%d) days 23:59:59" "+%s"`

rrdtool graph -f '' -s \$datestart -e \$dateend /dev/null \
DEF:in="\$1":traffic_in:MAX \
DEF:out="\$1":traffic_out:MAX \
CDEF:inbits=in,8,* \
CDEF:outbits=out,8,* \
VDEF:95pct_in=inbits,95,PERCENT \
VDEF:95pct_out=outbits,95,PERCENT \
PRINT:95pct_in:"IN='%.2lf %Sb'" \
PRINT:95pct_out:"OUT='%.2lf %Sb'"

root@server:/tmp# ./rrd95thmax /var/lib/cacti/rra/the_same_data.rrd

IN='12.72 Mb'
OUT='20.03 Mb'```