Решил таки прикрутить мониторинг к UPS по USB. Но наткнулся на проблемы с правами.

# usbconfig
ugen0.1: <OHCI root HUB ATI> at usbus0, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE ugen1.1: <OHCI root HUB ATI> at usbus1, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE ugen2.1: <EHCI root HUB ATI> at usbus2, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE ugen3.1: <OHCI root HUB ATI> at usbus3, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE ugen4.1: <OHCI root HUB ATI> at usbus4, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE ugen5.1: <EHCI root HUB ATI> at usbus5, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=SAVE ugen6.1: <OHCI root HUB ATI> at usbus6, cfg=0 md=HOST spd=FULL (12Mbps) pwr=SAVE ugen0.2: <USB to Serial Cypress Semiconductor> at usbus0, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON

#cat ups.conf
[ups]
    driver = megatec_usb
    port = "/dev/ugen0.2"
    desc = "Mustek PowerMust 2000"

Нифига.
# /usr/local/libexec/nut/megatec_usb -a ups -DD
Network UPS Tools - Megatec protocol driver 1.6 (2.4.1)
Serial-over-USB transport layer 0.10
debug level is '2'
No appropriate HID device found
No supported devices found. Please check your device availability with 'lsusb'
and make sure you have an up-to-date version of NUT. If this does not help,
try running the driver with at least 'vendorid' and 'subdriver' options
specified. Please refer to the man page for details about these options
(man 8 megatec_usb).
Please report your results to the NUT user's mailing list
<[email protected]>.

Но если запускаешь под рутом, то данные снимаются!

# /usr/local/libexec/nut/megatec_usb -a ups -u root -DD
Network UPS Tools - Megatec protocol driver 1.6 (2.4.1)
Serial-over-USB transport layer 0.10
debug level is '2'
Checking device (0665/5161) (/dev/usb//dev/ugen0.2)
- VendorID: 0665
- ProductID: 5161
- Manufacturer: Cypress Semiconductor
- Product: USB to Serial
- Serial Number: unknown
- Bus: /dev/usb
Trying to match device
Device matches
DTR=1, RTS=0
Starting UPS detection process...
Asking for UPS information [I]...
I => FAILED [short read]
Asking for UPS status [Q1]...
Q1 => OK [(230.1 230.5 224.1 025 50.1 27.2 25.0 00001001]
Q1 VALUES => [230.1 230.5 224.1 25.0 50.1 27.2 25.0 00001001]
Asking for UPS status [Q1]...
^CQ1 => OK [(228.6 228.1 224.1 025 50.1 27.2 25.0 00001001]
Q1 VALUES => [228.6 228.1 224.1 25.0 50.1 27.2 25.0 00001001]
Asking for UPS status [Q1]...
^CQ1 => OK [(227.2 227.2 221.7 024 50.1 27.2 25.0 00001001]
Q1 VALUES => [227.2 227.2 221.7 24.0 50.1 27.2 25.0 00001001]
Asking for UPS status [Q1]...
Q1 => OK [(228.1 228.6 221.4 025 50.1 27.2 25.0 00001001]
Q1 VALUES => [228.1 228.6 221.4 25.0 50.1 27.2 25.0 00001001]
Asking for UPS status [Q1]...
Q1 => OK [(226.7 226.7 221.4 025 50.0 27.2 25.0 00001001]
Q1 VALUES => [226.7 226.7 221.4 25.0 50.0 27.2 25.0 00001001]
0 out of 5 detection attempts failed (minimum failures: 2).
Cancelling any pending shutdown or battery test.
Asking for UPS information [I]...
I => FAILED [short read]
Megatec protocol UPS detected.
Parameter [ignoreoff]: [false]
Asking for UPS power ratings [F]...
F => OK [#220.0 007 24.00 50.0]
F VALUES => [220.0 7.0 24.0 50.0]
24.0V battery, interval [19.4V, 27.4V].
Done setting up the UPS.
Asking for UPS status [Q1]...
Q1 => OK [(226.2 226.2 221.4 024 50.0 27.2 25.0 00001001]
Q1 VALUES => [226.2 226.2 221.4 24.0 50.0 27.2 25.0 00001001]
Calculated battery charge: 97.5%
dstate_init: sock /var/db/nut/megatec_usb-ups open on fd 6
Signal 2: exiting


--
Vladislav V. Prodan
VVP24-UANIC
+380[67]4584408
+380[99]4060508
[email protected]

Ответить