A Nagios-plugin to monitor fail-counts of OpenVZ containers.

OpenVZ containers may have limited resources, if they reach their maximum and try to request more of a single resource they produce a fail-count that is displayed in /proc/user_beancounters . Maybe you want to get notified about that problem, this script monitors the file and alerts if any fail-counter increases. To reset the fail-counts you have to restart the container, but sometimes there isn’t the chance to reboot a virtual machine. So this script copies the /proc/user_beancounters (at default the copy is located at /tmp/user_beancounters ) and alerts about diffs. To disable the alert just delete the copy, the script will create a new copy when it is called the next time. So there won’t be a diff anymore.

To get read access to /proc/user_beancounters for the user nagios don’t forget to set the s -bit ( chmod +s check_UBC.pl ).

Here is the code.

Dependencies

  • Expects the beancounters in /proc/user_beancounters
  • Expects vzctl to be found in /usr/sbin/vzctl

Please consider to take a look at my general setup notes.

Download: Perl: check_UBC.pl (Please take a look at the man-page. Browse bugs and feature requests.)

Martin Scharm

stuff. just for the records.

Do you like this page?
You can actively support me!

3 comments

non7top | Permalink |

looks like it depends on some nagios libs as well, which makes it less portable.

Hartmut | Permalink |

On Debian i got this error: Can’t do setuid (cannot exec sperl) Just check the fix here: http://chrisjean.com/2011/06/06/fix-setuid-cannot-exec-sperl/

Martin Scharm | Permalink |

Hi Hartmut, thanks for reporting and providing the fix :)

Leave a comment

There are multiple options to leave a comment: