Created
April 14, 2017 10:15
-
-
Save raymond852/a16466b4a4af7b908a73b43cc8bfb4c8 to your computer and use it in GitHub Desktop.
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/sh | |
| Interval=2 | |
| #Format: idle,runq-sz,ldavg-1,proc_VmSize,proc_VmRSS | |
| echo "idle,runq-sz,ldavg-1,proc_VmSize,proc_VmRSS" | |
| if [ ! -f /proc/$1/status ]; then | |
| echo "Please specify the correct pid of process as parameter!!!" | |
| exit | |
| fi | |
| while true; do | |
| CPU=`sar -u -q $Interval 1 | grep -v Average | grep -v Linux | grep -v '^$' | \ | |
| { read a && read b && read c && read d; echo "$b $d"; } | \ | |
| awk '{print $9","$12","$14}'` | |
| MEM=`cat /proc/$1/status |grep -e VmSize -e VmRSS|awk {'print $2'}` | |
| VmSize=`echo $MEM | cut -d \ -f 1 | tr -d "\n"` | |
| VmRSS=`echo $MEM | cut -d \ -f 2 | tr -d "\n"` | |
| VMSize1=`expr $VmSize / 1024` | |
| VmRSS1=`expr $VmRSS / 1024` | |
| echo $CPU,$VMSize1,$VmRSS1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment