【原创】Erlang 之 erl_crash.dump 文件分析

简介:
      先看一下坚强兄的博文     [Erlang 0057] Erlang 排错利器: Erlang Crash Dump Viewer     中说了什么:  
1. 基于 crashdump_viewer 的 web 页面进行查看  
crashdump_viewer:start().
补充:  
The Crashdump Viewer is an HTML based tool for browsing Erlang crashdumps. Crashdump Viewer runs under the WebTool application.
2. 基于 recon 的  erl_crashdump_analyzer.sh 分析脚本   进行查看  

-=-=-=-=- 我是88界奥斯卡颁奖礼的分隔线 -=-=-=-=-  

文章中设计到两种工具,下面分别说明  

【crashdump_viewer】  

 
 
 
 
 
 
 
 
 
 
 
 


  erl_crashdump_analyzer.sh    

      该工具是 recon 工具中的其中一个,详细信息可以
  参考其 github 上的说明  

      下面给出 erl_crashdump_analyzer.sh 内容的注释说明
 。 
[root@YOYO Erlang]# vi erl_crashdump_analyzer.sh 

#!/usr/bin/env bash
DUMP=$1

echo -e "analyzing $DUMP, generated on: " `head -2 $DUMP | tail -1` "\n"   -- echo -e 表示接受 \ 转义;

### SLOGAN ###
grep Slogan: $DUMP -m 1         -- 仅过滤出一条(即第一条)含有 "Slogan:" 的信息

### MEMORY ###                  -- 内存使用情况统计
echo -e "\nMemory:\n==="
M=`grep -m 1 'processes' $DUMP | sed "s/processes: //"`    -- 获取 "processes: " 后的数值(字节)
let "m=$M/(1024*1024)"
echo "  processes: $m Mb"
M=`grep -m 1 'processes_used' $DUMP | sed "s/processes_used: //"`
let "m=$M/(1024*1024)"
echo "  processes_used: $m Mb"
M=`grep -m 1 'system' $DUMP | sed "s/system: //"`
let "m=$M/(1024*1024)"
echo "  system: $m Mb"
M=`grep -m 1 'atom' $DUMP | sed "s/atom: //"`
let "m=$M/(1024*1024)"
echo "  atom: $m Mb"
M=`grep -m 1 'atom_used' $DUMP | sed "s/atom_used: //"`
let "m=$M/(1024*1024)"
echo "  atom_used: $m Mb"
M=`grep -m 1 'binary' $DUMP | sed "s/binary: //"`
let "m=$M/(1024*1024)"
echo "  binary: $m Mb"
M=`grep -m 1 'code' $DUMP | sed "s/code: //"`
let "m=$M/(1024*1024)"
echo "  code: $m Mb"
M=`grep -m 1 'ets' $DUMP | sed "s/ets: //"`
let "m=$M/(1024*1024)"
echo "  ets: $m Mb"
M=`grep -m 1 'total' $DUMP | sed "s/total: //"`
let "m=$M/(1024*1024)"
echo -e "  ---\n  total: $m Mb"

### PROCESS MESSAGE QUEUES LENGTHS ###
echo -e "\nDifferent message queue lengths (5 largest different):\n==="
grep 'Message queue len' $DUMP | sed 's/Message queue length: //g' | sort -n -r | uniq -c | head -5   -- 排序所有进程的消息队列长度,取消息数最多的 5 个显示出来

### ERROR LOGGER QUEUE LENGTH ###
echo -e "\nError logger queue length:\n==="
grep -C 10 'Name: error_logger' $DUMP -m 1| grep 'Message queue length' | sed 's/Message queue length: //g'  -- 匹配第一条 "Name: error_logger" 行,同时输出其上下各 10 行数据,从这些数据中匹配 'Message queue length: ' 获取其对应值

### PORT/FILE DESCRIPTOR INFO ###
echo -e "\nFile descriptors open:\n==="
echo -e "  UDP: "   `grep 'Port controls linked-in driver:' $DUMP | grep 'udp_inet' | wc -l`  -- udp_inet 对应 UDP 端口使用
echo -e "  TCP: "   `grep 'Port controls linked-in driver:' $DUMP | grep 'tcp_inet' | wc -l`  -- tcp_inet 对应 UDP 端口使用
echo -e "  Files: " `grep 'Port controls linked-in driver:' $DUMP | grep -vi 'udp_inet' | grep -vi 'tcp_inet' | wc -l`  -- 去除 udp_inet 和 tcp_inet 对应的行,剩下的对应 FILE 相关使用(efile 或 tty_sl -c -e 等)
echo -e "  ---\n  Total: " `grep 'Port controls linked-in driver:' $DUMP | wc -l`

### NUMBER OF PROCESSES ###
echo -e "\nNumber of processes:\n==="
grep '=proc:' $DUMP | wc -l     -- 统计进程数量(以 "=proc:" 开头的部分对应进程信息开始)

### PROC HEAPS+STACK ###
echo -e "\nProcesses Heap+Stack memory sizes (words) used in the VM (5 largest different):\n==="
grep 'Stack+heap' $DUMP | sed "s/Stack+heap: //g" | sort -n -r | uniq -c | head -5              -- 获取 "Stack+heap: " 字段后的数值,排序后取前 5 

### PROC OLDHEAP ###
echo -e "\nProcesses OldHeap memory sizes (words) used in the VM (5 largest different):\n==="
grep 'OldHeap' $DUMP | sed "s/OldHeap: //g" | sort -n -r | uniq -c | head -5

### PROC STATES ###
echo -e "\nProcess States when crashing (sum): \n==="
grep 'State: ' $DUMP | sed "s/State: //g" | sort | uniq -c               -- 获取发生 crash 时的全部进程状态(例如 Waiting 或 Running)

分析举例  
[root@YOYO Erlang]# ./erl_crashdump_analyzer.sh erl_crash.dump 
analyzing erl_crash.dump, generated on:  Thu Oct 8 09:51:53 2015 

Slogan: init terminating in do_boot ()

Memory:
===
  processes: 13 Mb
  processes_used: 13 Mb
  system: 24 Mb
  atom: 0 Mb
  atom_used: 0 Mb
  binary: 0 Mb
  code: 18 Mb
  ets: 0 Mb
  ---
  total: 38 Mb

Different message queue lengths (5 largest different):
===
     43 0

Error logger queue length:
===
0

File descriptors open:
===
  UDP:  0
  TCP:  2
  Files:  4
  ---
  Total:  6

Number of processes:
===
43

Processes Heap+Stack memory sizes (words) used in the VM (5 largest different):
===
      4 6772
      3 4185
      2 2586
      3 1598
      5 987

Processes OldHeap memory sizes (words) used in the VM (5 largest different):
===
      1 46422
      1 17731
      2 10958
      3 4185
      1 2586

Process States when crashing (sum): 
===
      1 Running
     42 Waiting
[root@YOYO Erlang]#

从上面的输出中,可以看到

  • 内存的分配量和使用量
  • 消息队列信息
  • 文件描述符使用信息
  • 堆+栈内存使用量


补充:
      在 lib/observer-2.0/priv/bin 路径下还有一个 cdv 脚本封装了针对 crashdump_viewer 的调用



目录
相关文章
|
2月前
|
XML 运维 监控
【深入探究 C++ 日志库清理策略】glog、log4cplus 和 spdlog 的日志文件管理策略
【深入探究 C++ 日志库清理策略】glog、log4cplus 和 spdlog 的日志文件管理策略
83 0
都8102年了,还用fastq-dump,快换fasterq-dump吧
之前写过一篇文章Fastq-dump: 一个神奇的软件, 详细介绍了fastq-dump的用法。 虽然fastq-dump参数很多,而且一直被吐槽参数说明写的太差,但是如果真的要用起来其实也就是一行代码 fastq-dump --gzip --split-3 --defline-qual '+' --defline-seq '@$ac-$si/$ri' SRRXXXXX| SRRXXXX.sra # 加上--gzip后需要时间进行文件压缩 当然除了参数问题,还有一个让人诟病的地方就是他只能单个线程,所以速度特别的慢。
4785 0
都8102年了,还用fastq-dump,快换fasterq-dump吧
VisualVM导入dump提示“不是有效的核心dump”
VisualVM导入dump提示“不是有效的核心dump”
556 0
VisualVM导入dump提示“不是有效的核心dump”
|
存储 API C++
dump系列(2)C++程序异常或内存错误,导致闪退的解决办法:分析dump文件
dump系列(2)C++程序异常或内存错误,导致闪退的解决办法:分析dump文件
1677 0
|
Linux 测试技术
软件测试Linux面试题:三种查看server.log的文件内容
软件测试Linux面试题:三种查看server.log的文件内容
375 0
|
NoSQL 网络协议 Linux
【GDB调试】Linux Core Dump分析经典案例之一
这次我们一起来看一下在GDB调试中属于比较典型的案例,因此也借这篇文章向大家阐述个人在分析Core Dump时的一些思路。
5080 0
|
C++ Windows
dump解析入门-用VS解析dump文件进行排障
突然有一天部署在服务器的一个应用挂掉了,没办法只能进入服务器打开     【事件查看器】查看下,好不容易找到了打开后一脸懵逼       事件查看器查到的内容根本对我们排障没有任何作用。 在这个时候如果有对应的dump文件就能派上用场了, 只要有dump文件就能查到应用挂掉那刻的一手情报,可能有人认为分析dump文件是非常难的事情, 但是最近不断有新的dump分析工具出来,例如用vs2017就能够很简单的分析dump文件。
3751 0
|
监控 开发工具 索引
使用Logging Handler自动上传Python程序日志到日志服务
想要日志上云,又不想修改程序代码? 或者不希望进行相对复杂的客户端部署?那么您需要使用Logging Handler,现在Python程序也支持了!
3952 0
|
数据库 关系型数据库 Oracle