Skip to content
Open
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
1 change: 1 addition & 0 deletions .github/workflows/01-make-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ jobs:
libfreeipmi-dev libipmimonitoring-dev \
libavahi-common-dev libavahi-core-dev libavahi-client-dev \
libgpiod-dev \
libglib2.0-dev \
bash dash ksh busybox \
libneon27-gnutls-dev \
build-essential git-core libi2c-dev i2c-tools lm-sensors \
Expand Down
42 changes: 40 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 @@ -5432,6 +5442,34 @@ AS_IF([test x"$have_PKG_CONFIG" = xyes],
)
AC_MSG_RESULT(${have_cppunit})

dnl ----------------------------------------------------------------------
dnl Check for GLib / GIO (Required for UPower driver)
dnl ----------------------------------------------------------------------

have_glib=no

if test "${with_upower}" != "no"; then
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])]
)
fi

if test "${have_glib}" = "yes"; then
AC_DEFINE(HAVE_GLIB, 1, [Define to 1 if GLib and GIO are available])
else
if test "${with_upower}" = "yes"; then
AC_MSG_ERROR([GLib/GIO not found but requested via --with-upower])
fi
AC_MSG_WARN([GLib/GIO not found. The 'upower' driver will not be built.])
fi

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

dnl On some systems, CppUnit inexplicably fails with trivial assertions
dnl so it should not be enabled with those environments, corrupting the
dnl test results with misleading errors.
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 = upower_dbus.txt
INST_MAN_UPOWER_PAGES = upower_dbus.$(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 = \
upower_dbus.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
71 changes: 71 additions & 0 deletions docs/man/upower_dbus.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
UPOWER_DBUS(8)
==============

NAME
----
upower_dbus - Driver for UPower devices via D-Bus

SYNOPSIS
--------
*upower_dbus* -h

*upower_dbus* -a 'UPS_NAME' ['OPTIONS']

NOTE: This man page only documents the specific features of the
*upower_dbus* driver. For information about the core driver, see
linkman:nutupsdrv[8].

DESCRIPTION
-----------
This driver allows the monitoring of power devices (UPS, batteries) that are
managed by the UPower daemon via the D-Bus system bus.

It maps UPower properties (state, percentage, voltage, etc.) to standard NUT
variables, allowing NUT clients to monitor devices that are natively supported
by the OS desktop environment but not directly by other NUT drivers.

EXTRA ARGUMENTS
---------------
This driver supports the following optional settings in linkman:ups.conf[5]:

*port*::
The UPower Object Path of the device to monitor.

If set to `auto` (the default), the driver will scan for the first UPower device
whose object path contains the string "ups_".

If set to a specific path (e.g., `/org/freedesktop/UPower/devices/ups_hiddev0`),
the driver will attempt to monitor that specific device.

*lowbatt*::
The battery percentage threshold below which the `LB` (Low Battery) status
flag is set. The default value is 20.0.

INSTALLATION
------------
To use this driver, add a section to your *ups.conf*:

----
[myups]
driver = upower_dbus
port = auto
lowbatt = 20
desc = "Laptop Battery or generic UPS via UPower"
----

REQUIREMENTS
------------
This driver requires the `upower` daemon to be running and accessible via the
D-Bus system bus. It also requires GLib 2.0 and GIO libraries.

AUTHOR
------
Tim Niemueller <tim@niemueller.de>

SEE ALSO
--------
linkman:ups.conf[5], linkman:nutupsdrv[8], linkman:upsc[8]

Internet Resources:
~~~~~~~~~~~~~~~~~~~
The NUT (Network UPS Tools) home page: https://www.networkupstools.org/
8 changes: 7 additions & 1 deletion docs/nut.dict
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 3632 utf-8
personal_ws-1.1 en 3638 utf-8
AAC
AAS
ABI
Expand Down Expand Up @@ -241,6 +241,7 @@ Cygwin
DATACABLE
DATAPATH
DBCF
DBUS
DCE
DCF
DCO
Expand Down Expand Up @@ -434,7 +435,9 @@ GES
GETADDRINFO
GETPID
GID
GIO
GITREV
GLib
GND
GNUmakefile
GObject
Expand Down Expand Up @@ -850,6 +853,7 @@ Netman
NetworkUPSTools
Neus
Niels
Niemueller
Niklas
Niro
NixOS
Expand Down Expand Up @@ -1925,6 +1929,7 @@ datasheet
datasize
datastale
dblatex
dbus
dcd
dcn
ddk
Expand Down Expand Up @@ -2133,6 +2138,7 @@ formatstring
fosshost
fp
freebsd
freedesktop
freeipmi
freetype
frob
Expand Down
12 changes: 12 additions & 0 deletions drivers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,15 @@ LINUX_I2C_DRIVERLIST = asem pijuice hwmon_ina219
POWERMAN_DRIVERLIST = powerman-pdu
IPMI_DRIVERLIST = nut-ipmipsu
GPIO_DRIVERLIST = generic_gpio_libgpiod
UPOWER_DRIVERLIST = upower_dbus

# distribute all drivers, even ones that are not built by default
EXTRA_PROGRAMS = $(SERIAL_DRIVERLIST) $(USB_DRIVERLIST) $(SERIAL_USB_DRIVERLIST)
EXTRA_PROGRAMS += $(SNMP_DRIVERLIST) $(NEONXML_DRIVERLIST) $(MACOSX_DRIVERLIST)
EXTRA_PROGRAMS += $(LINUX_I2C_DRIVERLIST)
EXTRA_PROGRAMS += $(NUTSW_DRIVERLIST)
EXTRA_PROGRAMS += $(GPIO_DRIVERLIST)
EXTRA_PROGRAMS += $(UPOWER_DRIVERLIST)

# construct the list of drivers to build
if SOME_DRIVERS
Expand Down Expand Up @@ -364,6 +366,16 @@ mge_shut_SOURCES = usbhid-ups.c libshut.c libhid.c hidparser.c mge-hid.c
mge_shut_CFLAGS = $(AM_CFLAGS) -DSHUT_MODE=1
mge_shut_LDADD = $(LDADD_DRIVERS_SERIAL) -lm

# UPower
if HAVE_GLIB
# Only build upower if GLib was found
driverexec_PROGRAMS += $(UPOWER_DRIVERLIST)

upower_dbus_SOURCES = upower_dbus.c
upower_dbus_LDADD = $(LDADD_DRIVERS) $(GLIB_LIBS)
upower_dbus_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
endif

# SNMP
# Please keep the MIB table below sorted roughly alphabetically (incidentally
# by vendor too) to ease maintenance and codebase fork resynchronisations
Expand Down
Loading
Loading