Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: NUT plugin w/ UI #374

Closed
djzort opened this issue Nov 14, 2017 · 72 comments
Closed

Feature Request: NUT plugin w/ UI #374

djzort opened this issue Nov 14, 2017 · 72 comments
Assignees
Labels
feature Adding new functionality

Comments

@djzort
Copy link

djzort commented Nov 14, 2017

I think everyone is familiar with NUT, the open source UPS software that supports just about everything http://networkupstools.org/

pfSense has a sufficiently decent plugin and UI for it (https://doc.pfsense.org/index.php/Nut_package)

It would be great to get something similar in OPNsense, it is one of the missing features stopping us from migrating our fleet of pfSense firewalls.

@fichtner
Copy link
Member

Maybe a new challenge for @mimugmail ? :)

Thank you for the request,
Franco

@mimugmail
Copy link
Member

Challenge accepted :)
Can you send me a conf of your Pf machines?

@djzort
Copy link
Author

djzort commented Nov 14, 2017

Take a look at: https://gist.github.com/djzort/6944d5b1a6b19ec2cbfbc691503e65e2

I just pulled the sections out of a back up.

End lines got mutilated by Gist... sorry.

@mimugmail
Copy link
Member

Please use something like pastebin :)

@djzort
Copy link
Author

djzort commented Nov 14, 2017

@mimugmail
Copy link
Member

I meant nut.conf and upsd.conf in /usr/local/etc ... I need them for templating

@djzort
Copy link
Author

djzort commented Nov 14, 2017

upsd.users.txt
upsmon.conf.txt
ups.conf.txt
upsd.conf.txt

Renamed to .txt so GH will accept them. The passwords i believe are just generated by the plugin so that it can admin the running daemon

@mimugmail
Copy link
Member

Ok, seems fairly easy. Give me two weeks and then I'd please you to test intensively as I don't have an APC here to test :)

@djzort
Copy link
Author

djzort commented Nov 14, 2017

i can just send you a small one if you like.

@fabianfrz fabianfrz added the feature Adding new functionality label Nov 14, 2017
@mimugmail
Copy link
Member

@djzort whats the UPS type you are using? Since you are the first user using the UI there will be only one (yours) but easily extendable :)

@djzort
Copy link
Author

djzort commented Nov 21, 2017

The UPS I use are all APC. They tend to be the least terrible. They all use the usbhid-ups driver. This is a generic usb driver though which supports UPS devices from a range of manufacturers.

See also http://networkupstools.org/docs/man/usbhid-ups.html

@mimugmail
Copy link
Member

@djzort can you send me a screenshot of the status overview? Last two weeks were quite busy, but I think this should be done til mid december ...

@djzort
Copy link
Author

djzort commented Dec 1, 2017

Hopefully this will do...
untitled

@mimugmail
Copy link
Member

@djzort sorry, I'm a little late .. can you send me a copy of your nut.conf and tell me user the daemon runs (ps aufx)

@djzort
Copy link
Author

djzort commented Dec 18, 2017

[2.4.2-RELEASE][root@firebug.fragfest.local]/usr/local/etc/nut: ps aufx | grep ups
root    65210   0.0  0.1  12576   2488  -  Is   Fri09       0:00.00 /usr/local/sbin/upsmon
uucp    65989   0.0  0.1  12576   2500  -  S    Fri09       0:19.30 /usr/local/sbin/upsmon
root    67850   0.0  0.1  12588   2536  -  Ss   Fri09       0:21.53 /usr/local/sbin/upsd -u root
uucp    67892   0.0  0.1  12748   2736  -  Ss   Fri09       1:57.76 /usr/local/libexec/nut/usbhid-ups -a APC_Back-UPS_CS650

much like the spoon, there is no nut.conf

[2.4.2-RELEASE][root@firebug.fragfest.local]/usr/local/etc/nut: ls -la
total 160
drwxr-xr-x   2 root  wheel    512 Oct 13 10:22 .
drwxr-xr-x  29 root  wheel   2048 Dec 15 09:52 ..
-rw-r--r--   1 root  wheel  13860 Oct  9 09:22 cmdvartab
-rw-r--r--   1 root  wheel  77732 Oct  9 09:22 driver.list
-rw-r--r--   1 root  wheel   1538 Oct  9 09:22 nut.conf.sample
-rw-r-----   1 root  wheel     49 Dec 15 09:52 ups.conf
-rw-r--r--   1 root  wheel   4618 Oct  9 09:22 ups.conf.sample
-rw-r-----   1 root  wheel     28 Dec 15 09:52 upsd.conf
-rw-r--r--   1 root  wheel   4578 Oct  9 09:22 upsd.conf.sample
-rw-r-----   1 root  wheel    117 Dec 15 09:52 upsd.users
-rw-r--r--   1 root  wheel   2131 Oct  9 09:22 upsd.users.sample
-rw-r-----   1 root  wheel    129 Dec 15 09:52 upsmon.conf
-rw-r--r--   1 root  wheel  15329 Oct  9 09:22 upsmon.conf.sample
-rw-r--r--   1 root  wheel   3895 Oct  9 09:22 upssched.conf.sample

@mimugmail
Copy link
Member

@djzort would you test the package please?
pkg install os-nut-devel via CLI

ATM it supports only your driver and is missing a status view.

@fabianfrz
Copy link
Member

@mimugmail just tell us when we should close it.

@mimugmail
Copy link
Member

@djzort were you able to test it?

@mimugmail
Copy link
Member

@djzort ?? some kind of feedback would be cool .. also when don't find the time ATM.

@djzort
Copy link
Author

djzort commented Jan 15, 2018

Ive been totally flat out and trying to find a UPS not in production to test this with - obviously with zero success so far

@mimugmail
Copy link
Member

@djzort ok, so we'll leave this one open and let the plugin in devel.

@megagolgoth
Copy link

megagolgoth commented Feb 4, 2018

As requested on [IRC:]

nut.conf
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
MODE=standalone

upsd.conf
# Please don't modify this file as your changes might be overwritten with
# the next update.
#
MODE=standalone

@nmaster2042
Copy link

Hi,

I'm a new OPNsense user coming from pfsense and the NUT plugin is something I was using before.
So I got your plugin a try with a APC Back-UPS ES 550G USBHID UPS.

I installed the plugin from cli, enabled NUT, selected standalone mode.
Then I enable the USBHID type, and gave a name to my UPS.

After saving setting, I checked on cli, ups daemons doesn't seem to start on my box.

@mimugmail
Copy link
Member

Yay, new Beta tester! Can you reboot and then send me the system.log if it doesnt work?

@nmaster2042
Copy link

@mimugmail yes, here is my system.log after reboot.
system.log

@mimugmail
Copy link
Member

Hm, but this looks good?

Mar 25 18:09:12 OPNsense usbhid-ups[35388]: Startup successful
Mar 25 18:09:12 OPNsense upsd[35670]: /usr/local/etc/nut/upsd.conf is world readable
Mar 25 18:09:12 OPNsense upsd[35670]: listening on ::1 port 3493
Mar 25 18:09:12 OPNsense upsd[35670]: listening on 127.0.0.1 port 3493
Mar 25 18:09:12 OPNsense upsd[35670]: /var/db/nut is world readable
Mar 25 18:09:12 OPNsense upsd[35670]: Connected to UPS [MyUPS]: usbhid-ups-MyUPS
Mar 25 18:09:12 OPNsense upsd[35670]: /usr/local/etc/nut/upsd.users is world readable
Mar 25 18:09:12 OPNsense upsd[35966]: Startup successful

To be honest I'm not really familiar with the tools, but there should be a cli command to ask the daemon of the current ups status ..

man upsc

@nmaster2042
Copy link

Yes, I tried upsc commands with no success.

Tried to list UPS on the opnsense host:

$ upsc -l opnsense
-> stays locked, no reply

Tried to get info from the MyUPS connected to my opnsense box:

$ upsc MyUPS@opnsense
-> same result as above

Listing all ups daemons loaded on my opnsense box:

$ ps aux | grep ups

or

$ ps aux | grep nut

-> no daemon seems to be loaded

@mimugmail
Copy link
Member

Is this a test system where I can have a look at?

@flounderscore
Copy link

One thing I noticed: when the ups name was containing " " and "-"s it didn't work, but as soon as I changed it to "apcups" it worked correctly.

@mimugmail
Copy link
Member

mimugmail commented Apr 8, 2018 via email

@flounderscore
Copy link

It would also be great if one could configure what address/interface uspd was bound to.

@mimugmail
Copy link
Member

mimugmail commented Apr 9, 2018 via email

@flounderscore
Copy link

@mimugmail Yes, that's what I was thinking. I have home automation software using the UPS status as an indicator for a power outage. If I manually change the upsd.conf it's going to be overwritten, unfortunately.
Off-topic: There might be a way to do port-forwarding from/to localhost, but I lack the pf skills to do that.

@mimugmail
Copy link
Member

Can you Upload all configs without passwords?

@mimugmail
Copy link
Member

Now I got an own UPS for testing. After installation I had to reboot the firewall to get connected to the UPS:

