[systemd-devel] Netconsole NG

poma pomidorabelisima at gmail.com
Wed Apr 9 01:11:49 PDT 2014


On 08.04.2014 23:27, poma wrote:
> On 08.04.2014 14:25, Tom Gundersen wrote:
>> 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
>>
> 
> In fact, this method has long been known from the
> Lm_sensors - Linux hardware monitoring
> http://lm-sensors.org/browser/lm-sensors/trunk/prog/init/lm_sensors.service
> [Unit]
> Description=Initialize hardware monitoring sensors
> 
> [Service]
> EnvironmentFile=/etc/sysconfig/lm_sensors
> Type=oneshot
> RemainAfterExit=yes
> ExecStart=-/sbin/modprobe -qab $BUS_MODULES $HWMON_MODULES
> ExecStart=/usr/bin/sensors -s
> ExecStop=-/sbin/modprobe -qabr $BUS_MODULES $HWMON_MODULES
> 
> [Install]
> WantedBy=multi-user.target
> 

Back to the roots.

$ systemctl is-enabled NetworkManager systemd-networkd
enabled
disabled

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# brctl show bridge1
bridge name	bridge id		STP enabled	interfaces
bridge1		8000.00123456789a	no		bond1

# bondctl detail bond1
Bonding Master: bond1
    Oper State:     up
    Slaves:         enp1s2
    Active Slave:   enp1s2
    Mode:           active-backup 1
    Monitor:        MII: 1msec

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ cat /usr/lib/systemd/system/netconsole-lnykryn-dcbw-ng.service
[Unit]
Description=Adds the netconsole module with the configured parameters
After=network.target

[Service]
EnvironmentFile=/etc/sysconfig/netconsole
Type=oneshot
RemainAfterExit=yes
ExecStartPre=/bin/nm-online
ExecStart=/etc/init.d/netconsole start
ExecStop=/etc/init.d/netconsole stop

[Install]
WantedBy=multi-user.target

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ cat /etc/sysconfig/netconsole
# This is the configuration file for the netconsole service.  By starting
# this service you allow a remote syslog daemon to record console output
# from this system.

# The local port number that the netconsole module will use
# LOCALPORT=6666

# The ethernet device to send console messages out of (only set this if it
# can't be automatically determined)
# DEV=

# The IP address of the remote syslog server to send messages to
SYSLOGADDR=192.168.1.1

# The listening port of the remote syslog daemon
# SYSLOGPORT=514

# The MAC address of the remote syslog server (only set this if it can't
# be automatically determined)
# SYSLOGMACADDR=

~~~~~~~~~~~~~~~~

/etc/init.d/netconsole:
$ curl \
https://git.fedorahosted.org/cgit/initscripts.git/plain/rc.d/init.d/netconsole

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ dmesg | grep netcon
[   67.213643] netpoll: netconsole: local port 6666
[   67.213649] netpoll: netconsole: local IPv4 address 192.168.1.2
[   67.213650] netpoll: netconsole: interface 'bridge1'
[   67.213652] netpoll: netconsole: remote port 514
[   67.213653] netpoll: netconsole: remote IPv4 address 192.168.1.1
[   67.213655] netpoll: netconsole: remote ethernet address
00:11:22:33:44:55
[   67.214707] console [netcon0] enabled
[   67.214745] netconsole: network logging started

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Within the NetworkManager is needed a little bit of help,
i.e. ExecStartPre=/bin/nm-online
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


$ systemctl is-enabled systemd-networkd NetworkManager
enabled
disabled

~~~~~~~~~~~~~~~~~~~~

# brctl show bridge1
bridge name	bridge id		STP enabled	interfaces
bridge1		8000.00123456789a	no		bond1

# bondctl detail bond1
Bonding Master: bond1
    Oper State:     unknown
    Slaves:         enp1s2
    Active Slave:   enp1s2
    Mode:           active-backup 1
    Monitor:        No monitoring enabled

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ cat /usr/lib/systemd/system/netconsole-lnykryn-teg-ng.service
[Unit]
Description=Adds the netconsole module with the configured parameters
After=network.target

[Service]
EnvironmentFile=/etc/sysconfig/netconsole
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/init.d/netconsole start
ExecStop=/etc/init.d/netconsole stop

[Install]
WantedBy=multi-user.target

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ dmesg | grep netcon
[   36.674993] netpoll: netconsole: local port 6666
[   36.674998] netpoll: netconsole: local IPv4 address 192.168.1.2
[   36.675000] netpoll: netconsole: interface 'bridge1'
[   36.675001] netpoll: netconsole: remote port 514
[   36.675003] netpoll: netconsole: remote IPv4 address 192.168.1.1
[   36.675004] netpoll: netconsole: remote ethernet address
00:11:22:33:44:55
[   36.715656] console [netcon0] enabled
[   36.715689] netconsole: network logging started

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Within the systemd-networkd Transwarp drive no need for
ExecStartPre=/usr/lib/systemd/systemd-networkd-wait-online :)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Talk about 'modprobe' & 'internetz', :)

$ grep modprobe /usr/lib/systemd/system/*.service
/usr/lib/systemd/system/fcoe.service:ExecStartPre=/sbin/modprobe -qa
$SUPPORTED_DRIVERS
/usr/lib/systemd/system/irda.service:ExecStartPre=-/sbin/modprobe -qab
ircomm-tty irtty-sir irnet
/usr/lib/systemd/system/lm_sensors.service:ExecStart=-/usr/libexec/lm_sensors/lm_sensors-modprobe-wrapper
$BUS_MODULES $HWMON_MODULES
/usr/lib/systemd/system/lm_sensors.service:ExecStop=-/usr/libexec/lm_sensors/lm_sensors-modprobe-r-wrapper
$BUS_MODULES $HWMON_MODULES
/usr/lib/systemd/system/multipathd.service:ExecStartPre=/sbin/modprobe
dm-multipath
/usr/lib/systemd/system/xl2tpd.service:ExecStartPre=/sbin/modprobe -q
l2tp_ppp


That's all folks!

poma



More information about the systemd-devel mailing list