1. #!/bin/bash
    2. HOST_INFO=host.info
    3. for IP in $(awk '/^[^#]/{print $1}' $HOST_INFO); do
    4. USER=$(awk -v ip=$IP 'ip==$1{print $2}' $HOST_INFO)
    5. PORT=$(awk -v ip=$IP 'ip==$1{print $3}' $HOST_INFO)
    6. TMP_FILE=/tmp/disk.tmp
    7. ssh -p $PORT $USER@$IP 'df -h' > $TMP_FILE
    8. USE_RATE_LIST=$(awk 'BEGIN{OFS="="}/^\/dev/{print $NF,int($5)}' $TMP_FILE)
    9. for USE_RATE in $USE_RATE_LIST; do
    10. PART_NAME=${USE_RATE%=*}
    11. USE_RATE=${USE_RATE#*=}
    12. if [ $USE_RATE -ge 80 ]; then
    13. echo "Warning: $PART_NAME Partition usage $USE_RATE%!"
    14. fi
    15. done
    16. done