NUT port configuration "No such file"?

I'm trying to configure sysutils/nut to work with my new UPS, a CP1000PFCLCD. This shows up like so:
Code:
# uname -mrs
FreeBSD 9.1-RC2 amd64

# dmesg|grep LCD
ugen1.3: <CP1000PFCLCD> at usbus1

# usbconfig|grep ugen1\.3
ugen1.3: <CRDA103-461 CP1000PFCLCD> at usbus1, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON

# ls -l /dev/ugen1.3
lrwxr-xr-x  1 root  wheel  9 Oct 18 02:25 /dev/ugen1.3 -> usb/1.3.0

# ls -l /dev/usb/1.3.0
crw-------  1 root  operator    0, 131 Oct 18 02:25 /dev/usb/1.3.0

According to the NUT HCL, this is supported by the usbhid-ups driver. A few configuration files later and I have, for ups.conf
Code:
[CP1000PFCLCD]
     driver = usbhid-ups
     port = /dev/ugen1.3
     desc = "CyberPower 600W/1000VA Pure Sine Wave UPS via USB"

However, when trying to start upsd (as root for testing), I get:
Code:
# upsd -DDDD
Network UPS Tools upsd 2.6.4-Unversioned directory
   0.000000     fopen /var/db/nut/upsd.pid: No such file or directory
   0.001335     /usr/local/etc/nut/upsd.conf is world readable
   0.003906     listen_add: added 127.0.0.1:3493
   0.005861     setuptcp: try to bind to 127.0.0.1 port 3493
   0.007928     listening on 127.0.0.1 port 3493
   0.010450     /var/run/nut is world readable
   0.012052     [B][color="Red"]Can't connect to UPS [CP1000PFCLCD] (usbhid-ups-CP1000PFCLCD): No such file or directory[/color][/B]
   0.016362     /usr/local/etc/nut/upsd.users is world readable
...

Reading around, I've seen recommendations for using "port = auto", but that fails with the same error. So, if I can see it in dmesg, usbconfig, and in /dev/, why does upsd have so much trouble finding it? Anything else I should be doing to debug? Unfortunately the docs aren't that great, so I've been mostly relying on guides and other users' experiences, many of which are from FBSD 7.x/8.x, or FreeNAS, which has web configuration, so is of much less help.

Edit: found a little more info on debugging. Tried another USB port, where it shows up as ugen2.2 and ran:
Code:
# /usr/local/libexec/nut/usbhid-ups -DDDDD -a CP1000PFCLCD
Network UPS Tools - Generic HID driver 0.37 (2.6.4-Unversioned directory)
USB communication driver 0.31
   0.000000     send_to_all: SETINFO driver.parameter.port "/dev/ugen2.2"
   0.000095     debug level is '5'
   0.001747     upsdrv_initups...
   0.002136     No appropriate HID device found
   0.002178     No matching HID UPS found

So, is this device just not supported? I seem to recall reading that certain UPS devices had to be blacklisted from ugen, so that the correct driver (uhid?) could attach... [Edit: Whoops, that was the reverse that people were talking about, i.e. blacklisting it from uhid so ugen could attach]
 
