Révision 0283dce0
New plugin: check memory usage by user
| plugins/processes/proc_mem_by_user | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
# |
|
| 3 |
# (c) 2014, Gilles Fauvie <gfauvie@opendbteam.com> |
|
| 4 |
# Based on the 'du_multidirs' plugin, written by Christian Kujau <lists@nerdbynature.de> |
|
| 5 |
# |
|
| 6 |
# Configure it by using the processes env var, i.e.: |
|
| 7 |
# |
|
| 8 |
# [proc_mem_by_user] |
|
| 9 |
# env.processes munin-node jprod |
|
| 10 |
# |
|
| 11 |
|
|
| 12 |
. $MUNIN_LIBDIR/plugins/plugin.sh |
|
| 13 |
|
|
| 14 |
if [ "$1" = "autoconf" ]; then |
|
| 15 |
echo yes |
|
| 16 |
exit 0 |
|
| 17 |
fi |
|
| 18 |
|
|
| 19 |
users=${processes:="munin-node"}
|
|
| 20 |
|
|
| 21 |
if [ "$1" = "config" ]; then |
|
| 22 |
echo 'graph_title Memory usage by process by user' |
|
| 23 |
echo 'graph_args --base 1024 -l 0' |
|
| 24 |
echo 'graph_vlabel Bytes' |
|
| 25 |
echo 'graph_category processes' |
|
| 26 |
echo 'graph_info This graph shows the memory usage of several processes of one user' |
|
| 27 |
|
|
| 28 |
for user in $users; do |
|
| 29 |
echo "$user.label $user" |
|
| 30 |
done |
|
| 31 |
|
|
| 32 |
# echo "$u".warning 0 |
|
| 33 |
# echo "$u".critical 0 |
|
| 34 |
|
|
| 35 |
exit 0 |
|
| 36 |
fi |
|
| 37 |
|
|
| 38 |
for user in $users; do |
|
| 39 |
echo "$user.value " `ps u -U $user | awk 'BEGIN { sum = 0 } NR > 1 { sum += $6 }; END { print sum * 1024 }'`
|
|
| 40 |
done |
|
Formats disponibles : Unified diff