Chinaunix首页 | 论坛 | 博客
  • 博客访问: 542352
  • 博文数量: 32
  • 博客积分: 5359
  • 博客等级: 大校
  • 技术积分: 1535
  • 用 户 组: 普通用户
  • 注册时间: 2005-01-04 20:39
文章分类

全部博文(32)

文章存档

2011年(1)

2010年(1)

2009年(6)

2008年(24)

我的朋友

分类:

2009-12-04 00:26:40

    AIX平台要查看最耗内存的进程可以用svmon命令,但此命令的输出看不出相关进程的命令全貌,为解决这个问题,写了个mtop()函数,在AIX5.2、5.3、6.1上测试通过:
mtop() {
svmon -Pt $1 | awk -v sq="'" -v dq='"' '
/^--/{a=1}
$1=="Vsid"{
  system("echo;ps alxww "pid"|awk -F: -v OFS=: "sq"length($0)>200{for(i=2;i<=NF;i++){gsub("dq" "dq","dq" )
  a=0
  }
a{print;if($1~/[1-9]/){pid=$1}}'
}

    又由于有些命令选项很多,尤其是java类的进程,CMD部分输出好几行,看着就眼晕,所以对这些长命令的CMD,特意将空格后自动补一个换行符。下面是AIX5.3上查看最耗内存的两个进程的例子:
16:27:19 2
-------------------------------------------------------------------------------
     Pid Command          Inuse      Pin     Pgsp  Virtual 64-bit Mthrd  16MB
  315462 java             30858     9183    53903    83473      Y     Y     N

     PageSize      Inuse        Pin       Pgsp    Virtual
     s   4 KB      14730       9135      53343      62993
     m  64 KB       1008          3         35       1280


     F S UID    PID   PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
242001 A   0 315462      1   4  60 20 23c9510 189080 20212       *      - 128:37
/usr/IBM/WebSphere/AppServer/java/bin/java
-Declipse.security
-Dwas.status.socket=32831
-Dosgi.install.area=/usr/IBM/WebSphere/AppServer
-Dosgi.configuration.area=/usr/IBM/WebSphere/AppServer/profiles/dmgr01/configuration
-Djava.awt.headless=true
-Dosgi.framework.extensions=com.ibm.cds
-Xshareclasses:name=webspherev61_%g,groupAccess,nonFatal
-Xscmx50M
-Xbootclasspath/p:/usr/IBM/WebSphere/AppServer/java/jre/lib/ext/ibmorb.jar:/usr/IBM/WebSphere/AppServer/java/jre/lib/ext/ibmext.jar
-classpath
/usr/IBM/WebSphere/AppServer/profiles/dmgr01/properties:/usr/IBM/WebSphere/AppServer/properties:/usr/IBM/WebSphere/AppServer/lib/startup.jar:/usr/IBM/WebSphere/AppServer/lib/bootstrap.jar:/usr/IBM/WebSphere/AppServer/lib/j2ee.jar:/usr/IBM/WebSphere/AppServer/lib/lmproxy.jar:/usr/IBM/WebSphere/AppServer/lib/urlprotocols.jar:/usr/IBM/WebSphere/AppServer/deploytool/itp/batchboot.jar:/usr/IBM/WebSphere/AppServer/deploytool/itp/batch2.jar:/usr/IBM/WebSphere/AppServer/java/lib/tools.jar
-Dibm.websphere.internalClassAccessMode=allow
-Xms50m
-Xmx256m
-Dws.ext.dirs=/usr/IBM/WebSphere/AppServer/java/lib:/usr/IBM/WebSphere/AppServer/profiles/dmgr01/classes:/usr/IBM/WebSphere/AppServer/classes:/usr/IBM/WebSphere/AppServer/lib:/usr/IBM/WebSphere/AppServer/installedChannels:/usr/IBM/WebSphere/AppServer/lib/ext:/usr/IBM/WebSphere/AppServer/web/help:/usr/IBM/WebSphere/AppServer/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime
-Dderby.system.home=/usr/IBM/WebSphere/AppServer/derby
-Dcom.ibm.itp.location=/usr/IBM/WebSphere/AppServer/bin
-Djava.util.logging.configureByServer=true
-Duser.install.root=/usr/IBM/WebSphere/AppServer/profiles/dmgr01
-Djavax.management.builder.initial=com.ibm.ws.management.PlatformMBeanServerBuilder
-Dwas.install.root=/usr/IBM/WebSphere/AppServer
-Dpython.cachedir=/usr/IBM/WebSphere/AppServer/profiles/dmgr01/temp/cachedir
-Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogManager
-Dserver.root=/usr/IBM/WebSphere/AppServer/profiles/dmgr01
-Djava.security.auth.login.config=/usr/IBM/WebSphere/AppServer/profiles/dmgr01/properties/wsjaas.conf
-Djava.security.policy=/usr/IBM/WebSphere/AppServer/profiles/dmgr01/properties/server.policy
com.ibm.wsspi.bootstrap.WSPreLauncher
-nosplash
-application
com.ibm.ws.bootstrap.WSLauncher
com.ibm.ws.runtime.WsServer
/usr/IBM/WebSphere/AppServer/profiles/dmgr01/config
cbsCell
ST-FREECellManager01
dmgr

-------------------------------------------------------------------------------
     Pid Command          Inuse      Pin     Pgsp  Virtual 64-bit Mthrd  16MB
  405566 java             30177     9190    63936    93470      Y     Y     N

     PageSize      Inuse        Pin       Pgsp    Virtual
     s   4 KB      14049       9142      63376      72990
     m  64 KB       1008          3         35       1280


     F S UID    PID   PPID   C PRI NI ADDR  SZ  RSS   WCHAN    TTY  TIME CMD
242001 A   0 405566      1   5  60 20 2c71e510 228980 17688       *      - 151:33
/usr/IBM/WebSphere/AppServer/java/bin/java
-Declipse.security
-Dwas.status.socket=32968
-Dosgi.install.area=/usr/IBM/WebSphere/AppServer
-Dosgi.configuration.area=/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/configuration
-Dosgi.framework.extensions=com.ibm.cds
-Xshareclasses:name=webspherev61_%g,groupAccess,nonFatal
-Xscmx50M
-Xbootclasspath/p:/usr/IBM/WebSphere/AppServer/java/jre/lib/ext/ibmorb.jar:/usr/IBM/WebSphere/AppServer/java/jre/lib/ext/ibmext.jar
-classpath
/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/properties:/usr/IBM/WebSphere/AppServer/properties:/usr/IBM/WebSphere/AppServer/lib/startup.jar:/usr/IBM/WebSphere/AppServer/lib/bootstrap.jar:/usr/IBM/WebSphere/AppServer/lib/j2ee.jar:/usr/IBM/WebSphere/AppServer/lib/lmproxy.jar:/usr/IBM/WebSphere/AppServer/lib/urlprotocols.jar:/usr/IBM/WebSphere/AppServer/deploytool/itp/batchboot.jar:/usr/IBM/WebSphere/AppServer/deploytool/itp/batch2.jar:/usr/IBM/WebSphere/AppServer/java/lib/tools.jar
-Dibm.websphere.internalClassAccessMode=allow
-Xms50m
-Xmx256m
-Dws.ext.dirs=/usr/IBM/WebSphere/AppServer/java/lib:/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/classes:/usr/IBM/WebSphere/AppServer/classes:/usr/IBM/WebSphere/AppServer/lib:/usr/IBM/WebSphere/AppServer/installedChannels:/usr/IBM/WebSphere/AppServer/lib/ext:/usr/IBM/WebSphere/AppServer/web/help:/usr/IBM/WebSphere/AppServer/deploytool/itp/plugins/com.ibm.etools.ejbdeploy/runtime
-Dderby.system.home=/usr/IBM/WebSphere/AppServer/derby
-Dcom.ibm.itp.location=/usr/IBM/WebSphere/AppServer/bin
-Djava.util.logging.configureByServer=true
-Duser.install.root=/usr/IBM/WebSphere/AppServer/profiles/AppSrv01
-Djavax.management.builder.initial=com.ibm.ws.management.PlatformMBeanServerBuilder
-Dwas.install.root=/usr/IBM/WebSphere/AppServer
-Dpython.cachedir=/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/cachedir
-Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogManager
-Dserver.root=/usr/IBM/WebSphere/AppServer/profiles/AppSrv01
-Djava.awt.headless=true
-Djava.security.auth.login.config=/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/properties/wsjaas.conf
-Djava.security.policy=/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/properties/server.policy
com.ibm.wsspi.bootstrap.WSPreLauncher
-nosplash
-application
com.ibm.ws.bootstrap.WSLauncher
com.ibm.ws.runtime.WsServer
/usr/IBM/WebSphere/AppServer/profiles/AppSrv01/config
cbsCell
ST-FREENode01
nodeagent

16:27:23 ]#

    之前还写过几个版本的mtop(),一并贴出来:
