3

Description of the problem

I have UPS Orvaldi KC2000 (its capacity: 2000VA/1400W) and I want to setup configuration of my Debian 10 (Buster which is currently testing) to:

  1. get GUI (preferably GNOME) notifications when there is power failure and my computer is running on UPS battery (to know that I have little time to save the work and turn off the system),
  2. automatically turn off the computer when the battery of my UPS is critically low.

I hoped that this is easy with NUT (Network UPS Tools), but it turned out that there is no obvious way to meet the 1-st requirement – which is getting GUI (preferably GNOME) notifications.

What I've done to solve the problem?

I've installed NUT (provided by nut package which installs [among others] nut-server and nut-client) and I configured it by editing files residing in /etc/nut directory.

root@host:~# ls /etc/nut
nut.conf  ups.conf  upsd.conf  upsd.users  upsmon.conf  upssched.conf

specifically:

  • /etc/nut/upsd.users:

    [upsmon]  # name of my UPS
    password = my_UPS_password
    actions = SET
    instcmds = ALL
    upsmon master
    
  • /etc/nut/nut.conf:

    MODE=standalone
    
  • /etc/nut/ups.conf:

    maxretry = 3
    
    [myups]
        driver = blazer_usb
        port = auto
    
  • /etc/nut/upsmon.conf:

    MONITOR myups@localhost 1 upsmon my_UPS_password master
    MINSUPPLIES 1
    SHUTDOWNCMD "/sbin/shutdown -h +0"
    POLLFREQ 5
    POLLFREQALERT 5
    HOSTSYNC 15
    DEADTIME 15
    POWERDOWNFLAG /etc/killpower
    RBWARNTIME 43200
    NOCOMMWARNTIME 300
    FINALDELAY 5
    
  • rest of the files (/etc/nut/upsd.conf, /etc/nut/upssched.conf) have default content – /etc/nut/upsd.conf is empty and /etc/nut/upssched.conf has single line: CMDSCRIPT /bin/upssched-cmd.

(I skipped the comments sections in the above listings.)

After editing above configuration files I needed to run systemctl restart nut-*. * may be overkill, but I don't remember which services need to be restarted – nut-client.service, nut-driver.service, nut-monitor.service or nut-server.service.

I also installed nut-monitor which (quote): provides nut-monitor, a GUI application to monitor UPS status. I hoped that nut-monitor has some functionality that allows to popup warning window if UPS battery is low or there is some way to configure GNOME to display status of the UPS, but unfortunately I didn't find any way to do that.

To simulate power failure I use 2 commands: upsdrvctl -t shutdown and upsmon -c fsd (which shuts down the computer).

Recently I've found that there is nut-hal-drivers package that provides GUI notifications, but:

  1. I can't find this package in Debian repository.
  2. nut-hal-drivers package apparently doesn't work with upsmon and upsd provided by the nut package.

The question

My question: how can I setup configuration of my system to popup some kind of warning (preferably popup message native for given desktop environment) if there is power failure and my computer is using UPS' battery?

1 Answer 1

2

This probably a partial duplicate of: Run various shell commands when NUT reports a low UPS battery

The tricky part is to display the notification on the desktop, googling a bit, I found http://rogerprice.org/NUT/ConfigExamples.A5.pdf, page 71 it describes some scripts how to do that.

3
  • This thread doesn't address my problem. The document you linked is outstanding and directly refers to the problem. Unfortunately the suggested solution is quite complex, thus I'll wait for more answers for my question. If no one answers, I'll accept your answer. ;-) Feb 19, 2018 at 21:49
  • 1
    I don't see any easy way of doing that to be honest. I've opened github.com/networkupstools/nut/issues/526 to see if some D-Bus API could be created to expose the state of the UPS to other applications. As an interim solution, you could use upssched (from the other thread) to write some file on disk and use the content (or the mere presence of that file) to get the state of the UPS. That would requires to write an application that run in the user session as well.
    – Bigon
    Feb 19, 2018 at 21:55
  • Wow! Thanks for your commitment! You definitely deserved +1 and accepted answer tick ✔. Nonetheless I wait for a response from NUT developers. Feb 19, 2018 at 21:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .