netconsole.txt 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. started by Ingo Molnar <mingo@redhat.com>, 2001.09.17
  2. 2.6 port and netpoll api by Matt Mackall <mpm@selenic.com>, Sep 9 2003
  3. IPv6 support by Cong Wang <xiyou.wangcong@gmail.com>, Jan 1 2013
  4. Extended console support by Tejun Heo <tj@kernel.org>, May 1 2015
  5. Please send bug reports to Matt Mackall <mpm@selenic.com>
  6. Satyam Sharma <satyam.sharma@gmail.com>, and Cong Wang <xiyou.wangcong@gmail.com>
  7. Introduction:
  8. =============
  9. This module logs kernel printk messages over UDP allowing debugging of
  10. problem where disk logging fails and serial consoles are impractical.
  11. It can be used either built-in or as a module. As a built-in,
  12. netconsole initializes immediately after NIC cards and will bring up
  13. the specified interface as soon as possible. While this doesn't allow
  14. capture of early kernel panics, it does capture most of the boot
  15. process.
  16. Sender and receiver configuration:
  17. ==================================
  18. It takes a string configuration parameter "netconsole" in the
  19. following format:
  20. netconsole=[+][src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr]
  21. where
  22. + if present, enable extended console support
  23. src-port source for UDP packets (defaults to 6665)
  24. src-ip source IP to use (interface address)
  25. dev network interface (eth0)
  26. tgt-port port for logging agent (6666)
  27. tgt-ip IP address for logging agent
  28. tgt-macaddr ethernet MAC address for logging agent (broadcast)
  29. Examples:
  30. linux netconsole=4444@10.0.0.1/eth1,9353@10.0.0.2/12:34:56:78:9a:bc
  31. or
  32. insmod netconsole netconsole=@/,@10.0.0.2/
  33. or using IPv6
  34. insmod netconsole netconsole=@/,@fd00:1:2:3::1/
  35. It also supports logging to multiple remote agents by specifying
  36. parameters for the multiple agents separated by semicolons and the
  37. complete string enclosed in "quotes", thusly:
  38. modprobe netconsole netconsole="@/,@10.0.0.2/;@/eth1,6892@10.0.0.3/"
  39. Built-in netconsole starts immediately after the TCP stack is
  40. initialized and attempts to bring up the supplied dev at the supplied
  41. address.
  42. The remote host has several options to receive the kernel messages,
  43. for example:
  44. 1) syslogd
  45. 2) netcat
  46. On distributions using a BSD-based netcat version (e.g. Fedora,
  47. openSUSE and Ubuntu) the listening port must be specified without
  48. the -p switch:
  49. 'nc -u -l -p <port>' / 'nc -u -l <port>' or
  50. 'netcat -u -l -p <port>' / 'netcat -u -l <port>'
  51. 3) socat
  52. 'socat udp-recv:<port> -'
  53. Dynamic reconfiguration:
  54. ========================
  55. Dynamic reconfigurability is a useful addition to netconsole that enables
  56. remote logging targets to be dynamically added, removed, or have their
  57. parameters reconfigured at runtime from a configfs-based userspace interface.
  58. [ Note that the parameters of netconsole targets that were specified/created
  59. from the boot/module option are not exposed via this interface, and hence
  60. cannot be modified dynamically. ]
  61. To include this feature, select CONFIG_NETCONSOLE_DYNAMIC when building the
  62. netconsole module (or kernel, if netconsole is built-in).
  63. Some examples follow (where configfs is mounted at the /sys/kernel/config
  64. mountpoint).
  65. To add a remote logging target (target names can be arbitrary):
  66. cd /sys/kernel/config/netconsole/
  67. mkdir target1
  68. Note that newly created targets have default parameter values (as mentioned
  69. above) and are disabled by default -- they must first be enabled by writing
  70. "1" to the "enabled" attribute (usually after setting parameters accordingly)
  71. as described below.
  72. To remove a target:
  73. rmdir /sys/kernel/config/netconsole/othertarget/
  74. The interface exposes these parameters of a netconsole target to userspace:
  75. enabled Is this target currently enabled? (read-write)
  76. extended Extended mode enabled (read-write)
  77. dev_name Local network interface name (read-write)
  78. local_port Source UDP port to use (read-write)
  79. remote_port Remote agent's UDP port (read-write)
  80. local_ip Source IP address to use (read-write)
  81. remote_ip Remote agent's IP address (read-write)
  82. local_mac Local interface's MAC address (read-only)
  83. remote_mac Remote agent's MAC address (read-write)
  84. The "enabled" attribute is also used to control whether the parameters of
  85. a target can be updated or not -- you can modify the parameters of only
  86. disabled targets (i.e. if "enabled" is 0).
  87. To update a target's parameters:
  88. cat enabled # check if enabled is 1
  89. echo 0 > enabled # disable the target (if required)
  90. echo eth2 > dev_name # set local interface
  91. echo 10.0.0.4 > remote_ip # update some parameter
  92. echo cb:a9:87:65:43:21 > remote_mac # update more parameters
  93. echo 1 > enabled # enable target again
  94. You can also update the local interface dynamically. This is especially
  95. useful if you want to use interfaces that have newly come up (and may not
  96. have existed when netconsole was loaded / initialized).
  97. Extended console:
  98. =================
  99. If '+' is prefixed to the configuration line or "extended" config file
  100. is set to 1, extended console support is enabled. An example boot
  101. param follows.
  102. linux netconsole=+4444@10.0.0.1/eth1,9353@10.0.0.2/12:34:56:78:9a:bc
  103. Log messages are transmitted with extended metadata header in the
  104. following format which is the same as /dev/kmsg.
  105. <level>,<sequnum>,<timestamp>,<contflag>;<message text>
  106. Non printable characters in <message text> are escaped using "\xff"
  107. notation. If the message contains optional dictionary, verbatim
  108. newline is used as the delimeter.
  109. If a message doesn't fit in certain number of bytes (currently 1000),
  110. the message is split into multiple fragments by netconsole. These
  111. fragments are transmitted with "ncfrag" header field added.
  112. ncfrag=<byte-offset>/<total-bytes>
  113. For example, assuming a lot smaller chunk size, a message "the first
  114. chunk, the 2nd chunk." may be split as follows.
  115. 6,416,1758426,-,ncfrag=0/31;the first chunk,
  116. 6,416,1758426,-,ncfrag=16/31; the 2nd chunk.
  117. Miscellaneous notes:
  118. ====================
  119. WARNING: the default target ethernet setting uses the broadcast
  120. ethernet address to send packets, which can cause increased load on
  121. other systems on the same ethernet segment.
  122. TIP: some LAN switches may be configured to suppress ethernet broadcasts
  123. so it is advised to explicitly specify the remote agents' MAC addresses
  124. from the config parameters passed to netconsole.
  125. TIP: to find out the MAC address of, say, 10.0.0.2, you may try using:
  126. ping -c 1 10.0.0.2 ; /sbin/arp -n | grep 10.0.0.2
  127. TIP: in case the remote logging agent is on a separate LAN subnet than
  128. the sender, it is suggested to try specifying the MAC address of the
  129. default gateway (you may use /sbin/route -n to find it out) as the
  130. remote MAC address instead.
  131. NOTE: the network device (eth1 in the above case) can run any kind
  132. of other network traffic, netconsole is not intrusive. Netconsole
  133. might cause slight delays in other traffic if the volume of kernel
  134. messages is high, but should have no other impact.
  135. NOTE: if you find that the remote logging agent is not receiving or
  136. printing all messages from the sender, it is likely that you have set
  137. the "console_loglevel" parameter (on the sender) to only send high
  138. priority messages to the console. You can change this at runtime using:
  139. dmesg -n 8
  140. or by specifying "debug" on the kernel command line at boot, to send
  141. all kernel messages to the console. A specific value for this parameter
  142. can also be set using the "loglevel" kernel boot option. See the
  143. dmesg(8) man page and Documentation/kernel-parameters.txt for details.
  144. Netconsole was designed to be as instantaneous as possible, to
  145. enable the logging of even the most critical kernel bugs. It works
  146. from IRQ contexts as well, and does not enable interrupts while
  147. sending packets. Due to these unique needs, configuration cannot
  148. be more automatic, and some fundamental limitations will remain:
  149. only IP networks, UDP packets and ethernet devices are supported.