OPNsense Forum

English Forums => Development and Code Review => Topic started by: smajor on June 26, 2015, 01:20:52 AM

Title: UPS Support
Post by: smajor on June 26, 2015, 01:20:52 AM
I didn't see anything on the roadmap.  I'm curious if we'll eventually see UPS support for graceful shutdowns.

Perhaps when plugin support is added we'll see something like this?:

http://wiki.ipfire.org/en/addons/nut/start
Title: Re: UPS Support
Post by: franco on June 26, 2015, 07:19:36 AM
apcupsd will be in the next release as an optional package, if somebody steps up and implements the GUI parts that would be awesome.
Title: Re: UPS Support
Post by: guest7876 on August 15, 2015, 10:26:52 AM
having apcupsd would be awesome. especially with a GUI to configure it.

Title: Re: UPS Support
Post by: franco on August 16, 2015, 05:10:10 PM
apcupsd package has been available via manual install for a while, a GUI plugin is not currently there.
Title: Re: UPS Support
Post by: guest7876 on August 21, 2015, 05:47:16 AM
Quote from: franco on August 16, 2015, 05:10:10 PM
apcupsd package has been available via manual install for a while, a GUI plugin is not currently there.

i dont mind editing the config files by hand for now. and at least it doesnt start twice  and cause all kinds of chaos like it does with the **sense does.
Title: Re: UPS Support
Post by: ezhik on October 08, 2016, 01:45:42 AM
Any progress on this? Would be nice to have compatibility with APC/CyberPower UPSs.
Title: Re: UPS Support
Post by: fabian on October 08, 2016, 10:18:17 AM
Not that I would be aware of.
Title: Re: UPS Support
Post by: ezhik on October 10, 2016, 09:49:21 PM
Any good guides on how to setup UPS support?

I have CyberPower 850VA. On Linux boxes I've used apcupsd.

Cheers.
Title: Re: UPS Support
Post by: franco on October 10, 2016, 11:17:10 PM
Hi there,

We do have packages for apcupsd for amd64/i386:

# pkg install apcupsd

http://www.freebsddiary.org/apcupsd.php

or nut for amd64:

# pkg install nut

https://people.freebsd.org/~thierry/nut_FreeBSD_HowTo.txt

A plugin for these would be nice eventually, but larger construction sites are improving API coverage. If anybody is willing to look into this:

https://docs.opnsense.org/development/examples/helloworld.html


Cheers,
Franco
Title: Re: UPS Support
Post by: ezhik on November 06, 2016, 02:51:13 PM
Thank you.

Going to give this a shot today.

Cheers.
Title: Re: UPS Support
Post by: ezhik on December 24, 2016, 06:11:30 PM
Couldn't get this setup over USB. Always complained that communication was lost. I did setup it up using the "net" driver (over network). However when a shutdown is initiated, instead of shutting down OPNSense reboots... Anybody experienced this issue?
Title: Re: UPS Support
Post by: mw01 on December 31, 2016, 03:40:11 PM
I have it working on an apu2, nano.  Modified the /usr/local/etc/rc.d/apcupsd file to enable and create the "default" lockfile folder on the tmpfs.  The service start file was placed in /etc/rc.conf.d/  To address notifications the apcupsd scripts where changed to provide the Subject: and message piped to a python script, which requires scrutiny.  Looked at the GUI example - will take some time to digest.

#!/usr/local/bin/python2.7

import sys
import smtplib

def prompt(prompt):
    return raw_input(prompt).strip()

fromaddr = 'my@address'
toaddrs  = 'my@address'

email_user = 'myAccount'
email_pwd = 'myPassword'

msg = """\
From: Me<my@address>
To: Me<my@address>
"""

while 1:
    try:
        line = raw_input()
    except EOFError:
        break
    msg = msg + line + "\n"

try:
   server = smtplib.SMTP('smtp.server:587')
   server.ehlo()
   server.starttls()
   server.login(email_user, email_pwd)
   server.sendmail(fromaddr, toaddrs, msg)

except:
    sys.exit( "sendmsg failed:", sys.exc_info()[0] )

finally:
   server.quit()
Title: Re: UPS Support
Post by: ezhik on July 14, 2023, 12:14:09 AM
Has anyone managed to make it work properly? For some reason apcupsd does not shutdown the system, it stays running as if it is waiting for the final manual "power off" by a human...
Title: Re: UPS Support
Post by: vpx23 on July 15, 2023, 11:57:34 AM
Apcupsd is outdated, did you try NUT?

https://docs.opnsense.org/manual/how-tos/nut.html
Title: Re: UPS Support
Post by: ezhik on July 24, 2023, 11:10:03 PM
I did not, I will give it a shot. Can it talk to apcupsd master server over the network?

EDIT: It cannot, for obvious compatibility issues.