root / plugins / apache / apache_threads @ 17f78427
Historique | Voir | Annoter | Télécharger (1,32 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.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 | 17f78427 | Lars Kruse | echo yes |
| 36 | 4771fd2b | rfrail3 | 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 | 65652aa0 | dipohl | echo 'graph_category webserver' |
| 46 | 4771fd2b | rfrail3 | 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 | fba800ae | Veres Lajos | # Catch process pid |
| 64 | d189784c | rfrail3 | VAL1=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | awk '{print $2}' `
|
| 65 | 4771fd2b | rfrail3 | |
| 66 | # Count pids |
||
| 67 | d189784c | rfrail3 | COUNT=`ps auxf | grep ${PROCS} | grep ^${USR} | grep -v grep | wc -l`
|
| 68 | 4771fd2b | rfrail3 | |
| 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))`" |
