📜 ⬆️ ⬇️

How to understand why the server fell without connecting a monitor and keyboard to it?

It so happens that the server freezes, but neither the keyboard nor the monitor is connected to it.

I do not have an extra monitor, and finding that the server is not responding over the network,
take a monitor from my computer and connect to the server in the closet there is no desire and strength.

Linux has a kernel feature like Netconsole .
Netconsole allows you to send messages from the kernel to a remote computer.
')
To set up a netconsole, you need another (constantly on) computer that will receive a message over the network.

Tested on Ubuntu 10.04

On the server that we are debugging perform:

1. In / etc / modules add netconsole

2. In /etc/modprobe.d/netconsole.conf we write
options netconsole netconsole=SRCPORT@SRCHOST/eth0,DSTPORT@DSTHOST/DSTMAC

Where SRCPORT and SRCHOST are respectively the port and the IP address of the server that is being debugged.

And DSTPORT and DSTHOST port and IP address of the server that will receive messages.

DSTMAC is the MAC address of the server that will receive messages IF it is on the same network. If it is behind a router or somewhere on the Internet, then you need to specify the MAC address of the nearest router (Gateway).

You should get something like
options netconsole netconsole=6666@192.168.1.2/eth0,6666@192.168.1.3/e0:91:f5:7d:e6:38

On the server that will receive messages.

We need to run a program that will listen to the DSTPORT UDP port and record messages somewhere.

The easiest way is to run a netcat that will display everything that comes to the port. In order that after closing the window, this program does not stop working, you can run it in screen.

1. Run the screen
screen -U -D -RR

2. Run in the netcat window
netcat -l -u DSTHOST DSTPORT

How to understand that everything works?

You can wait for some event, but how to make sure that the messages really go? You can activate the SysRQ kernel mechanism.
echo 1 > /proc/sys/kernel/sysrq
echo h > /proc/sysrq-trigger


After that, on the server that receives messages in the window with netcat, a text like
[ 7849.700372] SysRq : HELP : loglevel(0-9)....

Links

Source: https://habr.com/ru/post/131220/


All Articles