Difference between revisions of "Netconsole"
(→Build-in Configuration) |
(→Build-in Configuration) |
||
Line 10: | Line 10: | ||
== Build-in Configuration == | == Build-in Configuration == | ||
− | ''Netconsole'' and other modules' [[Kernel parameters]] can be passed from a bootloader | + | ''Netconsole'' and other modules' [[Kernel parameters]] can be passed from a bootloader to kernel at its start via kernel command line by modifying the bootloader environment, which is type and version specific. Example for Uboot, where 1st IP is Dockstar ArchLinux device's netconsole Out IP and Port, and 2nd IP is your PC's netconsole In IP and Port: |
fw_setenv usb_custom_params 'loglevel=7 netconsole=6666@192.168.1.28/eth0,6666@192.168.1.19/00:13:32:20:r9:a5' | fw_setenv usb_custom_params 'loglevel=7 netconsole=6666@192.168.1.28/eth0,6666@192.168.1.19/00:13:32:20:r9:a5' |
Revision as of 17:11, 1 September 2012
netconsole is a kernel module that sends all kernel log messages (i.e. dmesg) over the network to another computer, without involving user space (e.g. syslogd). Name "netconsole" is a misnomer because it's not really a "console", more like a remote logging service.
It can be used either built-in or as a module. Built-in netconsole initializes immediately after NIC cards and will bring up the specified interface as soon as possible. The module is mainly used for capturing kernel panic output from a headless machine, or in other situations where the user space is no more functional.
Documentation is available in the Linux kernel tree under Documentation/networking/netconsole.txt
Build-in Configuration
Netconsole and other modules' Kernel parameters can be passed from a bootloader to kernel at its start via kernel command line by modifying the bootloader environment, which is type and version specific. Example for Uboot, where 1st IP is Dockstar ArchLinux device's netconsole Out IP and Port, and 2nd IP is your PC's netconsole In IP and Port:
fw_setenv usb_custom_params 'loglevel=7 netconsole=6666@192.168.1.28/eth0,6666@192.168.1.19/00:13:32:20:r9:a5'
Logging is done by your ArchLinux release default logger like syslog-ng, and available loglevels (output details) are defined in that logger docs, and may differ for each log type. One can also pass netconsole parameters at kernel runtime, start netconsole on a remote PC and restart it on the PC or device you are logging:
# set log level for kernel messages dmesg -n 8 netconsole=6665@192.168.0.111/eth0,6665@192.168.0.17/00:43:24:96:d7:v5
Dynamic configuration
# set log level for kernel messages dmesg -n 8 modprobe configfs modprobe netconsole mount none -t configfs /sys/kernel/config mkdir /sys/kernel/config/netconsole/target1 cd /sys/kernel/config/netconsole/target1 # set local IP address echo 192.168.0.111 > local_ip # set destination IP address echo 192.168.0.17 > remote_ip # find destination MAC address arping `cat remote_ip` -f |grep -o ..:..:..:..:..:.. > remote_mac echo 1 > enabled
netconsole should now be configured. To verify, run 'dmesg |tail' and you should see "netconsole: network logging started"
Receiver
nc -u -l 6666
or
nc -u -l -p 6666