# Core dump分析

## 修改core dump存储位置

`/proc/sys/kernel/core_pattern` 设置了生成core文件的路径，参考 `man core`

```
echo '/tmp/core_%e.%p' | sudo tee /proc/sys/kernel/core_pattern
```

上述命令可以使得core文件保存在`/tmp`目录下的 `core_[program].[pid]`

## 设置sysrq和nmi

* 启用sysrq

```
echo 1 | sudo tee /proc/sys/kernel/unknown_nmi_panic
```

* 启用nmi

```
echo 1 | sudo tee /proc/sys/kernel/sysrq
```

* 触发crash

```
echo c | sudo tee /proc/sysrq-trigger
```

* 也可以通过ipmi再次发送nmi（终极大招）

```
ipmitool -I lanplus -H <OOB_IP> -U <USERNAME> -P <PASSWORD> chassis power diag
```

> [排查XEN服务器hang机core dump](https://github.com/huataihuang/cloud-atlas-draft/tree/6f3204fffc11cf006abd394631e2598d98b415c3/os/linux/kernel/tracing/analysis_xen_hang_core_dump/README.md)的一个实战案例

## 参考

* [Changing location of core dump](http://stackoverflow.com/questions/16048101/changing-location-of-core-dump)
* [Generating an NMI through IPMI](http://www.ibm.com/support/knowledgecenter/linuxonibm/liaai.crashdump/liaaicrashdumpnmiipmi.htm)
* [How to trigger SysRq from ipmitool and ipmiconsole using the SysRq magic keys over an HP iLO4 ?](https://github.com/huataihuang/cloud-atlas-draft/tree/6f3204fffc11cf006abd394631e2598d98b415c3/os/linux/kernel/tracing/How%20to%20trigger%20SysRq%20from%20ipmitool%20and%20ipmiconsole%20using%20the%20SysRq%20magic%20keys%20over%20an%20HP%20iLO4%20?/README.md)
* [How to do SOL (Serial Over LAN aka Console Redirection) on Dell Servers](https://www.symantec.com/connect/articles/how-do-sol-serial-over-lan-aka-console-redirection-dell-servers)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huataihuang.gitbook.io/cloud-atlas-draft/os/linux/kernel/tracing/core_dump_analysis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
