OpenVZ is a great virtualization tool for
Linux servers. 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
bashls -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. Read more for the full details. 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 , but 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:
bashvzctl enter) rather than the guest.
I got a patch idea for this script from a co-worker, and decided it was time to move it to some version-control system. Chose GitHub since I’m interested in learning a bit more about git and how it works.
http://github.com/alexdean/beancounter/tree/master☙ ☙ ☙