Coder Social home page Coder Social logo

ericbo / apc-ipmi-monitor Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 18 KB

A python script that polls data from an APC branded UPS to automate the shutdown of bare metal servers.

Home Page: https://pypi.org/project/apc-ipmi-monitor-ericbo

Python 97.18% Shell 2.82%

apc-ipmi-monitor's Introduction

ericbo/apc-ipmi-monitor

Python package Upload Python Package

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

source

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

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.