TEXT   47

netconsole.txt

Guest on 5th August 2021 01:52:05 AM

  1.  
  2.  
  3.  
  4. Introduction:
  5. =============
  6.  
  7. This module logs kernel printk messages over UDP allowing debugging of
  8. problem where disk logging fails and serial consoles are impractical.
  9.  
  10. It can be used either built-in or as a module. As a built-in,
  11. netconsole initializes immediately after NIC cards and will bring up
  12. the specified interface as soon as possible. While this doesn't allow
  13. capture of early kernel panics, it does capture most of the boot
  14. process.
  15.  
  16. Sender and receiver configuration:
  17. ==================================
  18.  
  19. It takes a string configuration parameter "netconsole" in the
  20. following format:
  21.  
  22.  netconsole=[src-port]@[src-ip]/[<dev>],[tgt-port]@<tgt-ip>/[tgt-macaddr]
  23.  
  24.    where
  25.         src-port      source for UDP packets (defaults to 6665)
  26.         src-ip        source IP to use (interface address)
  27.         dev           network interface (eth0)
  28.         tgt-port      port for logging agent (6666)
  29.         tgt-ip        IP address for logging agent
  30.         tgt-macaddr   ethernet MAC address for logging agent (broadcast)
  31.  
  32. Examples:
  33.  
  34.  linux netconsole=4444@10.0.0.1/eth1,9353@10.0.0.2/12:34:56:78:9a:bc
  35.  
  36.   or
  37.  
  38.  insmod netconsole netconsole=@/,@10.0.0.2/
  39.  
  40. It also supports logging to multiple remote agents by specifying
  41. parameters for the multiple agents separated by semicolons and the
  42. complete string enclosed in "quotes", thusly:
  43.  
  44.  modprobe netconsole netconsole="@/,@10.0.0.2/;@/eth1,6892@10.0.0.3/"
  45.  
  46. Built-in netconsole starts immediately after the TCP stack is
  47. initialized and attempts to bring up the supplied dev at the supplied
  48. address.
  49.  
  50. The remote host can run either 'netcat -u -l -p <port>',
  51. 'nc -l -u <port>' or syslogd.
  52.  
  53. Dynamic reconfiguration:
  54. ========================
  55.  
  56. Dynamic reconfigurability is a useful addition to netconsole that enables
  57. remote logging targets to be dynamically added, removed, or have their
  58. parameters reconfigured at runtime from a configfs-based userspace interface.
  59. [ Note that the parameters of netconsole targets that were specified/created
  60. from the boot/module option are not exposed via this interface, and hence
  61. cannot be modified dynamically. ]
  62.  
  63. To include this feature, select CONFIG_NETCONSOLE_DYNAMIC when building the
  64. netconsole module (or kernel, if netconsole is built-in).
  65.  
  66. Some examples follow (where configfs is mounted at the /sys/kernel/config
  67. mountpoint).
  68.  
  69. To add a remote logging target (target names can be arbitrary):
  70.  
  71.  cd /sys/kernel/config/netconsole/
  72.  mkdir target1
  73.  
  74. Note that newly created targets have default parameter values (as mentioned
  75. above) and are disabled by default -- they must first be enabled by writing
  76. "1" to the "enabled" attribute (usually after setting parameters accordingly)
  77. as described below.
  78.  
  79. To remove a target:
  80.  
  81.  rmdir /sys/kernel/config/netconsole/othertarget/
  82.  
  83. The interface exposes these parameters of a netconsole target to userspace:
  84.  
  85.         enabled         Is this target currently enabled?       (read-write)
  86.         dev_name        Local network interface name            (read-write)
  87.         local_port      Source UDP port to use                  (read-write)
  88.         remote_port     Remote agent's UDP port                 (read-write)
  89.         local_ip        Source IP address to use                (read-write)
  90.         remote_ip       Remote agent's IP address               (read-write)
  91.         local_mac       Local interface's MAC address           (read-only)
  92.         remote_mac      Remote agent's MAC address              (read-write)
  93.  
  94. The "enabled" attribute is also used to control whether the parameters of
  95. a target can be updated or not -- you can modify the parameters of only
  96. disabled targets (i.e. if "enabled" is 0).
  97.  
  98. To update a target's parameters:
  99.  
  100.  cat enabled                            # check if enabled is 1
  101.  echo 0 > enabled                       # disable the target (if required)
  102.  echo eth2 > dev_name                   # set local interface
  103.  echo 10.0.0.4 > remote_ip              # update some parameter
  104.  echo cb:a9:87:65:43:21 > remote_mac    # update more parameters
  105.  echo 1 > enabled                       # enable target again
  106.  
  107. You can also update the local interface dynamically. This is especially
  108. useful if you want to use interfaces that have newly come up (and may not
  109. have existed when netconsole was loaded / initialized).
  110.  
  111. Miscellaneous notes:
  112. ====================
  113.  
  114. WARNING: the default target ethernet setting uses the broadcast
  115. ethernet address to send packets, which can cause increased load on
  116. other systems on the same ethernet segment.
  117.  
  118. TIP: some LAN switches may be configured to suppress ethernet broadcasts
  119. so it is advised to explicitly specify the remote agents' MAC addresses
  120. from the config parameters passed to netconsole.
  121.  
  122. TIP: to find out the MAC address of, say, 10.0.0.2, you may try using:
  123.  
  124.  ping -c 1 10.0.0.2 ; /sbin/arp -n | grep 10.0.0.2
  125.  
  126. TIP: in case the remote logging agent is on a separate LAN subnet than
  127. the sender, it is suggested to try specifying the MAC address of the
  128. default gateway (you may use /sbin/route -n to find it out) as the
  129. remote MAC address instead.
  130.  
  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.  
  136. NOTE: if you find that the remote logging agent is not receiving or
  137. printing all messages from the sender, it is likely that you have set
  138. the "console_loglevel" parameter (on the sender) to only send high
  139. priority messages to the console. You can change this at runtime using:
  140.  
  141.  dmesg -n 8
  142.  
  143. or by specifying "debug" on the kernel command line at boot, to send
  144. all kernel messages to the console. A specific value for this parameter
  145. can also be set using the "loglevel" kernel boot option. See the
  146. dmesg(8) man page and Documentation/kernel-parameters.txt for details.
  147.  
  148. Netconsole was designed to be as instantaneous as possible, to
  149. enable the logging of even the most critical kernel bugs. It works
  150. from IRQ contexts as well, and does not enable interrupts while
  151. sending packets. Due to these unique needs, configuration cannot
  152. be more automatic, and some fundamental limitations will remain:
  153. only IP networks, UDP packets and ethernet devices are supported.

Raw Paste


Login or Register to edit or fork this paste. It's free.