原数据:
/ # zpool list -HvPo name,size,alloc,free,ckpoint,expandsz,frag,cap,dedup,health
data 596G 2.08G 594G - - 0% 0% 1.00x ONLINE
raidz1-0 596G 2.08G 594G - - 0% 0.34% - ONLINE
/dev/vdb1 - - - - - - - - ONLINE
/dev/vdc1 - - - - - - - - ONLINE
/dev/vdd1 - - - - - - - - ONLINE
data2 298G 2.42M 298G - - 0% 0% 1.00x ONLINE
raidz1-0 298G 2.42M 298G - - 0% 0.00% - ONLINE
/dev/vdh1 - - - - - - - - ONLINE
/dev/vdi1 - - - - - - - - ONLINE
/dev/vdj1 - - - - - - - - ONLINE
data3 179G 2.44M 179G - - 0% 0% 1.00x DEGRADED
raidz1-0 179G 2.44M 179G - - 0% 0.00% - DEGRADED
/dev/vdk1 - - - - - - - - ONLINE
2673216700079444558 - - - - - - - - FAULTED
/dev/vdl1 - - - - - - - - ONLINE
logs - - - - - - - - -
/dev/vdm1 59.5G 0 59.5G - - 0% 0.00% - ONLINE
/dev/vdn1 59.5G 0 59.5G - - 0% 0.00% - ONLINE
cache - - - - - - - - -
/dev/vdo1 - - - - - - - - UNAVAIL
/ #
zpool list -HvPo name,size,alloc,free,ckpoint,expandsz,frag,cap,dedup,health | awk 'BEGIN {str="["} \\
{str = str "{\\"name\\":\\""$1"\\",\\"size\\":\\""$2"\\",\\"alloc\\":\\""$3"\\",\\"free\\":\\""$4"\\",\\"ckpoint\\":\\""$5"\\",\\"expandsz\\":\\""$6"\\",\\"frag\\":\\""$7"\\",\\"cap\\":\\""$8"\\",\\"dedup\\":\\""$9"\\",\\"health\\":\\""$10"\\"},"} \\
END {str = substr(str, 1, length(str)-1) "]"; print str}' | sed 's#"-"#""#g'
show
[
{
"name": "data",
"size": "596G",
"alloc": "2.09G",
"free": "594G",
"ckpoint": "",
"expandsz": "",
"frag": "0%",
"cap": "0%",
"dedup": "1.00x",
"health": "ONLINE"
},
{
"name": "raidz1-0",
"size": "596G",
"alloc": "2.09G",
"free": "594G",
"ckpoint": "",
"expandsz": "",
"frag": "0%",
"cap": "0.35%",
"dedup": "",
"health": "ONLINE"
},
{
"name": "/dev/vdb1",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": "ONLINE"
},
{
"name": "/dev/vdc1",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": "ONLINE"
},
{
"name": "/dev/vdd1",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": "ONLINE"
},
{
"name": "data2",
"size": "298G",
"alloc": "2.42M",
"free": "298G",
"ckpoint": "",
"expandsz": "",
"frag": "0%",
"cap": "0%",
"dedup": "1.00x",
"health": "ONLINE"
},
{
"name": "raidz1-0",
"size": "298G",
"alloc": "2.42M",
"free": "298G",
"ckpoint": "",
"expandsz": "",
"frag": "0%",
"cap": "0.00%",
"dedup": "",
"health": "ONLINE"
},
{
"name": "/dev/vdh1",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": "ONLINE"
},
{
"name": "/dev/vdi1",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": "ONLINE"
},
{
"name": "/dev/vdj1",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": "ONLINE"
},
{
"name": "data3",
"size": "179G",
"alloc": "2.44M",
"free": "179G",
"ckpoint": "",
"expandsz": "",
"frag": "0%",
"cap": "0%",
"dedup": "1.00x",
"health": "DEGRADED"
},
{
"name": "raidz1-0",
"size": "179G",
"alloc": "2.44M",
"free": "179G",
"ckpoint": "",
"expandsz": "",
"frag": "0%",
"cap": "0.00%",
"dedup": "",
"health": "DEGRADED"
},
{
"name": "/dev/vdk1",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": "ONLINE"
},
{
"name": "2673216700079444558",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": "FAULTED"
},
{
"name": "/dev/vdl1",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": "ONLINE"
},
{
"name": "logs",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": ""
},
{
"name": "/dev/vdm1",
"size": "59.5G",
"alloc": "0",
"free": "59.5G",
"ckpoint": "",
"expandsz": "",
"frag": "0%",
"cap": "0.00%",
"dedup": "",
"health": "ONLINE"
},
{
"name": "/dev/vdn1",
"size": "59.5G",
"alloc": "0",
"free": "59.5G",
"ckpoint": "",
"expandsz": "",
"frag": "0%",
"cap": "0.00%",
"dedup": "",
"health": "ONLINE"
},
{
"name": "cache",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": ""
},
{
"name": "/dev/vdo1",
"size": "",
"alloc": "",
"free": "",
"ckpoint": "",
"expandsz": "",
"frag": "",
"cap": "",
"dedup": "",
"health": "UNAVAIL"
}
]