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

84 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2012-09-18 19:15:56 +02:00
#!/bin/sh
# -*- sh -*-
: << =cut
=head1 NAME
apache_threads -Indicate the memdium number of threads for all child process
=head1 CONFIGURATION
[apache_*]
env.apuser user_runnin_apache
env.binname apache_binary_name
=head1 AUTHOR
Ricardo Fraile <rfrail3@yahoo.es>
=head1 LICENSE
GPLv2
=head1 MAGICK MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
. $MUNIN_LIBDIR/plugins/plugin.sh
if [ "$1" = "autoconf" ]; then
echo yes
2012-09-18 19:15:56 +02:00
exit 0
fi
if [ "$1" = "config" ]; then
echo 'graph_title Medium number of threads for child process.'
echo 'graph_args --base 1000 -l 0 '
echo 'graph_vlabel Threads'
echo 'graph_scale no'
echo 'graph_category webserver'
2012-09-18 19:15:56 +02:00
echo 'graph_info Indicate the memdium number of threads for all child process.'
echo "threads.label threads"
echo "threads.type GAUGE"
echo "threads.min 0"
exit 0
fi
SUM=0
COUNT=0
USR=$apuser
PROCS=$binname
# Catch process pid
2012-09-19 08:49:07 +02:00
VAL1=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | awk '{print $2}' `
2012-09-18 19:15:56 +02:00
# Count pids
2012-09-19 08:49:07 +02:00
COUNT=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | wc -l`
2012-09-18 19:15:56 +02:00
# Read threads per pid
for i in $VAL1; do
VAL2="$VAL2 `cat /proc/$i/status | grep 'Threads:' | awk '{print $2}'`"
done
# Sun threads
for z in ${VAL2}; do
SUM=`expr $SUM + $z`
done
echo "threads.value `echo $((SUM / $COUNT))`"