#!/bin/sh
# 
# Plugin to monitor the number of open files in the system on a vserver
#
# written by: Thorsten Schmale (thorsten@schmalenegger.com)
#
# Parameters:
# 	
# 	config   (required)
# 	autoconf (optional - used by munin-config)
#

if [ "$1" = "autoconf" ]; then
    if [ -r /proc/user_beancounters ] ; then
		echo yes
		exit 0
	else
        echo Cannot read Beancounters >&2
		echo no
		exit 1
	fi
fi

if [ "$1" = "config" ]; then
	echo 'graph_title Open files'
	#echo 'graph_args --base 1000 -l 0'
	echo 'graph_vlabel number of open files'
	echo 'graph_category system'
	echo 'graph_info This graph monitors the amount of open files on the system.'
	echo 'used.label open files'
	echo 'used.info The number of currently open files.'
	echo 'max.label max open files'
	echo 'max.info The maximum supported number of open files.'
	exit 0
fi

cat /proc/user_beancounters | grep numfile | awk '{print "used.value "$2 "\nmax.value "$3}'

