Finding Disk Usage in DomU from Dom0 in Xen
Posted by Tres Sat, 12 Apr 2008 11:48:00 GMT
If you’re trying to monitor disk usage in a Xen domU and are using ext3fs formatted filesystems on LVM partitions, you can use dumpe2fs -h to get an idea of the current disk usage in domU from dom0.
[tres blas.phemo.us ~]$ sudo dumpe2fs -h /dev/vol00/xen_root_img dumpe2fs 1.39 (29-May-2006) Filesystem volume name:Last mounted on: Filesystem UUID: d18fab79-7123-4289-bd28-222ec8739874 Filesystem magic number: 0xEF53 Filesystem revision #: 1 (dynamic) Filesystem features: has_journal resize_inode dir_index filetype needs_recovery sparse_super large_file Default mount options: (none) Filesystem state: clean Errors behavior: Continue Filesystem OS type: Linux Inode count: 311296 Block count: 622592 Reserved block count: 31129 Free blocks: 336965 Free inodes: 256927 First block: 0 Block size: 4096 Fragment size: 4096 Reserved GDT blocks: 151 Blocks per group: 32768 Fragments per group: 32768 Inodes per group: 16384 Inode blocks per group: 512 Filesystem created: Tue Feb 5 18:57:47 2008 Last mount time: Fri Feb 15 14:42:15 2008 Last write time: Fri Feb 15 14:42:15 2008 Mount count: 6 Maximum mount count: 25 Last checked: Tue Feb 5 19:01:06 2008 Check interval: 15552000 (6 months) Next check after: Sun Aug 3 20:01:06 2008 Reserved blocks uid: 0 (user root) Reserved blocks gid: 0 (group root) First inode: 11 Inode size: 128 Journal inode: 8 First orphan inode: 32775 Default directory hash: tea Directory Hash Seed: d3f9829f-e127-427b-be56-4e840a139ccf Journal backup: inode blocks Journal size: 64M
So amongst all of the output, there are three lines that provide the magic: Block count:, Block size: and Free blocks:.
It’s easy enough to grab the three lines and then process them however you need to. This is a link to a ruby script that will check domU disk usage from dom0