bdf의 결과를 GB단위로 보여주는 스크립트
2015.10.27 00:20
원문 : http://www.ischo.net -- 조인상 // 시스템 엔지니어
Writer : http://www.ischo.net -- ischo // System Engineer in Replubic Of Korea
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
원문 : http://www.ischo.net -- 조인상 //시스템 엔지니어
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
HP-UX의 bdf 명령어는 KB단위로 파일시스템 사용량 테이블을 보여주기 때문에
GB단위로 보고자 할때 불편하다.
아래의 스크립트를 gdf 라는 이름으로 심볼릭링크를 걸어서 사용하면 편리하다.
#!/usr/bin/ksh
######################################################################################
# script by ischo.
# http://www.ischo.net
# mail:chosim1@naver.com
# script description :
# This script read first bdf command list, then convert to GB format
######################################################################################
# SET INITIAL VAR values
FILESYSTEM=0
TOTAL=0
USED=0
FREE=0
PERCENT=0
MOUNT_POINT=0
COUNT=1
# PRINT TITLE
echo "FILESYSTEM TOTAL(GB) USED(GB) LV_FREE(GB) USED(%) MOUNT_POINT" | awk '{printf "%-30s %13s %13s %13s %13s %-20s\n",$1,$2,$3,$4,$5,$6}'
echo =========================================================================================================
# PRINT ALLOCATION TABLES
for LINE in `bdf`
do
# skip first lines for TITLE low
if [ $COUNT -le 7 ]
then
COUNT=`expr $COUNT + 1`
continue
else
case "`expr $COUNT \% 7`" in
1)
FILESYSTEM=$LINE
COUNT=`expr $COUNT + 1`
;;
2)
TOTAL=$LINE
COUNT=`expr $COUNT + 1`
;;
3)
USED=$LINE
COUNT=`expr $COUNT + 1`
;;
4)
FREE=$LINE
COUNT=`expr $COUNT + 1`
;;
5)
PERCENT=$LINE
COUNT=`expr $COUNT + 1`
;;
6)
MOUNT_POINT=$LINE
COUNT=8
echo $FILESYSTEM $TOTAL $USED $FREE $PERCENT $MOUNT_POINT | awk '{printf "%-30s %13.2f %13.2f %13.2f %13.2f %-20s\n",$1,$2/1024/1024,$3/1024/1024,$4/1024/1024,$3/$2*100,$6}'
;;
esac
fi
done
좋은 정보 감사합니다.