#!/bin/sh
#
# Plugin to monitor NFS client traffic
#
# $Log$
# Revision 1.8.2.1  2005/03/16 13:45:45  ilmari
# Fix autoconf for linux/{nfsd,nfs_client}.
#
# Revision 1.8  2004/12/10 10:47:49  jimmyo
# Change name from ${scale} to ${graph_period}, to be more consistent.
#
# Revision 1.7  2004/12/09 22:12:56  jimmyo
# Added "graph_period" option, to make "graph_sums" usable.
#
# Revision 1.6  2004/11/21 00:17:12  jimmyo
# Changed a lot of plugins so they use DERIVE instead of COUNTER.
#
# Revision 1.5  2004/10/01 12:32:09  ilmari
# complete "rpc" removal
#
# Revision 1.4  2004/10/01 08:40:50  ilmari
# Remove useless 'rpc' field, add total field
#
# Revision 1.3  2004/05/20 19:02:37  jimmyo
# Set categories on a bunch of plugins
#
# Revision 1.2  2004/05/15 21:33:29  jimmyo
# "Upped" som plugins from contrib/manual to manual or auto.
#
#
#%# family=auto
#%# capabilities=autoconf

NFS=/proc/net/rpc/nfs

proc="getattr setattr lookup access readlink read write create mkdir symlink mknod remove rmdir rename link readdir readdirplus fsstat fsinfo pathconf commit"

if [ "$1" = "autoconf" ]; then
	if [ -f "$NFS" ]; then
		echo yes
		exit 0
	else
		echo "no (no $NFS)"
		exit 1
	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 $proc ; do echo "$a.label $a" ; echo "$a.type DERIVE"; echo "$a.min 0"; done
	exit 0
fi

i=4;

for a in $proc; do
	echo -n "$a.value "
	grep proc3 $NFS \
		| cut -f $i -d ' ' \
		| awk '{print $1}'
	i=$(expr $i + 1)
done
