#!/bin/sh
# -*- sh -*-

: << =cut

=head1 NAME

df_inode - Plugin to monitor inode-usage.

=head1 NOTES

This plugin is meant to be generic unix but there will be specific
kinks on each platform that may justify custom versions.  It does not
work on SunOS/Solaris/Cygwin.

=head1 CONFIGURATION

The following environment variables are used by this plugin:

 warning  - Warning percentage (Default: 92)
 critical - Critical percentage (Default: 98)

=head1 MAGIC MARKERS:

 #%# family=auto
 #%# capabilities=autoconf

=cut

. $MUNIN_LIBDIR/plugins/plugin.sh

print_values() {
    df -P -l -i 2>/dev/null | sed -e '1d' -e '/\/\//d' -e 's/%//' |
    while read dev avail used free pct fs; do
        echo "$(clean_fieldname $dev).value $pct"
    done
}

if [ "$1" = "autoconf" ]; then
    if [ -z "$(print_values)" ] ; then
	echo no
    else
	echo yes
    fi
    exit 0
fi

if [ "$1" = "config" ]; then
    echo 'graph_title Inode usage in percent'
    echo 'graph_args --upper-limit 100 -l 0'
    echo 'graph_vlabel %'
    echo 'graph_scale no'
    echo 'graph_category disk'
    df -P -l -i  | sed -e '1d' -e '/\/\//d' -e 's/%//' | sort |
    while read dev avail used free pct fs; do
	name=$(clean_fieldname $dev)
	echo "$name.label $fs"
	print_warning $name
	print_critical $name
    done
    exit 0
fi

print_values
