Created
May 22, 2017 04:58
-
-
Save theeye-io/45b29900113353063235cccc1aba5b3b to your computer and use it in GitHub Desktop.
Bash Script monitor to get ETH pricing and compare if pricing is going down.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#This script gets a minum percent as a warning threshold for monitoring ETH value in USD decrease. | |
#Receives | |
# { | |
# "ask": 156.36401186, | |
# "bid": 156.08050201, | |
# "high": "160", | |
# "last": "156.38627418", | |
# "low": "125.27376294", | |
# "timestamp": "1495427025", | |
# "volume": "24449.61369000", | |
# "volume30d": "307424.31339500" | |
# } | |
result=$(curl -X GET https://cex.io/api/ticker/ETH/USD) | |
percent=${1:-0} #Set to first argument or 0 | |
echo $result |tr -s ',' '\n' | |
last=$(echo $result|tr -s ',' '\n'|grep last|cut -d':' -f2|sed -s s/\"//g) | |
low=$(echo $result|tr -s ',' '\n'|grep low|cut -d':' -f2|sed -s s/\"//g) | |
lastToLowProximityInPercent=$(echo "($low*100/$last)"|bc) | |
echo "Last price is %$lastToLowProximityInPercent close to slowest value since yesterday and you set %$percent as threshold" | |
if [ "$lastToLowProximityInPercent" -lt "$percent" ];then | |
echo "Failure" | |
else | |
echo "Normal " | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment