Created
April 1, 2022 19:53
-
-
Save lesserfish/95b3dbf03fc66575bd770195540c2f15 to your computer and use it in GitHub Desktop.
Gets CPU usage of different cores
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 | |
declare -a HostArray=("gateway" "puchkin" "deepone" "deeptwo" "deepthree" "curie" "lovelace" "hopper" "hamilton" "mon01" ) | |
echo -n Username: | |
read username | |
echo | |
echo -n Password: | |
read -s password | |
echo | |
for host in ${HostArray[@]}; do | |
sshpass -p$password ssh -q $username@$host exit | |
if [ $? == 0 ] | |
then | |
echo $host | |
sshpass -p$password ssh $username@$host python3 -c '"import psutil;print(psutil.cpu_percent(interval=1, percpu=True))"' | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment