2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/memory/proc_memory_status

64 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
# Julien Francoz CoCoZ <julien@francoz.net>
# 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
else
echo no
fi
exit 0
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 processes'
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\+/ /'