Giter VIP home page Giter VIP logo

apcupsd's People

Contributors

bnhf avatar gregewing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

apcupsd's Issues

Volumes need to be defined in docker-compose

@gregewing

Rather than tacking-on to the PR that didn't make the grade, I thought I'd open an issue to expand on a couple of topics:

Following the direction you want to go, and for the purposes of the README with the recently updated docker-compose, the volume needs to be defined in the yaml. It does not need to be created in advance. Also, the name of the stack is appended to the front of the volume, so a volume name of "config" results in a directory named "apcupsd_config" in /var/lib/docker/volumes (assuming a stack name of apcupsd) :

version: '3.7'
services:
  apcupsd:
    image: gregewing/apcupsd:latest
    container_name: apcupsd
    devices:
      - /dev/usb/hiddev0 # This device needs to match what the APC UPS on your system uses.
    ports:
      - 3551:3551
    environment:
      - TZ=${TZ}
    volumes:
      - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
      - config:/etc/apcupsd
    restart: unless-stopped
volumes:
  config:

And this results in the following directory being created, and populated:

screenshot-raspberrypi10-2023 02 02-19_05_34

I think you'll find that the start.sh in the PR works equally well whether the binding is to a directory (like /data/apcupsd) or to a volume (like config:). Either way, somebody can launch an apcupsd daemon container all from a Portainer-Stack, without having to execute or modify anything from the command line.

If you're willing, I'd like to figure out why you were unsuccessful using the docker-compose from my fork. I've been using it for my "Ultimate APC UPS Monitoring" project, and it's been dead-simple and reliable so far. Did your portainer stack look like this?:

screencapture-raspberrypi10-9000-2023-01-30-14_29_02

can't get modbus working

I am trying to get usb-modbus communication working on an APC SMT1500i (ID=18, firmware 9.3), but seemingly it won't connect:

root@a0689fdd2dae:/# apcaccess status
APC      : 001,018,0450
DATE     : 2023-06-06 20:43:12 +0200  
HOSTNAME : a0689fdd2dae
VERSION  : 3.14.14 (31 May 2016) debian
UPSNAME  : smt1500i
CABLE    : USB Cable
DRIVER   : MODBUS UPS Driver
UPSMODE  : Stand Alone
STARTTIME: 2023-06-06 20:43:00 +0200  
STATUS   : COMMLOST 
MBATTCHG : 5 Percent
MINTIMEL : 5 Minutes
MAXTIME  : 0 Seconds
NUMXFERS : 0
TONBATT  : 0 Seconds
CUMONBATT: 0 Seconds
XOFFBATT : N/A
STATFLAG : 0x05000100
END APC  : 2023-06-06 20:43:12 +0200  

I have enabled modbus on the device's menu. Could it be that the code is not build with modbus support? Maybe hitting this? https://marc.info/?l=apcupsd-users&m=148305369513924&w=2

Multi-arch container with arm/v7 and arm/64

@gregewing

Any reason the container couldn't be built multi-arch? I have 6 APC UPS units, half of which I'm monitoring using apcupsd with nearby PCs. The other half are in locations where deploying a Raspberry Pi seems like about the best best for adding monitoring -- and I do everything I can using Docker these days. :-)

In addition to monitoring each of my UPS units using system tray icons:

Screenshot 2023-01-15 131915

I'd also like to be able to pull up a Docker-based Grafana Dashboard like this:

image

But that's in the future, right now I'd like to just get this running under the 64-bit version of the Raspberry Pi OS with Docker.

Unable to mount /etc/apcupsd/ as a volume

Hello, I wanted to mount /etc/apcupsd as a volume.
This is the docker-compose that I am using:

services:
  apcupsd:
    container_name: apcupsd
    devices:
    - /dev/bus/usb/001/006
    environment:
      TZ: Europe/Rome
    image: gregewing/apcupsd:latest
    ports:
    - published: 3551
      target: 3551
    privileged: true
    volumes:
    - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket:rw
    - /apps/apcupsd/config:/etc/apcupsd:rw
version: '3.3'

This is the error that I see if I run docker-compose logs -f

Attaching to apcupsd
apcupsd    | 0.005 apcupsd: drivers.c:182 Warning: no UPS driver found (ups->mode.type=0).
apcupsd    | apcupsd FATAL ERROR in apcupsd.c at line 196
apcupsd    | Apcupsd cannot continue without a valid driver.
apcupsd exited with code 1

If I remove - /apps/apcupsd/config:/etc/apcupsd:rw from the compose file I have a working container without errors but I have to reconfigure it every time and is not very pratical to use it in this way

Quick dumb question - how do I monitor this?

