memmon is a supervisor event listener which will restart supervisord child processes which are consuming "too much" memory. It will optionally notify a user via email that a restart occurred.
memmon is a supervisor "event
listener" which may be subscribed to a concrete
TICK_x event. When
memmon receives a TICK_x event
(TICK_60 is recommended, indicating activity every
60 seconds), memmon checks that a configurable list of programs
(or all programs running under supervisor) are not exceeding a
configurable about of memory (resident segment size, or RSS).
If one or more of these processes is consuming more than the
amount of memory that memmon believes
it should, memmon will restart the
process. memmon can be configured to
send an email notification when it restarts a process.
memmon is known to work on Linux and Mac OS X, but has not been tested on other operating systems (it relies on ps output and command-line switches).
memmon is incapable of monitoring the process status of processes which are not supervisord child processes.
memmon is a "console script" installed when you install supervisor. Although memmon is an executable program, it isn't useful as a general-purpose script: it must be run as a supervisor event listener to do anything useful. memmon accepts the following options:
Table 1.35. memmon Command-Line Options
| Option | Argument(s) | Description |
|---|---|---|
-h --help |
N/A | Show program help. |
-p --program |
name/size pair |
A name/size pair, e.g. "foo=1MB". The name represents
the supervisor program name that you'd like memmon to
monitor, the size represents the number of bytes
(suffix-multiplied using "KB", "MB" or "GB") that should
be considered "too much". Multiple -p
options can be provided to memmon to signify that you'd
like to monitor more than one program. Programs can be
specified as a "namespec", to disambiguate same-named
programs in different groups, e.g. "foo:bar" represents
the program "bar" in the "foo" group.
|
-g --groupname |
name/size pair |
A groupname/size pair, e.g. "group=1MB". The name
represents the supervisor group name that you'd like
memmon to monitor, the size represents the number of
bytes (suffix-multiplied using "KB", "MB" or "GB") that
should be considered "too much". Multiple
-g options can be provided to memmon to
signify that you'd like to monitor more than one group.
If any process in this group exceeds the maxmum, it will
be restarted.
|
-a --any |
size | A size (suffix-multiplied using "KB", "MB" or "GB") that should be considered "too much". If any program running as a child of supervisor exceeds this maximum, it will be restarted. E.g. 100MB. |
-s --sendmail_program |
command |
A command that will send mail if passed the email body
(including the headers). Defaults to
/usr/sbin/sendmail -t -i. Specifying this
doesn't cause memmon to send
mail by itself (see the -m/--email option).
|
-m --email |
email address | An email address to which to send email when a process is restarted. By default, memmon will not send any mail unless an email address is specified. |
An [eventlistener:x] section must be placed in
supervisord.conf in order for
memmon to begin working. See the
"Events" chapter elsewhere in this document for more information
about event listeners. The following examples assume that the
memmon is on your system PATH.
Example 1.11. memmon Example Configuration 1
This configuration causes memmon to
restart any process which is a child of
supervisord consuming more than
200MB of RSS, and will send mail to
bob@example.com when it restarts a process using
the default sendmail command.
[eventlistener:memmon]
command=memmon -a 200MB -m bob@example.com
events=TICK_60
Example 1.12. memmon Example Configuration 2
This configuration causes memmon to
restart any process with the supervisor program name "foo"
consuming more than 200MB of RSS, and will send mail to
bob@example.com when it restarts a process using
the default sendmail command.
[eventlistener:memmon]
command=memmon -p foo=200MB -m bob@example.com
events=TICK_60
Example 1.13. memmon Example Configuration 3
This configuration causes memmon to
restart any process in the process group "bar" consuming more
than 200MB of RSS, and will send mail to
bob@example.com when it restarts a process using
the default sendmail command.
[eventlistener:memmon]
command=memmon -g bar=200MB -m bob@example.com
events=TICK_60
