21.7. virt-df: Monitoring Disk Usage
virt-df, which displays file system usage from a disk image or a guest virtual machine. It is similar to the Linux
dfcommand, but for virtual machines.
21.7.2. Running virt-df
virt-df -a /dev/vg_guests/RHEL7Filesystem 1K-blocks Used Available Use% RHEL6:/dev/sda1 101086 10233 85634 11% RHEL6:/dev/VolGroup00/LogVol00 7127864 2272744 4493036 32%
/dev/vg_guests/RHEL7is a Red Hat Enterprise Linux 7 guest virtual machine disk image. The path in this case is the host physical machine logical volume where this disk image is located.)
virt-dfon its own to list information about all of your guest virtual machines known to libvirt. The
virt-dfcommand recognizes some of the same options as the standard
-i(show inodes instead of blocks).
virt-df -h -d domnameFilesystem Size Used Available Use% F14x64:/dev/sda1 484.2M 66.3M 392.9M 14% F14x64:/dev/vg_f14x64/lv_root 7.4G 3.0G 4.4G 41% RHEL6brewx64:/dev/sda1 484.2M 52.6M 406.6M 11% RHEL6brewx64:/dev/vg_rhel6brewx64/lv_root 13.3G 3.4G 9.2G 26%
virt-dfsafely on live guest virtual machines, since it only needs read-only access. However, you should not expect the numbers to be precisely the same as those from a
dfcommand running inside the guest virtual machine. This is because what is on disk will be slightly out of sync with the state of the live guest virtual machine. Nevertheless it should be a good enough approximation for analysis and monitoring purposes.
virt-dfis designed to allow you to integrate the statistics into monitoring tools, databases and so on. This allows system administrators to generate reports on trends in disk usage, and alerts if a guest virtual machine is about to run out of disk space. To do this you should use the
--csvoption to generate machine-readable Comma-Separated-Values (CSV) output. CSV output is readable by most databases, spreadsheet software and a variety of other tools and programming languages. The raw CSV looks like the following:
# virt-df --csv -d RHEL6Guest Virtual Machine,Filesystem,1K-blocks,Used,Available,Use% RHEL6brewx64,/dev/sda1,102396,24712,77684,24.1% RHEL6brewx64,/dev/sda2,20866940,7786652,13080288,37.3%