0
我們正在讀取一個存儲報告,其中運行了一個包含awk函數的isi-storagepool --list -v
,該函數執行一些計算並在最後打印數據。在awk函數中執行multipal命令
當前工作命令
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