惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
aimingoo的专栏
aimingoo的专栏
B
Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
Engineering at Meta
Engineering at Meta
IT之家
IT之家
V
Visual Studio Blog
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
A
About on SuperTechFans
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
N
News and Events Feed by Topic
A
Arctic Wolf
WordPress大学
WordPress大学
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Darknet – Hacking Tools, Hacker News & Cyber Security
F
Fortinet All Blogs
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
T
Threat Research - Cisco Blogs
Latest news
Latest news
Simon Willison's Weblog
Simon Willison's Weblog
Cyberwarzone
Cyberwarzone
S
Schneier on Security
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
L
Lohrmann on Cybersecurity
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
J
Java Code Geeks
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
I
Intezer
L
LangChain Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
G
GRAHAM CLULEY
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
News and Events Feed by Topic
AWS News Blog
AWS News Blog
Attack and Defense Labs
Attack and Defense Labs
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

博客园 - LittlePeng

ffmpeg+x264 Windows MSVC 静态编译 NodeJS Addon 多线程通信 c coroutine leveldb(ssdb)性能、使用场景评估 [微信协议分析] 多媒体 [微信协议分析] 多点登陆 [微信协议分析] 文本消息 paxos(chubby) vs zab(Zookeeper) 分布式一致性算法 erlang 健壮性 tcp 出现rst情况整理 tcp_tw_reuse、tcp_tw_recycle 使用场景及注意事项 erlang 故障排查工具 erlang 虚机crash Erlang C1500K长连接推送服务-内存 Erlang C1500K长连接推送服务-性能 redis lua erlang 虚机性能调优 java问题排查总结
erlang 在线生成crashdump
LittlePeng · 2014-12-07 · via 博客园 - LittlePeng

  一般说来抓dump 4种 方式:

     1. erlang:halt(“abort”).

     2. 在erlang shell下输入CTRL C + “大写的A”

     3.等着进程崩溃自己产生dump

     4.kill -SIGUSR1 <pid> (shell 无法进入时可以使用)

  不过4个方式无一不是需要node crash掉,如果我只想sapshot 一份进程状态以便分析呢?

  在google groups 找到答案,现在链接找不到了,分享一下:

crash_dump() ->
    Date = erlang:list_to_binary(rfc1123_local_date()),
    Header = binary:list_to_bin([<<"=erl_crash_dump:0.2\n">>,Date,<<"\nSystem version: ">>]),
    Ets = ets_info(),
    Report = binary:list_to_bin([Header,erlang:list_to_binary(erlang:system_info(system_version)),
                                 erlang:system_info(info),erlang:system_info(procs),Ets,erlang:system_info(dist),
                                 <<"=loaded_modules\n">>,binary:replace(erlang:system_info(loaded),
                                                                        <<"\n">>,<<"\n=mod:">>,[global])]),
    file:write_file("erl_crash.dump",Report).

ets_info() ->
    binary:list_to_bin([ets_table_info(T)||T<-ets:all()]).

ets_table_info(Table) ->
    Info = ets:info(Table),
    Owner = erlang:list_to_binary(erlang:pid_to_list(proplists:get_value(owner,Info))),
    TableN = erlang:list_to_binary(erlang:atom_to_list(proplists:get_value(name,Info))),
    Name = erlang:list_to_binary(erlang:atom_to_list(proplists:get_value(name,Info))),
    Objects = erlang:list_to_binary(erlang:integer_to_list(proplists:get_value(size,Info))),
    binary:list_to_bin([<<"=ets:">>,Owner,<<"\nTable: ">>,TableN,<<"\nName: ">>,Name,
                        <<"\nObjects: ">>,Objects,<<"\n">>]).

rfc1123_local_date() ->
    rfc1123_local_date(os:timestamp()).
rfc1123_local_date({A,B,C}) ->
    rfc1123_local_date(calendar:now_to_local_time({A,B,C}));
rfc1123_local_date({{YYYY,MM,DD},{Hour,Min,Sec}}) ->
    DayNumber = calendar:day_of_the_week({YYYY,MM,DD}),
    lists:flatten(
        io_lib:format("~s, ~2.2.0w ~3.s ~4.4.0w ~2.2.0w:~2.2.0w:~2.2.0w GMT",
                      [httpd_util:day(DayNumber),DD,httpd_util:month(MM),YYYY,Hour,Min,Sec]));
rfc1123_local_date(Epoch) when erlang:is_integer(Epoch) ->
    rfc1123_local_date(calendar:gregorian_seconds_to_datetime(Epoch+62167219200)).

erlang 的crash dump 是一个进程详细信息快照的文本文件,此方式自己拼接一个类似的文件,嗯crash_dumpviewer 会有警告,不过还是很好用。