On Wed, Jan 26, 2011 at 11:39:19AM +0000, Richard W.M. Jones wrote: > virt-top -b --script --csv /dev/stdout
Or here's another idea ... $ cat spaces.py #!/usr/bin/python import sys import csv out = csv.writer (sys.stdout, delimiter=' ') out.writerows (csv.reader (sys.stdin)) $ virt-top -b --script --csv /dev/stdout | ./spaces.py Hostname Time Arch "Physical CPUs" Count Running Blocked Paused Shutdown Shutoff Crashed Active Inactive %CPU "Total hardware memory (KB)" "Total memory (KB)" "Total guest memory (KB)" "Total CPU time (ns)" "Domain ID" "Domain name" "CPU (ns)" %CPU "Block RDRQ" "Block WRRQ" "Net RXBY" "Net TXBY" spin.home.annexia.org 11:47:58 x86_64 4 0 0 0 0 0 0 0 0 0 0.0 3832252 0 0 0 spin.home.annexia.org 11:48:01 x86_64 4 0 0 0 0 0 0 0 0 0 0.0 3832252 0 0 0 Notes: (1) The output is not line-buffered, so you won't see any output until the program ends. This seems to be a Python problem. (2) There are obviously problems with parsing the title row using naive string splitting (which is why doing it as a CSV is better). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org _______________________________________________ virt-tools-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/virt-tools-list
