## Variables
rrd_path="/tmp"
rrd_name="rrdtest-seconds"


# remove for testing
rm -v $rrd_path/test.png
rm -v $rrd_path/$rrd_name.rrd


## Check for present rrd
if [[ ! -f $rrd_path/$rrd_name.rrd ]]; then
    echo "RoundRobinDatabase $rrd_path/$rrd_name.rrd does not exist, creating:"
    echo
    rrdtool create $rrd_path/$rrd_name.rrd \
            --step 1000 \
            --start 1000000000 \
            DS:variable:GAUGE:2000:0:U \
            RRA:MAX:0.5:1:10
fi

timestamp1="1000001000"
timestamp2="1000002000"
timestamp3="1000003000"
timestamp4="1000004000"
timestamp5="1000005000"
timestamp6="1000006000"
timestamp7="1000007000"

variable1="1"
variable2="2"
variable3="3"
variable4="4"
variable5="5"
variable6="6"
variable7="7"


rrdtool updatev -t variable $rrd_path/$rrd_name.rrd $timestamp1:$variable1
rrdtool updatev -t variable $rrd_path/$rrd_name.rrd $timestamp2:$variable2
rrdtool updatev -t variable $rrd_path/$rrd_name.rrd $timestamp3:$variable3
rrdtool updatev -t variable $rrd_path/$rrd_name.rrd $timestamp4:$variable4
rrdtool updatev -t variable $rrd_path/$rrd_name.rrd $timestamp5:$variable5
rrdtool updatev -t variable $rrd_path/$rrd_name.rrd $timestamp6:$variable6
rrdtool updatev -t variable $rrd_path/$rrd_name.rrd $timestamp7:$variable7

rrdtool graph $rrd_path/test.png --start end-7000seconds --end 1000007000 DEF:variableDef=$rrd_path/$rrd_name.rrd:variable:MAX LINE2:variableDef#006699 --title="foobar" -w 1024 -h 800 -v "foobars" -X 0

feh $rrd_path/test.png

exit 0

