首页 > 代码库 > 【脚本】新增未扩展磁盘容量

【脚本】新增未扩展磁盘容量

当前物理存储容量


  1. df -h /data | grep data | awk ‘{print$(NF-4)}‘


新增未扩展磁盘容量


  1. #!/bin/bash
  2. #################################################
  3. # Create by liulin
  4. # 2016912 17:37:57
  5. ##################################################
  6. log_getUnExtendDisk="/data/logs/log_getUnExtendDisk.log"
  7. echo "====================================================" > $log_getUnExtendDisk
  8. echo "Begin to get UnExtendDisk storage at `date "+%Y-%m-%d %H:%M:%S"`" >> $log_getUnExtendDisk
  9. diskSizeCount="0"
  10. fdisk_tmp="/data/fdisk_tmp"
  11. pvs_tmp="/data/pvs_tmp"
  12. diffSet_tmp="/data/diffSet_tmp"
  13. getUnLvmDisk()
  14. {
  15. fdisk -l | grep /dev/[sh]d.: | awk -F ‘ ‘ ‘{print $2}‘ | awk -F ‘:‘ ‘{print $1}‘ > $fdisk_tmp
  16. # pvs | grep /dev/[sh]d. | awk -F ‘ ‘ ‘{print $1}‘ > $pvs_tmp
  17. pvscan | grep /dev/[sh]d. | awk -F ‘ ‘ ‘{print $2}‘ > $pvs_tmp
  18. #get Difference set
  19. # sort $fdisk_tmp $pvs_tmp $pvs_tmp | uniq -u > $diffSet_tmp
  20. grep -F -v -f $pvs_tmp $fdisk_tmp > $diffSet_tmp
  21. echo "-----------------------------" >> $log_getUnExtendDisk
  22. echo "fdisk_info is :" >> $log_getUnExtendDisk
  23. cat $fdisk_tmp >> $log_getUnExtendDisk
  24. echo "pvs_info is :" >> $log_getUnExtendDisk
  25. cat $pvs_tmp >> $log_getUnExtendDisk
  26. echo "diffSet is:" >> $log_getUnExtendDisk
  27. cat $diffSet_tmp >> $log_getUnExtendDisk
  28. echo "----------------------------" >> $log_getUnExtendDisk
  29. rm -rf $fdisk_tmp
  30. rm -rf $pvs_tmp
  31. }
  32. getUnLvmDisk
  33. content=`cat $diffSet_tmp`
  34. for dev_disk in $content then;
  35. do
  36. if [ $dev_disk != "/dev/sda" ] && [ $dev_disk != "/dev/hda" ] && [ `echo $dev_disk | wc -L` == 8 ];then
  37. # echo "+++++++++++++++++ [$dev_disk]"
  38. diskSize=`fdisk -l $dev_disk | grep /dev/[sh]d.: | awk ‘{print $3}‘ | awk -F ‘.‘ ‘{print $1}‘`
  39. echo " [$dev_disk] size is: $diskSize" >> $log_getUnExtendDisk
  40. diskSizeCount=$[ diskSizeCount + diskSize ]
  41. echo "curr diskSizeCount is: [$diskSizeCount]" >> $log_getUnExtendDisk
  42. fi
  43. done
  44. echo -e "----------------------------\n diskSizeCount : $diskSizeCount" >> $log_getUnExtendDisk
  45. echo $diskSizeCount















来自为知笔记(Wiz)


附件列表

     

    【脚本】新增未扩展磁盘容量