Created
August 27, 2017 11:49
-
-
Save eXtrem0us/c2531fd9c6898c71fba9d8eabcede5b3 to your computer and use it in GitHub Desktop.
get essential info from remote hosts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USEPRIVKEY="-i ~/.ssh/open.key" | |
#Put your server hostnames here: | |
for line in {server1,server2,server3} | |
do | |
echo "$line:" | |
echo -n "CPU Cores:" | |
ssh -q $USEPRIVKEY $line "cat /proc/cpuinfo | grep processor | wc -l" | |
echo -n "Total Memory:" | |
ssh -q $USEPRIVKEY $line "cat /proc/meminfo | tr -s ' ' | grep MemTotal | cut -d' ' -f2" | |
echo -n "Free Memory:" | |
ssh -q $USEPRIVKEY $line "cat /proc/meminfo | tr -s ' ' | grep MemFree | cut -d' ' -f2" | |
echo -n "Free Disk Space:" | |
ssh -q $USEPRIVKEY $line "df -h --total | grep total | tr -s ' ' | cut -d' ' -f4" | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment