脚本新增未扩展磁盘容量
Posted ssslinppp
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了脚本新增未扩展磁盘容量相关的知识,希望对你有一定的参考价值。
当前物理存储容量
df -h /data | grep data | awk ‘{print$(NF-4)}‘
新增未扩展磁盘容量
#!/bin/bash
#################################################
# Create by liulin
# 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}‘`
echo " [$dev_disk] size is: $diskSize" >> $log_getUnExtendDisk
diskSizeCount=$[ diskSizeCount + diskSize ]
echo "curr diskSizeCount is: [$diskSizeCount]" >> $log_getUnExtendDisk
fi
done
echo -e "----------------------------\n diskSizeCount : $diskSizeCount" >> $log_getUnExtendDisk
echo $diskSizeCount
附件列表
以上是关于脚本新增未扩展磁盘容量的主要内容,如果未能解决你的问题,请参考以下文章