mtop() {
svmon -Pt $1 | awk '
/^--/{a=1}
$1=="Vsid"{a=0}
a{print;if ($1~/[1-9]/){system("echo;ps eww "$1)}}'
}
mtop 2

mtop() {
svmon -Pt $1 | awk '
/^--/{a=1}
$1=="Vsid"{a=0}
a{print;if ($1~/[1-9]/){system("echo;ps alxww "$1)}}'
}
mtop 2

mtop() {
svmon -Pt $1 | awk -v sq="'" -v dq='"' '
/^--/{a=1}
$1=="Vsid"{a=0}
a{print;if ($1~/[1-9]/){system("echo;ps -elf | head -1;ps -elf|awk "sq"$4=="dq $1 dq sq)}}'
}
mtop 2

mtop() {
svmon -Pt $1 | awk -v sq="'" -v dq='"' '
/^--/{a=1}
$1=="Vsid"{a=0}
a{print
  if ($1~/[1-9]/){
  system("echo;ps alxww "$1"|awk -F: -v OFS=: "sq"length($0)>200{for(i=2;i<=NF;i++){gsub("dq" "dq","dq" )
  }
 }'
}
mtop 2


========================================================================
任何形式的转载,请写明出处:
email:
blog:    http://www.cublog.cn/u/739/
========================================================================

阅读(2809) | 评论(3) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2009-12-23 15:47:18

:D merry christmas! Free MP3 music at http://www.enginemp3.com

chinaunix网友2009-12-10 03:33:29

猜不到是什么原因。难倒是AIX版本问题?

chinaunix网友2009-12-04 21:21:24

怎么执行没反应啊?