脚本中的案例命令

时间:2018-04-05 09:27:02

标签: bash shell unix case

请在下面找到我的剧本:

#!/bin/bash
clear
echo "Will able to see the percentage of hard disk"
for line in $(cat /home/fk60/gerscript/systemlist/pre-prod.txt)
do
usage=$(ssh $line "df -P |grep '/opt/splunk'" | awk '{print $5}' | cut -d'%' -f1)
echo '-------------------------------------------------------------------------'

echo "Machine name: $( echo $line | cut -d'@' -f2 ) "
    case $usage in
         50 ) echo "when the hard disk is above 50%"
         echo "within limits"
            sudo /home/fk3/scripts/remove_old_data.sh 2880
            ;;
         [5-6][0-9]|7[0-5] ) echo "when the hard disk space is above 50%-75%"
          echo "out of limits"
            sudo /home/fk3/scripts/remove_old_data.sh 1440
            ;;
         7[6-9]|8[0-9]|90 ) echo "when the hard disk space is above 75%-90%"
            sudo /home/fk3/scripts/remove_old_data.sh 720
            ;;
         9[1-9]|100 ) echo "when the hard disk space above 91%"
           sudo  /home/fk3/scripts/remove_old_data.sh 360
            ;;
          * ) echo "Disk space is less than 50%"
            ;;
    esac
done

请找到输出:

输出

Will able to see the percentage of hard disk
-------------------------------------------------------------------------
Machine name: pd01.abc.com
Disk space is less than 50%
-------------------------------------------------------------------------
Machine name: pd02.abc.com
Disk space is less than 50%
-------------------------------------------------------------------------
Machine name: pd04.abc.com
when the hard disk space is above 50%-75%
out of limits
-------------------------------------------------------------------------
Machine name: pd05.abc.com
Disk space is less than 50%
-------------------------------------------------------------------------
Machine name: pd09.abc.com
Disk space is less than 50%
-------------------------------------------------------------------------

我无法获得服务器的百分比并且无法运行第二个脚本,如果第二个脚本也支持相同的百分比,则会根据数字(2880,1440,720,360)删除数据

0 个答案:

没有答案