Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
rough memory situation snapshotting function
from os import popen
import logging
from uuid import uuid4
try:
from magical_place import some_map_like_backing_store # Redis, memcached, database, whatever
except ImportError:
some_map_like_backing_store = {}
logging.basicConfig(level=logging.DEBUG)
def make_memory_report():
return "\n****\n".join([
popen('ps auxww').read(),
open('/proc/meminfo').read()
])
def store_memory_report(label="unknown"):
key = 'memory_report_' + uuid4().hex
some_map_like_backing_store[key] = key, make_memory_report()
logging.debug('memory report: label=%s, key=%s', label, key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.