#!/bin/sh # -*- sh -*- MUNIN_LIBDIR=/usr/share/munin/ if [ -z "$MUNIN_LIBDIR" ]; then MUNIN_LIBDIR="`dirname $(dirname "$0")`" fi . $MUNIN_LIBDIR/plugins/plugin.sh if [ "$1" = "autoconf" ]; then echo yes exit 0 fi if [ -z "$names" -o -z "$os" ]; then echo "Configuration required" exit 1 fi if [ "$1" = "config" ]; then echo graph_title Total memory usage echo 'graph_category processes' echo 'graph_args --base 1024 --vertical-label memory -l 0' for name in $names; do fieldname=$(clean_fieldname $name) REGEX='\<'"$name"'\>' echo "$fieldname.label $name" echo "$fieldname.draw LINE2" echo "$fieldname.info Processes matching this regular expression: /$REGEX/" done exit 0 fi for name in $names; do fieldname=$(clean_fieldname $name) printf "$fieldname.value " if [ "$os" = "freebsd" ]; then ps awxo rss,command | grep -w $name | grep -v grep | /usr/bin/awk '{ total += $1 } END { print total * 1024 }' else ps auxww | grep -w $name | grep -v grep | sed -re 's/[ ]{1,}/ /g' | /usr/bin/cut -d ' ' -f 6 | /usr/bin/awk '{ total = total + $1 } END { print total * 1024 }' fi done