net-offline-test
/home/admin/bin>curl -s -w '{"time_connect":%{time_connect},"time_total":%{time_total}}\n' http://10.10.20.202:8000 | jq
{
"time_connect": 0.000524,
"time_total": 0.001895
}
/home/admin/bin>com-net-test 192.168.0.1
{
"address": "192.168.0.1",
"port": "8000",
"time": {
"namelookup": "0.000027",
"connect": "0.000000",
"total": "10.001700"
}
}
construct timeout array
# total > 10.00
# connect == 0.00
/home/admin/bin>cat $SOURCE_JSON | jq '.data' | jq '.[] | select((.time.total | tonumber > 10.0) and (.time.connect | tonumber == 0))' | jq -s > $TMPJSON
calculate json size
/home/admin/bin>JSON_LENGTH=`cat $TMPJSON | jq '. | length' ` ; echo $JSON_LENGTH
2
make offline json
/home/admin/bin>TS=`date "+%Y-%m-%d %H:%M:%S"` ; echo $TS
2024-08-22 22:38:57
/home/admin/bin>(echo '{"name":"offline testing","size":'$JSON_LENGTH',"data":' && ( cat $TMPJSON ) && echo ',"dateInput":"'$TS'"}') | jq
{
"name": "offline net testing",
"size": 2,
"data": [
{
"address": "192.168.0.1",
"port": "8000",
"time": {
"namelookup": "0.000021",
"connect": "0.000000",
"total": "10.001630"
}
},
{
"address": "192.168.0.11",
"port": "8000",
"time": {
"namelookup": "0.000023",
"connect": "0.000000",
"total": "10.001588"
}
}
],
"dateInput": "2024-08-22 22:38:57"
}