Created
June 28, 2017 12:42
-
-
Save pongo/56ec4ff90156cbe4f62d3c41c446276e to your computer and use it in GitHub Desktop.
Script to inspect memcache. Python3 fork of https://github.com/internetarchive/openlibrary/blob/f8092840a77c7479a352fd83fd068d340f97d3e3/scripts/2011/08/inspect-memcache.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env python | |
| """Script to inspect memcache. | |
| Usage: | |
| python scripts/2011/08/inspect-memcache.py localhost:7060 | |
| """ | |
| import sys | |
| import memcache | |
| mc = memcache.Client([sys.argv[1]]) | |
| slabs = mc.get_stats("slabs")[0][1] | |
| keys = sorted([key.split(":")[0] for key in slabs if "chunk_size" in key], key=lambda k: int(k)) | |
| for k in keys: | |
| print(k) | |
| print(" chunk_size", slabs[k + ":chunk_size"]) | |
| print(" total_chunks", slabs[k + ":total_chunks"]) | |
| dump = mc.get_stats("cachedump %s 5" % k)[0][1] | |
| for dk, dv in list(dump.items()): | |
| print(" " + dk, dv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment