shell脚本--获取程序进程相关性能参数
2018-03-13 21:44
627 查看
获取某进程的线程数量 PID=$1 ThreadNumresult=`ps -eL| grep "$PID " | wc -l` echo $ThreadNumresult 获取某进程的handle 数量 PID=$1 getHandleNumber(){HandleNumresult=`lsof -n|grep " $PID " | awk '{print $2}'| grep $PID | wc -l`echo $HandleNumresult} resultnum=`getHandleNumber $PID`echo ${resultnum} 获取进程消耗CPU PID=$1result1=`top -bn 1 -p $PID|grep $PID|awk '{print $9}'| cut -f 1 -d "."` echo $result1 获取Old老年代内存 PID=$1result=`su ossuser -c "/opt/LinuxTools/zxg_sh/jdk/bin/jstat -gcold $PID" | awk '{print $6}'| grep -v OU` echo $result 获取Enden内存 PID=$1result=`su ossuser -c "/opt/LinuxTools/zxg_sh/jdk/bin/jstat -gcnew $PID" | awk '{print $9}'| grep -v EU` echo $result 获取物理内存 shellpath=`pwd` PID=$1 ResultDir=$2 phymem=$(top -bn 1 -p $PID|grep $PID|awk '{print $6}') if [ ${phymem:0-1:1} = "t" ] then phymemKb=$(echo $phymem|sed "s/\.//g"|sed "s/t/000000/g") elseif [ ${phymem:0-1:1} != "g" ] then phymemKb=$(echo $phymem|sed "s/m/000/g") elif [ ${phymem:0-5:1} == "." ] then phymemKb=$(echo $phymem|sed "s/\.//g"|sed "s/g/000/g") else phymemKb=$(echo $phymem|sed "s/g/000000/g") fi fi echo `expr $(($phymemKb/1000))` 获取虚拟内存 shellpath=`pwd` PID=$1 ResultDir=$2 virmem=$(top -bn 1 -p $PID|grep $PID|awk '{print $5}')if [ ${virmem:0-1:1} != "g" ] then virmemKb=$(echo $virmem|sed "s/m/000/g") elif [ ${virmem:0-5:1} == "." ] then virmemKb=$(echo $virmem|sed "s/\.//g"|sed "s/g/000/g") else virmemKb=$(echo $virmem|sed "s/g/000000/g") fi echo `expr $(($virmemKb/1000))`
相关文章推荐
- 程序向 shell脚本传递参数且获取shell的输出
- linux C程序中获取shell脚本输出
- linux c程序中获取shell脚本输出
- linux C程序中获取shell脚本输出(如获取system命令输出)
- linux c程序中获取shell脚本输出
- 使用Shell脚本查找程序对应的进程ID,并杀死进程
- loadrunner接口性能测试获取返回参数再传参脚本
- linux C程序中获取shell脚本输出(如获取system命令输出)
- linux c程序中获取shell脚本输出
- linux C 程序中获取shell脚本输出
- shell脚本之参数的获取
- shell 脚本之获取命令输出字符串以及函数参数传递
- shell脚本中如何获取命令的参数(2) ----处理命令参数
- linux c程序中获取shell脚本输出
- linux C程序中获取shell脚本输出(如获取system命令输出)
- linux c程序中获取shell脚本输出
- shell脚本程序函数参数传递
- linux下shell脚本获取网卡参数
- c程序调用shell脚本获取返回值方法
- shell 编程8 获取 java程序的pid 杀死pid 对应的进程