Supervisor/superlance — pull request #44 by lukasgraf (2014-08-02 20:52:50+00:00)
Title: Memmon: Add support for checking against cumulative RSS

This change fixes the issue brought up in https://github.com/Supervisor/superlance/issues/21 and addresses the points made by @mnaberez in pull request https://github.com/Supervisor/superlance/pull/22:

- Works with plain `ps` instead of `pstree`
- Unit tests included
- Argument parser / usage, docs and changelog have been updated

The implementation works by using `ps` to list PID, PPID (Parent PID) and RSS, then recursively gathering all child processes of the one being monitored, and summing up all their RSS values.

When implementing this, I took care not to modify the default behavior at all, and touched the existing code as little as possible (basically just factored out RSS calculation into a separate [`calc_rss(pid)`](https://github.com/lukasgraf/superlance/blob/199b69f5d2a0f1e257c2b2a2263ca28d5b54614c/superlance/memmon.py#L224) method and then extended it with the behavior required for calculating cumulative RSS).

I tested the specific `ps` options I'm using (`ps ax -o "pid= ppid= rss="`) on Linux (CentOS and SuSE) and OS X 10.9.4.