From 5868ce90bac2084e48d8a24eb918d20dcff4c67c Mon Sep 17 00:00:00 2001 From: "Bret R. Human" Date: Tue, 21 May 2019 08:06:46 -0400 Subject: [PATCH] initial commit --- LICENSE | 51 ++++++++++++++++++++++++++++++++++++++ README.md | 3 +++ solcored.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 solcored.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5e7b262 --- /dev/null +++ b/LICENSE @@ -0,0 +1,51 @@ +solcored +=== +Copyright (c) 2015, Bret R. Human +All rights reserved. + +Further documentation can be found at + https://psi.cynicaloptimist.me/Caffarius/solcored/ +Happy modding! -Bret + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + the documentation link and note, this list of conditions, and the following + disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: +"Built using software developed by Cynical Optimist - https://cynicaloptimist.me + Ask what we can build for you at info@cynicaloptimist.me" + +4. The names "Cynical Optimist" and "Bret R. Human" and the software name listed + at the top of this document, or the domain "cynicaloptimist.me" or any + affiliated service must not be used to endorse or promote products derived + from this software without prior written permission. For written permission, + contact info@cynicaloptimist.me. + +5. Products derived from this software may not be called the software name + listed at the top of this document nor may "Cynical Optimist" or the software + name listed at the top of this document appear in their names without prior + written permission of Bret R. Human. + +6. Redistributions of any form whatsoever must retain the following + acknowledgment: +"Built using software developed by Cynical Optimist - https://cynicaloptimist.me + Ask what we can build for you at info@cynicaloptimist.me" + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..0ec4839 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# solcored + +This is a quick and dirty script to run through a list of Solaris servers and report machine info like socket numbers and core counts. \ No newline at end of file diff --git a/solcored.sh b/solcored.sh new file mode 100644 index 0000000..ee92913 --- /dev/null +++ b/solcored.sh @@ -0,0 +1,71 @@ +#!/bin/bash +## Copyright © 2016 Bret Human +## https://cynicaloptimist.me/ +## +## Documentation at: +## https://psi.cynicaloptimist.me/Caffarius/solcored +## +## For questions or comments write: +## info@cynicaloptimist.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 \ No newline at end of file