-
Notifications
You must be signed in to change notification settings - Fork 0
/
antminer_query.sh
executable file
·22 lines (18 loc) · 1.07 KB
/
antminer_query.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
ips=$@
devs_header=$(echo '{"command": "devs"}' | nc $ips 4028 | jq '.[]?[]? |keys_unsorted| join(",")' | jq -s '[.[]?] | join(",")')
echo "$devs_header"
devs_cmd=$(echo '{"command": "devs"}' | nc $ips 4028 | jq '.[]?[]? | join(",")' | jq -s '[.[]?] | join(",")')
temps_header=$(echo '{"command": "temps"}' | nc $ips 4028 | jq '.[]?[]? |keys_unsorted| join(",")' | jq -s '[.[]?] | join(",")')
echo "$temps_header"
temps_cmd=$(echo '{"command": "temps"}' | nc $ips 4028 | jq '.[]?[]? | join(",")' | jq -s '[.[]?] | join(",")')
details_header=$(echo '{"command": "devdetails"}' | nc $ips 4028 | jq '.[]?[]? |keys_unsorted| join(",")' | jq -s '[.[]] | join(",")')
echo "$details_header"
details_cmd=$(echo '{"command": "devdetails"}' | nc $ips 4028 | jq '.[]?[]? | join(",")' | jq -s '[.[]] | join(",")')
if [ ! -f "$ips.csv" ]; then
header_fmt="Datetime,$devs_header,$temps_header,$details_header"
echo "${header_fmt//\"/}" > "$ips.csv"
fi
date_now=$(date -u --iso-8601=seconds)
csv_fmt="$date_now,$devs_cmd,$temps_cmd,$details_cmd"
echo "${csv_fmt//\"/}"
echo "${csv_fmt//\"/}" >> "$ips.csv"