#!/bin/bash export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin HOST_INFO=host.info for IP in $(awk '/^[^#]/ {print $1}' $HOST_INFO); do USER=$(awk -v ip=$IP 'ip==$1 {print $2}' $HOST_INFO) PORT=$(awk -v ip=$IP 'ip==$1 {print $3}' $HOST_INFO) TMP_FILE=/tmp/disk.tmp ssh -p $PORT $USER@$IP 'df -h' > $TMP_FILE USE_RATE_LIST=$(awk -v OFS="=" '/^\/dev/ {print $NF, int($5)}' $TMP_FILE) for USE_RATE in $USE_RATE_LIST; do PART_NAME=${USE_RATE%=*} USE_RATE=${USE_RATE#*=} if [ $USE_RATE -ge 80 ]; then echo -e "$IP \n Warning: $PART_NAME Partition usage ${USE_RATE}%!" fi done done # Usage: # ssh-keygen # ssh-copy-id -p <PORT> <USER>@<IP> # HOST_INFO: # <IP> <USER> <PORT>