Monitoring memory use
Lloyd Kvam
python at venix.com
Fri Sep 21 11:07:11 EDT 2007
On Fri, 2007-09-21 at 09:44 -0400, Kent Johnson wrote:
> Alex Hewitt wrote:
> > On Fri, 2007-09-21 at 08:27 -0400, Kent Johnson wrote:
> >> Is there some way I can
> >> wrap the cron job to log the memory used by the process?
> >
> > One simple way 'ps aux | grep myjob'
> >
> > If you loop on this and redirect the output to a file you can watch your
> > program grow. There is also a memstat utility that may or may not be
> > available on the system you are using.
>
> I was hoping for a utility that would wrap the process in some way and
> report the high-water memory use of the process. Oh well...
>
> I guess I can write this myself as a Python program that runs the
> desired program as a child process and monitors its memory usage by
> reading /proc/<pid>/stats. There is also the Python library function
> resource.getrusage() but it doesn't seem to help - the ru_maxrss
> parameter is always 0.
The file status (/proc/####/status) provides labels for the data and
would be easy to parse into a dictionary.
If you are tightly focused on memory, statm may be a better file to use
than stats. The second field is the RSS pages value.
You didn't specify which cron job caused the problem, but if it was
from /etc/cron.daily, the different pieces get kicked off in series. If
you do not already know the culprit, that can complicate things a bit.
Independently scanning /proc every minute may be a useful alternative.
>
> Thanks,
> Kent
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
--
Lloyd Kvam
Venix Corp
More information about the gnhlug-discuss
mailing list