Parade Series - json - jq


net-offline-test

c 复制代码
/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

c 复制代码
# 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

c 复制代码
/home/admin/bin>JSON_LENGTH=`cat $TMPJSON | jq '. | length' ` ; echo $JSON_LENGTH
2

make offline json

c 复制代码
/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"
}
相关推荐
ZhengEnCi5 分钟前
P2L-Matplotlib饼图完全指南-从数据可视化到图表定制的Python绘图利器
python·matlab
曲幽7 分钟前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南
python·fastapi·web·graphql·route·cors·rest·strawberry
用户8358086187911 小时前
基于 Self-RAG 与列表级重排序的进阶 RAG 系统设计与实现
python
Warson_L18 小时前
Python `Annotated` 与 LangGraph Reducer 学习笔记
python
韩师傅18 小时前
海天线算法的前世今生
python·计算机视觉
韩师傅18 小时前
当你的甲方设备过烂,要如何快速出效果?
python·计算机视觉
Warson_L18 小时前
LangGraph的MessageState and HumanMessage
python
韩师傅19 小时前
当你的甲方吐槽天空不够蓝,你应该如何应对
python·计算机视觉
Warson_L19 小时前
python的类&继承
python
Warson_L19 小时前
类型标注/type annotation
python