Page MenuHomePhabricator
Paste P8205

ats_cache_scan.py
ActivePublic

Authored by ema on Mar 15 2019, 10:33 AM.
Tags
None
Referenced Files
F28392982: raw.txt
Mar 15 2019, 2:38 PM
F28392422: raw.txt
Mar 15 2019, 10:33 AM
Subscribers
None
#!/usr/bin/python3 -OO
import os
import sys
import psutil
from scan import span
def all_urls(span_path="/dev/sda3"):
s = span.Span(span_path)
for counter, obj in enumerate(s.storedObjects()):
#print("=>", obj)
if counter % 1000 == 0:
print(counter)
print("Finished, total =", counter)
def first_docs(span_path="/dev/sda3", first=1000):
max_length = 0
s = span.Span(span_path)
for counter, block in enumerate(s.blocks):
block.readDir()
for docnum, doc in enumerate(block.firstDocs):
# doc.totalLength is Content-Length
# doc.data is the actual content
# str(doc.urls()[0]) is the remapped URL
# doc.alternates[0].requestHeaders (as bytearray)
# doc.alternates[0].responseHeaders
if doc.totalLength > max_length:
max_length = doc.totalLength
if docnum == first:
break
print("Max length out of {} objects: {} bytes".format(docnum, max_length))
if __name__ == "__main__":
# Lowest possible I/O priority to avoid interfering with actual ATS read/writes
p = psutil.Process(os.getpid())
p.ionice(psutil.IOPRIO_CLASS_IDLE)
print("DEBUG ->", __debug__)
first_docs("/dev/sdb3", first=10000000)