オムロンさんの無停電電源装置を使う事に.
装置の一覧はこちら https://socialsolution.omron.com/jp/ja/products_service/ups/product/ups.html
っで停電が起こった際にUSBとかで繋がっているマシンを止めてくれるアプリはこちら https://socialsolution.omron.com/jp/ja/products_service/ups/product/soft/soft.html
どちらも停止前に自前のコマンドを発行できるみたい. どちらも無償.
https://socialsolution.omron.com/jp/ja/products_service/ups/product/soft/powerattendant_standardedition.html
ダウンロードした「PowerAttendant-2.1.2-1.x86_64.rpm」をインストール.
epelのリポジトリが必要です
[root@rockylinux9 ~]# dnf install epel-release
[root@rockylinux9 ~]# unzip PASV212_linux_redhat.zip
[root@rockylinux9 ~]# cd PASV212_linux_redhat
[root@rockylinux9 PASV212_linux_redhat]# rpm -Uvh ./PowerAttendant-2.1.2-1.x86_64.rpm <-- dnf localinstall ではダメみたい
:
Do you agree this license? [ y/n ] y <-- yを入力
Please input a http port number(1~65535) of this software[80]: 8080 <-- PowerAttendant のwebサービスを提供するport番号
Updating / installing...
1:PowerAttendant-2.1.2-1 ################################# [100%]
Created symlink /etc/systemd/system/multi-user.target.wants/powerattendantd.service → /etc/systemd/system/powerattendantd.service.
Installation of PowerAttendant is finished.
[root@rockylinux9 PASV212_linux_redhat]#systemctlでサービスは管理されて
[root@rockylinux9 PASV212_linux_redhat]# systemctl status powerattendantd.service
● powerattendantd.service - PowerAttendant service
Loaded: loaded (/etc/systemd/system/powerattendantd.service; enabled; preset: disabled)
Active: active (running) since Sun 2026-03-22 22:50:21 JST; 51s ago
Main PID: 65219 (PowerAttendant)
Tasks: 16 (limit: 101925)
Memory: 88.7M (peak: 89.4M)
CPU: 4.004s
CGroup: /system.slice/powerattendantd.service
mq65219 /opt/OMRON/PowerAttendant/PowerAttendant
Mar 22 22:50:21 rockylinux9 systemd[1]: Starting PowerAttendant service...
Mar 22 22:50:21 rockylinux9 systemd[1]: Started PowerAttendant service.
Mar 22 22:50:21 rockylinux9 systemd[1]: /etc/systemd/system/powerattendantd.service:2: Unknown key name 'Name' in section 'Unit', ignoring.
Mar 22 22:50:21 rockylinux9 systemd[1]: /etc/systemd/system/powerattendantd.service:7: Unknown key name 'StartLimitIntervalSec' in section 'Service', ign>
[root@rockylinux9 PASV212_linux_redhat]#となっている。ちなみにportを確認すると
[root@rockylinux9 PASV212_linux_redhat]# lsof -i -P
:
PowerAtte 65297 root 346u IPv4 96088 0t0 TCP localhost:8080 (LISTEN)
PowerAtte 65297 root 347u IPv6 96089 0t0 TCP localhost:8080 (LISTEN)
:
[root@rockylinux9 PASV212_linux_redhat]#と「localhost:8080」なので、ローカルマシンからでないとアクセスできない。他のマシンからリモートでこのサービス(8080)にはアクセスできない。
どうしてもなら、
[root@rockylinux9 ~]# cp -a /opt/OMRON/PowerAttendant/appsettings.json /opt/OMRON/PowerAttendant/appsettings.json.orig
[root@rockylinux9 ~]# vi /opt/OMRON/PowerAttendant/appsettings.json
{"Kestrel": {"Endpoints": {"Http": {"Url": "http://localhost:8080"} } } }
↓
{"Kestrel": {"Endpoints": {"Http": {"Url": "http://0.0.0.0:8080"} } } }
[root@rockylinux9 ~]#と「localhost」を「0.0.0.0」に変更してpowerattendantd.serviceを再起動すればいいみたい
[root@rockylinux9 ~]# systemctl restart powerattendantd.service
[root@rockylinux9 ~]# lsof -i -P
:
PowerAtte 65452 root 346u IPv4 101850 0t0 TCP *:8080 (LISTEN)
:
[root@rockylinux9 ~]#「*:8080」なので他からのアクセスも可なのですが、「localhost」という名称でのアクセスが必要なようで、SSHトンネルを掘って、いま操作しているwin/macの特定ポート(例:8080)に「rockylinux9:8080」を繋げ、
ブラウザ上で「localhost:8080」を再現できれば、リモートでアクセス可能っぽい。
単に「「*:8080」ではダメのようで、さらにひと工夫必要みたい。
あとfirewallが動いているならその調整も必要。
[root@rockylinux9 ~]# firewall-cmd --add-port=8080/tcp --zone=public --permanent
[root@rockylinux9 ~]# firewall-cmd --reloadっで設定へ
アクセスすと下記画面が表示され「Admin」のパスワードを定義します

定義が完了すると下記画面になりますが、まだ「ログイン」はされていないです。

「ログイン」ボタンをクリックして表示されたダイアログに「Admin」とパスワードを入力してログインします

ログインに成功するとこんな画面に

「詳細設定」欄を開くと既定で用意されているタスクや指定ホスト(localhost)らが用意されている


ここらを編集して、shutdown前に特定プログラムを停止させたり、指定したホストに入って停止スクリプトを流したりする感じでしょうか。
systemctlで用意されているサービスは shutdown 時には手順良く落ちますが、それ以外のプログラムを落とす際には有効かなと。
UPSとUSB/シリアルで繋がったホスト マシンがUPSの通電停止を感知すると、バッテリー運転が始まって「待機時間」後に、PowerAttendantで設定した内容に従って処理が進む
その際はホストマシン自身の他に、ssh or telnet で接続可能なマシンに入ってコマンドを流すことができきるみたい
っでまずは相手先を登録。パスワードで行くみたい。公開鍵方式で行けるのかは不明。「root」アカウントが微妙なら別のユーザで入って、スクリプトでsudoとかで行けるようにでしょうか。

そして相手先で実行するスクリプトを用意します。

こちらはcephの停止コマンドです
ceph fs set emfs joinable false
ceph fs fail emfs
ceph osd set noout
ceph osd set norebalance
ceph osd set nobackfill
ceph osd set noautoscaleそして相手先とこのスクリプトを連携させたタスクを用意します。ここでは「実行前待機時間」を取ってます。ceph本体側でも停止作業が進んでいる場合、二重実行を回避したいので。

離れた場所にOSDがあって、統一したceph電源管理ができない場合のお話です。片方で停電、片方は問題ない場合でもcephを停止させる魂胆です