11月 152017
 

gops用来查看系统中存在的go进程。

注意事项:

gops有可能没发现你的go进程:

一方面可能进程是藏在容器中的,在宿主机上gops就发现不了

另一种情况,就是gops参考的是进程文件的特征,该特征在不同go版本可能不一样,比如,我的gops能发现go 1.11的go进程,就发现不了go 1.14的go进程

如下:

gops能list出来系统中的go进程,如果内置了agent的话,还能添加个星号,带星号的进程可以进行深度的分析(因为有agent呀)

那么,gops是如何找到所有go进程,又是如何识别出来agent的呢?

关键代码是这么写的:

 

  1. 拿到所有的系统进程
  2. 分析进程文件可以检测是否go进程
  3. 在进程的用户目录下查找 .config/gops/{$pid}  文件,如果存在,就认为是有内置了agent了,该文件中存放的是agentlisten的端口号

如下:

 Posted by at 下午 4:04

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据