2
0
mirror of https://github.com/munin-monitoring/contrib.git synced 2018-11-08 00:59:34 +01:00
contrib-munin/plugins/unicorn/unicorn_
Gareth Davies 2812f751f0 Added new non Ruby based Unicorn Plugin
The existing Unicorn plugins are written in Ruby, which didn't work well for me due to ENV variables etc.

This plugin monitors number of workers, total memory used and average memory per process for Unicorn.

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_processes

It can easily be adapated to any multi threaded server by just changing the value it searches for 'unicorn worker' in this case.
2013-05-16 18:07:01 +08:00

57 lines
1.9 KiB
Plaintext

#!/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 Unicorn Memory"
echo "graph_vlabel RAM"
echo "graph_category Unicorn"
echo "graph_args --base 1024"
echo "ram.label RAM"
exit 0
else
echo -n "ram.value "
ps awwwux | grep 'unicorn worker' | grep -v grep | awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}'
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" = "average" ]; 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 'php_average.label Unicorn Average Proccess Size'
echo 'php_average.draw LINE2'
echo 'php_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