You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB

4 years ago
function ifup {
if [[ ! -d /sys/class/net/${1} ]]; then
return 1
else
4 years ago
net=${1}
test_time=2
T1=$(cat /sys/class/net/$net/statistics/tx_bytes)
sleep $test_time
T2=$(cat /sys/class/net/$net/statistics/tx_bytes)
tot=$(( (T2 - T1)))
if [ $tot -eq 0 ]; then
return 1
fi
4 years ago
fi
}
if ifup $1; then
hybridswarm='Online'
else
hybridswarm='NotOnline'
fi
dockerswarm=$(docker info --format "{{json .}}" | jq .Swarm.LocalNodeState)
tempswarm="${dockerswarm%\"}"
tempswarm="${tempswarm#\"}"
dockerswarm=$tempswarm
dockerswarmid=$(docker info --format "{{json .}}" | jq .Swarm.NodeID)
tempswarm1="${dockerswarmid%\"}"
tempswarm1="${tempswarm1#\"}"
swarmlabid=$tempswarm1
#echo $dockerswarm
#echo $hybridswarm
#echo $swarmlabid
#jq --arg key0 'swarmlab' --arg swarmlab $dockerswarm --arg key1 'hybrid' --arg hybrid $hybridswarm --arg key2 'swarmlabid' --arg swarmlabid $swarmlabid'. | .[$key0]=$swarmlab | .[$key1]=$hybrid | .[$key2]=$swarmlabid' <<<'{}'
jq \
--arg key0 'swarmlab' --arg swarmlab $dockerswarm \
--arg key1 'hybrid' --arg hybrid $hybridswarm \
--arg key2 'swarmlabid' --arg swarmlabid $swarmlabid \
'. | .[$key0]=$swarmlab | .[$key1]=$hybrid | .[$key2]=$swarmlabid' <<<'{}'