Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 63 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. #!/usr/bin/env python3
  2.  
  3. # Requires root permissions
  4. import os
  5. import glob
  6. from pprint import pprint
  7.  
  8. stats = {}
  9. os.chdir('/sys/kernel/debug/zswap')
  10. for filename in  os.listdir():
  11.     with open(filename) as f:
  12.         stats[filename] = int(f.read())
  13.  
  14. max_text_lenght = max( { len(x) for x in stats.keys() } )
  15. template = "{0:" + str(max_text_lenght) + "}:{1:<20g}"
  16.  
  17. stats['pool_total_size (MB)'] = stats['pool_total_size'] / (1024*1024)
  18. stats['stored size (MB)'] = stats['stored_pages'] * 4096 / (1024*1024)
  19. stats['compression ratio'] = stats['stored_pages'] * 4096 / stats['pool_total_size']
  20.  
  21. for k, v in stats.items():
  22.     print(template.format(k,v))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top