1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

UPS1200LXのステータスをNUTから取得する

Last updated at Posted at 2025-11-20

概要

UPS1200LXのステータスをNUTから取得する。

環境

機材: RaspberryPi 3
OS: Debian GNU/Linux 13 (trixie)
nut version: 2.8.1

やりかた

NUTのインストール

sudo apt install nut

UPSを探す

sudo nut-scanner -U

成功すれば以下のように表示されるはず。

$ sudo nut-scanner -U
Cannot load SNMP library (libnetsnmp.so.40) : file not found. SNMP search disabled.
Cannot load XML library (libneon.so.27) : file not found. XML search disabled.
Cannot load AVAHI library (libavahi-client.so.3) : file not found. AVAHI search disabled.
Cannot load IPMI library (libfreeipmi.so.17) : file not found. IPMI search disabled.
Scanning USB bus.
[nutdev1]
        driver = "nutdrv_qx"
        port = "auto"
        vendorid = "0001"
        productid = "0000"
        product = "MEC0003"
        bus = "001"
        device = "007"
        busport = "004"
        ###NOTMATCHED-YET###bcdDevice = "0100"

設定ファイルを書く

driverとvendoridとproductidは、nut-scannerで取得したものに置き換える。

/etc/nut/ups.conf
[ups1]
    driver = nutdrv_qx
    port = auto
    vendorid = 0001
    productid = 0000
    desc = "UPS1200LX"

動作確認する

sudo /lib/nut/nutdrv_qx -a ups1 -DDDD

成功すると以下のように電圧などのステータスが表示されるはず。

   6.511354     [D1] upsdrv_updateinfo...
   6.511580     [D1] Quick update...
   6.511730     [D3] send: Q1
   6.512314     [D4] command index: 0x03
   6.523092     [D3] read: (104.0 000.0 103.0 019 50.1 27.3 29.0 00001000

接続を終了する

sudo upsdrvctl stop

nutc(クライアント)からパースした値を確認する

nut-serverをstandaloneモードで起動する

/etc/nut/nut.confの末尾に以下を追記する。

/etc/nut/nut.conf
MODE=standalone

nut-serverを起動する。

sudo service nut-server start

nutcで表示する

以下のコマンドを実行する。

sudo upsc ups1

成功すれば以下のように表示される。

$ sudo upsc classicpro
Init SSL without certificate database
battery.voltage: 27.2
device.type: ups
driver.debug: 0
driver.flag.allow_killpower: 0
driver.name: nutdrv_qx
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: auto
driver.parameter.productid: 0000
driver.parameter.synchronous: auto
driver.parameter.vendorid: 0001
driver.state: quiet
driver.version: 2.8.1
driver.version.data: Q1 0.08
driver.version.internal: 0.36
driver.version.usb: libusb-1.0.28 (API: 0x100010a)
input.frequency: 50.0
input.voltage: 102.0
input.voltage.fault: 0.0
output.voltage: 102.0
ups.beeper.status: disabled
ups.delay.shutdown: 30
ups.delay.start: 180
ups.load: 20
ups.productid: 0000
ups.status: OL
ups.temperature: 29.0
ups.type: online
ups.vendorid: 0001

トラブルシューティング

実行結果が以下のようになる場合

   1.515636     [D1] ups_infoval_set: non significant value [ups.firmware]
   1.515855     [D3] send: Q1
   1.515919     [D3] asking for: 0D
   1.531042     [D3] read: (000.0 000.0 000.0 000 00.0 0.00 00.0 00000000

UPS内部のチップに合ったdriverが選択できていない可能性があるので、USBの通信内容をデバッグしてChatGPTなどで解析してみると、適合したdriverが見つかるかもしれない。

usbmon1の部分は環境に合わせて変更する。

sudo modprobe usbmon
sudo tcpdump -i usbmon1 -vv -X

表示例

01:34:37.737496 USB CONTROL SUBMIT to 1:6:0
01:34:37.739626 USB CONTROL COMPLETE from 1:6:0
        0x0000:  1003 4d00 4500 4300 3000 3000 3000 3300  ..M.E.C.0.0.0.3.
01:34:37.739852 USB CONTROL SUBMIT to 1:6:0
01:34:37.749502 USB CONTROL COMPLETE from 1:6:0
        0x0000:  5003 2300 2000 2000 2000 2000 2000 2000  P.#.............
        0x0010:  2000 2000 2000 2000 2000 2000 2000 2000  ................
        0x0020:  2000 2000 2000 2000 2000 2000 2000 2000  ................
        0x0030:  2000 2000 2000 2000 2000 2000 2000 2000  ................
        0x0040:  2000 2000 2000 2000 2000 2000 2000 0d00  ................
01:34:37.749582 USB CONTROL SUBMIT to 1:6:0
01:34:37.750005 USB CONTROL COMPLETE from 1:6:0
        0x0000:  0403 0904                                ....
01:34:37.750067 USB CONTROL SUBMIT to 1:6:0
01:34:37.761501 USB CONTROL COMPLETE from 1:6:0
        0x0000:  6003 2800 3000 3000 3000 2e00 3000 2000  `.(.0.0.0...0...
        0x0010:  3000 3000 3000 2e00 3000 2000 3000 3000  0.0.0...0...0.0.
        0x0020:  3000 2e00 3000 2000 3000 3000 3000 2000  0...0...0.0.0...
        0x0030:  3000 3000 2e00 3000 2000 3000 2e00 3000  0.0...0...0...0.
        0x0040:  3000 2000 3000 3000 2e00 3000 2000 3000  0...0.0...0...0.
        0x0050:  3000 3000 3000 3000 3000 3000 3000 0d00  0.0.0.0.0.0.0...
01:34:37.761806 USB CONTROL SUBMIT to 1:6:0
01:34:37.766881 USB CONTROL COMPLETE from 1:6:0
        0x0000:  2e03 2300 3000 3000 3000 2e00 3000 2000  ..#.0.0.0...0...
        0x0010:  3000 2e00 3000 2000 3000 3000 2e00 3000  0...0...0.0...0.
        0x0020:  3000 2000 3000 3000 2e00 3000 0d00       0...0.0...0...

展望

Prometheus Exporterを通して、Grafanaとかで表示&アラートしたい。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?