Skip to content

Automate setting schedule_type to "dispatcher" when SIDECAR_DISPATCHER=1 is used #560

@eduardomozart

Description

@eduardomozart

Support guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

Currently, when setting up a Distributed Polling environment or just using the Dispatcher Service via Docker, we enable the sidecar by setting SIDECAR_DISPATCHER=1 in the compose.yml.

However, the main LibreNMS instance still defaults the schedule types to cron in the database. To make the Dispatcher actually take over, administrators must manually log into the Web UI (Settings -> System -> Scheduled Tasks) or run CLI commands to change the Schedule Type to dispatcher for:

  • Poller
  • Discovery
  • Services
  • Alerting
  • Billing

This manual intervention breaks the declarative "Infrastructure as Code" approach of Docker Compose, as the stack doesn't come up fully configured and ready to poll out of the box.

Describe the solution you'd like
It would be great if the Docker initialization scripts could automatically set the necessary configuration values in the database when the Dispatcher is intended to be used.

Possible approaches:

  1. Automatically run the equivalent of lnms config:set schedule_type.X dispatcher during container startup if a specific environment variable is detected (e.g., DISPATCHER_AUTO_ENABLE=true on the main app container).
  2. Or, if SIDECAR_DISPATCHER=1 is meant strictly for the sidecar, introduce a variable like USE_DISPATCHER_SCHEDULER=true for the main librenms container that handles this DB migration at startup.

Expected behaviour

Currently, the workaround is to wait for the stack to be healthy and then manually run a script against the container:
docker exec -it librenms lnms config:set schedule_type.poller dispatcher
docker exec -it librenms lnms config:set schedule_type.discovery dispatcher
...etc.

Actual behaviour

This is especially important for Distributed Polling setups where new users often assume that spinning up the librenms_dispatcher sidecar is enough, but then notice no polling is happening because the main UI is still waiting for a cron trigger that no longer exists.

Steps to reproduce

N/A

Docker info

Client: Docker Engine - Community
 Version:    29.4.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.33.0
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v5.1.2
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 14
  Running: 14
  Paused: 0
  Stopped: 0
 Images: 47
 Server Version: 29.4.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 301b2dac98f15c27117da5c8af12118a041a31d9
 runc version: v1.3.4-0-gd6d73eb8
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.8.0-107-generic
 Operating System: Ubuntu 24.04.4 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 7.725GiB
 Name: vaultwarden-server
 ID: 31827f6b-e548-4d03-9157-17f001b28730
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false
 Firewall Backend: iptables

Docker Compose config

