---
title: "使用etop查看系统中进程信息"
author: "litaocheng"
date: "2009-05-29T13:57:06Z"
tags: ["Erlang", "OS", "Windows"]
categories: ["编程语言"]
slug: "etop"
draft: false
lastmod: "2009-05-29T13:57:06Z"
id: 398071
url: "https://erlangdisplay.iteye.com/blog/398071"
---

Erlang提供了丰富的开发工具，你认为没有的时候，很可能是你不知道它存在.

 

在OS中，我们经常查看操作系统的进程信息，帮助我们进行诊断。

 

Erlang提供了一个小工具 etop (Erlang top)， 用来查看Erlang运行环境中，内存，ets，binary，进程等相关信息。

 

这些被收集的信息大部分是通过erlang module的相关bif输出，etop只是做了一个好的展现。

 

etop位于: erlang/lib/observer-xxx/priv/bin 目录下， etop为CLI，getop为GUI表现，在windows下也可以通过调用etop.bat和getop.bat显示相关信息.

 

下面是用法：

./etop Args

 

Args：  
node

被监控的Node

Value: atom()  
Mandatory

setcookie

etop节点的Cookie，必须和被监控节点的Cookie一致  
Value: atom()

lines

显示多少行Process相关信息  
Value: integer()  
Default: 10

interval

刷新频率(秒)  
Value: integer()  
Default: 5

accumulate

数据是否以累加方式显示  
Value: boolean()  
Default: false

sort

Process排序依据  
Value: runtime | reductions | memory | msg\_q  
Default: runtime (reductions if tracing=off )

tracing

etop使用trace机制进行执行时间的检测，当为on时，可以显示runtime，这样作增加了系统负载.

当为off时，无法显示runtime

Value: on | off  
Default: on

例子:  
 etop -node ip@litaocheng -lines 5 -sort memory -interval 1 -accumulate true -tracing on

 

显示信息如下:

写道

========================================================================================  
ip@litaocheng 05:54:40  
Load: cpu 0 Memory: total 69176 binary 42113  
procs 41 processes 23524 code 2307  
runq 0 atom 311 ets 152

Pid Name or Initial Func Time Reds Memory MsgQ Current Function  
\----------------------------------------------------------------------------------------  
&lt;4705.31.0&gt; erlang:apply/2 0 31385517249824 0 shell:get\_command1/5  
&lt;4705.54.0&gt; erlang:apply/2 0 2192005 6171152 0 shell:eval\_loop/3  
&lt;4705.26.0&gt; code\_server 0 171428 131756 0 code\_server:loop/1  
&lt;4705.5.0&gt; application\_controll 0 8560 119080 0 gen\_server:loop/6  
&lt;4705.30.0&gt; group:server/3 0 34084 33972 0 group:get\_line1/3  
\========================================================================================

 其中Memory单位为KB， process中的mmemory为bytes.