Debian12サーバを、OMRON BN50T とSimple Shutdown Softwareでシャットダウン

Linux

本ページは広告が含まれています。気になる広告をクリック頂けますと、サーバ運営費になります(^^

Simple Shutdown Software(オープンソース版)

Linux/Windowsシステムに自動シャットダウン機能を組込むとができます。

ダウンロードはここから

ダウンロードはこちら

debian:~$ ls
SimpleSoftwareVer241_Linux_X64.zip

インストール

とりあえずzipファイルを解凍するためにunzipをインストール

# apt-get install unzip

解凍する

# unzip SimpleSoftwareVer241_Linux_X64.zip

インストールするためにアクセス権を振る

/SimpleSoftwareVer241_Linux_X64# chmod 777 Release/

インストールスクリプトを走らせる

/SimpleSoftwareVer241_Linux_X64/Release# ./install.sh
Do you agree this license? [ y/n ] y
   Simple Shutdown program has been installed completely.
   Please run below command and setup the parameters of
   Simple Shutdown to meet your system.

   Command:  /usr/lib/ssd/master/config.sh

インストール完了

USB操作のための libusb-0.1-4をインストールしておく。これが入ってないと、config.shが通らない。

# apt-get install libusb-0.1-4

パラメータ設定

# /usr/lib/ssd/master/config.sh

モードの選択

とりあえず自動で試してみる

[UI Image of Shutdown Parameter Configuration]
********************************************************************************
Shutdown Parameter
********************************************************************************
Please input the shutdown parameters of the debian (Master Agent).
********************************************************************************
   1. Port Selection Mode:
      1. Auto Mode(Select all COM and USB device)
      2. Semiautomatic Mode(Only select all USB device)
      3. Manual Mode(Only select pointed COM port)
      (Default Mode is "Auto Mode(Select all COM and USB device)")
      Select Number:

USBモード Libusbで試す

   2. Select USB communication mode
      1. Libusb 2. HID
      (Default Mode is "Libusb")
      Select Number:

待機時間の設定 Default:60秒

   3. AC fail delay time
      (Default value is 60 Sec)
      [Information]
      * When UPS detects "AC fail" condition doesn't start shutdown action
        until pass this delay time.
      * The range of AC fail delay time is from 0 Sec to 36000 Sec.
      * The step between "0 Sec to 36000 Sec" is "1 Sec".
      AC fail delay time(Sec):

外部コマンドも実行できる

   4. External Command Line
      [Information]
      * After the AC fail delay time this External Command line will be execute
      * Please setup an External Command
      External Command Line:

外部コマンドの実行時間も指定可能

   5. External Command needs time
      (Default value is 0 Sec)
      [Information]
      * Please setup an External Command needs time from External Command start
        to External Command finish.
      * The range of External Command need time is from 0 Sec to 600 Sec.
      * The step between "0 Sec to 600 Sec" is "60 Sec".
      * If you use External Command for Virtual Server shutdown.
        please setup External Command needs time for Guest OS shutdown.
      External Command needs time (Sec):

シャットダウンに必要な時間

この時間でUPSも電源がきれてしまうので、ちゃんとシャットダウンにかかる時間を測定しておいた方がいいです。下手するとシャットダウン中に電源切れます。

   6. OS shutdown need time
      (Default value is 180 Sec)
      [Information]
      * Please setup an OS shutdown needs time from OS shutdown start
        to OS shutdown finish.
      * The range of OS Shutdown need time is from 0 Sec to 600 Sec.
      * The step between "0 Sec to 600 Sec" is "60 Sec".
      OS shutdown needs time (Sec):

ログインユーザにメッセージを表示

  7. Send Message to login users
      1. Disable 2. Enable
      (Default Value is "Disable")
      Select Number:2

システム終了モード

  7. Send Message to login users
      1. Disable 2. Enable
      (Default Value is "Disable")
      Select Number:2

仮想サーバ終了モード

   9. Virtual Server shutdown mode
      1. Shutdown by Linux system 2. Shutdown by Simple Shutdown
      (Default Mode is "Shutdown by Linux system")

全体設定の確認

********************************************************************************
[Reconfirm shutdown parameter of the debian (Master Agent)].
********************************************************************************
1. Port Selection Mode:               Auto Mode(Select all COM and USB device)
2. Select USB communication mode :    Libusb
3. AC fail Delay time (Sec):          30
4. External Command Line:
5. External Command needs time (Sec): 0
6. OS Shutdown needs time (Sec):      60
7. Send Message to login users:       Enable
8. System closing mode :              Shutdown
9. Virtual Server shutdown mode :     Shutdown by Linux System
********************************************************************************
1.OK 2.Cancel

OKすると、Shutdownエージェントが走る

Broadcast message from root@debian (somewhere) (Tue Jul 25 11:32:13 2023):

Shutdown Agent Start.

BNB50TとUSB接続する

Broadcast message from root@debian (somewhere) (Tue Jul 25 11:33:26 2023):

Communication Establish.

ログの確認

OMRON BN50TのUSBを認識した時

[ 1360.700386] usb 2-5: new low-speed USB device number 5 using xhci_hcd
[ 1360.865025] usb 2-5: New USB device found, idVendor=0590, idProduct=00b4, bcdDevice= 2.00
[ 1360.865038] usb 2-5: New USB device strings: Mfr=3, Product=1, SerialNumber=0
[ 1360.865044] usb 2-5: Product: BN50T
[ 1360.865049] usb 2-5: Manufacturer: OMRON
[ 1360.876154] hid-generic 0003:0590:00B4.0003: hiddev0,hidraw2: USB HID v1.11 Device [OMRON BN50T] on usb-0000:00:14.0-5/input0

停電試験

UPSへの電源をカットしてみます

すると、画面にメッセージが表示されました

Broadcast message from root@debian (somewhere) (Tue Jul 25 12:07:08 2023):

AC line failure!

無事シャットダウンスクリプトが働いてサーバがシャットダウンしました。

syslogを確認する

2023-07-25T12:05:19.098290+09:00 debian SimpleShutdown[782]: Communication Establish.
2023-07-25T12:07:08.550540+09:00 debian SimpleShutdown[782]: AC line failure!
2023-07-25T12:07:38.149380+09:00 debian SimpleShutdown[782]: Run External Command.
2023-07-25T12:07:39.146754+09:00 debian SimpleShutdown[782]: Shutdown Agent Stop.
2023-07-25T12:07:39.154369+09:00 debian SimpleShutdown[782]: Shutdown.

UPSとの通信が途切れ、電源喪失を確認30秒後、シャットダウンが走っているのが分かります。

自動起動させる

元々インストール時に rc.dに入っている自動起動スクリプトはDebianでうまく動かない

これが入っていると、systemdを利用してもうまく動かないのでスクリプトを削除しておく

root@debian:/etc# find /etc/rc?.d | grep SimpleShutdown |xargs rm -v
'/etc/rc0.d/K01SimpleShutdown' を削除しました
'/etc/rc1.d/K01SimpleShutdown' を削除しました
'/etc/rc2.d/K01SimpleShutdown' を削除しました
'/etc/rc3.d/K01SimpleShutdown' を削除しました
'/etc/rc4.d/K01SimpleShutdown' を削除しました
'/etc/rc5.d/K01SimpleShutdown' を削除しました
'/etc/rc6.d/K01SimpleShutdown' を削除しました

systemd 用にファイル作成

# cat /etc/systemd/system/SimpleShutdown.service
[Unit]
Description=Simple Shutdown Software

[Service]
Type=forking
ExecStart=/usr/lib/ssd/master/ssdService
KillSignal=SIGUSR1
Restart=on-abort
RestartSec=3

[Install]
WantedBy=multi-user.target

有効にする

# systemctl daemon-reload
# systemctl enable SimpleShutdown.service
# /usr/sbin/reboot

リブート後、動作を確認する

# systemctl status SimpleShutdown
● SimpleShutdown.service - Simple Shutdown Software
     Loaded: loaded (/etc/systemd/system/SimpleShutdown.service; enabled; preset: enabled)
     Active: active (running) since Wed 2023-07-26 16:37:29 JST; 1min 26s ago
    Process: 465 ExecStart=/usr/lib/ssd/master/ssdService (code=exited, status=0/SUCCESS)
   Main PID: 480 (ssdService)
      Tasks: 2 (limit: 18982)
     Memory: 3.1M
        CPU: 777ms
     CGroup: /system.slice/SimpleShutdown.service
             tq480 /usr/lib/ssd/master/ssdService
             mq490 /usr/lib/ssd/master/ssdDaemon

 7月 26 16:37:29 debian systemd[1]: Starting SimpleShutdown.service - Simple Shutdown Software...
 7月 26 16:37:29 debian systemd[1]: Started SimpleShutdown.service - Simple Shutdown Software.
 7月 26 16:37:29 debian SimpleShutdown[480]: Shutdown Agent Start.
 7月 26 16:37:40 debian SimpleShutdown[480]: Communication Establish.

UPSに供給されている電源を喪失させてうまく動けばOK

電源喪失試験

Broadcast message from root@debian (somewhere) (Wed Jul 26 16:44:02 2023):

AC line failure!

参考

Debian 11 で SimpleShutdownSoftware を使う

オムロンの UPS の自動シャットダウンツール用の systemd .service ファイルを書いたよ

自動起動を削除したい時

# systemctl disable SimpleShutdown.service
# systemctl daemon-reload
# rm /etc/systemd/system/SimpleShutdown.service
# /usr/sbin/reboot

Windows版だとこんな感じ

Windows版はGUIでの設定が可能になります

これが、Windows2022サーバで試し、中途半端な日本語設定していると文字化けする事があります。

日本語化設定するとこんな感じ

Unicode対応していないプログラムに対してどの言語で対応するかを設定する項目があり、それが日本語になっていないのが原因です。

設定方法はこちらから

Windows版にて障害発生

タスクインジケータにあるアイコンが赤くなります。

Windowsログ → Application

に、Simple Shutdown のログが残ります

無事に所定の時間でシャットダウンされました。

タイトルとURLをコピーしました