AIX 下用 ps -o 显示完整的 args

March 5, 2013

AIX 用

ps -ef|grep **

能够顺畅的找到进程的信息,但是同时我要取进程占用的 cpu,mem 等,就要用到 format

ps -eo pid,pcpu,pmem,args
ps -ef -o pid,pcpu,pmem,args

两个命令显示的 args 长度很长,但是遇到变态的 java 进程要监控,命令太长了,最后一节还是被截取了

454736   0.6   3.0 /usr/IBM/WebSphere/AppServer/java/bin/java -Declipse.security -Dwas.status.socket=37388 -Dosgi.install.area=/usr/IBM/WebSphere/AppS
erver -Dosgi.configuration.area=/usr/IBM/WebSphere/AppServer/profiles/crmapp3/configuration -Djava.awt.headless=true -Dosgi.framework.extensions=com.i
bm.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/crmapp3/properties:/usr/IBM/WebSphere/AppServ
er/properties:/usr/IBM/WebSphere/AppServer/lib/startup.jar:/usr/IBM/WebSphere/AppServer/lib/bootstrap.jar:/usr/IBM/WebSphere/AppServer/lib/j2ee.jar:/u
sr/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
-verbose:gc -Xms1536m -Xmx3072m -Dws.ext.dirs=/usr/IBM/WebSphere/AppServer/java/lib:/usr/IBM/WebSphere/AppServer/profiles/crmapp3/classes:/usr/IBM/Web
Sphere/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/WebSph
ere/AppServer/derby -Dcom.ibm.itp.location=/usr/IBM/WebSphere/AppServer/bin -Djava.util.logging.configureByServer=true -Duser.install.root=/usr/IBM/We
bSphere/AppServer/profiles/crmapp3 -Djavax.management.builder.initial=com.ibm.ws.management.PlatformMBeanServerBuilder -Dwas.install.root=/usr/IBM/Web
Sphere/AppServer -Dpython.cachedir=/usr/IBM/WebSphere/AppServer/profiles/crmapp3/temp/cachedir -Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogM
anager -Dserver.root=/usr/IBM/WebSphere/AppServer/profiles/crmapp3 -Xlp64k -Ddefault.client.encoding=GBK -Dfile.encod java

而用 ps -ef 是这样的结果

$ps -ef|grep 37388

  wasadm 454736 258118   0   Feb 27      - 643:25 /usr/IBM/WebSphere/AppServer/java/bin/java -Declipse.security -Dwas.status.socket=37388 -Dosgi.install.area=/usr/IBM/WebSphere/AppServer -Dosgi.configuration.area=/usr/IBM/WebSphere/AppServer/profiles/crmapp3/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/crmapp3/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 -verbose:gc -Xms1536m -Xmx3072m -Dws.ext.dirs=/usr/IBM/WebSphere/AppServer/java/lib:/usr/IBM/WebSphere/AppServer/profiles/crmapp3/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/crmapp3 -Djavax.management.builder.initial=com.ibm.ws.management.PlatformMBeanServerBuilder -Dwas.install.root=/usr/IBM/WebSphere/AppServer -Dpython.cachedir=/usr/IBM/WebSphere/AppServer/profiles/crmapp3/temp/cachedir -Djava.util.logging.manager=com.ibm.ws.bootstrap.WsLogManager -Dserver.root=/usr/IBM/WebSphere/AppServer/profiles/crmapp3 -Xlp64k -Ddefault.client.encoding=GBK -Dfile.encoding=GBK -Duser.language=Zh -Duser.region=CN -Djava.security.auth.login.config=/usr/IBM/WebSphere/AppServer/profiles/crmapp3/properties/wsjaas.conf -Djava.security.policy=/usr/IBM/WebSphere/AppServer/profiles/crmapp3/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/crmapp3/config CRMcell CRMAPP3node crmappserver3 

而我匹配的关键字,正好是最后的 crmappserver3,无奈了

貌似被截取到只显示 2048 个字的 args

参看 http://www.tek-tips.com/viewthread.cfm?qid=861064 老外也没什么好办法

似乎是 AIX 5.3 的 bug http://www-01.ibm.com/support/docview.wss?uid=isg1IZ55706

只能先用 ps -eo pid,pcpu,pmem,args 找,找的同时,将信息存在下来(pid)为key,如果找不到估计遇到了坑爹的 java

换 ps -ef|grep *** 来找,如果找到了,取出 pid ,匹配 存下来的那些信息.


comments powered by Disqus