Projet

Général

Profil

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

root / plugins / apache / apache_memory @ 09b88141

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

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

    
4
: << =cut
5

    
6
=head1 NAME
7

    
8
apache_memory - Indicate the medium size of all the apache child process
9

    
10
=head1 CONFIGURATION
11

    
12
 [apache_*]
13
 env.apuser user_running_apache (default: "www-data")
14
 env.binname apache_binary_name (default: "apache2")
15

    
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
USR=${apuser:-www-data}
35
PROCS=${binname:-apache2}
36

    
37

    
38
if [ "$1" = "autoconf" ]; then
39
    echo yes
40
    exit 0
41
fi
42

    
43
if [ "$1" = "config" ]; then
44

    
45
    echo 'graph_title Average size of apache child processes'
46
    echo 'graph_args --base 1024 -l 0 '
47
    echo 'graph_vlabel Bytes'
48
    echo 'graph_scale no'
49
    echo 'graph_category webserver'
50
    echo 'graph_info Indicate the memdium size of all the apache child process.'
51

    
52
    echo "servers.label servers"
53
    echo "servers.type GAUGE"
54
    echo "servers.min 0"
55

    
56
    exit 0
57
fi
58

    
59
matched_processes=$(ps auxf | grep -- "$PROCS" | grep "^$USR" | grep -v grep)
60
if [ -n "$matched_processes" ]; then
61
    average_memory=$(printf '%s' "$matched_processes" | awk '{count+=1; sum+=$6} END {print sum / count * 1024}')
62
else
63
    average_memory="U"
64
fi
65

    
66
echo "servers.value $average_memory"