Okay, solved the issue. Apparently, usbhid-ups drops privs before trying to open the device, even if you execute it as root and set "RUN_AS_USER root" in upsmon.conf. No idea what user it switches to, and it doesn't tell you this in the debug output regardless of how many '-D's you put when you execute it. However, if you force it to run as root with the -u switch, interesting things happen:
Code:
# /usr/local/libexec/nut/usbhid-ups -u root -DDDDD -a CP1000PFCLCD
Network UPS Tools - Generic HID driver 0.37 (2.6.4-Unversioned directory)
USB communication driver 0.31
   0.000000     send_to_all: SETINFO driver.parameter.port "auto"
   0.000107     debug level is '5'
   0.001663     upsdrv_initups...
   0.002817     Checking device (0764/0501) (/dev/usb//dev/ugen2.2)
   0.038481     - VendorID: 0764
   0.038509     - ProductID: 0501
   0.038523     - Manufacturer: CP1000PFCLCD
   0.038533     - Product: CRDA103-461
   0.038543     - Serial Number: CPS
   0.038552     - Bus: /dev/usb
   0.038565     Trying to match device
   0.038607     Device matches
   0.063507     HID descriptor, method 1: (9 bytes) => 09 21 10 01 21 01 22 ae 0
1
   0.063537     i=0, extra[i]=09, extra[i+1]=21
   0.063556     HID descriptor, method 2: (9 bytes) => 09 21 10 01 21 01 22 ae 0
1
   0.063574     HID descriptor length 430
   0.074495     Report Descriptor size = 430
...

Followed by more pages of text than can safely be pasted on the forums. Guess I'll just fix the permissions in devfs.conf.
 
Hi @Orum,

You're probably familiar with this HowTo. If not, you should have a look at it, could be useful. I haven't used nut so far, but as soon as I get my MGE E-NV600H UPS, I will give it a try.

Take care!
 
Last edited by a moderator:
How did you fix the permissions? I tried the method from the HOW-TO linked in this thread, but it seems to be for an earlier version of FreeBSD.
 
tedjohnson said:
How did you fix the permissions? I tried method from the HOW-TO linked in this thread, but is seems to be for the earlier version of FreeBSD.
I'm not familiar with the whole program, but when I peek at that HOWTO I don't see anything which can't be done on a modern FreeBSD. Which section is confusing you?

My guess would be the part about /etc/devfs.rules since that file isn't present on my setup, but if you check the devfs.rules(5) manualpage you'll see that it's still supported. And if a manualpage isn't convincing enough check /etc/defaults/devfs.rules (remember that you should not edit any files in /etc/default).
 
Here's what I tried, following the HOW-TO:

/etc/devfs.rules
Code:
[nut_usb=10]
add path 'ugen3.5' group wheel user uucp mode 0660
/etc/devfs.conf
Code:
perm    usb3    0660
own     usb3    root:uucp
/etc/rc.conf
Code:
devfs_system_ruleset="nut_usb"

followed by # /etc/rc.d/devfs restart.

I also tried usb, usb0, usb1 in /etc/devfs.conf.
 
I just wanted to add that I struggled with this initially but this should all be unnecessary. Essentially there is /usr/local/etc/devd/nut-usb.conf which handles all of this for you, but requires a sudo service devd restart to enable the rules, and then you may need to unplug and replug the USB device so that it re-enumerates and triggers the rule.

Everything should just work after a reboot. pkg list <pkgname> helps when figuring out what configuration is supplied with a package.

ETA: If you have a rule in /etc/devfs.rules that modifies the permissions of USB devices this will override the devd settings at boot time.
 
Last edited:
I just wanted to add that I struggled with this initially but this should all be unnecessary. Essentially there is /usr/local/etc/devd/nut-usb.conf which handles all of this for you...

I'm running NUT 2.7.4 on FreeBSD 11.0 (AMD64), and I finally got it running. (Yea!)

The quote above was the solution.

What had been styming me was a needed reboot in order for devd to see the presence of the UPS and process the conf file. I probably could have avoided the reboot using the directions given in the message, but I decided to do the reboot.

# upsc cpups
Code:
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 20
battery.mfr.date: CPS
battery.runtime: 6000
battery.runtime.low: 300
battery.type: PbAcid
battery.voltage: 14.2
battery.voltage.nominal: 12
device.mfr: CPS
device.model: EC750G
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: CyberPower HID 0.4
driver.version.internal: 0.41
input.transfer.high: 140
input.transfer.low: 96
input.voltage: 119.0
input.voltage.nominal: 120
output.voltage: 120.0
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.load: 0
ups.mfr: CPS
ups.model: EC750G
ups.productid: 0501
ups.realpower.nominal: 450
ups.status: OL
ups.test.result: No test initiated
ups.timer.shutdown: -60
ups.timer.start: 0
ups.vendorid: 0764
 
I'm running NUT 2.7.4 on FreeBSD 11.0 (AMD64), and I finally got it running. (Yea!)...


One further comment...

I replayed my steps for installing NUT via pkg, and I found my problem.

I had the UPS plugged into the USB port before I installed NUT.

As a result devd never had a chance to do its thing (via /usr/local/etc/devd/nut-usb.conf) with the permissions in the /dev/usb tree.

Once I unplugged the USB cable, waited about 10 seconds and plugged it in again, then everything worked fine.


So I would recommend that before installing NUT that the USB connection to the UPS be unplugged from the USB port on the computer.
 
I'd like to share my experience with an EATON 5E 650iUSB
At the time of writing the software is: NUT 2.7.4 on FreeBSD 11.0-p9 (AMD64)
Plugging the ups produces the following output:
# dmesg | grep ugen
Code:
...
ugen0.3: <EATON> at usbus0
...
/etc/devfs.rules
Code:
[nut_usb=10]
add path 'ugen0.3' group wheel user uucp mode 0770
add path 'usb/0.3.0' group wheel user uucp mode 0770
/etc/devfs.conf
Code:
perm    ugen0.3    0770
own     ugen0.3    uucp:wheel
/etc/rc.conf
Code:
devfs_system_ruleset="nut_usb"
nut_enable="YES"
nut_upsmon_enable="YES"
# The entries below are optional if you want to turn logging on.
nut_upslog_enable="YES"
nut_upslog_interval="300"
nut_upslog_ups="eaton@localhost"
Next the services:
# service devfs restart
# service devd restart
Set ownership and permissions after installing nut:
# chown root:uucp /usr/local/etc/nut/*
# chmod 640 /usr/local/etc/nut/*
# ls -la /usr/local/etc/nut/*.conf
Code:
-rw-r-----  1 root  uucp   1544 Apr 15 12:31 /usr/local/etc/nut/nut.conf
-rw-r-----  1 root  uucp   4707 Apr 15 12:22 /usr/local/etc/nut/ups.conf
-rw-r-----  1 root  uucp   4576 Apr 15 12:32 /usr/local/etc/nut/upsd.conf
-rw-r-----  1 root  uucp  15379 Apr 15 13:36 /usr/local/etc/nut/upsmon.conf
/usr/local/etc/nut/nut.conf
Code:
MODE=standalone
/usr/local/etc/nut/ups.conf
Code:
[eaton]
    driver=usbhid-ups
    port=/dev/ugen0.3
    desc="Eaton 5E UPS"
/usr/local/etc/nut/upsd.conf
Code:
LISTEN 127.0.0.1 3493
/usr/local/etc/nut/upsd.users
Code:
[admin]
   password = mypass
    actions = SET
    instcmds = ALL
[monuser]
    password  = mypass
    upsmon master
/usr/local/etc/nut/upsmon.conf
Code:
RUN_AS_USER uucp
MONITOR eaton@localhost 1 monuser mypass master
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -p +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
Finally, start the nut daemons:
# service nut start
# service nut_upsmon start

# upsc eaton
Code:
battery.charge: 24
battery.runtime: 381
battery.type: PbAc
device.mfr: EATON
device.model: 5E 650i
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: /dev/ugen0.3
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: MGE HID 1.39
driver.version.internal: 0.41
input.voltage: 232.0
outlet.1.status: on
outlet.desc: Main Outlet
outlet.id: 1
outlet.switchable: no
output.frequency: 49.9
output.frequency.nominal: 50
output.voltage: 232.0
output.voltage.nominal: 230
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: 01.04.0016
ups.load: 21
ups.mfr: EATON
ups.model: 5E 650i
ups.power.nominal: 650
ups.productid: ffff
ups.start.battery: yes
ups.status: OL
ups.timer.shutdown: -1
ups.vendorid: 0463
If you enabled logging, the log file is under /var/log/ups.log and should look similar to this:
Code:
...
20170415 234000 23 232.0 21 [OL] NA NA
20170415 234100 23 232.0 21 [OL] NA NA
20170415 234200 23 232.0 21 [OL] NA NA
20170415 234259 23 233.0 21 [OL] NA NA
20170415 234259 23 233.0 21 [OL] NA NA
...
Note: consider rotating the log file. This can be done in /etc/newsyslog.conf
 
If you have more than one machine (running freebsd) connected to the ups, you can set the one to which the ups is connected to act as a server, and the other(s) as clients, listening to it in order to shut down gracefully.

Using the example above, on the server machine you need to change:
/usr/local/etc/nut/nut.conf
Code:
MODE=netserver
/usr/local/etc/nut/upsd.conf
Code:
LISTEN 127.0.0.1 3493
LISTEN 10.10.1.250 3493 # <- put the IP address of the server
On the client machine(s) you only need to run the nut_upsmon daemon:
/etc/rc.conf
Code:
nut_upsmon_enable="YES"
/usr/local/etc/nut/upsmon.conf
Code:
MONITOR eaton@10.10.1.250 1 monuser mypass slave
Note that the communication between the server and the client(s) is not encrypted! If you need it -> configure SSL.
Start the monitor daemon on the client machine(s):
# service nut_upsmon start

Issue the same command as in the previous post to check the connection, but this time you need to add the IP address (or hostname, depending how you want it):
# upsc eaton@10.10.1.250
Code:
battery.charge: 18
battery.runtime: 300
battery.type: PbAc
device.mfr: EATON
device.model: 5E 650i
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: /dev/ugen0.3
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: MGE HID 1.39
driver.version.internal: 0.41
input.voltage: 232.0
outlet.1.status: on
outlet.desc: Main Outlet
outlet.id: 1
outlet.switchable: no
output.frequency: 50.0
output.frequency.nominal: 50
output.voltage: 230.0
output.voltage.nominal: 230
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: 01.04.0016
ups.load: 21
ups.mfr: EATON
ups.model: 5E 650i
ups.power.nominal: 650
ups.productid: ffff
ups.start.battery: yes
ups.status: OL
ups.timer.shutdown: -1
ups.vendorid: 0463
 
Back
Top