GithubHelp home page GithubHelp logo

alexdean / beancounter Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 3.0 115 KB

Python script to monitor resource overruns in OpenVZ guests.

Home Page: http://www.deanspot.org/content/monitor-resource-overruns-openvz

Python 100.00%

beancounter's Introduction

OpenVZ is a great virtualization tool for Linux servers, but not the friendliest to configure.  I've repeatedly run up against various resource limits, which can sometimes lead to really weird errors like 'cannot allocate memory' when you do something awful like 'ls -l'.  I cooked up the following script to keep a log file of times when a server overruns its bounds.  I can then either raise the limits, or try to correlate the overrun time to something going on at that time.

The script will examine the /proc/user_beancounters file and print any 'failcnt' values which have changed since the last run.  Set up a cron job every minute (or whatever frequency you like), and redirect output to get an easy failure log.

  * * * * * /usr/local/bin/beancount.py >> /var/log/beancount.log

This has to be run as root, since a non-root user cannot read the user_beancounters file.  It works equally well when run from a guest OS or from a host OS.  If run from the host, you'll get monitoring of all guests.

It doesn't track how long it's been since the last run, which you'd need for calculating failures/second or some other rate.  I'm working on the assumption that these failures should be fairly rare, and you're most interested in the fact that they're happening at all.

Some possible enhancements:
 * Add syslog or other logging facilities in addition to stdout.

beancounter's People

Contributors

ps2 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  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.