Skip to content

Instantly share code, notes, and snippets.

@countbuggula
Last active June 1, 2016 22:53
Show Gist options
  • Save countbuggula/99ffcaa2d15af740ef9ffdbfa571aa84 to your computer and use it in GitHub Desktop.
Save countbuggula/99ffcaa2d15af740ef9ffdbfa571aa84 to your computer and use it in GitHub Desktop.
hardware info
#!/bin/bash
# Syntax: while read server; do ./hardware <user> $server && echo "" ; done < serverlist.txt > hardware.txt
ssh_user=$1
ssh_host=$2
command_string="hostname && cat /proc/cpuinfo | grep 'model name' | sort -u && echo -e 'Cores:' && cat /proc/cpuinfo | grep 'core id' | sort -u | wc -l && cat /proc/meminfo | grep MemTotal && df -hl -x tmpfs | gawk -v hostname=$line '$1 ~ /^[0-9]+$/{sum += $1;} END{print hostname \" Total: \" (sum/1024/1024) \"G\";}'""
ssh -n -o BatchMode=yes -o StrictHostKeyChecking=no $ssh_user@$ssh_host $command_string 2>&1| grep -v "tput" | sed 's/^/ /g'
@countbuggula
Copy link
Author

Creates a text file listing CPU model, number of cores, total memory, and disk space for a group of servers. To use, create serverlist.txt with each IP address or URL on a new line. Requires login with ssh key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment