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 its 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 theuser Space is no moRe functional. Documentation is available in the linux kerneltree under documentation /networking/netconsole.txt. is a kernel module that sends all kernel log messages (that is, DMESG) to another computer over the network without user space (such as SYSLOGD). "Netconsole" The name is not very appropriate, because it is not a real "console", more like a remote logging service. It can be built-in or compiled into modules. The built-in Netconsole is initialized immediately after the NIC to establish the specified interface as soon as possible . module mode is typically used to obtain kernel panic output when a screen-free system or user space does not work
Basic Environment servera=10.1.10.250 (5.0.1) client serverb=10.1.10.117 (7.8) Server
First, 10.1.10.250 (client) ServerA configuration 1, the specific script cat aaa.sh#!/bin/bashsenddev=eth0receip=10.1.10.117receport=8888mac= gateway=$ (ip -4 -o route get $receip |/usr/bin/cut -f 3 -d ' ') if echo $gateway |/bin/grep -q ' ^[0-9]\+\. [0-9]\+\. [0-9]\+\. [0-9]\+$ ' then mac=$ (ip -4 neigh show $gateway |/usr/bin/cut -f 5 -d ' ') else /bin/ping -c 2 $receip > /dev/null mac=$ (ip -4 neigh show $receip |/usr/bin/cut -f 5 -d ' ') fi[ x$mac = x ] && exitecho 7 > /proc/sys/kernel/printk/sbin/modprobe -r netconsole/sbin/modprobe netconsole [ email protected]/$senddev, [email protected] $receip/$MAC 2, Description 1) the-r parameter of the modprobe command-r --remove this option causes modprobe to remove rather than insert a module. 2) Now we need to manually adjust the kernel PRINTK print level using the console function this side (man 2 syslog) 7 -- enable printk to console3) ip route get ADDRESS [ FROM ADDRESS IIF STRING  ] [ OIF STRING ]  [ TOS TOS ]4) ip neigh { show | flush } [ to PREFIX ] [ DEV DEV ] [ NUD STATE ]5) -4 shortcut for -family inet.6)-f, -family followed by protocol family identifier: inet, II, 10.1.10.117 (server side) ServerB configuration 1, create 1 files ending with. conf. content as follows Cat /etc /rsyslog.d/jimmygong.conf $ModLoad imudp$udpserverrun 8888$template dynfile, "/opt/rsyslog/ %fromhost-ip%.log "if $fromhost-ip startswith ' 10.1. ' then ? Dynfile& ~2, restart service/etc/init.d/rsyslog&nbsP;restart three, use and test 1, need to give aaa.sh enforcement rights CHMOD +X AAA.SH2, write into boot echo /root/aaa.sh >> / ETC/RC.LOCAL3, manual execution under BASH AAA.SH4, view DMESG information dmesg|grep console[ 0.004000] CONSOLE [TTY0] ENABLED[111098.509861] NETCONSOLE: LOCAL PORT 6665[111098.509983] netconsole: local ip 0.0.0.0[111098.510055] netconsole: interface eth0[ 111098.510122] netconsole: remote port 8888[111098.510193] netconsole: remote ip 10.1.10.117[111098.510273] netconsole: remote ethernet address 00:0c:29 : C8:87:a1[111098.510420] netconsole: local ip 10.1.10.250[111098.526162] console [netcon0] enabled[111098.526548] netconsole: network logging started[ 114036.698520] console [netcon0] enabled[114036.698621] netconsole: network Logging started5, check to see if there are log messages coming up 10.1.10.117 (service side) cat /opt/rsyslog/10.1.10.250.logjun 16 04:33:38 10.1.10.250 [ 111098.526162] console [netcon0] enabledjun 16 04:33:38 10.1.10.250 [ 111098.526548] netconsole: network logging startedjun 16 05:52:23 10.1.10.250 [115824.861174] console [netcon0] enabledjun 16 05:52:23 10.1.10.250 [115824.861460] netconsole: network logging started Four, reference article http// www.cyberciti.biz/tips/linux-netconsole-log-management-tutorial.htmlhttps://wiki.archlinux.org/index.php/ Netconsolehttps://wiki.ubuntu.com/kernel/netconsole
This article is from the "7928217" blog, please be sure to keep this source http://7938217.blog.51cto.com/7928217/1662524
Rsyslog Netconsole (Debian) II