X-Git-Url: http://git.treefish.org/~alex/bitvalue.git/blobdiff_plain/81cbb0eaf1f61c07079a990d088c906428dd776a..ada7bd686a459ee6325ac535ee08dbba0e6ba055:/bitvalue?ds=inline diff --git a/bitvalue b/bitvalue index 3f75ff2..0483eb1 100755 --- a/bitvalue +++ b/bitvalue @@ -14,19 +14,19 @@ Arguments: while getopts ':ht:' option; do case "$option" in - h) echo "$USAGE" - exit - ;; - t) TIMESPAN=$OPTARG - ;; - :) printf "missing argument for -%s\n" "$OPTARG" >&2 - echo "$usage" >&2 - exit 1 - ;; - \?) printf "illegal option: -%s\n" "$OPTARG" >&2 - echo "$usage" >&2 - exit 1 - ;; + h) echo "$USAGE" + exit + ;; + t) TIMESPAN=$OPTARG + ;; + :) printf "missing argument for -%s\n" "$OPTARG" >&2 + echo "$usage" >&2 + exit 1 + ;; + \?) printf "illegal option: -%s\n" "$OPTARG" >&2 + echo "$usage" >&2 + exit 1 + ;; esac done shift $((OPTIND - 1)) @@ -42,19 +42,25 @@ fi source $CONFIG -if ! ping -c 1 $HOST >/dev/null 2>&1; then - echo "Host $HOST is unreachable!" +URL="http://$HOST/export_data.csv?\ +currency=$CURRENCY&\ +data_type=price&\ +exchange=$EXCHANGE&\ +t=l&\ +timespan=$TIMESPAN" + +if ! wget -S --spider $URL 2>&1 | grep 'HTTP/1.1 200 OK' >/dev/null; then + echo "Can not retrieve data from $HOST!"; exit 1 fi -cat << EOF | gnuplot +cat << EOF | gnuplot 2>/dev/null set terminal dumb set datafile separator "," set xdata time set timefmt "%Y-%m-%d %H:%M:%S UTC" set title "EXCHANGE: $EXCHANGE | TIMESPAN: $TIMESPAN\nCURRENCY: $CURRENCY | BTC: $BTC " -plot "< wget -q -O - \"https://$HOST/export_data.csv?currency=$CURRENCY&data_type=price&exchange=$EXCHANGE&t=l×pan=$TIMESPAN\"" \ - using 1:(\$3*$BTC) with lines title "" +plot "< wget -q -O - \"$URL\"" using 1:(\$3*$BTC) with lines title "" EOF if [ $? -ne 0 ]; then