Last active
April 7, 2022 20:00
-
-
Save acrookston/70b03794db8d72afadc3 to your computer and use it in GitHub Desktop.
Munin plugin for monitoring memory usage based on process id's
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# (c) 2015, Andrew Crookston <andrew@caoos.com> | |
# Licence: GPLv2 | |
# | |
# Configure it by using the pidfiles env. Format: name:pidfile name:pidfile. e.g.: | |
# | |
# [proc_mem_pid] | |
# env.pidfiles munin-node:/var/run/munin/munin-node.pid | |
# | |
. $MUNIN_LIBDIR/plugins/plugin.sh | |
if [ "$1" = "autoconf" ]; then | |
echo yes | |
exit 0 | |
fi | |
pidfiles=${pidfiles:="munin-node:/var/run/munin/munin-node.pid"} | |
if [ "$1" = "config" ]; then | |
echo 'graph_title Memory usage by process id' | |
echo 'graph_args --base 1024 -l 0' | |
echo 'graph_vlabel Bytes' | |
echo 'graph_category processes' | |
echo 'graph_info This graph shows the memory usage of several processes' | |
for proc in $pidfiles; do | |
name=${proc%:*} | |
echo "$name.label $name" | |
done | |
exit 0 | |
fi | |
for proc in $pidfiles; do | |
name=${proc%:*} | |
pid=`cat ${proc#*:}` | |
echo "$name.value " `ps up $pid | awk 'BEGIN { sum = 0 } NR > 1 { sum += $6 }; END { print sum * 1024 }'` | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi acrookston.
I can run it on terminal, but can't put it on munin graphs.
can you help me plz?