root@OPNsense:~ # upsc UPSName
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 50
battery.runtime: 65535
battery.runtime.low: 120
battery.type: PbAc
battery.voltage: 131.4
battery.voltage.nominal: 120.0
device.mfr: American Power Conversion
device.model: Smart-UPS X 2200
device.serial: AS1730260672
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: APC HID 0.96
driver.version.internal: 0.41
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: UPS 07.4 / ID=01003
ups.mfr: American Power Conversion
ups.mfr.date: 2017/07/25
ups.model: Smart-UPS X 2200
ups.productid: 0003
ups.serial: AS1730260672
ups.status: OL
ups.timer.reboot: -1
ups.timer.shutdown: -1
ups.vendorid: 051d

@nmaster2042
Copy link

@flounderscore: If you want to be able to access the NUT server on your opnsense from your local net, you can add the following rules on the firewall:

Firewall / Rules / LAN:

Proto | Source | Port | Destination | Port | Gateway
IPv4 TCP | LAN net | * | LAN adresse | 3493 | *

Put the rule just after the anti lockout one.

Firewall ./ NAT / Port Forward:

If | Proto | Address | Ports | Address | Ports | IP | Ports
LAN | TCP | * | * | LAN address | 3493 | 127.0.0.1 | 3493

Save and restart firewal.

You should be able to get info from other computers on your LAN.

@mimugmail
Copy link
Member

mimugmail commented Apr 14, 2018 via email

@flounderscore
Copy link

flounderscore commented Apr 16, 2018

@nmaster2042 Is that working for you? I had tried that before and it was not working (slight difference: I have LAN + WLAN -> bridge).

Edit: You are correct, it is working perfectly. When I initially tried it from a jail that was bound to a virtual ip, it did not.

@nmaster2042
Copy link

nmaster2042 commented Apr 18, 2018

@flounderscore : sorry I'm replying too late but yes it's working for me.
It was the way I made it working on my old pfsense setup.

@mimugmail : Why not add in the plugin a checkbox for auto create of these 2 rules for users who want to access their UPS info from their LAN ?

@mimugmail
Copy link
Member

@nmaster2042 I'll integrate a listen directive .. first there has to be a diagnostics page.

@docb7
Copy link

docb7 commented Apr 19, 2018

It works for me too with the NAT Rule - thank you very much!

@mimugmail
Copy link
Member

With 18.1.7 you get version 0.5 of NUT plugin.

You now have a working setup for most UPSses in standalone mode, also netserver via NAT and netclient is also available.

There's a diagnostics tab refreshing every 2 seconds with the current printout of the UPS.

Please try it intensivly as it seems pretty good for a 1.0 release :)

@docb7
Copy link

docb7 commented May 3, 2018

Looks good an stable to me - THANK YOU SO MUCH!

@mimugmail
Copy link
Member

Sorry, please check that 0.6 is installed, otherwise the GUI will freeze when the UPS is not available

@fichtner
Copy link
Member

fichtner commented May 4, 2018

PS: 0.6 is not bundled with 18.1.7

@docb7
Copy link

docb7 commented May 4, 2018

how can I update? Via GUI is no update available (still 0.5 installed).

@fichtner
Copy link
Member

fichtner commented May 4, 2018

wait 30 minutes, the hotfix we needed to do will update it to 0.6 luckily

@alesnav
Copy link

alesnav commented Aug 8, 2018

Hello there,

I see that this plugin is on version 1.0, but the GUI is freezed, too, when saving the configuration from the plugin page.

I have a Eaton Ellipse ECO 800 connected via USB to a OPNsense virtual appliance (v18.7). It is detected on usb0, as shown in system.log:

Aug  8 18:29:24 firewall kernel: uhci0: <UHCI (generic) USB controller> port 0x2800-0x281f irq 18 at device 0.0 on pci2
Aug  8 18:29:24 firewall kernel: usbus0 on uhci0
Aug  8 18:29:24 firewall kernel: usbus0: 12Mbps Full Speed USB v1.0
Aug  8 18:29:24 firewall kernel: ehci0: <EHCI (generic) USB 2.0 controller> mem 0xfd49f000-0xfd49ffff irq 18 at device 8.0 on pci2
Aug  8 18:29:24 firewall kernel: usbus1: EHCI version 1.0
Aug  8 18:29:24 firewall kernel: usbus1 on ehci0
Aug  8 18:29:24 firewall kernel: usbus1: 480Mbps High Speed USB v2.0
Aug  8 18:29:24 firewall kernel: ugen1.1: <0x15ad EHCI root HUB> at usbus1
Aug  8 18:29:24 firewall kernel: ugen0.1: <0x15ad UHCI root HUB> at usbus0
Aug  8 18:29:24 firewall kernel: uhub0: <0x15ad EHCI root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
Aug  8 18:29:24 firewall kernel: uhub1: <0x15ad UHCI root HUB, class 9/0, rev 1.00/1.00, addr 1> on usbus0
Aug  8 18:29:24 firewall kernel: ugen0.2: <VMware VMware Virtual USB Mouse> at usbus0
Aug  8 18:29:24 firewall kernel: ugen0.3: <vendor 0x0e0f VMware Virtual USB Hub> at usbus0
Aug  8 18:29:24 firewall kernel: uhub2: <VMware Virtual USB Hub> on usbus0
Aug  8 18:29:24 firewall kernel: ugen0.4: <EATON Ellipse ECO> at usbus0
Aug  8 18:29:24 firewall kernel: uhid0: <VMware> on usbus0
Aug  8 18:29:24 firewall kernel: uhid1: <VMware> on usbus0

The GUI gets freezed until I kill the process from CLI:

root@firewall:~ # ps aux | grep ups
root   87413   0.0  0.1   12564  2124  -  S    18:49    0:00.00 /usr/local/bin/upsc eaton@127.0.0.1
root   87631   0.0  0.1   12564  2124  -  S    18:49    0:00.00 /usr/local/bin/upsc eaton@127.0.0.1
root   88065   0.0  0.1   12564  2124  -  S    18:49    0:00.00 /usr/local/bin/upsc eaton@127.0.0.1
root   88728   0.0  0.1   12564  2128  -  S    18:49    0:00.00 /usr/local/bin/upsc eaton@127.0.0.1
root   90573   0.0  0.1   12564  2120  -  S    18:49    0:00.00 /usr/local/bin/upsc eaton@127.0.0.1
root   94007   0.0  0.1 1080528  2840  0  S+   18:49    0:00.00 grep ups
root@firewall:~ # pkill upsc
root@firewall:~ # 

It seems that the processes are launched from the GUI, every time I access to the plugin webpage, which causes many and many calls to /api/nut/service/upsstatus endpoint. None of them work, every call gets a timeout.

Maybe I am missing something, but I think that it does not require so much configuration, at least from GUI.

I can test whatever you need, this is a test environment (but without access from internet).

Thanks!

@mimugmail
Copy link
Member

Is your UPS supported by the driver?

@alesnav
Copy link

alesnav commented Aug 8, 2018

I think so, because it is included in /usr/local/etc/devd/nut-usb.conf:

    #  various models  - usbhid-ups
    notify 100 {
            match "system"          "USB";
            match "subsystem"       "DEVICE";
            match "type"            "ATTACH";
            match "vendor"          "0x0463";
            match "product"         "0xffff";
            action "chgrp uucp /dev/$cdev; chmod g+rw /dev/$cdev";
    };
   0.078000     Checking device (0463/FFFF) (/dev/usb//dev/ugen0.4)
   0.829711     - VendorID: 0463
   0.829734     - ProductID: ffff
   0.829760     - Manufacturer: EATON
   0.829764     - Product: Ellipse ECO
   0.829767     - Serial Number: 000000000
   0.829783     - Bus: /dev/usb
   0.829786     - Device release number: 0100

@mimugmail
Copy link
Member

I'm not sure if this also means usbhid is the correct driver.
I think I'll refactor the code that status only will be called when clicked.

@alesnav
Copy link

alesnav commented Aug 8, 2018

Yes, I've checked it on https://networkupstools.org/stable-hcl.html, too:

image

EDIT: Maybe it is a cable problem, as stated on networkupstools/nut#515 . It seems that Eaton provides a very bad USB cable... Let me test it later (I have no other USB type B and need to buy a new one).

@alesnav
Copy link

alesnav commented Aug 16, 2018

Well, it was related to VMware passthrough. So I can not help anymore here because my OPNsense is a virtual machine.

@mimugmail
Copy link
Member

@fichtner please close ...

@fichtner fichtner closed this as completed Oct 4, 2018
@thutex
Copy link
Contributor

thutex commented Oct 9, 2018

since this seems to be the closest to what i am looking for, i am commenting here - up to you guys to reopen this issue or not.
since today i connected my UPS to my opnsense box, i have a generic gembird ups.

when enabling it through the firewall gui, there is no option to define the driver (its hardcoded in usr/local/opnsense/service/templates/OPNsense/Nut/ups.conf )
this causes the diagnostics to not work, until i manually change the ups.conf file to use the blazer_usb driver.

maybe we should have an option on the ups type page for USB where we can select/manually input the driver instead of hardcoding 1 driver?
nut works with a heck of a lot of UPS devices, but the current implementation in opnsense cripples it,
while i assume having 1 extra input field and a check to see if its not empty cant be that much extra work (in exchange for the bigger payoff that users can go around searching and applying the correct driver)?

@mimugmail
Copy link
Member

@thutex thx for your input. Can you open a new issue with your driver?
The reason why there is only one or two drivers is, that we only add drivers when we get feedback from the community that it works. So if you willing to help/test I'll add this driver and push a release for you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding new functionality
Development

No branches or pull requests