Skip to content

Instantly share code, notes, and snippets.

@Dih5
Last active March 18, 2016 08:16
Show Gist options
  • Save Dih5/61fb204bbbfc8dc6bed3 to your computer and use it in GitHub Desktop.
Save Dih5/61fb204bbbfc8dc6bed3 to your computer and use it in GitHub Desktop.
Check the CPU use of the system, including number of threads in use
#!/bin/bash
CPUUSE=`top -b -n2 | grep "Cpu(s)" | tail -1 | sed -e 's/[^0-9]*\([0-9][0-9]*[\.\,][0-9]\).*/\1/'`
CORES=`cat /proc/cpuinfo | grep -i 'processor' | wc -l`
USEDCORES=`echo "scale=1;$CPUUSE * $CORES / 100" | bc`
echo CPU used: $CPUUSE% Threads: $USEDCORES/$CORES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment