]> git.treefish.org Git - bitvalue.git/commitdiff
Use http request to check webpage availability
authorAlexander Schmidt <alex@treefish.org>
Wed, 15 Nov 2017 22:01:23 +0000 (23:01 +0100)
committerAlexander Schmidt <alex@treefish.org>
Wed, 15 Nov 2017 22:01:23 +0000 (23:01 +0100)
bitvalue

index 1454cab95547d91181757f3fec9c7c1d990e1e58..1c080812deb9cb4cc9d104087a92a98aa2815367 100755 (executable)
--- a/bitvalue
+++ b/bitvalue
@@ -42,8 +42,15 @@ fi
 
 source $CONFIG
 
-if ! ping -c 1 $HOST >/dev/null 2>&1; then
-    echo "Host $HOST is unreachable!"
+URL="https://$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
 
@@ -53,8 +60,7 @@ 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&timespan=$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