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
|
2018-08-02 02:03:42 +02:00
|
|
|
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'
|
2017-02-21 22:15:07 +01:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2014-12-05 00:37:42 +01:00
|
|
|
# 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))`"
|