1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Use UNIX line breaks

-  Using DOS line breaks introduced syntax errors
This commit is contained in:
Stig Sandbeck Mathisen 2014-10-04 18:58:23 +02:00
parent 098e1dde1c
commit ac2e2fda07

View file

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