首页 > 代码库 > 【脚本】新增未扩展磁盘容量
【脚本】新增未扩展磁盘容量
当前物理存储容量
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
来自为知笔记(Wiz)
附件列表
【脚本】新增未扩展磁盘容量
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。