I have the container up and running. I opted for the volume over bind mount (that didn't seem to work). At this point, I just do not know if its doing the job. What is the proper way to monitor status? I tired apcaccess but received Connection refused.

Thank you.

Environment variables and sample docker-compose for master-slave setups

@gregewing

Hey Greg - I know you've got a lot going on at the moment, but hopefully in the great spirit of open source we can enhance this project concurrently.

If you haven't seen, I added some additional comments to the open "Volumes" issue regarding the bnhf/apcupsd:latest container not being up-to-date with the PR I submitted. I've rectified that, and tested bind mounts of all types, and I think we're in good shape there. Now that I'm focusing on the master-slave shutdown capability of apcupsd, I see that we need all of the scripts and config files present in /etc/apcupsd, and that's been handled in this update.

What I'm working on now, which I hope you'll like, are additional environment variables to support setting up the UPS-connected computer as a master and any number of other boxes as slaves. For those who like the command line and editing config files nothing will change, but for those who prefer tools like Portainer the whole thing can be done from a stack.

This isn't quite ready to test yet, but I wanted to give you a preview of what I have in mind. Here are the paired down docker-compose yaml examples for a master-slave setup, followed by a "universal" fully annotated version that can be used for either master or slave:

Master with minimum required settings using a directory bind mount:

version: '3.7'
services:
  apcupsd:
    image: bnhf/apcupsd:test
    container_name: apcupsd
    devices:
      - /dev/usb/hiddev0
    ports:
      - 3551:3551
    environment:
      - UPSNAME=${UPSNAME}
      - APCUPSD_SLAVES=${APCUPSD_SLAVES} # Enter the APUPSD_SLAVES IP list here (space separated)
      - TZ=${TZ}
   volumes:
      - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
      - /data/apcupsd:/etc/apcupsd
     restart: unless-stopped

Slaves with minimum required settings using a directory bind mount:

version: '3.7'
services:
  apcupsd:
    image: bnhf/apcupsd:test
    container_name: apcupsd
    ports:
      - 3551:3551
    environment:
      - UPSCABLE=${UPSCABLE} # On APCUPSD_SLAVES set the value to ether
      - UPSTYPE=${UPSTYPE} # On APCUPSD_SLAVES set the value to net
      - DEVICE=${DEVICE} # On APCUPSD_SLAVES set the IP address of the APCUPSD_MASTER with the listening port (:3551)
      - TZ=${TZ}
    volumes:
      - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
      - /data/apcupsd:/etc/apcupsd
    restart: unless-stopped

And finally, here's the fully annotated "universal" docker-compose with all of the variables I've identified thus far, that someone may want to tweak:

version: '3.7'
services:
  apcupsd:
    image: bnhf/apcupsd:test
    container_name: apcupsd
    devices:
      - /dev/usb/hiddev0 # This device needs to match what the APC UPS on your APCUPSD_MASTER system uses -- Comment out this section on APCUPSD_SLAVES
    ports:
      - 3551:3551
    environment:
      - UPSNAME=${UPSNAME} # Sets a name for the UPS (1 to 8 chars), that will be used by System Tray notifications, apcupsd-cgi and Grafana dashboards
#      - UPSCABLE=${UPSCABLE} # Usually doesn't need to be changed on system connected to UPS. (default=usb) On APCUPSD_SLAVES set the value to ether
#      - UPSTYPE=${UPSTYPE} # Usually doesn't need to be changed on system connected to UPS. (default=usb) On APCUPSD_SLAVES set the value to net
#      - DEVICE=${DEVICE} # Use this only on APCUPSD_SLAVES to set the hostname or IP address of the APCUPSD_MASTER with the listening port (:3551)
#      - POLLTIME=${POLLTIME} # Interval (in seconds) at which apcupsd polls the UPS for status (default=60)
#      - ONBATTERYDELAY=${ONBATTERYDELAY} # Sets the time in seconds from when a power failure is detected until an onbattery event is initiated (default=6)
#      - BATTERYLEVEL=${BATTERYLEVEL} # Sets the daemon to send the poweroff signal when the UPS reports a battery level of x% or less (default=5)
#      - MINUTES=${MINUTES} # Sets the daemon to send the poweroff signal when the UPS has x minutes or less remaining power (default=5)
#      - TIMEOUT=${TIMEOUT} # Sets the daemon to send the poweroff signal when the UPS has been ON battery power for x seconds (default=0)
#      - SELFTEST=${SELFTEST} # Sets the daemon to ask the UPS to perform a self test every x hours (default=336)
#      - APCUPSD_SLAVES=${APCUPSD_SLAVES} # If this is the APCUPSD_MASTER, then enter the APUPSD_SLAVES list here (space separated)
      - TZ=${TZ}
    volumes:
      - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket # Required to support host shutdown from the container
      - /data/apcupsd:/etc/apcupsd # /etc/apcupsd can be bound to a directory or a docker volume
    restart: unless-stopped
# volumes: # Use this section for volume bindings only
#   config: # The name of the stack will be appended to the beginning of this volume name, if the volume doesn't already exist
#     external: true # Use this directive if you created the docker volume in advance

I have pretty much all of this working already with the exception of the APCUPSD_SLAVES variable, but the code for that is already present in some work I did on a apcupsd-cgi container -- so I just need to port it over.

Let me know what you think when you have a spare a moment. If you're open to some further collaboration, I think we can add some nice features to this project with a minimum of your bandwidth. Cheers.

`mail: not found` in log output

Hello and many thanks for your work! I'm wondering if it's known that the mail functionality isn't working - if yes, can I have a go at adding it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.