Giter Site home page Giter Site logo

jadonclegg / powermon Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 58 KB

Utility for turning off computers safely when the power goes out, and turning them back on.

License: GNU General Public License v3.0

Go 96.48% Makefile 3.52%
golang go wake-on-lan raspberry-pi power-outage battery-backup

powermon's Introduction

powermon

powermon is a utility for managing computers attached to battery backups when the power goes out, handling automatic shutdown if the power goes out, and can send WOL packets to power on the same computers.

The idea is to run the server on a computer that's NOT attached to backup power, so it goes down when the power goes out. (I'm using a Raspberry PI for this). When the clients fail to 'ping' the server, they will shut down automatically after the specified time. When the server comes back online, it will send WOL packets to each client listed, and turn them back on, and optionally keep sending those packets until it's verified that they are back online.

Usage

There are three sub commands to the powermon utility, we'll go over them here.

Global Options

These options are ignored for the powermon mac command.

Generic options

-v [--verbose] - enable verbose output

-l [--logfile] - specifies a file to log to

-n [--nickname] - nickname for the computer used in logging, and Pushover notifications.

Pushover options:

-k [--pushover-token] - specifies the Pushover API token to use

-u [--user-token] - specifies the user token to send Pushover notifications to. (can be specified more than once, i.e. -u <token> -u <second token> etc.)

Pushover is a utility for sending Push notifications to your devices. You can register an app to get an app token, and a user token, which you can provide to send yourself push notifications.

Commands

powermon mac

powermon mac

The mac command just lists the mac addresses and their interface names, so you can easily add them to the -w [--wake] option.

powermon server

powermon [Global Options] server [Server Options]

-p [--port] Port to listen on. Default is port 10101

-w [--wake]** MAC address to send WOL packet to upon startup. Can be specified more than one time.

--wakelist** A file with a list of one mac address per line to be woken up with WOL packets upon server startup. Empty lines are ignored, as well as lines beinning with # (comments)

--verify Keep sending WOL packets to MAC addresses specified with -w [--wake] or --wakelist until they have sent a ping to the server.

** Make sure you enable Wake-On-Lan in the BIOS settings of each computer you want to wake first. If you don't, it won't turn on. Some motherboards don't support WOL, and some list it as 'allow pcie wakeup events' or something similar. Google your specific computer / motherboard if you want to turn it on.

powermon client

powermon [Global Options] client [Client Options]

-a [--address] Address of server. Can be an IP or a domain name.

-p [--port] Port to send pings to, make sure this is the same port the server is listening on. Defaults to 10101

-t [--timeout] Shuts the computer down X seconds after a ping fails. Cancelled if a ping succeeds. Default is 60

-i [--interval] Ping the server every X seconds. Default is 60

Compiling

Just run go build after cloning the project.

Make commands

make - runs the default command make powermon - basically an alias to go build

make arm** - builds for the arm (32bit) architecture, output file is powermon-arm (Raspberry Pi 0, 1? not verified)

make arm64** - builds for the arm (64bit) architecture, output file is powermon-arm64 (Verified to work on my raspberry pi 4 running ubuntu server 20.04)

make instaill - run with sudo. Builds and installs to /usr/bin/powermon

make uninstall - run with sudo. Deletes file at /usr/bin/powermon

make clean - Delete all built executables (powermon, powermon-arm, powermon-arm64)

make all - build all 3 versions at the same time.

** The arm builds are because I didn't want to install all the golang utilities on my raspberry pi. I'm compiling on my main computer, and just copying over the executable. You could just install go on your raspberry pi and run go build.

powermon's People

Contributors

jadonclegg avatar

Watchers

 avatar  avatar

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.