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