#!/bin/sh
############################################################################
##
## Copyright (c) 2000-2015 BalaBit IT Ltd, Budapest, Hungary
##
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License along
## with this program; if not, write to the Free Software Foundation, Inc.,
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
##
############################################################################
#
# Script to monitor disk usage.
#
# Parameters understood:
#
# 	config   (required)
# 	autoconf (optional - used by munin-config)

# Magic markers (optional - used by munin-config and installation
# scripts):
#
#%# family=auto
#%# capabilities=autoconf

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


	echo 'graph_title Zorp instances memory usage (in KBytes)'
	echo 'graph_args --base 1024 -l 0'
	echo 'graph_vlabel KBytes'
	echo 'graph_category Zorp'

	ps aufx | fgrep /usr/lib/zorp/zorp | fgrep -v grep | tr -s " " | cut -d " " -f14 | while read i; do
	echo $i"_vsz.label" $i"_VSZ"
	done
	exit 0
fi

	
ps aufx | fgrep /usr/lib/zorp/zorp | fgrep -v grep | tr -s " " | cut -d " " -f5,6,14 | while read i; do
	echo `echo $i | cut -d " " -f3`"_vsz.value "`echo $i | cut -d " " -f1` 
done
