Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collectd startup too early, network error #52

Open
Bensge opened this issue Dec 17, 2020 · 1 comment
Open

collectd startup too early, network error #52

Bensge opened this issue Dec 17, 2020 · 1 comment

Comments

@Bensge
Copy link

Bensge commented Dec 17, 2020

When my Raspberry PI 4 boots up, during the collectdstartup, the fritzcolltectd plugin chokes on the network because it doesn't appear to be connected yet. When I restart collectd manually, it works great.
Is this problem known and are there any solutions to delay the startup until the network is ready?

Cheers, Benno

● collectd.service - Statistics collection and monitoring daemon
   Loaded: loaded (/lib/systemd/system/collectd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-12-17 08:47:08 CET; 7h ago
     Docs: man:collectd(1)
           man:collectd.conf(5)
           https://collectd.org
  Process: 475 ExecStartPre=/usr/sbin/collectd -t (code=exited, status=0/SUCCESS)
 Main PID: 484 (collectd)
    Tasks: 11 (limit: 3861)
   CGroup: /system.slice/collectd.service
           └─484 /usr/sbin/collectd

Dez 17 08:46:48 raspi4 collectd[484]: plugin_load: plugin "network" successfully loaded.
Dez 17 08:47:07 raspi4 collectd[484]: Systemd detected, trying to signal readyness.
Dez 17 08:47:08 raspi4 systemd[1]: Started Statistics collection and monitoring daemon.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dez 17 08:47:13 raspi4 collectd[484]: Unhandled python exception in init callback: IOError: fritzcollectd: Failed to connect to 192.168.178.1
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dez 17 08:47:13 raspi4 collectd[484]: Initialization complete, entering read-loop.
@pantaluna
Copy link

pantaluna commented Jul 15, 2023

You can restart the collectd service 5 minutes after the server had started booted. Assuming the network is up by then...

# @doc https://wiki.archlinux.org/index.php/Systemd/Timers
# Config
MYFILE=/etc/systemd/system/mjd-restart-collectd-after-lan-connected.timer
cat << 'THETEXTBLOCK' > ${MYFILE}
    # A timer which will trigger ONCE, {x} minutes after the machine was booted.
    [Unit]
    Description=(timer)mjd-restart-collectd-after-lan-connected
    [Timer]
    OnBootSec=5min
    [Install]
    WantedBy=timers.target
THETEXTBLOCK
cat ${MYFILE}
ll  ${MYFILE}
MYFILE=/etc/systemd/system/mjd-restart-collectd-after-lan-connected.service
cat << 'THETEXTBLOCK' > ${MYFILE}
    # The .service file does not require an [Install] section as it is controlled by the related timer unit.
    [Unit]
    Description=mjd-restart-collectd-after-lan-connected
    [Service]
    Type=oneshot
    ExecStart=/bin/sh -ec "systemctl restart collectd; systemctl status collectd"
THETEXTBLOCK
cat ${MYFILE}
ll  ${MYFILE}
# ENABLE AT BOOT
MYUNIT=mjd-restart-collectd-after-lan-connected
MYSERVICE=${MYUNIT}.service
MYTIMER=${MYUNIT}.timer
systemctl enable ${MYTIMER};
systemctl status ${MYTIMER};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants