Skip to content

Instantly share code, notes, and snippets.

@biaocy
Last active December 22, 2017 12:42
Show Gist options
  • Save biaocy/5fddcde133203136e7789a03d6c7fcf6 to your computer and use it in GitHub Desktop.
Save biaocy/5fddcde133203136e7789a03d6c7fcf6 to your computer and use it in GitHub Desktop.
bittrex neo coin alert script
#curl -s https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-neo | awk -F , '{print }' | awk -F : '{print }'
date=`date +"%FT%T"`
log="/var/log/neo.log"
url="https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-neo"
subject="NEO"
threshold="0.003"
mailto="email" # email here
msg=`curl -s $url`
if echo $msg | grep -q "\"success\"\:true"; then
cur_val=`echo $msg | awk -F , '{print $7}' | awk -F : '{print $2}'`
# bash can't compare floating point number, so use 'bc' compare them
anwser=`echo "$cur_val >= $threshold" | bc`
if [ $anwser -eq 1 ]; then
echo "$cur_val >= t$threshold, exceed!" >> $log
mailx -s $subject $mailto << EOF
Fuck $cur_val >= t$threshold, excced!!
EOF
else
echo "$date: $cur_val < t$threshold, not exceed!" >> $log
fi
else
echo "$date: fetch faild! $msg" >> $log
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment