netconsole.txt 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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 can run either 'netcat -u -l -p <port>',
  38. 'nc -l -u <port>' or syslogd.
  39. Dynamic reconfiguration:
  40. ========================
  41. Dynamic reconfigurability is a useful addition to netconsole that enables
  42. remote logging targets to be dynamically added, removed, or have their
  43. parameters reconfigured at runtime from a configfs-based userspace interface.
  44. [ Note that the parameters of netconsole targets that were specified/created
  45. from the boot/module option are not exposed via this interface, and hence
  46. cannot be modified dynamically. ]
  47. To include this feature, select CONFIG_NETCONSOLE_DYNAMIC when building the
  48. netconsole module (or kernel, if netconsole is built-in).
  49. Some examples follow (where configfs is mounted at the /sys/kernel/config
  50. mountpoint).
  51. To add a remote logging target (target names can be arbitrary):
  52. cd /sys/kernel/config/netconsole/
  53. mkdir target1
  54. Note that newly created targets have default parameter values (as mentioned
  55. above) and are disabled by default -- they must first be enabled by writing
  56. "1" to the "enabled" attribute (usually after setting parameters accordingly)
  57. as described below.
  58. To remove a target:
  59. rmdir /sys/kernel/config/netconsole/othertarget/
  60. The interface exposes these parameters of a netconsole target to userspace:
  61. enabled Is this target currently enabled? (read-write)
  62. dev_name Local network interface name (read-write)
  63. local_port Source UDP port to use (read-write)
  64. remote_port Remote agent's UDP port (read-write)
  65. local_ip Source IP address to use (read-write)
  66. remote_ip Remote agent's IP address (read-write)
  67. local_mac Local interface's MAC address (read-only)
  68. remote_mac Remote agent's MAC address (read-write)
  69. The "enabled" attribute is also used to control whether the parameters of
  70. a target can be updated or not -- you can modify the parameters of only
  71. disabled targets (i.e. if "enabled" is 0).
  72. To update a target's parameters:
  73. cat enabled # check if enabled is 1
  74. echo 0 > enabled # disable the target (if required)
  75. echo eth2 > dev_name # set local interface
  76. echo 10.0.0.4 > remote_ip # update some parameter
  77. echo cb:a9:87:65:43:21 > remote_mac # update more parameters
  78. echo 1 > enabled # enable target again
  79. You can also update the local interface dynamically. This is especially
  80. useful if you want to use interfaces that have newly come up (and may not
  81. have existed when netconsole was loaded / initialized).
  82. Miscellaneous notes:
  83. ====================
  84. WARNING: the default target ethernet setting uses the broadcast
  85. ethernet address to send packets, which can cause increased load on
  86. other systems on the same ethernet segment.
  87. TIP: some LAN switches may be configured to suppress ethernet broadcasts
  88. so it is advised to explicitly specify the remote agents' MAC addresses
  89. from the config parameters passed to netconsole.
  90. TIP: to find out the MAC address of, say, 10.0.0.2, you may try using:
  91. ping -c 1 10.0.0.2 ; /sbin/arp -n | grep 10.0.0.2
  92. TIP: in case the remote logging agent is on a separate LAN subnet than
  93. the sender, it is suggested to try specifying the MAC address of the
  94. default gateway (you may use /sbin/route -n to find it out) as the
  95. remote MAC address instead.
  96. NOTE: the network device (eth1 in the above case) can run any kind
  97. of other network traffic, netconsole is not intrusive. Netconsole
  98. might cause slight delays in other traffic if the volume of kernel
  99. messages is high, but should have no other impact.
  100. NOTE: if you find that the remote logging agent is not receiving or
  101. printing all messages from the sender, it is likely that you have set
  102. the "console_loglevel" parameter (on the sender) to only send high
  103. priority messages to the console. You can change this at runtime using:
  104. dmesg -n 8
  105. or by specifying "debug" on the kernel command line at boot, to send
  106. all kernel messages to the console. A specific value for this parameter
  107. can also be set using the "loglevel" kernel boot option. See the
  108. dmesg(8) man page and Documentation/kernel-parameters.txt for details.
  109. Netconsole was designed to be as instantaneous as possible, to
  110. enable the logging of even the most critical kernel bugs. It works
  111. from IRQ contexts as well, and does not enable interrupts while
  112. sending packets. Due to these unique needs, configuration cannot
  113. be more automatic, and some fundamental limitations will remain:
  114. only IP networks, UDP packets and ethernet devices are supported.