netconsole.txt 6.4 KB

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