root / plugins / apache / apache_memory @ 09b88141
Historique | Voir | Annoter | Télécharger (1,24 ko)
| 1 | 4771fd2b | rfrail3 | #!/bin/sh |
|---|---|---|---|
| 2 | # -*- sh -*- |
||
| 3 | |||
| 4 | : << =cut |
||
| 5 | |||
| 6 | =head1 NAME |
||
| 7 | |||
| 8 | f6738f41 | Lars Kruse | apache_memory - Indicate the medium size of all the apache child process |
| 9 | 4771fd2b | rfrail3 | |
| 10 | =head1 CONFIGURATION |
||
| 11 | |||
| 12 | 09b88141 | Lars Kruse | [apache_*] |
| 13 | env.apuser user_running_apache (default: "www-data") |
||
| 14 | env.binname apache_binary_name (default: "apache2") |
||
| 15 | 4771fd2b | rfrail3 | |
| 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 | 1ac5fbdf | Lars Kruse | . "$MUNIN_LIBDIR/plugins/plugin.sh" |
| 33 | 4771fd2b | rfrail3 | |
| 34 | edb4e1e8 | Lars Kruse | USR=${apuser:-www-data}
|
| 35 | PROCS=${binname:-apache2}
|
||
| 36 | 4771fd2b | rfrail3 | |
| 37 | |||
| 38 | if [ "$1" = "autoconf" ]; then |
||
| 39 | b087127c | Lars Kruse | echo yes |
| 40 | exit 0 |
||
| 41 | 4771fd2b | rfrail3 | fi |
| 42 | |||
| 43 | if [ "$1" = "config" ]; then |
||
| 44 | |||
| 45 | d8fd604e | Lars Kruse | echo 'graph_title Average size of apache child processes' |
| 46 | e7fbfe0b | Lars Kruse | echo 'graph_args --base 1024 -l 0 ' |
| 47 | echo 'graph_vlabel Bytes' |
||
| 48 | b087127c | Lars Kruse | echo 'graph_scale no' |
| 49 | echo 'graph_category webserver' |
||
| 50 | echo 'graph_info Indicate the memdium size of all the apache child process.' |
||
| 51 | 4771fd2b | rfrail3 | |
| 52 | b087127c | Lars Kruse | echo "servers.label servers" |
| 53 | echo "servers.type GAUGE" |
||
| 54 | echo "servers.min 0" |
||
| 55 | 4771fd2b | rfrail3 | |
| 56 | b087127c | Lars Kruse | exit 0 |
| 57 | 4771fd2b | rfrail3 | fi |
| 58 | |||
| 59 | dd41152c | Lars Kruse | matched_processes=$(ps auxf | grep -- "$PROCS" | grep "^$USR" | grep -v grep) |
| 60 | if [ -n "$matched_processes" ]; then |
||
| 61 | e7fbfe0b | Lars Kruse | average_memory=$(printf '%s' "$matched_processes" | awk '{count+=1; sum+=$6} END {print sum / count * 1024}')
|
| 62 | dd41152c | Lars Kruse | else |
| 63 | average_memory="U" |
||
| 64 | fi |
||
| 65 | 4771fd2b | rfrail3 | |
| 66 | dd41152c | Lars Kruse | echo "servers.value $average_memory" |
