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
Veres Lajos fba800ae52 typofixes - https://github.com/vlajos/misspell_fixer
Suspicious sections:
plugins/mail/postfix_mail_stats		recieved.label
plugins/nginx/nginx_vhost_traffic
2015-03-02 11:51:38 +00:00

89 lines
1.3 KiB
Bash
Executable File

#!/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
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 apache'
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
VAL1=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | awk '{print $2}' `
# Count pids
COUNT=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | wc -l`
# 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))`"