当前物理存储容量
df -h /data | grep data | awk '{print$(NF-4)}'
新增未扩展磁盘容量
新增了物理磁盘,但是还未扩展到/data下的磁盘容量
#!/bin/bash
#################################################
# Create by ssslinppp
# 2016912 17:37:57
##################################################
log_getUnExtendDisk="/data/logs/log_getUnExtendDisk.log"
echo "====================================================" > $log_getUnExtendDisk
echo "Begin to get UnExtendDisk storage at `date "+%Y-%m-%d %H:%M:%S"`" >> $log_getUnExtendDisk
diskSizeCount="0"
fdisk_tmp="/data/fdisk_tmp"
pvs_tmp="/data/pvs_tmp"
diffSet_tmp="/data/diffSet_tmp"
getUnLvmDisk()
{
fdisk -l | grep /dev/[sh]d.: | awk -F ' ' '{print $2}' | awk -F ':' '{print $1}' > $fdisk_tmp
# pvs | grep /dev/[sh]d. | awk -F ' ' '{print $1}' > $pvs_tmp
pvscan | grep /dev/[sh]d. | awk -F ' ' '{print $2}' > $pvs_tmp
#get Difference set
# sort $fdisk_tmp $pvs_tmp $pvs_tmp | uniq -u > $diffSet_tmp
grep -F -v -f $pvs_tmp $fdisk_tmp > $diffSet_tmp
echo "-----------------------------" >> $log_getUnExtendDisk
echo "fdisk_info is :" >> $log_getUnExtendDisk
cat $fdisk_tmp >> $log_getUnExtendDisk
echo "pvs_info is :" >> $log_getUnExtendDisk
cat $pvs_tmp >> $log_getUnExtendDisk
echo "diffSet is:" >> $log_getUnExtendDisk
cat $diffSet_tmp >> $log_getUnExtendDisk
echo "----------------------------" >> $log_getUnExtendDisk
rm -rf $fdisk_tmp
rm -rf $pvs_tmp
}
getUnLvmDisk
content=`cat $diffSet_tmp`
for dev_disk in $content then;
do
if [ $dev_disk != "/dev/sda" ] && [ $dev_disk != "/dev/hda" ] && [ `echo $dev_disk | wc -L` == 8 ];then
# echo "+++++++++++++++++ [$dev_disk]"
diskSize=`fdisk -l $dev_disk | grep /dev/[sh]d.: | awk '{print $3}' | awk -F '.' '{print $1}'`
sizeUnit=`fdisk -l $dev_disk | grep /dev/[sh]d.: | awk '{print $4}' | awk -F '.' '{print $1}'`
echo " [$dev_disk] size is: $diskSize$sizeUnit" >> $log_getUnExtendDisk
if [ $sizeUnit = "MB," ];then
diskSize=$[ diskSize / 1024 ]
fi
diskSizeCount=$[ diskSizeCount + diskSize ]
echo "curr diskSizeCount is: [$diskSizeCount]G" >> $log_getUnExtendDisk
fi
done
echo -e "---------------------------- diskSizeCount : $diskSizeCount" >> $log_getUnExtendDisk
echo $diskSizeCount