From 55401f04c411af9bddf6dbbe91a0733bd260b438 Mon Sep 17 00:00:00 2001 From: Julien Francoz Date: Wed, 7 May 2008 23:46:03 +0200 Subject: [PATCH] Initial version --- plugins/other/proc_memory_status | 64 ++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100755 plugins/other/proc_memory_status diff --git a/plugins/other/proc_memory_status b/plugins/other/proc_memory_status new file mode 100755 index 00000000..7c10cecd --- /dev/null +++ b/plugins/other/proc_memory_status @@ -0,0 +1,64 @@ +#!/bin/sh + +# Julien Francoz CoCoZ + +# graph memory usage detail for a process using /proc/$PID/status +# create a link to this plugin with the syntax proc_yourprocessname_status +# example : proc_master_status pour postfix master process + +cmd=`basename "$0"` +process=`echo "$cmd"| cut -d'_' -f 2` +pid=`pgrep -o -x "$process"` +#echo $pid + +if [ "$1" = "autoconf" ]; then + if [ -r /proc/$pid/status ]; then + echo yes + exit 0 + else + echo no + exit 1 + fi +fi + +if [ "$1" = "config" ]; then + + echo "graph_title Memory usage for process $process" + echo "graph_order VmExe VmLib VmStk VmData VmRSS VmSize" + echo 'graph_vlabel Ko' + echo 'graph_scale no' + echo "graph_info This graph display memory usage for a process" + echo 'graph_category system' + echo 'graph_period second' + + echo 'VmExe.label VmExe' + echo 'VmExe.draw AREA' + echo "VmExe.info The size of the executable segment" + + echo 'VmLib.label VmLib' + echo 'VmLib.draw STACK' + echo 'VmLib.info The size of the library code' + + echo 'VmStk.label VmStk' + echo 'VmStk.draw STACK' + echo 'VmStk.info The stack size' + + echo 'VmLck.label VmLck' + echo 'VmLck.draw STACK' + echo 'VmLck.info The amount of locked memory' + + echo 'VmData.label VmData' + echo 'VmData.draw STACK' + echo 'VmData.info The size of the Data segment' + + echo 'VmRSS.label VmRSS' + echo 'VmRSS.draw LINE2' + echo 'VmRSS.info The amount of memory mapped in RAM ( instead of swapped out)' + + echo 'VmSize.label VmSize' + echo 'VmSize.draw LINE2' + echo 'VmSize.info The size of the virtual memory allocated to the process' + exit 0 +fi + +cat /proc/$pid/status |grep -E '^Vm' | sed -e 's/:/.value/' -e 's/\s\+kB$//' -e 's/\s\+/ /'