Skip to content

Instantly share code, notes, and snippets.

@eXtrem0us
Created August 27, 2017 11:49
Show Gist options
  • Save eXtrem0us/c2531fd9c6898c71fba9d8eabcede5b3 to your computer and use it in GitHub Desktop.
Save eXtrem0us/c2531fd9c6898c71fba9d8eabcede5b3 to your computer and use it in GitHub Desktop.
get essential info from remote hosts
#!/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