Monitoring of max open files in a vserver

Running services on a virtual server sometimes causes problems. I often faced such porblems by reaching the maximum amount of open files. In that case applications like Apache or Postfix fill up their logs with lines like this:

„Too many open files in system“

I wanted to be able to monitor the amount of open files on my server (OpenVZ/ Virtuozzo) to easily see when there were and also when there might be problems. I decided to give Munin a try. Installation and basic Configuration was really simple and what I like very much is that custom plugins can be written very quickly with basic knowlegde of bash or perl.

Attached is my munin plugin. Just copy it to /etc/munin/plugins (in the default installation of munin) and rename it to vserver_open_files. Also add following lines to the file /etc/munin/plugin-conf.d/munin-node, because this plugin needs to run with root privileges.

[vserver_open_files] user root

vserver_open_files-day

Here is the link: https://www.schmalenegger.com/files/vserver_open_files.sh