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

Added symlinks to enable the plugin in the header comments.

This commit is contained in:
Gareth Davies 2013-06-14 02:13:49 +08:00
parent 4a7a0de134
commit eec974c510

View File

@ -1,63 +1,69 @@
#!/bin/bash #!/bin/bash
# Copyright (c) 2013 Gareth Davies (shaolintiger@gmail.com www.shaolintiger.com) # Copyright (c) 2013 Gareth Davies (shaolintiger@gmail.com www.shaolintiger.com)
# License GPLv2 # License GPLv2
# This plugin monitors number of workers, total memory used and average memory per process for Unicorn.
mode=`echo $0 | cut -d _ -f 2` # Here are the symlinks to enable it
#
if [ "$1" = "suggest" ]; then # ln -s /usr/share/munin/plugins/unicorn_ /etc/munin/plugins/unicorn_average
echo "memory" # ln -s /usr/share/munin/plugins/unicorn_ /etc/munin/plugins/unicorn_memory
echo "processes" # ln -s /usr/share/munin/plugins/unicorn_ /etc/munin/plugins/unicorn_processes
echo "average"
exit 0 mode=`echo $0 | cut -d _ -f 2`
fi
if [ "$1" = "suggest" ]; then
if [ "$mode" = "memory" ]; then echo "memory"
if [ "$1" = "config" ]; then echo "processes"
echo "graph_title Total Unicorn Memory" echo "average"
echo "graph_vlabel Total RAM" exit 0
echo "graph_category Unicorn" fi
echo "graph_args --base 1024"
echo "ram.label Total RAM" if [ "$mode" = "memory" ]; then
exit 0 if [ "$1" = "config" ]; then
else echo "graph_title Total Unicorn Memory"
echo "graph_vlabel Total RAM"
memory_array=(`ps auwx | grep "unicorn worker" | grep -v grep | awk '{print $6 }'`) echo "graph_category Unicorn"
echo "graph_args --base 1024"
for i in "${memory_array[@]}" echo "ram.label Total RAM"
do exit 0
sum=$(( $sum + ( $i * 1024) )) else
done
echo -n "ram.value " memory_array=(`ps auwx | grep "unicorn worker" | grep -v grep | awk '{print $6 }'`)
echo $sum
for i in "${memory_array[@]}"
fi do
sum=$(( $sum + ( $i * 1024) ))
elif [ "$mode" = "processes" ]; then done
if [ "$1" = "config" ]; then echo -n "ram.value "
echo "graph_title Unicorn Processes" echo $sum
echo "graph_vlabel Processes"
echo "graph_category Unicorn" fi
echo "processes.label active processes"
else elif [ "$mode" = "processes" ]; then
echo -n "processes.value " if [ "$1" = "config" ]; then
ps awwwux | grep 'unicorn worker' | grep -v grep | wc -l echo "graph_title Unicorn Processes"
exit 0 echo "graph_vlabel Processes"
fi echo "graph_category Unicorn"
echo "processes.label active processes"
elif [ "$mode" = "average" ]; then else
if [ "$1" = "config" ]; then echo -n "processes.value "
echo 'graph_title Unicorn Average Process Size' ps awwwux | grep 'unicorn worker' | grep -v grep | wc -l
echo 'graph_args --base 1024 -l 0 ' exit 0
echo 'graph_vlabel Average Process Size' fi
echo 'graph_category Unicorn'
echo 'unicorn_average.label Average Process Size' elif [ "$mode" = "average" ]; then
echo 'unicorn_average.draw LINE2' if [ "$1" = "config" ]; then
echo 'unicorn_average.info The average process size for Unicorn' echo 'graph_title Unicorn Average Process Size'
else echo 'graph_args --base 1024 -l 0 '
echo -n "unicorn_average.value " echo 'graph_vlabel Average Process Size'
ps awwwux | grep 'unicorn worker' | grep -v grep | grep -v master | awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}' echo 'graph_category Unicorn'
exit 0 echo 'unicorn_average.label Average Process Size'
fi echo 'unicorn_average.draw LINE2'
echo 'unicorn_average.info The average process size for Unicorn'
fi else
exit 0 echo -n "unicorn_average.value "
ps awwwux | grep 'unicorn worker' | grep -v grep | grep -v master | awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}'
exit 0
fi
fi
exit 0