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.
47 lines
1.2 KiB
47 lines
1.2 KiB
|
|
|
|
function ifup {
|
|
if [[ ! -d /sys/class/net/${1} ]]; then
|
|
return 1
|
|
else
|
|
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
|
|
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' <<<'{}'
|
|
|
|
|