【发布时间】:2017-06-16 14:57:12
【问题描述】:
我们正在获取一个存储报告,我们在其中运行 isi-storagepool --list -v,其中包括一个 awk 函数,该函数进行一些计算并在最后打印数据。
当前工作命令
isi storagepool list -v |awk 'function num2gb(n) { if (n ~ /T$/) return n / 1; return n / 1024; }
/Requested Protection:/ { parity=substr($NF,length($NF)-1,1) }
/Nodes:/ { nodes=$NF }
/HDD Total/ { hdd_total=$NF }
/HDD Used/ { hdd_used=num2gb($NF) }
END {
multiplier=nodes-parity
total=hdd_total/nodes*multiplier
used=hdd_used/nodes
eu=used*multiplier*0.8
et=total*0.8
used1=eu/et*100
print "parity =" parity
print "NodeNumber =" nodes
print "Total = " total " TB"
print "Effective Total volume = " total*0.8 " TB"
print "USED =" used1 " %"
print "Effective used=" used*multiplier*0.8 " TB"
print "Available volume=" (hdd_total-hdd_used)/nodes*multiplier*0.8 " TB" }'
当前工作命令的示例输出
parity =1
NodeNumber =3
Total = 37.3013 TB
Effective Total volume = 29.8411 TB
USED =333975%
Effective used=534360 TB
Available volume=-534330 TB
现在我们想在上面的示例输出中添加更多信息,我们将从以下命令获得。
# isi_classic snapshot usage | tail -n 1
358G n/a (R) 0.63% (T)
所以需求输出应该如下
parity =1
NodeNumber =3
Total = 37.3013 TB
Effective Total volume = 29.8411 TB
USED =333975%
Effective used=534360 TB
Available volume=-534330 TB
Snapshot USED = 358G # added output from the new command # isi_classic snapshot usage
Snapshot USED % = 0.63% # added output from the new command # isi_classic snapshot usage
【问题讨论】: