[systemd-devel] Netconsole NG

Tom Gundersen teg at jklm.no
Tue Apr 8 05:25:54 PDT 2014


On Tue, Apr 8, 2014 at 2:10 PM, poma <pomidorabelisima at gmail.com> wrote:
> On 08.04.2014 04:03, poma wrote:
>> On 07.04.2014 19:55, Zbigniew Jędrzejewski-Szmek wrote:
>>> On Mon, Apr 07, 2014 at 05:34:10PM +0200, Lukáš Nykrýn wrote:
>>>> The reason why this was not rewritten a long time ago is that the
>>>> initscript tries to figure some of those values by itself (for
>>>> example the MAC address). But yes, we need to do something with
>>>> netconsole. It is a blocker for my initscripts evil plan.
>>> Doesn't netconsole figure out most of those settings by itself, and
>>> others default to sensible values, so if the network card is up
>>> and has an address configured, only the device and target ip must be given?
>>>
>>>> Dne 6.4.2014 17:59, poma napsal(a):
>>>>>
>>>>> /etc/sysconfig/netconsole:
>>>>> # This is the EnvironmentFile for the netconsole service. Starting this
>>>>> # service enables the capture of dmesg output on a destination machine.
>>>>>
>>>>> # Source port
>>>>> SRC_PORT=12345
>>> This should default to empty... Kernel will pick something.
>>>
>>>>>
>>>>> # Source IP address
>>>>> SRC_IP=192.168.1.2
>>> This should default to empty... Kernel will use configured address,
>>> since we order after network.target anyway.
>>>
>>>>> # Source network device
>>>>> SRC_DEV=enp1s2
>>> Maybe this can be made into a instance argument?
>>>
>>>>> # Destination port
>>>>> DST_PORT=12345
>>> I think this should default to 514/syslog, and can be left unset.
>>>
>>>>> # Destination IP address
>>>>> DST_IP=192.168.1.1
>>>>>
>>>>> # Destination ethernet address
>>>>> DST_EHA=00:11:22:33:44:55
>>> This should default to unset. The kernel will query it if not set.
>>>
>>>>> /usr/lib/systemd/system/netconsole.service:
>>>>> [Unit]
>>>>> Description=Adds the netconsole module with the configured parameters
>>>>> After=network.target
>>>>>
>>>>> [Service]
>>>>> EnvironmentFile=/etc/sysconfig/netconsole
>>> This is Fedora/RH specific. But I don't know what the proper path should
>>> be, so maybe this is OK for now.
>>>
>>>>> Type=simple
>>> This is the default... No need to specify.
>>>
>>>>> RemainAfterExit=yes
>>>>> ExecStart=/usr/sbin/modprobe netconsole
>>> This should be /sbin/modprobe for compatibility with split root.
>>>
>>>>> netconsole=${SRC_PORT}@${SRC_IP}/${SRC_DEV},${DST_PORT}@${DST_IP}/${DST_EHA}
>>>>> ExecStop=/usr/sbin/modprobe -r netconsole
>>> Ditto.
>>>
>>>>>
>>>>> [Install]
>>>>> WantedBy=multi-user.target
>>> That's a really late... But I don't see a better place unfortunately.
>>>
>>>>> The original SysV netconsole service with related config - still in use,
>>>>> https://git.fedorahosted.org/cgit/initscripts.git/plain/rc.d/init.d/netconsole
>>>>> https://git.fedorahosted.org/cgit/initscripts.git/plain/sysconfig/netconsole
>>>>>
>>>>> Feel free to comment.
>>> Looks like an improvement on status quo.
>>>
>>> Zbyszek
>>>
>>
>> Shall we still leave something for users to configure.
>> Thanks for your review.
>>
>
> $ cat /usr/lib/systemd/system/netconsole-zbyszek.service
> [Unit]
> Description=Adds the netconsole module with the configured parameters
> After=network.target
>
> [Service]
> EnvironmentFile=/etc/sysconfig/netconsole-zbyszek
> RemainAfterExit=yes
> ExecStart=/sbin/modprobe netconsole netconsole=@/${SRC_DEV},@${DST_IP}/
> ExecStop=/sbin/modprobe -r netconsole
>
> [Install]
> WantedBy=multi-user.target
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> $ cat /etc/sysconfig/netconsole-zbyszek
> # This is the EnvironmentFile for the netconsole service. Starting this
> # service enables the capture of dmesg output on a destination machine.
>
> # Source network device
> SRC_DEV=enp1s2
>
> # Destination IP address
> DST_IP=192.168.1.1
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> $ dmesg | grep netcon
> [   24.361611] netpoll: netconsole: local port 6665
> [   24.361764] netpoll: netconsole: local IPv4 address 0.0.0.0
> [   24.361893] netpoll: netconsole: interface 'enp1s2'
> [   24.362061] netpoll: netconsole: remote port 6666
> [   24.362344] netpoll: netconsole: remote IPv4 address 192.168.1.1
> [   24.362635] netpoll: netconsole: remote ethernet address
> ff:ff:ff:ff:ff:ff
> [   24.362909] netpoll: netconsole: no IP address for enp1s2, aborting
> [   24.363186] netconsole: cleaning up
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> This turns out to be a bare minimum, i.e.
> # modprobe netconsole netconsole=@/enp1s2, at 192.168.1.1/
> but that is also squeeze breeze ...
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> $ cat /usr/lib/systemd/system/netconsole-poma.service
> [Unit]
> Description=Adds the netconsole module with the configured parameters
> After=network.target
>
> [Service]
> EnvironmentFile=/etc/sysconfig/netconsole-poma
> RemainAfterExit=yes
> ExecStart=/sbin/modprobe netconsole
> netconsole=@${SRC_IP}/${SRC_DEV},@${DST_IP}/
> ExecStop=/sbin/modprobe -r netconsole
>
> [Install]
> WantedBy=multi-user.target
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> $ cat /etc/sysconfig/netconsole-poma
> # This is the EnvironmentFile for the netconsole service. Starting this
> # service enables the capture of dmesg output on a destination machine.
>
> # Source IP address
> SRC_IP=192.168.1.2
>
> # Source network device
> SRC_DEV=enp1s2
>
> # Destination IP address
> DST_IP=192.168.1.1
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> $ dmesg | grep netcon
> [   23.156730] netpoll: netconsole: local port 6665
> [   23.156735] netpoll: netconsole: local IPv4 address 192.168.1.2
> [   23.156736] netpoll: netconsole: interface 'enp1s2'
> [   23.156737] netpoll: netconsole: remote port 6666
> [   23.156738] netpoll: netconsole: remote IPv4 address 192.168.1.1
> [   23.156739] netpoll: netconsole: remote ethernet address
> ff:ff:ff:ff:ff:ff
> [   23.156742] netpoll: netconsole: device enp1s2 not up yet, forcing it
> [   25.539701] console [netcon0] enabled
> [   25.539720] netconsole: network logging started
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> And this turns out to be a true bare minimum, i.e.
> # modprobe netconsole netconsole=@192.168.1.2/enp1s2, at 192.168.1.1/
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This looks like a definitive improvement.

Maybe one day we want to take things one step further and unify the
logic for built-in and modular netconsole (the current way feels a bit
odd).

Cheers,

Tom


More information about the systemd-devel mailing list