-
-
Notifications
You must be signed in to change notification settings - Fork 406
nut‐driver‐enumerator (NDE)
The nut-driver-enumerator (NDE) feature is provided since NUT v2.8.0 release to facilitate automatic service unit instance creation for each NUT device driver definition, so that the drivers for each device have independent life-cycles (unlike the singular nut-driver units in earlier releases, or singular init-scripts using upsdrvctl by default without specific device names).
You can see an example unit deployment detailed in NUT systemd service units page.
Benefits include, for example, that:
- A failed and restarted driver no longer causes a restart of the whole NUT stack and does not impact fellow drivers that did not have any problems.
- Initialization time of one driver (notably
snmp-upscan have long first data walks) does not impact other drivers which can start in parallel (caveat: unless such init is CPU-intensive and there are very many drivers - may be a problem on weak appliances with grand plans). - Dependencies can be defined, whether prerequisites for the drivers (some need networking or similar facilities, others do not), or some further programs of your choice starting because a particular NUT driver runs.
- Edition of
ups.confis automatically applied to the actual set of running NUT driver daemons, each isolated in itsnut-driverservice unit instance.
This feature is currently supported for Linux systemd and Solaris/illumos SMF service management frameworks. PRs are of course welcome to extend it for more such systems.
Caveat emptor: Many instructions about NUT suggest using upsdrvctl to manage driver lifecycle, or to run driver programs directly when troubleshooting with higher verbosity and/or picking the options for driver configuration. This can conflict with service unit instances created by NDE (which can in turn be automatically enabled as part of NUT packages) and managed by the OS to keep the drivers alive. The new driver program started on command line would typically kill off an older copy (assuming it is stuck), then systemd or SMF would revive the driver wrapped into the service instance and kill off the one started on command line.
- When troubleshooting, remember to either temporarily stop the service units while fiddling with command-line driver instances, or to embrace the automatic reconfiguration and make use of
debug_minsetting temporarily to collect information into the service logs. See Changing NUT daemon debug verbosity for more details on that. - When managing driver instances,
upsdrvsvcctl(part of NDE) can help.
On the technical side, NDE is primarily a portable shell script which can parse configuration from the ups.conf global and per-device sections, and to discover the service instances for each device (along with saved checksum of last applied configuration), and compares the two lists. If there are any discrepancies (typically device sections appearing, disappearing, or being changed), NDE adds, removes or changes definitions of service units and stops/starts them as applicable, and notifies the upsd data server to reload configuration (or restart).
- See current source code version at https://github.com/networkupstools/nut/blob/master/scripts/upsdrvsvcctl/nut-driver-enumerator.sh.in
- See current man page at https://github.com/networkupstools/nut/blob/master/docs/man/nut-driver-enumerator.txt or https://networkupstools.org/docs/man/nut-driver-enumerator.html
For practical purposes, NDE is a script that people can run manually when they install NUT or change ups.conf definitions, and either a run-once service that takes effect during boot (to refresh current device lists), or a daemon that runs an infinite loop to pick up the changes over time (for monitoring platforms that track a varying population of power devices). Depending on the platform, other triggers may be available, e.g. "path" units which allow the OS to react to filesystem changes and trigger the run-once service (or send a refresh signal to daemon-mode service).
It is accompanied by upsdrvsvcctl which allows to manage service management framework instances wrapping the drivers, while mimicking upsdrvctl (which manages driver daemon binaries directly):
- See current source code version at https://github.com/networkupstools/nut/blob/master/scripts/upsdrvsvcctl/upsdrvsvcctl.in
- See current man page at https://github.com/networkupstools/nut/blob/master/docs/man/upsdrvsvcctl.txt or https://networkupstools.org/docs/man/upsdrvsvcctl.html
Depending on the OS and NUT release, you can see some or all of the following:
- The
nut-driver-enumerator.shscript which does all the work about parsingups.confand managing service units, itslibexecdirlocation depends on packaging. - The
upsdrvsvcctlscript which manages service unit instances which each wrap a single NUT driver configuration, itssbindirlocation depends on packaging. - Services for single-shot runs (aimed at majority of users with rarely edited configurations):
- A
nut-driver-enumerator.service(systemd) ornut-driver-enumerator:default(SMF) which runs once to add/removenut-driverservice unit instances and exits, typically upon OS boot or when triggered by external callers. - A
nut-driver-enumerator.path(systemd) to trigger single runs ofnut-driver-enumerator.servicewheneverups.confis edited.
- A
- Services for daemonized runs (aimed at larger monitoring systems whose population of known power devices can change frequently):
- A
nut-driver-enumerator-daemon.service(systemd) ornut-driver-enumerator:daemon(SMF) which runs persistently, to pick up editions ofups.confas it checks the file every minute or so, or instantly on-demand when it receives a signal. - A
nut-driver-enumerator-daemon-activator.service(systemd) which causes a "reload-or-restart" of thenut-driver-enumerator-daemon.serviceto cause instant processing (without waiting for a loop delay to expire). - A
nut-driver-enumerator-daemon-activator.path(systemd) to trigger single runs ofnut-driver-enumerator-daemon-activator.servicewheneverups.confis edited.
- A
Obviously, the single-shot and daemon approaches are mutually exclusive. Depending on the OS capabilities (and throttling of those) and on the activated or disabled units, both approaches can result in automatic reconfiguration of nut-driver service instances as you edit the ups.conf file.
Welcome to the Network UPS Tools (NUT) project Wiki, and feel free to contribute tricks and insights.
While there are several good entries in the menu, ones referenced most frequently in issue discussions include:
- Building NUT for in-place upgrades or non-disruptive tests (including the build prerequisites for different platforms in-tree or as a rendered page on NUT website) and Using NIT (NUT Integration Test suite) sandbox
- Technicalities: Customizing (NUT) config files and scripts delivered by packaging
- Links to distribution packaging recipes and repository sections
- Troubleshooting
upsdrvctldrivers not starting ("insufficient permissions on everything" or "Can't claim USB device [VVVV:PPPP]@0/0: Entity not found") possibly due to nut-driver-enumerator (NDE) services having been there before you with NUT 2.8.x, and "insufficient permissions" when starting USB drivers for a different PoV on this; see also an example unit deployment detailed in NUT systemd service units page - Changing NUT daemon debug verbosity
- Building NUT integration for Home Assistant
- Running NUT in an LXC container
- Troubleshooting eventual disconnections (Data stale) and CyberPower Systems (CPS) know-how
- NUT for Windows
- NUT HCL and DDL
- Code contributions, PRs, PGP and DCO
- NUT CI farm
Also keep in mind the documentation links from NUT website and the FAQ in particular.