How to Extract some Fields from Real Time Output of a Command in Bash script
I want to extract some fields out of output of command xentop. It's like
top command; provides an ongoing look at cpu usage,memory usage,...in real
time. If I run this command in batch mode, I will have its output as you
see in a file:
NAME STATE CPU(sec) CPU(%) MEM(k) MEM(%) MAXMEM(k) MAXMEM(%)
VCPUS NETS NETTX(k) NETRX(k) VBDS VBD_OO VBD_RD VBD_WR
VBD_RSECT VBD_WSECT SSID
Domain-0 -----r 13700 33.0 7127040 85.9 no limit n/a
8 0 0 0 0 0 0 0 0
0 0
fed18 -----r 738 190.6 1052640 12.7 1052672 12.7
3 1 259919 8265 1 0 82432 22750
2740966 1071672 0
and running this
cat file| tr '\r' '\n' | sed 's/[0-9][;][0-9][0-9][a-Z]/ /g' | col -bx |
awk '{print $1,$4,$6}'
on this file gives me what I want
NAME CPU(%) MEM(%)
Domain-0 33.0 85.9
fed18 190.6 12.7
but my script doesn't work on realtime output of xentop. I even tried to
just run xentop one time by setting itteration option as 1(xentop -i 1)
but It does not work! How can I pipe output of xentop as "not" realtime to
my script?
No comments:
Post a Comment