#!/bin/sh -e
#
# Reference script for creating an RRD with the standard origin and extent.
#
# standard interval is 1 minute,
# heartbeat is 5 minutes,
# xff is 1/5
#
# For reference, each RRA requires about 8 bytes per DS per row.
#
#	[DS:ds-name:DST:heartbeat:min:max]
#	[RRA:CF:xff:steps:rows]
#
# $Cambridge: hermes/src/stats/scripts/rrdmk,v 1.5 2004/08/09 17:52:45 fanf2 Exp $

DST=ABSOLUTE

case $1 in
-gauge)
	DST=GAUGE
	shift
esac

# define the RRAs
# total size is 7242 rows or 57K per DS.

# 1 minute intervals for 1 day
RRA1=RRA:AVERAGE:0.2:1:1440

# 15 minute intervals for 15 days (fortnight)
RRA2=RRA:AVERAGE:0.2:15:1440

# 1 hour intervals for 60 days (2 months)
RRA3=RRA:AVERAGE:0.2:60:1440

# 1 day intervals for 4 years
RRA4=RRA:AVERAGE:0.2:1440:1461

# 1 week intervals for 28 years
RRA5=RRA:AVERAGE:0.2:10080:1461


# command line abbreviation
RRDCMD="rrdtool create $1 --start 20040801,00:00 --step 60"
RRDRRA="$RRA1 $RRA2 $RRA3 $RRA4 $RRA5"
shift

# avoid rrdtool's localtime braindamage
export TZ=UTC

# reformat the arguments
DS=''
for arg
do
	DS="$DS DS:$1:$DST:300:0:U"
	shift
done

# do the thing
$RRDCMD	$DS $RRDRRA

exit 0
