#!/bin/bash ## Copyright © 2016 Bret Human ## https://cynop.me/ ## ## Documentation at: ## https://psi.cynop.me/Caffarius/solcored ## ## For questions or comments write: ## info@cynop.me # # Logs into every server and reports sockets/cores # # Prereq: Next to nothing. SSH? Bash? # # If you don't have an ssh key in your ~/.ssh folder this # is going to be a loooooooooooooooooooooooooooooooooooooo # ooooooooooooooooooooooooooooooooooooong process for you. # Clean up any previous runs... rm result.txt > /dev/null 2>&1 rm result.csv > /dev/null 2>&1 # If started with the -c flag, output a CSV. while getopts "c:" option; do case $option in c) csv=${OPTARG};; esac done # File containing a list of servers to hit: list="~/solServerList" echo "Press CTRL-C to skip a server, CTRL-D to quit the script." echo "" if [ -z "$csv" ]; then #TEXT FILE OUTPUT! for thisHereServer in $(< "$list") ; do trap "echo CTRL-C was pressed" 2 trap "echo CTRL-D was pressed" 1 echo $thisHereServer >>result.txt echo "Trying $thisHereServer..." ssh $thisHereServer 'echo "Vendor: `sudo dmidecode | grep -i vendor | head -1 | cut -d":" -f2 | cut -c2- | cut -d"," -f1`"; \ echo "Product Name: `sudo dmidecode | grep -i "Product Name" | head -1 | cut -d":" -f2 | cut -c2-`"; \ echo "Model: `cat /proc/cpuinfo | grep "model name" | head -1 | cut -d":" -f2 | tr -s " " | cut -c2-`"; \ echo "Sockets: `cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l`"; \ echo "Cores per socket: `egrep -e "core id" -e ^physical /proc/cpuinfo|xargs -l2 echo|sort -u | grep "0 core" | wc -l`"; \ echo "Total threads: `egrep -e "core id" -e ^physical /proc/cpuinfo|xargs -l2 echo|sort -u | wc -l`"'>>result.txt || \ echo "Host unreachable." >>result.txt echo "" >>result.txt done else #CSV FILE OUTPUT! echo "Hostname,Sockets,Cores per Socket,Total threads">result.csv for thisHereServer in $(< "$list") ; do trap "echo CTRL-C was pressed" 2 trap "echo CTRL-D was pressed" 1 echo "Trying $thisHereServer..." ssh $thisHereServer 'echo "`hostname`,`psrinfo -p`,`kstat -m cpu_info|grep -w core_id|uniq|wc -l`,`psrinfo|wc -l`" | tr -s " "'>>result.csv || \ echo "$thisHereServer,Host unreachable." >>result.csv done fi exit 0