Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ https://github.com/networkupstools/nut/milestone/12
* Fixed default `unit_id`, apparently broken by changes in NUT v2.8.1.
[issue #3191, PR #3192]

- Introduced a new NUT driver named `nut-upower` which provides support
for monitoring UPS and battery devices managed by the UPower daemon
via D-Bus. This also introduces a new category of drivers that talk to
operating system services to obtain power state information. [PR #3279]

- `usbhid-ups` driver updates:
* Declared support for APC with USB ID `051d:0005` (details may evolve
as the devices become better known). [issue #3047, PR #3081]
Expand Down
5 changes: 5 additions & 0 deletions UPGRADING.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ Changes from 2.8.4 to 2.8.5
updated, either to explicitly package the binding for several versions,
or to not-deliver files no longer installed into the prototype area. [#1792]

- Introduced a new driver category for interaction with OS-reported UPS
devices via D-Bus, with the `nut-upower` driver as the first implementation.
This driver requires `glib-2.0` and `gio-2.0` development libraries to be
available at build time. For packagers, this adds new dependencies if the
build should include this driver. [PR #3279]

Changes from 2.8.3 to 2.8.4
---------------------------
Expand Down
80 changes: 78 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,7 @@ AC_ARG_WITH(drivers,
if test -z "${with_powerman}"; then with_powerman="yes"; fi
if test -z "${with_modbus}"; then with_modbus="yes"; fi
if test -z "${with_ipmi}"; then with_ipmi="yes"; fi
if test -z "${with_upower}"; then with_upower="yes"; fi

dnl Platform-dependent snowflakes that are required or auto:
if test -z "${with_gpio}"; then
Expand Down Expand Up @@ -2353,6 +2354,7 @@ AC_ARG_WITH(drivers,
if test -z "${with_powerman}"; then with_powerman="${withval}"; fi
if test -z "${with_modbus}"; then with_modbus="${withval}"; fi
if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi
if test -z "${with_upower}"; then with_upower="${withval}"; fi
if test -z "${with_gpio}"; then with_gpio="${withval}"; fi
if test -z "${with_linux_i2c}"; then with_linux_i2c="${withval}"; fi
if test -z "${with_macosx_ups}"; then with_macosx_ups="${withval}"; fi
Expand All @@ -2369,7 +2371,8 @@ AC_ARG_WITH(drivers,
SERIAL_DRIVERLIST USB_LIBUSB_DRIVERLIST SERIAL_USB_DRIVERLIST
SNMP_DRIVERLIST NEONXML_DRIVERLIST
MACOSX_DRIVERLIST MODBUS_DRIVERLIST LINUX_I2C_DRIVERLIST
POWERMAN_DRIVERLIST IPMI_DRIVERLIST GPIO_DRIVERLIST"
POWERMAN_DRIVERLIST IPMI_DRIVERLIST GPIO_DRIVERLIST
UPOWER_DRIVERLIST"

dnl Gets ONE Makefile assignment value
get_drivers_makefile_value() (
Expand Down Expand Up @@ -2520,6 +2523,11 @@ AC_ARG_WITH(drivers,
[AC_MSG_NOTICE([Requiring --with-gpio=yes for driver "$DRV"])
with_gpio=yes]
)],
[UPOWER_DRIVERLIST], [
AS_IF([test -z "${with_upower}"],
[AC_MSG_NOTICE([Requiring --with-upower=yes for driver "$DRV"])
with_upower=yes]
)],

[AC_MSG_WARN([Unhandled DRVLIST_NAME=$DRVLIST_NAME])]
)
Expand Down Expand Up @@ -2553,7 +2561,7 @@ dnl check for --with-all (or --without-all, or --with-all=auto) flag

AC_MSG_CHECKING(for --with-all)
AC_ARG_WITH(all,
AS_HELP_STRING([--with-all], [enable serial, usb, snmp, neon, ipmi, powerman, modbus, gpio (currently on Linux released after ~2018), linux_i2c (on Linux), macosx-ups (on MacOS), cgi, dev, avahi, nut-scanner, nutconf, dev-libnutconf, pynut]),
AS_HELP_STRING([--with-all], [enable serial, usb, snmp, neon, ipmi, powerman, modbus, gpio (currently on Linux released after ~2018), linux_i2c (on Linux), upower, macosx-ups (on MacOS), cgi, dev, avahi, nut-scanner, nutconf, dev-libnutconf, pynut]),
[
if test -n "${withval}"; then
dnl Note: we allow "no" as a positive value, because
Expand All @@ -2567,6 +2575,7 @@ AC_ARG_WITH(all,
if test -z "${with_powerman}"; then with_powerman="${withval}"; fi
if test -z "${with_modbus}"; then with_modbus="${withval}"; fi
if test -z "${with_ipmi}"; then with_ipmi="${withval}"; fi
if test -z "${with_upower}"; then with_upower="${withval}"; fi

dnl Platform-dependent snowflakes that are required or auto:
if test -z "${with_gpio}"; then
Expand Down Expand Up @@ -2845,6 +2854,7 @@ dnl Platform-dependent drivers, currently their detection code is directly
dnl spelled out in configure.ac
NUT_ARG_WITH([macosx_ups], [build and install Mac OS X Power Sources meta-driver], [auto])
NUT_ARG_WITH([linux_i2c], [build and install i2c drivers], [auto])
NUT_ARG_WITH([upower], [build and install UPower driver (requires GLib/GIO)], [auto])

dnl A Python GUI client application for the sysadmin desktop
dnl (not necessarily on the NUT server itself):
Expand Down Expand Up @@ -3136,6 +3146,72 @@ NUT_REPORT_DRIVER([build Mac OS X meta-driver],
[${nut_with_macosx_ups}], [${nut_macosx_ups_lib}],
[WITH_MACOSX], [Define to enable Mac OS X meta-driver])

dnl ----------------------------------------------------------------------
dnl Check for libGLib / libGIO (Required for UPower driver)
dnl NOTE: Do not confuse libglib{2} (GNOME) with glibc (part of compiler)
dnl ----------------------------------------------------------------------

have_glib=no

AS_IF([test "${with_upower}" != "no"], [
AS_IF([test x"$have_PKG_CONFIG" = xyes],
[ifdef([PKG_CHECK_MODULES],
[PKG_CHECK_MODULES(GLIB, [glib-2.0 gio-2.0], [have_glib=yes], [have_glib=no])],
[have_glib=no])
],
[AC_MSG_WARN([pkg-config not found, cannot look properly for glib-2.0/gio-2.0])]
)
])

AS_IF([test "${have_glib}" = "yes"], [
AC_DEFINE(HAVE_GLIB, 1, [Define to 1 if GLib and GIO are available])

dnl GLib headers seem incorrect and offensive to many compilers
dnl (starting names with underscores and capital characters,
dnl varying support for attributes, method pointer mismatches).
dnl There is nothing NUT can do about it, except telling the
dnl compiler that we take these headers from the system as they
dnl are, so strict checks should not apply to them.
dnl On newer releases (2025+) the headers and CLANG seem to work
dnl together out of the box, but during the decade before this is
dnl troublesome.
AS_IF([test "${CLANGCC}" = "yes" || test "${GCC}" = "yes"], [
myGLIB_CFLAGS=""
for TOKEN in ${GLIB_CFLAGS} ; do
AS_CASE(["${TOKEN}"],
[-I/*], [
_IDIR="`echo \"${TOKEN}\" | sed 's/^-I//'`"
AS_IF([echo " ${GLIB_CFLAGS}" | ${EGREP} " -isystem *${_IDIR}" >/dev/null],
[myGLIB_CFLAGS="${myGLIB_CFLAGS} ${TOKEN}"],
[myGLIB_CFLAGS="${myGLIB_CFLAGS} -isystem ${_IDIR} ${TOKEN}"]
)],
[myGLIB_CFLAGS="${myGLIB_CFLAGS} ${TOKEN}"]
)
done
unset TOKEN
unset _IDIR
myGLIB_CFLAGS="`echo \"${myGLIB_CFLAGS}\" | sed 's/^ *//'`"

AS_IF([test x"${GLIB_CFLAGS}" != x -a x"${GLIB_CFLAGS}" != x"${myGLIB_CFLAGS}"], [
AC_MSG_NOTICE([Patched libglib/libgio CFLAGS to declare -isystem])
AS_IF([test x"${nut_enable_configure_debug}" = xyes], [
AC_MSG_NOTICE([(CONFIGURE-DEVEL-DEBUG) old: ${GLIB_CFLAGS}])
AC_MSG_NOTICE([(CONFIGURE-DEVEL-DEBUG) new: ${myGLIB_CFLAGS}])
])
GLIB_CFLAGS="${myGLIB_CFLAGS}"
])
unset myGLIB_CFLAGS
])
], [
AS_CASE(["${with_upower}"],
[yes], [AC_MSG_ERROR([GLib/GIO not found but requested via --with-upower])],
[auto],[AC_MSG_WARN([GLib/GIO not found. The 'upower' driver will not be built.])]
)
])

AM_CONDITIONAL(HAVE_GLIB, test "${have_glib}" = "yes")
AC_MSG_RESULT(${have_glib})

dnl ----------------------------------------------------------------------
dnl checks related to --with_linux_i2c
dnl Check for i2c header on Linux, used for ASEM UPS driver
Expand Down
15 changes: 13 additions & 2 deletions docs/config-prereqs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ metadata about recently published package revisions:
libssl-dev libnss3-dev \
augeas-tools libaugeas-dev augeas-lenses \
libusb-dev libusb-1.0-0-dev \
libglib2.0-dev \
libi2c-dev \
libmodbus-dev \
libsnmp-dev \
Expand Down Expand Up @@ -459,6 +460,7 @@ drivers in distro packaging of NUT. Resolution and doc PRs are welcome.
openssl-devel nss-devel \
augeas augeas-devel \
libusb-devel libusbx-devel \
glib2-devel \
i2c-tools \
libmodbus-devel \
net-snmp-devel \
Expand Down Expand Up @@ -561,6 +563,7 @@ Install tools and prerequisites for NUT:
openssl nss \
augeas \
libusb \
glib2 \
neon \
net-snmp \
freeipmi \
Expand Down Expand Up @@ -732,6 +735,7 @@ For NUT dependencies and build tools:
:; slackpkg-install \
openssl openssl-solibs mozilla-nss \
libusb \
glib2 \
net-snmp \
neon

Expand Down Expand Up @@ -870,6 +874,8 @@ below.
cppunit \
nss \
augeas \
libusb \
glib \
libmodbus \
neon \
net-snmp \
Expand Down Expand Up @@ -1041,6 +1047,7 @@ Finally, as `root` add the packages:
openssl nss \
augeas \
libusb1 \
glib2 \
net-snmp \
avahi

Expand Down Expand Up @@ -1232,6 +1239,7 @@ but can be created in `/etc/` and is honoured by `pkgin`:
openssl nss \
augeas \
libusb libusb1 \
glib2 \
neon \
net-snmp \
avahi
Expand Down Expand Up @@ -1366,6 +1374,7 @@ Typical tooling would include:
library/augeas python/augeas \
libusb-1 libusbugen system/library/usb/libusb \
system/header/header-usb driver/usb/ugen \
glib2 \
libmodbus \
library/neon \
system/management/snmp/net-snmp \
Expand Down Expand Up @@ -1508,6 +1517,7 @@ site for setup details.
developer/build/libtool library/libtool/libltdl \
build-essential ccache git developer/pkg-config \
runtime/perl \
glib \
asciidoc \
libgd

Expand Down Expand Up @@ -1725,7 +1735,7 @@ Currently known dependencies for basic build include:
# Required:
:; brew install ccache bash libtool binutils autoconf automake git m4 \
pkg-config aspell asciidoc docbook-xsl cppunit gd \
libusb neon net-snmp \
libusb glib neon net-snmp \
nss openssl \
libmodbus freeipmi powerman

Expand Down Expand Up @@ -1935,7 +1945,8 @@ export PATH

# This also pulls *-devel of several other projects:
:; pacman -S --needed \
mingw-w64-x86_64-neon libneon-devel
mingw-w64-x86_64-neon libneon-devel \
mingw-w64-x86_64-glib2

# Other dependencies:
:; pacman -S --needed \
Expand Down
14 changes: 14 additions & 0 deletions docs/configure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,20 @@ This allows to monitor numerous Power Supply Units (PSU) found on servers.
Note that you need to install freeipmi (0.8.5 or higher, for nut-scanner;
and 1.0.1 or higher, for nut-ipmipsu) development package or files.

UPower/D-Bus drivers
~~~~~~~~~~~~~~~~~~~~

--with-upower (default: auto-detect)

Build and install the `nut-upower` driver.

This allows to monitor UPS and battery devices managed by the UPower daemon
via D-Bus. This introduces a new category of drivers that talk to operating
system services to obtain power state information.

Note that you need to install `glib-2.0` and `gio-2.0` development packages
or files.

I2C bus drivers
~~~~~~~~~~~~~~~

Expand Down
41 changes: 38 additions & 3 deletions docs/man/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,38 @@ else !DOC_INSTALL_SELECTED_MANS_PROGS_BUILT
LINKMAN_PAGES_DRIVERS += $(SRC_GPIO_PAGES)
endif !DOC_INSTALL_SELECTED_MANS_PROGS_BUILT

# (--with-upower)
SRC_UPOWER_PAGES = nut-upower.txt
INST_MAN_UPOWER_PAGES = nut-upower.$(MAN_SECTION_CMD_SYS)
DIST_ALL_MAN_PAGES += $(INST_MAN_UPOWER_PAGES)

if ! SOME_DRIVERS
if WITH_MANS
MAN_UPOWER_PAGES = $(INST_MAN_UPOWER_PAGES)
endif WITH_MANS

if HAVE_GLIB
mansys_DATA += $(MAN_UPOWER_PAGES)
endif HAVE_GLIB
endif ! SOME_DRIVERS

INST_HTML_UPOWER_MANS = \
nut-upower.html
DIST_ALL_HTML_PAGES += $(INST_HTML_UPOWER_MANS)

if ! SOME_DRIVERS
HTML_UPOWER_MANS = $(INST_HTML_UPOWER_MANS)
endif ! SOME_DRIVERS

# FIXME? Refine for HTML etc.?
if DOC_INSTALL_SELECTED_MANS_PROGS_BUILT
if HAVE_GLIB
LINKMAN_PAGES_DRIVERS += $(SRC_UPOWER_PAGES)
endif HAVE_GLIB
else !DOC_INSTALL_SELECTED_MANS_PROGS_BUILT
LINKMAN_PAGES_DRIVERS += $(SRC_UPOWER_PAGES)
endif !DOC_INSTALL_SELECTED_MANS_PROGS_BUILT

# Summarize which pages we ultimately install:
MAN_MANS =
if WITH_MANS
Expand All @@ -1486,7 +1518,8 @@ MAN_MANS += \
$(MAN_MACOSX_PAGES) \
$(MAN_MODBUS_PAGES) \
$(MAN_LINUX_I2C_PAGES) \
$(MAN_GPIO_PAGES)
$(MAN_GPIO_PAGES) \
$(MAN_UPOWER_PAGES)
endif WITH_MANS

SRC_DRIVERS_PAGES = \
Expand All @@ -1500,7 +1533,8 @@ SRC_DRIVERS_PAGES = \
$(SRC_MACOSX_PAGES) \
$(SRC_MODBUS_PAGES) \
$(SRC_LINUX_I2C_PAGES) \
$(SRC_GPIO_PAGES)
$(SRC_GPIO_PAGES) \
$(SRC_UPOWER_PAGES)

if SOME_DRIVERS
# (Legacy note) The list above probably came up empty in this case, so make sure
Expand Down Expand Up @@ -1576,7 +1610,8 @@ HTML_MANS = \
$(HTML_MACOSX_MANS) \
$(HTML_MODBUS_MANS) \
$(HTML_LINUX_I2C_MANS) \
$(HTML_GPIO_MANS)
$(HTML_GPIO_MANS) \
$(HTML_UPOWER_MANS)

# htmlmandir is set by autoconf/automake
htmlman_DATA =
Expand Down
Loading
Loading