Skip to content

Instantly share code, notes, and snippets.

@lesserfish
Created April 1, 2022 19:53
Show Gist options
  • Save lesserfish/95b3dbf03fc66575bd770195540c2f15 to your computer and use it in GitHub Desktop.
Save lesserfish/95b3dbf03fc66575bd770195540c2f15 to your computer and use it in GitHub Desktop.
Gets CPU usage of different cores
#!/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