table of contents
- Tumbleweed 2.8.4-1.1
- Leap-16.0
APC_MODBUS(8) | NUT Manual | APC_MODBUS(8) |
NAME¶
apc_modbus - Driver for APC Smart-UPS Modbus protocol
SYNOPSIS¶
apc_modbus -h
apc_modbus -a UPS_NAME [OPTIONS]
SUPPORTED HARDWARE¶
Generally this driver should work for all the APC Modbus UPS devices. Some devices might expose more than is currently supported, like multiple phases. A general rule of thumb is that APC devices (or firmware versions) released after 2010 are more likely to support Modbus than the USB HID standard.
Tested with the following hardware:
Note that you will have to enable Modbus communication. In the front panel of the UPS, go to Advanced Menu mode, under Configuration and enable Modbus.
Note
This driver was tested with Serial, TCP and USB interfaces for Modbus. Notably, the Serial ports are not available on all devices nowadays; the TCP support may require a purchase of an additional network management card; and the USB support currently requires a non-standard build of libmodbus (pull request against the upstream library is pending, as of at the time of this publication) as a pre-requisite to building NUT with this part of the support. For more details (including how to build the custom library and NUT with it) please see NUT PR #2063
Note
As currently published, this driver supports reading information from the UPS. Implementation of support to write (set modifiable variables or send commands) is expected with a later release. This can impact the host shutdown routines in particular (no ability to actively tell the UPS to power off or cycle in the end). As a workaround, you can try integrating apctest (from the "apcupsd" project) with a "Test to kill power" into your late-shutdown procedure, if needed.
EXTRA ARGUMENTS¶
This driver also supports the following optional settings:
port = string
Note
This could be a device filesystem path like /dev/usb/hiddev0 but current use of libusb API precludes knowing and matching by such identifiers. They may also be inherently unreliable (dependent on re-plugging and enumeration order). At this time the actual value is ignored, but syntactically some port configuration must still be there.
It is possible to control multiple UPS units simultaneously by running several instances of this driver, provided they can be uniquely distinguished by setting some combination of the vendor, product, vendorid, productid, serial, bus and/or device options detailed below. For devices or operating systems that do not provide sufficient information, the allow_duplicates option can be of use (limited and risky!)
vendorid = regex, productid = regex, vendor = regex, product = regex, serial = regex
Try lsusb(8) or running this NUT driver with -DD command-line argument for finding out the strings to match.
Examples:
bus = regex
Select a UPS on a specific USB bus or group of buses. The argument is a regular expression that must match the bus name where the UPS is connected (e.g. bus="002" or bus="00[2-3]") as seen on Linux in /sys/bus/usb/devices or lsusb(8); including leading zeroes.
Note
Bus numbers are not guaranteed by the OS to be stable across re-boots, kernel driver reloads or device re-plugging (e.g. changing visible population of USB hubs).
device = regex
Select a UPS on a specific USB device or group of devices. The argument is a regular expression that must match the device name where the UPS is connected (e.g. device="001" or device="00[1-2]") as seen on Linux in /sys/bus/usb/devices or lsusb(8); including leading zeroes.
Note
Device numbers are not guaranteed by the OS to be stable across re-boots or device re-plugging.
busport = regex
If supported by the hardware, OS and libusb on the particular deployment, this option should allow to specify physical port numbers on an USB hub, rather than logical device enumeration values, and in turn — this should be less volatile across reboots or re-plugging. The value may be seen in the USB topology output of lsusb -tv on systems with that tool, for example.
Note
This option is not practically supported by some NUT builds (it should be ignored with a warning then), and not by all systems that NUT can run on.
allow_duplicates
If you have several UPS devices which may not be uniquely identified by the options above (e.g. only VID:PID can be discovered there), this flag allows each driver instance where it is set to take the first match if available, or proceed to try another.
Normally the driver initialization would abort at this point claiming "Resource busy" or similar error, assuming that the otherwise properly matched device is unique — and some other process already handles it.
Warning
This feature is inherently non-deterministic! The association of driver instance name to actual device may vary between runs!
If you only care to know that at least one of your no-name UPSes is online, this option can help.
If you must really know which one, it will not!
usb_set_altinterface = bAlternateSetting
usb_config_index, usb_hid_rep_index, usb_hid_desc_index, usb_hid_ep_in, usb_hid_ep_out
As a rule of thumb for usb_hid_desc_index discovery, you can see larger wDescriptorLength values (roughly 600+ bytes) in reports of lsusb or similar tools.
LIBUSB_DEBUG = INTEGER
For the latter, you can set the LIBUSB_DEBUG driver option; alternatively you can classically export the environment variable LIBUSB_DEBUG before starting a NUT driver program (may be set and "exported" in driver init script or service method, perhaps via nut.conf(5)), to a numeric value such as 4 ("All messages are emitted").
For more details, including the currently supported values for your version of the library, see e.g.:
porttype=value
port=value
baudrate=num
parity=value
databits=num
stopbits=num
slaveid=num
response_timeout_ms=num
BUGS¶
RTU USB support¶
This driver relies on advanced features of libmodbus to talk Modbus protocol over USB specifically (Serial and TCP are part of common library codebase). At the time of this writing, the common library project is just expecting a merge of the pull request with this ability.
For the time being, if your OS distribution does not ship the required feature set, you may have to build your own libmodbus and subsequently (re-)build NUT against this library, as detailed in the NUT GitHub Wiki at https://github.com/networkupstools/nut/wiki/APC-UPS-with-Modbus-protocol
The short sequence may be like follows:
cd ~/ git clone -b rtu_usb https://github.com/networkupstools/libmodbus cd libmodbus ./autogen.sh ./configure --with-libusb --prefix=/path/to/prefix make install
Note
cd ~/ git clone https://github.com/networkupstools/nut cd nut ./autogen.sh ./configure --with-drivers=apc_modbus --with-usb --with-modbus \
--with-modbus-includes=-I/path/to/prefix/include/modbus \
--with-modbus-libs="-L/path/to/prefix/lib -lmodbus" make
Note
The ./configure --enable-inplace-runtime may be a good start to inherit build configuration from an existing NUT deployment, as further detailed at https://github.com/networkupstools/nut/wiki/Building-NUT-for-in%E2%80%90place-upgrades-or-non%E2%80%90disruptive-tests
Using host names for UPS NMC¶
An UPS network management card may be assigned a fixed/static IP address or a dynamic one (e.g. by DHCP) in your network. Due to this, you may want or have to use a dynamic naming service to access the UPS. Note that this may become a problem specifically during large outages and shutdowns, when your DHCP/DNS server might already go down while the driver needs to resolve the name involved (especially during late-shutdown hooks, when a new instance of the driver program might start just to tell the UPS to power off or to power-cycle).
It may be wise to ensure your OS name service client can cache the UPS name sufficiently long, or to use fixed IP addressing (and an entry in /etc/hosts for good measure, so you only have one spot to eventually re-configure this).
AUTHORS¶
SEE ALSO¶
The core driver¶
Internet resources¶
The NUT (Network UPS Tools) home page: https://www.networkupstools.org/historic/v2.8.4/
08/12/2025 | Network UPS Tools 2.8.4 |