#!@@GOODSH@@
#
# Plugin to monitor the number of forks per second on the machine.
#
# Parameters:
#
# 	config   (required)
# 	autoconf (optional - used by munin-config)
#
# $Log: forks.in,v $
# 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.
#
#
#
#
# Magick markers (optional - used by munin-config and som installation
# scripts):
#%# family=auto
#%# capabilities=autoconf



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

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

    echo 'graph_title Fork rate'
    echo 'graph_args --base 1000 -l 0 '
    echo 'graph_vlabel forks / ${graph_period}'
    echo 'graph_category processes'
    echo 'graph_info This graph shows the number of forks (new processes started) per second.'

    echo 'forks.label forks'
    echo 'forks.type DERIVE'
    echo 'forks.min 0'
    echo 'forks.max 100000'
    echo 'forks.info The number of forks per second.'

    echo 'forkblk.label forks blocked parent'
    echo 'forkblk.type DERIVE'
    echo 'forkblk.min 0'
    echo 'forkblk.max 100000'
    echo 'forkblk.info The number of forks which blocked the parent process.'

    echo 'forksh.label shared addrs w. parent'
    echo 'forksh.type DERIVE'
    echo 'forksh.min 0'
    echo 'forksh.max 100000'
    echo 'forksh.info The number of forks which shared address space with the parent process.'

    exit 0
fi

vmstat -s | awk '
/forks total$/			{ print "forks.value " $1; }
/forks blocked parent$/		{ print "forkblk.value " $1; }
/forks shared address space with parent$/ { print "forksh.value " $1; }
'
