#!/bin/bash
#                       /usr/local/bin/silver.rrd.create
#  http://crystalfaeries.net/posix/bin/silver.rrd.create
# celeste:crystalfaery 2016-04-20 08:22:20+00:00
# create our silver rrd database
/usr/local/bin/silverlog				# agregate data
line="`head -n 1 /usr/local/share/ag/silverlog.txt`"	# oldest data-point
price=$(echo $line | sed 's/^.*KitCoAg: //g')		# oldest price
datstr="$(echo $line | sed 's/ KitCoAg.*$//g')"		# oldest date-time
datim=$(date -d "$datstr" +%s)				# in UNIX format
rrdtool create /usr/local/share/ag/silver.rrd \
	-s $datim \
	--step 300 \
	DS:silver:GAUGE:600:0:100 \
	RRA:AVERAGE:0.5:1:1200 \
	RRA:MIN:0.5:12:2400 \
	RRA:MAX:0.5:12:2400 \
	RRA:LAST:0.5:12:2400 \
	RRA:HWPREDICT:1440:0.1:0.0035:288:3 \
	RRA:DEVPREDICT:1440:5 \
	RRA:SEASONAL:288:0.1:2 \
	RRA:DEVSEASONAL:288:0.1:2 \
	RRA:FAILURES:288:7:9:5
exit	$?


syntax highlighted by Code2HTML, v. 0.9.1