root / plugins / apache / apache_threads @ d189784c
Historique | Voir | Annoter | Télécharger (1,37 ko)
| 1 | 4771fd2b | rfrail3 | #!/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.url http://USER:PASS@127.0.0.1/server-status?auto |
||
| 14 | env.apuser user_runnin_apache |
||
| 15 | env.binname apache_binary_name |
||
| 16 | |||
| 17 | =head1 AUTHOR |
||
| 18 | |||
| 19 | Ricardo Fraile <rfrail3@yahoo.es> |
||
| 20 | |||
| 21 | =head1 LICENSE |
||
| 22 | |||
| 23 | GPLv2 |
||
| 24 | |||
| 25 | =head1 MAGICK MARKERS |
||
| 26 | |||
| 27 | #%# family=auto |
||
| 28 | #%# capabilities=autoconf |
||
| 29 | |||
| 30 | =cut |
||
| 31 | |||
| 32 | . $MUNIN_LIBDIR/plugins/plugin.sh |
||
| 33 | |||
| 34 | |||
| 35 | if [ "$1" = "autoconf" ]; then |
||
| 36 | echo yes |
||
| 37 | exit 0 |
||
| 38 | fi |
||
| 39 | |||
| 40 | if [ "$1" = "config" ]; then |
||
| 41 | |||
| 42 | echo 'graph_title Medium number of threads for child process.' |
||
| 43 | echo 'graph_args --base 1000 -l 0 ' |
||
| 44 | echo 'graph_vlabel Threads' |
||
| 45 | echo 'graph_scale no' |
||
| 46 | echo 'graph_category apache' |
||
| 47 | echo 'graph_info Indicate the memdium number of threads for all child process.' |
||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | echo "threads.label threads" |
||
| 52 | echo "threads.type GAUGE" |
||
| 53 | echo "threads.min 0" |
||
| 54 | |||
| 55 | exit 0 |
||
| 56 | fi |
||
| 57 | |||
| 58 | SUM=0 |
||
| 59 | COUNT=0 |
||
| 60 | USR=$apuser |
||
| 61 | PROCS=$binname |
||
| 62 | |||
| 63 | |||
| 64 | # Catch proccess pid |
||
| 65 | d189784c | rfrail3 | VAL1=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | awk '{print $2}' `
|
| 66 | 4771fd2b | rfrail3 | |
| 67 | # Count pids |
||
| 68 | d189784c | rfrail3 | COUNT=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | wc -l`
|
| 69 | 4771fd2b | rfrail3 | |
| 70 | # Read threads per pid |
||
| 71 | for i in $VAL1; do |
||
| 72 | |||
| 73 | VAL2="$VAL2 `cat /proc/$i/status | grep 'Threads:' | awk '{print $2}'`"
|
||
| 74 | done |
||
| 75 | |||
| 76 | # Sun threads |
||
| 77 | for z in ${VAL2}; do
|
||
| 78 | |||
| 79 | SUM=`expr $SUM + $z` |
||
| 80 | |||
| 81 | done |
||
| 82 | |||
| 83 | |||
| 84 | echo "threads.value `echo $((SUM / $COUNT))`" |
||
| 85 | |||
| 86 | |||
| 87 | |||
| 88 |
