Created
December 7, 2015 01:10
-
-
Save crackwitz/f3dd427da82b28083101 to your computer and use it in GitHub Desktop.
grab info out of Tivoli Storage Manager using the client console (dsmc)
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
import os | |
import sys | |
import re | |
import subprocess | |
import pprint; pp = pprint.pprint | |
dsmdir = "p:\\tivoli\\tsm\\baclient" | |
assert os.getenv("PASS") is not None | |
filerex = re.compile(r"([0-9,']+) B .* (\\.*) Never") | |
def filesizes(output): | |
return [ | |
( | |
int(matches[0].translate(None, "',.")), | |
matches[1] | |
) | |
for matches in filerex.findall(output) | |
] | |
def dsmc(*query): | |
try: | |
res = subprocess.check_output( | |
" ".join(["dsmc"] + list(query) + ["-password=%PASS%"]), | |
cwd=dsmdir, | |
shell=True) | |
except subprocess.CalledProcessError, e: | |
print e | |
return None | |
return res | |
def query_archive(*args): | |
output = dsmc("q ar -querysummary -subdir=yes", *args) | |
if output is None: | |
return 0 | |
else: | |
sizes = filesizes(output) | |
return sum(u for u,v in sizes) | |
filespaces = re.findall(r'\s+(\\.*?)\s*$', dsmc("q fi"), re.M) | |
pp(filespaces) | |
if 1: | |
sizes = {} | |
for space in filespaces: | |
size = query_archive(space + "\\", '-des="Video AG*"') | |
print "{0:20,d} {1}".format(size, space) | |
sizes[space] = size | |
total = sum(sizes.values()) | |
print "{0:20,d}\n{0:20d}".format(total) | |
# >>> query_archive("\\\\video2\\v$\\", '-des="*150616*"'); print "{0:,d}".format(_) | |
# >>> query_archive("\\\\video2\\v$\\"); print "{0:,d}".format(_) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment