In [1]:
from qumulo.rest_client import RestClient
In [3]:
# change these to your Qumulo API cluster and credentials
rc = RestClient('<qumulo-cluster>', 8000)
rc.login('<login>', '<password>');
In [20]:
activity_data = rc.analytics.current_activity_get()
In [21]:
list(set([d['type'] for d in activity_data['entries']]))
Out[21]:
In [22]:
types_data = {}
for d in activity_data['entries']:
if d['type'] not in types_data:
types_data[d['type']] = 0
types_data[d['type']] += d['rate']
for t, val in types_data.iteritems():
print("%22s - %.1f" % (t, val))
In [23]:
ip_data = {}
for d in activity_data['entries']:
if 'throughput' in d['type']:
if d['ip'] not in ip_data:
ip_data[d['ip']] = 0
ip_data[d['ip']] += d['rate']
for ip, val in sorted(ip_data.items(), key=lambda x: x[1], reverse=True):
print("%22s - %.1f" % (ip, val))
In [24]:
batch_size = 1000
ids_to_paths = {}
ids = list(set([d['id'] for d in activity_data['entries']]))
for offset in range(0, len(ids), batch_size):
resolve_data = rc.fs.resolve_paths(ids[offset:offset+batch_size])
for id_path in resolve_data:
ids_to_paths[id_path['id']] = id_path['path']
print("Resolved %s ids to paths." % len(ids_to_paths))
In [25]:
batch_size = 100
ips_to_names = {}
ips = list(set([d['ip'] for d in activity_data['entries']]))
for offset in range(0, len(ips), batch_size):
resolve_data = rc.dns.resolve_ips_to_names(ips[offset:offset+batch_size])
for d in resolve_data:
ips_to_names[d['ip_address']] = d['hostname']
print("Resolved %s ips to hosts." % len(ips_to_names))
In [26]:
directory_levels = 1
path_data = {}
for d in activity_data['entries']:
path = ids_to_paths[d['id']]
if path == '':
path = '/'
path = '/'.join(path.split('/')[0:directory_levels+1])
if 'throughput' in d['type']:
if path not in path_data:
path_data[path] = 0
path_data[path] += d['rate']
for path, val in sorted(path_data.items(), key=lambda x: x[1], reverse=True):
print("%32s - %.1f" % (path, val))
In [27]:
ip_data = {}
for d in activity_data['entries']:
if 'throughput' in d['type']:
if d['ip'] not in path_data:
ip_data[d['ip']] = 0
ip_data[d['ip']] += d['rate']
for ip, val in sorted(ip_data.items(), key=lambda x: x[1], reverse=True):
print("%20s (%s) - %.1f" % (ips_to_names[ip], ip, val))