3. OS이야기/03. Shell Script

linux 전체 파일시스템 용량 및 사용량 확인 스크립트

OSSW(Open Source System SoftWare 2014. 6. 18. 10:36

linux에서 시스템 전체 파일시스템의 용량 및 사용량 확인 스크립트     

 

------------------------------------------------------------------------------------------------------

#!/bin/sh

 

 

df -k | awk 'BEGIN { Total_Size=0; Total_Used=0; Total_Avail=0 } { Total_Size += $2; Total_Used += $3 ; Total_Avail += $4 } END { printf("Total Size : %5.1f GB, Total Used : %5.1f GB, Total_Avail : %5.1f GB, Used % : %5.1f %\n", Total_Size/1024/1024, Total_Used/1024/1024, Total_Avail/1024/1024, Total_Used/Total_Size*100) }'

------------------------------------------------------------------------------------------------------

 

< 결과 >

$ df -k

Filesystem 1K-blocks Used Available Use% Mounted on

/dev/xvda3  20642428 659376 18934476 4% /

tmpfs          10194012 0 10194012 0% /dev/shm

/dev/xvda1 1032088 79052 900608 9% /boot

/dev/xvda2 30963708 16381900 13008944 56% /home

/dev/xvda5 20642428 1653392 17940460 9% /usr

/dev/xvda6 20642428 515020 19078832 3% /var

/dev/xvdb1 1028100912 429494932 546381480 45% /app

/dev/xvdc1 516054864 52777072 437063732 11% /data

 

$ df -k | awk 'BEGIN { Total_Size=0; Total_Used=0; Total_Avail=0 } { Total_Size += $2; Total_Used += $3 ; Total_Avail += $4 } END { printf("Total Size : %5.1f GB, Total Used : %5.1f GB, Total_Avail : %5.1f GB, Used % : %5.1f %\n", Total_Size/1024/1024, Total_Used/1024/1024, Total_Avail/1024/1024, Total_Used/Total_Size*100) }'

 

Total Size : 1571.9 GB, Total Used : 478.3 GB, Total_Avail : 1014.2 GB, Used % : 30.4 %

 

 

 

by 이찬호