Created
February 18, 2020 07:57
-
-
Save aamsur-mkt/3529891881d0239b7457dd975478a739 to your computer and use it in GitHub Desktop.
check resource (cpu & memory)
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 | |
## check cpu usage linux | |
## tpk 20190308 | |
cores=`cat /proc/cpuinfo | grep processor | wc -l` | |
c_usage=`ps axfu | grep -v grep | awk '{sum += $3} END {print sum}'` | |
c=`echo "scale=2; $c_usage / $cores" | bc` | |
m_usage=`ps axfu | grep -v grep | awk '{sum += $4} END {print sum}'` | |
echo "cpu:$c mem:$m_usage" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment