mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
8ff6e0fdf2
- Fixed memory and average giving same results - Fixed error in average graphing
65 lines
2.0 KiB
Bash
65 lines
2.0 KiB
Bash
#!/bin/bash
|
|
# Copyright (c) 2013 Gareth Davies (shaolintiger@gmail.com www.shaolintiger.com)
|
|
# License GPLv2
|
|
|
|
mode=`echo $0 | cut -d _ -f 2`
|
|
|
|
if [ "$1" = "suggest" ]; then
|
|
echo "memory"
|
|
echo "processes"
|
|
echo "average"
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$mode" = "memory" ]; then
|
|
if [ "$1" = "config" ]; then
|
|
echo "graph_title Total Unicorn Memory"
|
|
echo "graph_vlabel Total RAM"
|
|
echo "graph_category Unicorn"
|
|
echo "graph_args --base 1024"
|
|
echo "ram.label Total RAM"
|
|
exit 0
|
|
else
|
|
|
|
memory_array=(`ps auwx | grep "unicorn worker" | grep -v grep | awk '{print $6 }'`)
|
|
|
|
for i in "${memory_array[@]}"
|
|
do
|
|
sum=$(( $sum + $i ))
|
|
done
|
|
echo -n "ram.value "
|
|
echo $sum
|
|
|
|
fi
|
|
|
|
elif [ "$mode" = "processes" ]; then
|
|
if [ "$1" = "config" ]; then
|
|
echo "graph_title Unicorn Processes"
|
|
echo "graph_vlabel Processes"
|
|
echo "graph_category Unicorn"
|
|
echo "processes.label active processes"
|
|
else
|
|
echo -n "processes.value "
|
|
ps awwwux | grep 'unicorn worker' | grep -v grep | wc -l
|
|
exit 0
|
|
fi
|
|
|
|
elif [ "$mode" = "average" ]; then
|
|
if [ "$1" = "config" ]; then
|
|
echo 'graph_title Unicorn Average Process Size'
|
|
echo 'graph_args --base 1024 -l 0 '
|
|
echo 'graph_vlabel Unicorn Average Process Size'
|
|
echo 'graph_category Unicorn'
|
|
echo 'unicorn_average.label Unicorn Average Proccess Size'
|
|
echo 'unicorn_average.draw LINE2'
|
|
echo 'unicorn_average.info The average process size for Unicorn'
|
|
else
|
|
echo -n "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
|
|
|