openbsd-ports/net/munin/files/vmstat

85 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
#
# $OpenBSD: vmstat,v 1.2 2010/10/23 15:52:22 sthen Exp $
#
# Adapted from node/node.d.freebsd/vmstat.in
#
# Plugin to monitor the number of procs in io-sleep and other wait
# states. Uses `vmstat`.
#
# Parameters:
#
# config (required)
# autoconf (optional - used by munin-config)
#
# _Log$
# Revision 1.4.2.1 2005/01/28 14:51:22 lupe
# Add graph_info and some filed.info
#
# Revision 1.5 2005/01/28 14:47:31 lupe
# Add graph_info and some filed.info
#
# Revision 1.4 2004/11/28 09:43:54 lupe
# 6-CURRENT support
#
# Revision 1.3 2004/05/20 19:02:36 jimmyo
# Set categories on a bunch of plugins
#
# Revision 1.2 2004/02/01 18:59:54 lupe
# FreeBSD 5 compatibility.
#
# Revision 1.1 2004/01/02 18:50:00 jimmyo
# Renamed occurrances of lrrd -> munin
#
# Revision 1.1.1.1 2004/01/02 15:18:07 jimmyo
# Import of LRRD CVS tree after renaming to Munin
#
# Revision 1.2 2003/11/07 17:43:16 jimmyo
# Cleanups and log entries
#
#
#
# Magick markers (optional):
#%# family=auto
#%# capabilities=autoconf
if [ "$1" = "autoconf" ]; then
/usr/bin/vmstat 1 1 2>/dev/null >/dev/null
RESULT=$?
NAME=/usr/bin/vmstat
if [ $RESULT -eq 0 ]; then
echo yes
exit 0
else
if [ $RESULT -eq 127 ]; then
echo "no (could not run \"$NAME\")"
exit 1
else
echo no
exit 1
fi
fi
fi
if [ "$1" = "config" ]; then
echo 'graph_title VMstat'
echo 'graph_args --base 1000 -l 0'
echo 'graph_vlabel process states'
echo 'graph_category processes'
echo 'graph_info This graph shows number of processes in each state.'
echo 'running.label running'
echo 'running.info processes on CPU or waiting for CPU'
echo 'running.type GAUGE'
echo 'blocked.label wait'
echo 'blocked.info processes blocked for resources (I/O, paging, etc)'
echo 'blocked.type GAUGE'
echo 'pagewait.label pagewait'
echo 'pagewait.info processes waiting for page-in'
echo 'pagewait.type GAUGE'
exit 0
fi
/usr/bin/vmstat 1 2 | /usr/bin/awk 'END { print "running.value " $1 "\nblocked.value " $2 "\npagewait.value " $3}'