[Nut-upsuser] Simulating an UPS

Roger Price roger at rogerprice.org
Wed Jun 29 15:25:04 BST 2022

On Sat, 25 Jun 2022, PeReZ via Nut-upsuser wrote:

> Hi,I create a script to build a file for the dummy-ups to simulate an UPS from 
> other two in redundant mode for devices that allows monitoring only one UPS.
> The diagram: https://imgur.com/a/z4ZUuNw

I tried this with three different browsers, but all I got was all-black 
screens or a javascript error.

> I made some configurations that I put here:
> https://pastebin.com/yiQ1ju10
> Can you look at them and tell me if it can works before I try physically?
> Just saw an error on upsmon.conf where I put a symbolic IP address for the two UPSes but I must put the name in ups.conf instead.
> My doubts are in upsmon.conf where I defined a custom script to be called on NOTIFYCMD and I don't know if now the upssched will be called anyway by NUT.
> I don't know if upssched is needed to power off the UPSes.
> Then in upsd.conf should I put the static IP other than
> There is also a dummy.dev file with default values to be sure that the dummy ups can read something even before the start of the script.

  # *** ups.conf ***
  driver = usbhid-ups
  driver = dummy-ups
  port = /etc/nut/dummy.dev
  desc = "Sum Of Two"

  # *** upsmon.conf ***
  MONITOR UPS1 at 1 ups_admin PASSWORD master
  MONITOR UPS2 at 1 ups_admin PASSWORD master

Why "1" ?  Surely you need them both.

  NOTIFYCMD "/etc/nut/notifycmd.sh"

This says which program is to be invoked when upsmon detects a NOTIFY event 
flagged as EXEC.  This is often used to point to /sbin/upssched, but in your 
case you point directly to your own script.  Does NUT expect a script or a 
configuration file?


  # *** upssched.conf ***

This file is never used

  CMDSCRIPT /etc/nut/upssched-cmd

This script is never called.

  # *** notifycmd.sh ***
  #! /bin/bash
  # notifycmd.sh
  # This script notify user of all updates on two physical UPSes
  # then it creates the file that will be read from dummy-ups
  EMAIL='youremail at domain.tld'
  echo -e "Subject: [NUT] $NOTIFYTYPE\r\n\r\nUPS: $UPSNAME\r\nAlert type: $NOTIFYTYPE\r\n\r\n`upsc $UPSNAME`" | msmtp -a default $EMAIL

It would probably be useful for debugging to echo this to the command line 
together with the arguments received by the script.

  CHARGE = $( upsc $UPS1 battery.charge )

  if [ $CHARGE -ge $CHARGE2 ]; then
  cat > /etc/nut/dummy.dev << _EOF_
  battery.charge: ${ CHARGE }

You rewrite dummy.dev for every UPS event.

Why don't you use upssched?  What is it that prevents you from using the 
upsmon.conf option MINSUPPLIES 2 ?


More information about the Nut-upsuser mailing list