Script to check Disk space in all remonte servers in network

#!/bin/bash
# ssh password less login is required

# mention below remote server seperated by space

remote_srv=(192.168.1.1 192.168.1.2  )

do_ssh() {
    ssh $s “$@”
    echo -e
}

header() {
    echo “#==================={$@}==========================#”
}

n=${#remote_srv[@]} # number of ip’s in array

for (( i=0;i<$n;i++)); do
            echo -e
            echo “$(tput bold)$(tput setaf 2)* Connected Server: ${remote_srv[$i]}  @@ $(date) @@”
            echo “* Fetching info…$(tput sgr 0)”
            s=${remote_srv[$i]}

            header “Disk Usage”
            do_ssh df -h
done

## EOF

  • March 30, 2016 | 15 views