Try   HackMD

c4lab-server Share UPS status across machines

tags: c4lab

TL;DR

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Backgroud

I have four machines plugged on apcups, include two server, one Synology NAS, one QNAP NAS. Yet the ups has only one USB port, I will try to share the ups status to all machines and notify them whether the power is gone.

Get UPS status via USB

Connect one of the server to APC via USB.

Then, setup apcupsd

For Ubuntu

sudo apt -y install apcupsd

In /etc/apcupsd/apcupsd.conf

UPSCABLE usb
UPSTYPE usb
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551

The NISIP is set to 0.0.0.0 that allow remote access.

And start the services

sudo systemctl enable apcupsd
sudo systemctl start apcupsd

Connect by other server

The other server can get the ups status by apcupsd through network

In /etc/apcupsd/apcupsd.conf

UPSCABLE ether
UPSTYPE net
DEVICE 192.168.1.2:3551

where 192.168.1.2 is the IP of server connected via USB.

Don't forget to manage by systemctl.

Before Connect to NAS

Both Synology and QNAP are support nut protocal.

Now we setup nut server:

You can install nut server or start it in Docker

  • Ubuntu: sudo apt install -y nut
  • Docker: kmlucy/docker-nut

The Configuration:
nut.conf

MODE=netserver

upsd.conf

LISTEN 0.0.0.0 3493

upsd.user and ups.conf are also need to modify. I will mention later.

Connect to synology NAS

You can login to Synology NAS terminal to find the setting of nut client. It is in /usr/syno/etc/ups, however, it doesn't work when I change the default setting. Thus I try to fit it by changing our configuration.

upsd.user

[monuser]
	password = secret
	actions = SET
	instcmds = ALL
	upsmon slave

ups.conf

[ups]
	driver = apcupsd-ups
	port = 192.168.1.2:3551
	desc = "My ups"

And in Synology NAS: Change the setting in the web interface.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

It works if the Device Information can show the status.

Connect to QNAP NAS

The setting are located in /etc/config/ups in QNAP terminal. It doesn't work again when I change the default setting. Here is my setting for QNAP.

upsd.user

[admin]
	password = 123456
	actions = SET
	instcmds = ALL
	upsmon slave

ups.conf

[qnapups]
	driver = apcupsd-ups
	port = 192.168.1.2:3551
	desc = "c4lab ups for qnap"

Setup in QNAP web

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Merge them

Now, you can merge the configuration together if you have both Synology and QNAP NAS.

upsd.user

[monuser]
	password = secret
	actions = SET
	instcmds = ALL
	upsmon slave
    
[admin]
	password = 123456
	actions = SET
	instcmds = ALL
	upsmon slave

ups.conf

[ups]
	driver = apcupsd-ups
	port = 192.168.1.2:3551
	desc = "My ups"
    
[qnapups]
	driver = apcupsd-ups
	port = 192.168.1.2:3551
	desc = "c4lab ups for qnap"