메뉴 건너뛰기

Korea Oracle User Group

OS

df 명령어 대신 사용할 수 있는 python용 pydf

 

가상환경에서 사용하기 위해 아래와 같이 설치해 본다.

 

[root@kwan21c ~]# python3 -m venv pydf
[root@kwan21c ~]# source pydf/bin/activate
(pydf) [root@kwan21c ~]# python3 -m pip install pydf
Collecting pydf
  Downloading https://files.pythonhosted.org/packages/c7/27/8174d7338be329ea3aabb185a3a19860ea97b8e223b78b21511df529e0fe/pydf-12.tar.gz
Installing collected packages: pydf
  Running setup.py install for pydf ... done
Successfully installed pydf-12
You are using pip version 9.0.3, however version 23.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(pydf) [root@kwan21c ~]#

 

이제 명령어를 사용해 보자.

 

(pydf) [root@kwan21c ~]# pydf
Filesystem            Size  Used Avail Use%                                 Mounted on
/dev/ol_kwan21c/root   50G 8067M   42G 15.8 [#####........................] /         
/dev/sda2            1014M  461M  553M 45.4 [#############................] /boot     
/dev/sda1             599M 5156k  594M  0.8 [.............................] /boot/efi 
/dev/ol_kwan21c/home   30G  270M   30G  0.9 [.............................] /home     
/dev/ol_kwan21c/u01   198G   17G  181G  8.5 [##...........................] /u01      
(pydf) [root@kwan21c ~]

 

명령어의 help 내용을 한번 살펴보자

 

(pydf) [root@kwan21c ~]# pydf --help
Usage: pydf [options] arg
 
Options:
  --help                show this help message
  -v, --version         show version
  -a, --all             include filesystems having 0 blocks
  -h, --human-readable  print sizes in human readable format (e.g., 1K 234M
                        2G)
  -H, --si              likewise, but use powers of 1000 not 1024
  -b BLOCKSIZE, --block-size=BLOCKSIZE
                        use BLOCKSIZE-byte blocks
  -l, --local           limit listing to local filesystems
  -k, --kilobytes       like --block-size=1024
  -m, --megabytes       like --block-size=1048576
  -g, --gigabytes       like --block-size=1073741824
  --blocks              use filesystem native block size
  --bw                  do not use colours
  --mounts=MOUNTS_FILE  File to get mount information from. On normal Linux
                        systems only /etc/mtab or /proc/mounts make sense.
                        Some other Unices use /etc/mnttab. Use /proc/mounts
                        when /etc/mtab is corrupted or inaccessible  (the
                        output looks a bit weird in this case).
  -B, --show-binds      show 'mount --bind' mounts
  -i, --inodes          show inode instead of block usage

 

위와 같은 옵션들이 있다.

 

몇가지 사용예를 확인해 보자

 

(pydf) [root@kwan21c ~]# pydf -a
Filesystem            Size  Used Avail Use%                          Mounted on                     
/dev/ol_kwan21c/root   50G 8067M   42G 15.8 [###...................] /                              
/dev/sda2            1014M  461M  553M 45.4 [##########............] /boot                          
/dev/sda1             599M 5156k  594M  0.8 [......................] /boot/efi                      
devtmpfs             4806M     0 4806M  0.0 [......................] /dev                           
hugetlbfs                0     0     0    - [......................] /dev/hugepages                 
mqueue                   0     0     0    - [......................] /dev/mqueue                    
devpts                   0     0     0    - [......................] /dev/pts                       
tmpfs                4835M     0 4835M  0.0 [......................] /dev/shm                       
/dev/ol_kwan21c/home   30G  270M   30G  0.9 [......................] /home                          
proc                     0     0     0    - [......................] /proc                          
binfmt_misc              0     0     0    - [......................] /proc/sys/fs/binfmt_misc       
tmpfs                4835M   25M 4810M  0.5 [......................] /run                           
gvfsd-fuse               0     0     0    - [......................] /run/user/0/gvfs               
tmpfs                 967M   52k  967M  0.0 [......................] /run/user/54321                
gvfsd-fuse               0     0     0    - [......................] /run/user/54321/gvfs           
sysfs                    0     0     0    - [......................] /sys                           
efivarfs                 0     0     0    - [......................] /sys/firmware/efi/efivars      
none                     0     0     0    - [......................] /sys/fs/bpf                    
tmpfs                4835M     0 4835M  0.0 [......................] /sys/fs/cgroup                 
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/blkio           
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/cpu,cpuacct     
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/cpuset          
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/devices         
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/freezer         
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/hugetlb         
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/memory          
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/net_cls,net_prio
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/perf_event      
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/pids            
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/rdma            
cgroup                   0     0     0    - [......................] /sys/fs/cgroup/systemd         
fusectl                  0     0     0    - [......................] /sys/fs/fuse/connections       
pstore                   0     0     0    - [......................] /sys/fs/pstore                 
configfs                 0     0     0    - [......................] /sys/kernel/config             
debugfs                  0     0     0    - [......................] /sys/kernel/debug              
securityfs               0     0     0    - [......................] /sys/kernel/security           
none                     0     0     0    - [......................] /sys/kernel/tracing            
/dev/ol_kwan21c/u01   198G   17G  181G  8.5 [##....................] /u01                           
sunrpc                   0     0     0    - [......................] /var/lib/nfs/rpc_pipefs  

 

-h 옵션(human readable)으로 사용해 보자

 

(pydf) [root@kwan21c ~]# pydf -h
Filesystem            Size  Used Avail Use%                                 Mounted on
/dev/ol_kwan21c/root   50G 8067M   42G 15.8 [#####........................] /         
/dev/sda2            1014M  461M  553M 45.4 [#############................] /boot     
/dev/sda1             599M 5156k  594M  0.8 [.............................] /boot/efi 
/dev/ol_kwan21c/home   30G  270M   30G  0.9 [.............................] /home     
/dev/ol_kwan21c/u01   198G   17G  181G  8.5 [##...........................] /u01    

 

Gbyte 단위로 표시해 보자

 

(pydf) [root@kwan21c ~]# pydf -g
Filesystem           Size Used Avail Use%                                 Mounted on
/dev/ol_kwan21c/root   50    8    42 15.8 [#####........................] /         
/dev/sda2               1    0     1 45.4 [#############................] /boot     
/dev/sda1               1    0     1  0.8 [.............................] /boot/efi 
/dev/ol_kwan21c/home   30    0    30  0.9 [.............................] /home     
/dev/ol_kwan21c/u01   198   17   181  8.5 [##...........................] /u01   

 

가독성면에서 df 보다는 조금 괜찮은 듯한 명령어입니다.

df에 질렸다면 한번 써봐도 괜찮을 듯 합니다.

 

위로