APC UPS new plugin

Started by Droid999, February 13, 2021, 05:04:01 AM

Previous topic - Next topic
OK,

whats with the file apcupsd in /etc/rc.conf.d?

This file should contain apcupsd_enable="YES" ....

Cheers

hloiter

Ok

Had a go at fixing some of the issues - still no idea on how to make this "official" or do a PR.

Fixed up so it should work with the latest version now - mine broke and wouldn't report the status anymore.

Added the file apcupsd.inc - it goes in "/usr/local/etc/inc/plugins.inc.d/" - this makes the apcupsd service appear in the Services widget on the dashboard.

I haven't got any problems with saving the config, and updating the apcupsd.conf file - so I can't find a fix there.

June 20, 2021, 06:45:46 PM #17 Last Edit: June 20, 2021, 08:16:18 PM by hloiter
Hmm, i think there is something wrong with the apcupsd.conf and some other files ....

After i copy the new version to my opnsense i can not start the service with the new apcupsd.conf.
When i replace the old one, then i can start the service but get no status anymore ...

Here is a screenshot:



With the new apcupsd.inc is the apcupsd service not shown in the service widget and the apcupsd.conf is not written new with klick on the button "Save Config" ....

Cheers

hloiter

Did you grab the new script file to get the Status ?

You can grab them from here:

https://github.com/Gibbon99/apcupsd/tree/master/usr/local/opnsense/scripts/OPNsense/Apcupsd

and put them here:

/usr/local/opnsense/scripts/OPNsense/Apcupsd

Should be two files:

-rwxr-xr-x  1 root  wheel  366 Jun 20 16:16 getNisStatus.py*
-rwxr-xr-x  1 root  wheel  206 Jun 20 16:24 getServiceStatus.py*
root@firewall:/usr/local/opnsense/scripts/OPNsense/Apcupsd #


What happens when you run this from the command line?

configctl apcupsd getNisStatus


This is what I have to make it show up in the Services Widget



root@firewall:/usr/local/etc/inc/plugins.inc.d # ll apcupsd.inc
-rw-r--r--  1 root  wheel  2358 Jun 20 18:25 apcupsd.inc



It's not saving the config on my box anymore either. Just fails silently.

I'll chase it up.

Will have a look at your hints and post a feedback as soon as possible.

hloiter

June 21, 2021, 12:49:58 PM #20 Last Edit: June 21, 2021, 12:56:54 PM by hloiter
Quote from: Droid999 on June 21, 2021, 11:50:28 AM
Did you grab the new script file to get the Status ?

You can grab them from here:

https://github.com/Gibbon99/apcupsd/tree/master/usr/local/opnsense/scripts/OPNsense/Apcupsd

and put them here:

/usr/local/opnsense/scripts/OPNsense/Apcupsd

Should be two files:

-rwxr-xr-x  1 root  wheel  366 Jun 20 16:16 getNisStatus.py*
-rwxr-xr-x  1 root  wheel  206 Jun 20 16:24 getServiceStatus.py*
root@firewall:/usr/local/opnsense/scripts/OPNsense/Apcupsd #



Yes, i grab the new files and put them in the right directory.

Quote
What happens when you run this from the command line?

configctl apcupsd getNisStatus







And this happens when i call the file direct:



Quote

This is what I have to make it show up in the Services Widget



root@firewall:/usr/local/etc/inc/plugins.inc.d # ll apcupsd.inc
-rw-r--r--  1 root  wheel  2358 Jun 20 18:25 apcupsd.inc


Yes, the file is there but no APC UPS Service shown in the Service section ...



Have i to run something in the shell to activate it?

Quote

It's not saving the config on my box anymore either. Just fails silently.

I'll chase it up.

Cheers

hloiter


was it able to get it save and working again?


Fixed the issue with the config not being saved.  Seems to be working properly now.

Also fixed the issue with the Status not showing.

I don't know why it's not showing in your Services widget - you could try > service configd restart - but I'm just guessing. or perhaps a  reboot might help  ?



June 26, 2021, 02:39:15 PM #23 Last Edit: June 26, 2021, 03:13:39 PM by hloiter
Hi Droid999,

thanks for your work.

Everything is fine now and working and up.

Cheers

hloiter

Hello,

I have joined Droid999's small team of developing the Apcupsd plugin and the current version in external repo works OK now. Have tried to help Droid999 to squash some issues found.

I am in the process to do some cleanup, preparing the plugin to be migrated into the official opnsense_plugin repo.  Have not planned a official date yet for the move as I may need some help with the GitHub migration so we don't screw anything up or loose some data. If someone is good in doing that, please contact us through PM. :-)

Best regards
Dan Lundqvist (mrzaz)
Best regards
Dan Lundqvist (mrzaz)

"It's better to burn up, than fade away..." (Highlander)

November 04, 2021, 04:03:34 PM #25 Last Edit: November 05, 2021, 10:31:02 AM by Mario_Rossi
Hi, sorry for the ignorance, I can't figure out how to have my ups detected and managed.
I have migrated from pfsense to opnsense and am not yet practical.

I have an APC SMT1500i with AP9630 network card.
In pfSense I had both Nut (snmp) and APCUPSD (pcnet).

I don't understand what I have to download and where I have to put it.


EDIT: Problem solved.
It would be nice to have a widget on the dashboard with ups status and battery charge as there was a pfsense

Quote from: Mario_Rossi on November 04, 2021, 04:03:34 PM
It would be nice to have a widget on the dashboard with ups status and battery charge as there was a pfsense

Hello, you can use my fork here: https://github.com/xbb/apcupsd (branch dev if you want to verify the code)

I have made improvements, it has a widget and if you check the releases I provide packages too.

I'm waiting for the other guys to merge the projects and possibly send a pull request to the official plugins repo.

Before installing the package I suggest you remove the previous version files and remove any manually applied modifications (apcupsd auto start, it's now controlled by the plugin)

Ignore the docs for the moment they need updating, download the package file and install it with: pkg install ./os-apcupsd-1.2.1.txz

@Droid999, @mrzaz, @xbb

Hey guys, wanted to say thank you for working on this.

I have installed v1.2.2 of the package from @xbb's fork on OPNsense 22.1, works exactly as expected so far. I am connected to another server running apcupsd via the Ether and net options.

In the future, it would be interesting to expose these options through the GUI as well:

BATTERYLEVEL
MINUTES

With these two options one can fine tune when the system is shut down in the event of a power failure. The default settings of 3 minutes runtime left and 5% charge remaining are a little on the aggressive side.

Another thing to think about would be exposing the hosts.conf file somehow and integrate monitoring remote devices if OPNsense functions as a server for a USB connected UPS.

Sadly, I am not a programmer, so I cant help much in that area, but if you need further testing let me know.

Cheers!

February 01, 2022, 08:52:02 AM #28 Last Edit: February 01, 2022, 08:59:00 AM by mrzaz
Hi,
This could already be done if you click on "advance mode". 🙂

Best regards
Dan Lundqvist (mrzaz)
Best regards
Dan Lundqvist (mrzaz)

"It's better to burn up, than fade away..." (Highlander)

Hi mrzaz,

wow, I'm stupid  ::)

Anyway, just changed my settings and tested the auto shutdown, works perfectly!
The Dashboard widget also works without issues.

Thanks again for you guys's work, I highly recommend anyone with an APC UPS to check this out. Looking forward for this to become official  :D

Cheers!