VolGroup으로  구성되어 있을 때, df -h명령어로 보면 아래와 같이  출력값이 오버가 된다.



평상시에는 상관없지만 , disk 사용량을 shellscript 로 구성할 때는 출력값을 제대로 못 가져올 경우가 있다.
따라서 df -hP 옵션을 주면 출력값은 오버되지 않고 한 줄로 출력된다.


이렇게 출력 되면 disk usage shellscript 짤 때, 쉽게 Use% 값을 구할 수 있다.

<참고 : disk usage script>

#!/bin/bash
s_time=$(date +%Y-%m-%d' '%H:%M:%S)
df -HP | grep -vE '^Filesystem'|awk '{print $5 " " $1 " " $6}' | while read output;
do
  echo $output
  usage=$(echo $output | cut -d'%' -f1  )
  partition=$(echo $output | awk '{ print $2 " " $3 }' )
  if [ $usage -ge 95 ]; then
    echo "Running out of space \"$partition ($usage%)\" on $(hostname) as on $s_time" |
     mail -s "Alert: Almost out of disk space $usage%" root@test.com
  fi
done

Posted by 박물지