Files
zabbix-mining/AntMinerGetAllstats
T
2019-05-22 15:21:44 +08:00

23 lines
367 B
Bash
Executable File

#!/bin/bash
up=`/usr/bin/fping -c1 -t300 $1 &> /dev/null ; echo $?`
if [ $up = 0 ]; then
set -o errexit
set -o nounset
ADDRESS=$1
PORT=$2
stats_raw=`echo '{"command":"stats"}' | nc $ADDRESS $PORT | tr -d '\0\n'`
stats_raw=$(sed 's/}{/\},{/' <<< "$stats_raw")
STATS=$(jq '.STATS' <<< "$stats_raw")
#fan_num=$(jq -r '.[1].fan_num' <<< "$STATS")
echo $STATS
fi