Kernel Crash Trace Log: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
Line 21: Line 21:


== Server2 configuration ==
== Server2 configuration ==
Now you can setup a rsyslog service to log the other server or you get the log with nc direct to a console on a remote device.


=== Set up a rsyslog ===
<ol>
<ol>
<li> Create a new file '''/etc/rsyslog.d/01-netconsole-collector.conf''' with the following content:
<li> Create a new file '''/etc/rsyslog.d/01-netconsole-collector.conf''' with the following content:
<pre>
<pre>
# Start UDP server on port 6666
# Start UDP server on port 5555
$ModLoad imudp
$ModLoad imudp
$UDPServerRun 6666
$UDPServerRun 5555


# Define templates
# Define templates
Line 46: Line 48:
<li> Restart rsyslog
<li> Restart rsyslog
<pre>
<pre>
/etc/init.d/rsyslog restart
sysytemctl restart rsyslog
</pre>
</pre>
</li>
</li>
Line 52: Line 54:


* Note: it's good idea to disable this configuration after you have done with debugging because $EscapeControlCharactersOnReceive and $DropTrailingLFOnReception are global options and they change default behaviour of rsyslog.
* Note: it's good idea to disable this configuration after you have done with debugging because $EscapeControlCharactersOnReceive and $DropTrailingLFOnReception are global options and they change default behaviour of rsyslog.
<pre>
 
mv /etc/rsyslog.d/01-netconsole-collector.conf /etc/rsyslog.d/01-netconsole-collector.conf.disabled
=== Output on remote conlsole  ===
/etc/init.d/rsyslog restart
 
</pre>
nc -l -p 5555 -u


== Examination ==
== Examination ==

Revision as of 14:23, 28 November 2016

Introduction

  • Sometimes you are not able to get a trace log of crashed kernel because it is not written into any file in a filesystem. This guide is aimed to help with getting a kernel crash log.
  • The easiest way to archive the goal is to utilize a remote system through network. This example shows the case with two Proxmox VE 2.X hosts. One of them (server1) is the host to debug and another one (server2) is the host to catch a log.
  • Server1 IP: 10.10.10.1
  • Server2 IP: 10.10.10.2

Server1 configuration

Insert the following line to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub

netconsole=<port>@<your ip>/eth0,<port>@<remote logging ip>/<mac address of logging pc> loglevel=7

The hole line locks like this. GRUB_CMDLINE_LINUX_DEFAULT="quiet netconsole=5555@192.168.18.81/eth0,5555@192.168.16.32/0c:c4:7a:44:1e:fe loglevel=7"

To find out your MAC address use on the logging Server/Laptop

ip a

Server2 configuration

Now you can setup a rsyslog service to log the other server or you get the log with nc direct to a console on a remote device.

Set up a rsyslog

  1. Create a new file /etc/rsyslog.d/01-netconsole-collector.conf with the following content:
    # Start UDP server on port 5555
    $ModLoad imudp
    $UDPServerRun 5555
    
    # Define templates
    $template NetconsoleFile,"/var/log/netconsole/%fromhost-ip%.log"
    $template NetconsoleFormat,"%rawmsg%"
    
    # Accept endline characters (unfortunatelly these options are global)
    $EscapeControlCharactersOnReceive off
    $DropTrailingLFOnReception off
    
    # Store collected logs using templates without local ones
    :fromhost-ip, !isequal, "127.0.0.1"     ?NetconsoleFile;NetconsoleFormat
    
    # Discard logs match the rule above
    & ~
    
  2. Restart rsyslog
    sysytemctl restart rsyslog
    
  • Note: it's good idea to disable this configuration after you have done with debugging because $EscapeControlCharactersOnReceive and $DropTrailingLFOnReception are global options and they change default behaviour of rsyslog.

Output on remote conlsole

nc -l -p 5555 -u

Examination

  • We can check if everything works by causing kernel crash intentionally (be careful!, it's going to be a real crash), type the following command on server1
echo c > /proc/sysrq-trigger
  • Server1 will crash and you should get a crash log in /var/log/netconsole/10.10.10.1.log on server2