root/trunk/plugins/node.d/multips_memory.in

Revision 3335, 3.5 kB (checked in by feiner.tom, 1 month ago)

multips_memory plugin: Correct documentation to reflect the name multips_memory instead of the previous multimemory. Fix some typos

Line 
1 #!@@GOODSH@@
2 # -*- sh -*-
3
4 : <<=cut
5
6 =head1 NAME
7
8 multips_memory - Munin plugin to monitor memory usage of processes. Which
9 processes are configured in a file in plugin-conf.d.
10
11 =head1 APPLICABLE SYSTEMS
12
13 Any system with a compatible SysV style ps command that understands
14
15   ps -eo rss,comm
16
17 =head1 CONFIGURATION
18
19 You must specify what process names to monitor:
20
21   [multips_memory]
22      env.names apache2 mysqld php-cgi
23
24 The names are are matched with awk.  Any regular expression meta
25 characters in each of the words on the names list are "active" in the
26 regular expression.
27
28
29 The by default RSS is monitored, but other sizes provided by your ps
30 is directly usable (the plugin assumes all sizes reported by ps is in
31 KB).  Candidates on Linux are rss, size, resident, share, vsize.  See
32 your ps man page for more information especially with regards to
33 interpretation of the values.  You can change what is monitored by
34
35   [multips_memory]
36       env.monitor vsize
37
38 You cannot specify multiple sizes. The plugin handles only one.
39
40 If for some reason you want separate graphs, you can make separately
41 named symlinks in the plugins directory on the node (most often either
42 /etc/munin/plugins or /etc/opt/munin/plugins), eg. multips_memory_rss and
43 multips_memory_vsize as symlinks to multips_memory and configure them thus:
44
45   [multips_memory*]
46       env.names apache2 mysqld php-cgi
47
48   [multips_memory_rss]
49       env.monitor rss
50
51   [multips_memory_vsize]
52       env.monitor vsize
53
54 They can of course also have different process names as well.  Eg. one
55 list for the "LAMP" stack and one for the Java/Oracle stack in
56 separate graphs.
57
58
59 =head1 INTERPRETATION
60
61 This plugin adds up the RSS (or other memory size if configured) of
62 all processes matching the process name, as reported by ps.
63
64 =head1 MAGIC MARKERS
65
66   #%# family=manual
67   #%# capabilities=autoconf
68
69 =head1 VERSION
70
71   0.1 first release, based on multips as distributed in Debian.
72
73   $Id $
74
75 =head1 BUGS AND RESTRICTIONS
76
77 Only the executable name is matched against (ps -eo comm)1, and it must
78 be a full string match to the executable base name, not substring,
79 unless you enter a name such as ".*apache" since RE meta characters in
80 the names are active.
81
82 You cannot specify multiple sizes. The plugin handles only one.
83
84 =head1 AUTHOR
85
86 Originally: Unknown.
87
88 Made into multimemory by: github.com/dominics github.com/yhager.
89
90 Renamed to multips_memory when included in official munin trunk.
91
92 Thanks to: wix
93
94 Some further work to make more generic by Nicolai Langfeldt
95
96 =head1 LICENSE
97
98 GPLv2
99
100 =cut
101
102 . $MUNIN_LIBDIR/plugins/plugin.sh
103
104 if [ "$1" = "autoconf" ]; then
105     if [ -z "$names" ]; then
106         echo "no (Configuration required)"
107         exit 0
108     fi
109
110     echo yes
111     exit 0
112 fi
113
114 if [ -z "$names" ]; then
115     echo "(Configuration required)"
116     exit 1
117 fi
118
119 monitor=${monitor:-rss}
120
121 if [ "$1" = "config" ]; then
122         echo graph_title Process $monitor summed by name
123         echo 'graph_category processes'
124         echo 'graph_args --base 1024 -l 0'
125         echo 'graph_vlabel memory'
126         echo "graph_info This plugin shows $monitor memory usage for commands matching the respective regular expressions"
127         for name in $names; do
128                 fieldname="$(clean_fieldname "$name")"
129                 eval REGEX='^$name$';
130
131                 echo "$fieldname.label $name"
132                 echo "$fieldname.info For /$REGEX/"
133         done
134         exit 0
135 fi
136
137 for name in $names; do
138         fieldname="$(clean_fieldname "$name")"
139
140         ps -eo $monitor,comm | gawk '
141 BEGIN              { total = "U"; } # U = Unknown.
142 /grep/             { next; }
143 $2 ~ /^'"$name"'$/ { total = total + ($1*1024); }
144 END                { print "'"$fieldname"'.value", total; }'
145 done
Note: See TracBrowser for help on using the browser.