mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Plugin to monitor uWSGI Average Memory Usage, Number of Process & Total Memory Used
This commit is contained in:
parent
dc75b52a7d
commit
2dc145e2af
1 changed files with 70 additions and 0 deletions
70
plugins/uwsgi/uwsgi_
Normal file
70
plugins/uwsgi/uwsgi_
Normal file
|
@ -0,0 +1,70 @@
|
|||
#!/bin/bash
|
||||
# Copyright (c) 2013 Gareth Davies (shaolintiger@gmail.com www.shaolintiger.com)
|
||||
# License GPLv2
|
||||
# This plugin monitors number of workers, total memory used and average memory per process for uWSGI.
|
||||
# Here are the symlinks to enable it
|
||||
#
|
||||
# ln -s /usr/share/munin/plugins/uwsgi_ /etc/munin/plugins/uwsgi_average
|
||||
# ln -s /usr/share/munin/plugins/uwsgi_ /etc/munin/plugins/uwsgi_memory
|
||||
# ln -s /usr/share/munin/plugins/uwsgi_ /etc/munin/plugins/uwsgi_processes
|
||||
|
||||
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 uWSGI Memory"
|
||||
echo "graph_vlabel Total RAM"
|
||||
echo "graph_category uWSGI"
|
||||
echo "graph_args --base 1024"
|
||||
echo "ram.label Total RAM"
|
||||
exit 0
|
||||
else
|
||||
|
||||
memory_array=(`ps auwx | grep "uwsgi_python" | grep -v grep | awk '{print $6 }'`)
|
||||
|
||||
for i in "${memory_array[@]}"
|
||||
do
|
||||
sum=$(( $sum + ( $i * 1024) ))
|
||||
done
|
||||
echo -n "ram.value "
|
||||
echo $sum
|
||||
|
||||
fi
|
||||
|
||||
elif [ "$mode" = "processes" ]; then
|
||||
if [ "$1" = "config" ]; then
|
||||
echo "graph_title uWSGI Processes"
|
||||
echo "graph_vlabel Processes"
|
||||
echo "graph_category uWSGI"
|
||||
echo "processes.label active processes"
|
||||
else
|
||||
echo -n "processes.value "
|
||||
ps awwwux | grep 'uwsgi_python' | grep -v grep | wc -l
|
||||
exit 0
|
||||
fi
|
||||
|
||||
elif [ "$mode" = "average" ]; then
|
||||
if [ "$1" = "config" ]; then
|
||||
echo 'graph_title uWSGI Average Process Size'
|
||||
echo 'graph_args --base 1024 -l 0 '
|
||||
echo 'graph_vlabel Average Process Size'
|
||||
echo 'graph_category uWSGI'
|
||||
echo 'uwsgi_average.label Average Process Size'
|
||||
echo 'uwsgi_average.draw LINE2'
|
||||
echo 'uwsgi_average.info The average process size for uWSGI'
|
||||
else
|
||||
echo -n "uwsgi_average.value "
|
||||
ps awwwux | grep 'uwsgi_python' | grep -v grep | awk '{total_mem = $6 * 1024 + total_mem; total_proc++} END{printf("%d\n", total_mem / total_proc)}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
fi
|
||||
exit 0
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue