Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / apache / apache_threads @ 17f78427

Historique | Voir | Annoter | Télécharger (1,32 ko)

1
#!/bin/sh
2
# -*- sh -*-
3

    
4
: << =cut
5

    
6
=head1 NAME
7

    
8
apache_threads -Indicate the memdium number of threads for all child process
9

    
10
=head1 CONFIGURATION
11

    
12
[apache_*]
13
env.apuser user_runnin_apache
14
env.binname apache_binary_name
15

    
16
=head1 AUTHOR
17

    
18
Ricardo Fraile <rfrail3@yahoo.es>
19

    
20
=head1 LICENSE
21

    
22
GPLv2
23

    
24
=head1 MAGICK MARKERS
25

    
26
 #%# family=auto
27
 #%# capabilities=autoconf
28

    
29
=cut
30

    
31
. $MUNIN_LIBDIR/plugins/plugin.sh
32

    
33

    
34
if [ "$1" = "autoconf" ]; then
35
	echo yes
36
	exit 0
37
fi
38

    
39
if [ "$1" = "config" ]; then
40

    
41
	echo 'graph_title Medium number of threads for child process.'
42
	echo 'graph_args --base 1000 -l 0 '
43
	echo 'graph_vlabel Threads'
44
	echo 'graph_scale no'
45
	echo 'graph_category webserver'
46
	echo 'graph_info Indicate the memdium number of threads for all child process.'
47

    
48

    
49

    
50
        echo "threads.label threads"
51
        echo "threads.type GAUGE"
52
        echo "threads.min 0"
53

    
54
	exit 0
55
fi
56

    
57
SUM=0
58
COUNT=0
59
USR=$apuser
60
PROCS=$binname
61

    
62

    
63
# Catch process pid
64
VAL1=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | awk '{print $2}' `
65

    
66
# Count pids
67
COUNT=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | wc -l`
68

    
69
# Read threads per pid
70
for i in $VAL1; do
71

    
72
        VAL2="$VAL2 `cat /proc/$i/status | grep 'Threads:' | awk '{print $2}'`"
73
done
74

    
75
# Sun threads
76
for z in ${VAL2}; do
77

    
78
        SUM=`expr $SUM + $z`
79

    
80
done
81

    
82

    
83
echo "threads.value `echo $((SUM /  $COUNT))`"