PHP Interface for Network UPS Tools
- Ubuntu Server 20.04 running on a VPS/VM with at least 1vCPU and 2GB RAM, 50GB storage.
- LAMP stack installed and configured with PHP7.4 minimum
- git Installed (apt install git)
- Install Network UPS Tools
NUTas described below:
Install NUT
apt-get install nut
nano /etc/nut/ups.confPaste the foollowing at the bottom. Mine’s an Eaton3s 550, so I’ve set it to a recognizable name (eaton3s)
[eaton3s]
driver = usbhid-ups
port = automkdir /var/run/nut
chown root:nut /var/run/nut
chmod 770 /var/run/nutsh upsdrvctl start
Should give the following output
Network UPS Tools - UPS driver controller 2.4.3
Network UPS Tools - Generic HID driver 0.34 (2.4.3)
USB communication driver 0.31
Using subdriver: EATON HID 0.95nano /etc/nut/upsd.confAdd the following lines where is the IP of your machine
LISTEN 127.0.0.1 3493
LISTEN ::1 3493
LISTEN <IPADDRESS> 3493nano /etc/nut/nut.conf:Enter the following:
MODE=netserverupsdupsc eaton3slocalhost ups.statusShould output the following
OLOL means your system is running On Line power. If you want to see all the info, try this instead
nano /etc/nut/upsd.usersAdd monitor master user and a monitor slave user for remote machines
[monuser]
password = <PASSWORD_REPLACE>
actions = SET FSD
instcmds = ALL
upsmon masterReload upsd
upsd -c reloadnano /etc/nut/upsmon.confPaste the following
MONITOR eaton3s@localhost 1 local_mon <PASSWORD_REPLACE> mastergit clone https://github.com/Dezrin/nut.git
cp nut-*/* /var/www/html/cd /var/www/htmlEdit the config.php file with your NUT details
nano config.phpEnsure these are the same settings that you configured NUT as above
'port' => '3493', /* Port of NUT Server */
'server' => '10.20.10.191', /* NUT Server */
'ups_name' => 'eaton3s', /* UPS name configured in ups.conf */Head to your VM's IP address in your web browser: http://127.0.0.1/ as an example.
Create an external volume on your docker host called php-apache
Download this GIT repository as a .zip file and upload the contents to your docker host in the volume you just created
services:
registry:
image: registry.dezr.in/php:7.4-apache
container_name: Web-NUT
working_dir: /var/www/html
labels:
# - "kop.bind.ip=192.168.254.155" # kop.bind.ip label needed if your using a macVLAN address
- "traefik.enable=true"
- "traefik.http.routers.ups-secure.entrypoints=https" # This is the entry point. You can add custom ports in traefik.yaml etc
- "traefik.http.routers.ups-secure.rule=Host(`ups.dezr.in`)" # Host name
- "traefik.http.routers.ups-secure.tls=true" # This tells traefic your want it to get a cert and use ssl
- "traefik.http.routers.ups-secure.tls.certresolver=cloudflare" # This Label is required only on the Redis hosts
- "traefik.http.routers.ups-secure.service=ups-secure" # What show up on the Traefic Dashboard
- "traefik.http.services.ups-secure.loadbalancer.server.port=8888" # This is the port the container uses
# - "traefik.http.services.ups-secure.loadbalancer.server.scheme=https" # To send HTTPS request to the origin server, instead of HTTP
- 'traefik.http.routers.ups-secure.middlewares=realCloudflareIP@file, authentik@file' # These a middleware files which you can have multiple comma-separated
# - 'traefik.http.routers.nginx2.middlewares=lockdown-headers@file, authentik@file' # example with Authentic middleware label
ports:
- "8888:80"
environment:
- PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
- PHPIZE_DEPS=autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2c
- PHP_INI_DIR=/usr/local/etc/php
- APACHE_CONFDIR=/etc/apache2
- APACHE_ENVVARS=/etc/apache2/envvars
- PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
- PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
- PHP_LDFLAGS=-Wl,-O1 -pie
- GPG_KEYS=42670A7FE4D0441C8E4632349E4FDC074A4EF02D 5A52880781F755608BF815FC910DEB46F53EA312
- PHP_VERSION=7.4.33
- PHP_URL=https://www.php.net/distributions/php-7.4.33.tar.xz
- PHP_ASC_URL=https://www.php.net/distributions/php-7.4.33.tar.xz.asc
- PHP_SHA256=924846abf93bc613815c55dd3f5809377813ac62a9ec4eb3778675b82a27b927
volumes:
- php-apache:/var/www/html
volumes:
php-apache:
external: true
To run NUT-Web without Traefik, just remove all the Labels in the above compose file
This will now load your UPS information and display it on the web.