name: librenms
services:
  dispatcher:
    cap_add:
      - NET_ADMIN
      - NET_RAW
    container_name: librenms_dispatcher
    depends_on:
      librenms:
        condition: service_started
        required: true
      redis:
        condition: service_started
        required: true
    environment:
      CACHE_DRIVER: redis
      DB_HOST: mariadb
      DB_NAME: librenms
      DB_PASSWORD: ****************
      DB_TIMEOUT: "60"
      DB_USER: librenms
      DISPATCHER_NODE_ID: dispatcher1
      LIBRENMS_SNMP_COMMUNITY: librenmsdocker
      LIBRENMS_WEATHERMAP: "false"
      LIBRENMS_WEATHERMAP_SCHEDULE: '*/5 * * * *'
      LOG_IP_VAR: remote_addr
      MAX_INPUT_VARS: "1000"
      MEMORY_LIMIT: 256M
      OPCACHE_MEM_SIZE: "128"
      PGID: "1000"
      PUID: "1000"
      REAL_IP_FROM: 0.0.0.0/32
      REAL_IP_HEADER: X-Forwarded-For
      REDIS_HOST: redis
      SESSION_DRIVER: redis
      SIDECAR_DISPATCHER: "1"
      TZ: America/Sao_Paulo
      UPLOAD_MAX_SIZE: 16M
    hostname: librenms-dispatcher
    image: librenms/librenms:latest
    networks:
      default: null
    restart: always
    volumes:
      - type: bind
        source: /home/vaultwarden/docker/librenms/docker-master/examples/compose/librenms
        target: /data
        bind: {}
  librenms:
    cap_add:
      - NET_ADMIN
      - NET_RAW
    container_name: librenms
    depends_on:
      msmtpd:
        condition: service_started
        required: true
      redis:
        condition: service_started
        required: true
    environment:
      CACHE_DRIVER: redis
      DB_HOST: mariadb
      DB_NAME: librenms
      DB_PASSWORD: ****************
      DB_TIMEOUT: "60"
      DB_USER: librenms
      LIBRENMS_SNMP_COMMUNITY: librenmsdocker
      LIBRENMS_WEATHERMAP: "false"
      LIBRENMS_WEATHERMAP_SCHEDULE: '*/5 * * * *'
      LOG_IP_VAR: remote_addr
      MAX_INPUT_VARS: "1000"
      MEMORY_LIMIT: 256M
      OPCACHE_MEM_SIZE: "128"
      PGID: "1000"
      PUID: "1000"
      REAL_IP_FROM: 0.0.0.0/32
      REAL_IP_HEADER: X-Forwarded-For
      REDIS_HOST: redis
      RRDC_HOST: rrdcached
      RRDC_PORT: "42217"
      SESSION_DRIVER: redis
      TZ: America/Sao_Paulo
      UPLOAD_MAX_SIZE: 16M
    hostname: librenms
    image: librenms/librenms:latest
    networks:
      default: null
    ports:
      - mode: ingress
        target: 8000
        published: "8000"
        protocol: tcp
    restart: always
    volumes:
      - type: bind
        source: /home/vaultwarden/docker/librenms/docker-master/examples/compose/librenms
        target: /data
        bind: {}
  msmtpd:
    container_name: librenms_msmtpd
    environment:
      SMTP_AUTH: "on"
      SMTP_FROM: foo@gmail.com
      SMTP_HOST: smtp.gmail.com
      SMTP_PASSWORD: bar
      SMTP_PORT: "587"
      SMTP_STARTTLS: "on"
      SMTP_TLS: "on"
      SMTP_TLS_CHECKCERT: "on"
      SMTP_USER: foo
    image: crazymax/msmtpd:latest
    networks:
      default: null
    restart: always
  redis:
    container_name: librenms_redis
    environment:
      TZ: America/Sao_Paulo
    image: redis:7.2-alpine
    networks:
      default: null
    restart: always
  rrdcached:
    container_name: rrdcached
    environment:
      PGID: "1000"
      PUID: "1000"
      TZ: America/Sao_Paulo
    image: crazymax/rrdcached:latest
    networks:
      default: null
    ports:
      - mode: ingress
        target: 42217
        published: "42217"
        protocol: tcp
    restart: always
    volumes:
      - type: bind
        source: /home/vaultwarden/docker/librenms/docker-master/examples/compose/librenms/rrd
        target: /data/db
        bind: {}
      - type: bind
        source: /home/vaultwarden/docker/librenms/docker-master/examples/compose/librenms/journal
        target: /data/journal
        bind: {}
  snmptrapd:
    cap_add:
      - NET_ADMIN
      - NET_RAW
    container_name: librenms_snmptrapd
    depends_on:
      librenms:
        condition: service_started
        required: true
      redis:
        condition: service_started
        required: true
    environment:
      CACHE_DRIVER: redis
      DB_HOST: mariadb
      DB_NAME: librenms
      DB_PASSWORD: ****************
      DB_TIMEOUT: "60"
      DB_USER: librenms
      LIBRENMS_SNMP_COMMUNITY: librenmsdocker
      LIBRENMS_WEATHERMAP: "false"
      LIBRENMS_WEATHERMAP_SCHEDULE: '*/5 * * * *'
      LOG_IP_VAR: remote_addr
      MAX_INPUT_VARS: "1000"
      MEMORY_LIMIT: 256M
      OPCACHE_MEM_SIZE: "128"
      PGID: "1000"
      PUID: "1000"
      REAL_IP_FROM: 0.0.0.0/32
      REAL_IP_HEADER: X-Forwarded-For
      REDIS_HOST: redis
      SESSION_DRIVER: redis
      SIDECAR_SNMPTRAPD: "1"
      TZ: America/Sao_Paulo
      UPLOAD_MAX_SIZE: 16M
    hostname: librenms-snmptrapd
    image: librenms/librenms:latest
    networks:
      default: null
    ports:
      - mode: ingress
        target: 162
        published: "162"
        protocol: tcp
      - mode: ingress
        target: 162
        published: "162"
        protocol: udp
    restart: always
    volumes:
      - type: bind
        source: /home/vaultwarden/docker/librenms/docker-master/examples/compose/librenms
        target: /data
        bind: {}
  syslogng:
    cap_add:
      - NET_ADMIN
      - NET_RAW
    container_name: librenms_syslogng
    depends_on:
      librenms:
        condition: service_started
        required: true
      redis:
        condition: service_started
        required: true
    environment:
      CACHE_DRIVER: redis
      DB_HOST: mariadb
      DB_NAME: librenms
      DB_PASSWORD: F)tYAR/F)k.YB.X(
      DB_TIMEOUT: "60"
      DB_USER: librenms
      LIBRENMS_SNMP_COMMUNITY: librenmsdocker
      LIBRENMS_WEATHERMAP: "false"
      LIBRENMS_WEATHERMAP_SCHEDULE: '*/5 * * * *'
      LOG_IP_VAR: remote_addr
      MAX_INPUT_VARS: "1000"
      MEMORY_LIMIT: 256M
      OPCACHE_MEM_SIZE: "128"
      PGID: "1000"
      PUID: "1000"
      REAL_IP_FROM: 0.0.0.0/32
      REAL_IP_HEADER: X-Forwarded-For
      REDIS_HOST: redis
      SESSION_DRIVER: redis
      SIDECAR_SYSLOGNG: "1"
      TZ: America/Sao_Paulo
      UPLOAD_MAX_SIZE: 16M
    hostname: librenms-syslogng
    image: librenms/librenms:latest
    networks:
      default: null
    ports:
      - mode: ingress
        target: 514
        published: "514"
        protocol: tcp
      - mode: ingress
        target: 514
        published: "514"
        protocol: udp
    restart: always
    volumes:
      - type: bind
        source: /home/vaultwarden/docker/librenms/docker-master/examples/compose/librenms
        target: /data
        bind: {}
networks:
  default:
    name: mariadb_default
    external: true

Logs

N/A

Additional info

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions