Try   HackMD

Ubuntu 安裝APC管理程式 : apcupsd

前情提要, 設備, 環境

  • OS : Ubuntu 22.04
  • UPS : APC BN650M1-TW (650VA/360W 離線式)
    Image Not Showing Possible Reasons
    • The image was uploaded to a note which you don't have access to
    • The note which the image was originally uploaded to has been deleted
    Learn More →

    詳細介紹可參考網友的這篇文章:
    https://forum.gamer.com.tw/C.php?bsn=60030&snA=489621

APC的UPS在Windows平台下可以使用下面的PowerChute Personal Edition,︁使用起來很方便
但是其他平台下(linux)則必須使用apcupsd這套軟體才能監控

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

設定apcupsd

安裝必要套件

sudo apt-get -y install apcupsd apcupsd-cgi apache2

修改conf檔

sudo vim /etc/apcupsd/apcupsd.conf

須包含以下:

  • UPSNAME XXX UPS名稱
  • UPSCABLE usb 以USB連接UPS
  • UPSTYPE usb 以USB連接UPS
  • DEVICE 設定裝置,︁Ubuntu這邊不能使用預設的DEVICE /dev/ttyS0,︁否則會無法連接
    • Image Not Showing Possible Reasons
      • The image was uploaded to a note which you don't have access to
      • The note which the image was originally uploaded to has been deleted
      Learn More →
  • POLLTIME 60 輪詢UPS狀態的時間間隔

修改設定完成標記

sudo vim /etc/default/apcupsd

ISCONFIGURED=no改成ISCONFIGURED=yes

終端機監控

查看目前的各項資訊

apcaccess status

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →


執行測試,︁要先把apcupsd先關掉

sudo systemctl stop apcupsd
sudo apctest
選擇你要進行的測試
sudo systemctl start apcupsd

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

比較常會用的是2號,︁測試切換到電池供電有沒有問題

網頁監控

把.cgi檔複製到 /var/www/html/apcupsd

cd /var/www/html
sudo mkdir apcupsd
sudo cp /usr/lib/cgi-bin/apcupsd/*.cgi /var/www/html/apcupsd

Apache2預設是不支援使用cgi的,︁啟用方法:

cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/cgi.load
cd /etc/apache2
sudo vim apache2.conf
最下方新增 "Include /etc/apache2/apcupsd.conf"

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

sudo vim /etc/apache2/apcupsd.conf

貼上以下內容

<Directory "/var/www/html/apcupsd">
        Order allow,deny
        Allow from all
        AllowOverride None
        Options Indexes FollowSymLinks ExecCGI
        AddHandler cgi-script .cgi
        Require all granted
</Directory>

重啟Apache服務

sudo service apache2 reload

開啟網頁
http://localhost/apcupsd/

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

如果進不去,︁可能是因為還沒開啟apache2

sudo service apache2 start

如果想要在開機時就啟動apache2

sudo systemctl enable apache2
可以從網頁上查看各項資訊: http://localhost/apcupsd/multimon.cgi
Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

http://localhost/apcupsd/upsstats.cgi
Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

http://localhost/apcupsd/upsstats.cgi
Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

參考資料