自宅サーãƒãƒ¼ (ï¼) ãŒã¡ã‚‡ã„ã¡ã‚‡ã„è½ã¡ã‚‹ã‚“ã§ã™ã€‚ãŸã¶ã‚“コンソールã«ã¯ kernal panic 時㮠oops メッセージãŒè¡¨ç¤ºã•ã‚Œã¦ã‚‹ã¨æ€ã†ã‚“ã§ã™ãŒã€ãƒ¢ãƒ‹ã‚¿ã¯ç¹‹ã„ã§ãªã„ã—宅内ã«ã¯ä»–ã«ã‚µãƒ¼ãƒãƒ¼ã‚‚ã„ãªã„ã®ã§ã‚·ãƒªã‚¢ãƒ«çµŒç”±ã§é€ä¿¡ã™ã‚‹ã“ã¨ã‚‚ã§ããªã„ã®ã§ç¢ºèªã™ã‚‹è¡“ãŒãªã。
ã§ã€ãã†ã„ãˆã° netconsole ã£ã¦ã®ãŒã‚ã£ãŸãªãƒ¼ã¨æ€ã„出ã—ãŸã‚“ã§ã€è¨å®šã—ã¦ã¿ãŸæ¬¡ç¬¬ã§ã™ã€‚
ã¡ãªã¿ã«é€ä¿¡å…ˆã¯ GCE ã® Always Free ã®ã‚¤ãƒ³ã‚¹ã‚¿ãƒ³ã‚¹ (ã¡ã‚ƒã‚“ã¨ä¸å›½ã¨ã‚ªãƒ¼ã‚¹ãƒˆãƒ©ãƒªã‚¢ã‹ã‚‰ã®ã‚¢ã‚¯ã‚»ã‚¹ã¯ãƒ•ã‚£ãƒ«ã‚¿ã—ã¦ã„ã¾ã™) ã§ã™ã€‚
疎通ã®ç¢ºèª
netconsole 㯠UDP を使ã„ã¾ã™ã€‚å—ä¿¡å´ã®ãƒãƒ¼ãƒˆç•ªå·ã‚’決ã‚㦠(6666 ã¨ã—ã¾ã™) ã€ã¾ãšã¯ãã‚ŒãŒé€šã‚‹ã‚ˆã†ã«ãƒ•ã‚£ãƒ«ã‚¿ãƒªãƒ³ã‚°ã®è¨å®šã‚’ã—ã¾ã™ã€‚
疎通確èªã¯ã“ã‚“ãªæ„Ÿã˜ã§ã€‚
# å—ä¿¡å´ sudo tcpdump -i any -nlxX port 6666
# é€ä¿¡å´ echo konyanya-chiwa > /dev/udp/DEST_IP_ADDRESS/6666
é€ä¿¡å´ã®è¨å®š
echo 'options netconsole netconsole=6665@SRC_IP_ADDRESS/eth0,6666@DEST_IP_ADDRESS/GW_MAC_ADDRESS' | sudo tee /etc/modprobe.d/netconsole.conf echo netconsole | sudo tee -a /etc/modules sudo modprobe netconsole
SRC_IP_ADDRESS
- é€ä¿¡å…ƒã® eth0 ã«ã¤ã„ã¦ã‚‹ãƒ—ライベート IP アドレス
DEST_IP_ADDRESS
- é€ä¿¡å…ˆã®ã‚°ãƒãƒ¼ãƒãƒ« IP アドレス
GW_MAC_ADDRESS
- é€ä¿¡å…ƒã®ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã‚²ãƒ¼ãƒˆã‚¦ã‚§ã‚¤ã® MAC アドレス
- é€ä¿¡å…ˆãŒåŒã˜ã‚µãƒ–ãƒãƒƒãƒˆå†…ã®å ´åˆã¯é€ä¿¡å…ˆã® MAC アドレスを指定ã—ã¾ã™ãŒã€ã‚µãƒ–ãƒãƒƒãƒˆå¤–ã®å ´åˆã¯ãƒ‡ãƒ•ã‚©ãƒ«ãƒˆã‚²ãƒ¼ãƒˆã‚¦ã‚§ã‚¤ã® MAC アドレスを指定ã—ã¾ã™
00:00:5e:00:53:31
ãªæ„Ÿã˜ã§æŒ‡å®š
試行錯誤ã™ã‚‹ã¨ãã¯ã“ã‚“ãªæ„Ÿã˜ã§ãŠï½‹
sudo modprobe netconsole 'netconsole=6665@SRC_IP_ADDRESS/eth0,6666@DEST_IP_ADDRESS/GW_MAC_ADDRESS' sudo rmmod netconsole
å—ä¿¡å´ã®è¨å®š
syslog ã¯ä½¿ã‚ãšã« udplogger を使ã„ã¾ã—ãŸã€‚
curl -L -o udplogger.c 'https://osdn.net/projects/akari/scm/svn/blobs/head/branches/udplogger/udplogger.c?export=raw' gcc -Wall -o udplogger udplogger.c mkdir /var/log/netconsole udplogger dir=/var/log/netconsole port=6666
動作確èª
é€ä¿¡å´ã§
echo s | sudo tee /proc/sysrq-trigger
ã™ã‚‹ã¨ã€å—ä¿¡å´ã§
# /var/log/netconsole/YYYY-MM-DD.log 2020-02-21 13:25:36 192.0.2.100:6665 [271267.178610] sysrq: Emergency Sync
ã¨å‡ºåŠ›ã•ã‚Œã‚‹ã¯ãšã§ã™ã€‚