Collectd is an RRD based tool to collect utilization and usage data for servers and services. While it comes with an OpenVZ plugin it is currently lacking the possibility to monitor OpenVZ beancounters from within a container. Here is my plugin to do just that.
The plugin is written in C and parses the relevant entries in the /proc pseudo file system (e.g. /proc/user_beancounters). So it doesn’t produce any additional overhead by calling external programs. It collects the four main values (held, maxheld, barrier, limit) plus the fail counter for a resource counter. If you don’t want to monitor all resources you can specify either an include or exclude list in the configuration file. See the comments in the source for more details.
Some example graphs that are built upon memory related beancounters:
The source code has already been posted to the collectd mail list on 2011-04-15, but alas I haven’t received any feedback. My data collection has been running with the plugin for a couple of months now (Debian Lenny with collectd-4.10.1 from backports). I haven’t had any trouble so far and so I would like to make the source available for everybody.
You can download the following files: