Trigger a graceful shutdown on all servers in the event there is an extended power outage.
Project description
ericbo/apc-ipmi-monitor
WARNING! This is just a prof of concept I created during some free time. It is not in a state were I would use it in my own homelab yet.
A tool designed for non enterprise APC branded UPS's. This will allow you to define many IPMI devices across your network and will trigger a graceful shutdown on all servers in the event there is an extended power outage.
Getting Started
In the system that will be directly interfacing with the APC UPS, you must have apcupsd and ipmitool installed. On Ubuntu, this can be installed with the following commands:
sudo apt-get -y install apcupsd
sudo apt-get -y install ipmitool
Running apcupsd
For this script to monitor the status of your APC battery apcupsd must be running.
Assuming you are using an APC with a single USB connection, make sure UPSCABLE
and UPSTYPE
are both set to usb in your /etc/apcupsd/apcupsd.conf
file. I
would also suggest commenting out DEVICE /dev/ttyS0
. Example:
## apcupsd.conf v1.1 ##
...
UPSCABLE usb
...
UPSTYPE usb
...
#DEVICE /dev/ttyS0
Running the Monitor
You will need pip installed, specifically pip for python 3. You can then directly install this package via pypi.org by running the following:
sudo apt-get -y install python3-pip
pip3 install apc-ipmi-monitor-ericbo
Next create a simple config file with a list of your servers & credentials:
servers:
server 1:
hostname: 0.0.0.0
username: ADMIN
password: ADMIN
server 2:
hostname: 0.0.0.0
username: ADMIN
password: ADMIN
apc_shutdown_threshold:
field: BCHARGE # Which field do you want to consider
value: 80 # When the field dips bellow this value, all servers will shutdown
Finally you can get a quick overview of all your IPMI devices by running:
apc-ipmi-monitor monitoring server-status
Running on Startup
Finally, you will want to ensure this monitor is being ran regularly. I would suggest using systemctl or crontabs. The example bellow is a simple crontab setup. In the future there will be a full guide on setting this up with systemctl.
crontab -e
* * * * * python /home/user/upc-ipmi-tool/src/__main__.py # Run every minute
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file apc-ipmi-monitor-ericbo-0.1.1.tar.gz
.
File metadata
- Download URL: apc-ipmi-monitor-ericbo-0.1.1.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1847d3f8f78c0fc992bee5f268de0acf1d0008d18293b21b26b88bb7212a2a4c |
|
MD5 | 21990b8d845b2bdd3c1066470b2d18b7 |
|
BLAKE2b-256 | ed0235e51ff6089c1d99e089d20b81cb9a36f5842b756ed08ffdd307202cb2cc |
File details
Details for the file apc_ipmi_monitor_ericbo-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: apc_ipmi_monitor_ericbo-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecabeb7d14762740eafc27e51f359ef40344da6ed29343b321e3c57da9381450 |
|
MD5 | ae63c53af95954f5c2f20dab0b7f3b1b |
|
BLAKE2b-256 | 9defbd635baa60ba4988d97b431ac8c826a4d01bdc7e4cf8ba30d4d7cd52dcb7 |