#!/bin/sh

: << =cut

=head1 NAME

nfs_client - Plugin to monitor NFS client traffic

=head1 NOTES

Revision 1.1.1.1  2006/06/04 20:53:57  he

Import the client version of the Munin system monitoring/graphing tool
-- project homepage is at http://munin.sourceforge.net/

This package has added support for NetBSD, via a number of new plugin
scripts where specific steps needs to be taken to collect information.

I also modified the ntp_ plugin script to make it possible to not plot
the NTP poll delay, leaving just jitter and offset, which IMO produces
a more telling graph.

=head1 AUTHOR

Unknown author

CVS revision indicates checkin by "he".  See "NOTES" for more
information.

=head1 LICENSE

GPLv2

=head1 MAGIC MARKERS

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

=cut

#
# 
#
#
#
#
#


getnames () {
    /usr/bin/nfsstat -c | awk '
/RPC Counts/ { coll = 1; next; }
/RPC Info/ { exit 0; }
/[a-z]/ && coll {
    for (n = 1; n <= NF; n++) {
	print $n
    }
}
'
}

if [ "$1" = "autoconf" ]; then
    if [ -x /usr/bin/nfsstat ]; then
	echo yes
	exit 0
    else
	echo no
	exit 0
    fi
fi

if [ "$1" = "config" ]; then

    echo 'graph_title NFS Client'
    echo 'graph_args --base 1000 -l 0'
    echo 'graph_vlabel requests / ${graph_period}'
    echo 'graph_total total'
    echo 'graph_category NFS'
    for a in `getnames` ; do
	echo "$a.label $a"
	echo "$a.type DERIVE"
	echo "$a.min 0"
    done
    exit 0
fi

/usr/bin/nfsstat -c | awk '
/RPC Counts/ { coll=1; next; }
/RPC Info/ { exit 0; }
/[a-z]/ && coll {
    for (n in names) {
	names[n] = ""
    }
    for (n = 1; n <= NF; n++) {
	names[n] = $n
    }
}
/[0-9]/ && coll {
    for (n = 1; n <= NF/2; n++) {
	name = names[n]
	values[name] = $((n - 1) * 2 + 1)
    }
}
END {
    for (v in values) {
	print v ".value " values[v];
    }
}
'
