add erasure total counts

This commit is contained in:
Cayo Puigdefabregas 2022-09-19 14:04:30 +02:00
parent b118edb0a9
commit 1ec0f83d28
2 changed files with 10 additions and 6 deletions

View file

@ -42,7 +42,7 @@ class InternalStatsView:
def generate_post_csv(self, query):
data = StringIO()
cw = csv.writer(data, delimiter=';', lineterminator="\n", quotechar='"')
cw.writerow(InternalStatsRow('', "2000-1", []).keys())
cw.writerow(InternalStatsRow('', "2000-1", [], []).keys())
for row in self.get_rows(query):
cw.writerow(row)
@ -52,6 +52,7 @@ class InternalStatsView:
def get_rows(self, query):
d = {}
dd = {}
disks = []
for ac in query:
create = '{}-{}'.format(ac.created.year, ac.created.month)
user = ac.author.email
@ -66,7 +67,7 @@ class InternalStatsView:
for user, createds in d.items():
for create, actions in createds.items():
r = InternalStatsRow(user, create, actions)
r = InternalStatsRow(user, create, actions, disks)
dd[user][create] = r
return self.get_placeholders(dd)
@ -84,7 +85,7 @@ class InternalStatsView:
dd[user][create] = None
if not dd[user][create]:
dd[user][create] = InternalStatsRow(user, create, [])
dd[user][create] = InternalStatsRow(user, create, [], [])
dd[user][create]['Placeholders'] += 1

View file

@ -620,7 +620,7 @@ class ActionRow(OrderedDict):
class InternalStatsRow(OrderedDict):
def __init__(self, user, create, actions):
def __init__(self, user, create, actions, disks):
super().__init__()
# General information about all internal stats
# user, quart, month, year:
@ -628,13 +628,14 @@ class InternalStatsRow(OrderedDict):
# Snapshots (Update)
# Snapshots (All)
# Drives Erasure
# Drives Erasure Uniques
# Placeholders
# Allocate
# Deallocate
# Live
self.actions = actions
year, month = create.split('-')
self.disks = []
self.disks = disks
self['User'] = user
self['Year'] = year
@ -644,6 +645,7 @@ class InternalStatsRow(OrderedDict):
self['Snapshot (Update)'] = 0
self['Snapshot (All)'] = 0
self['Drives Erasure'] = 0
self['Drives Erasure Uniques'] = 0
self['Placeholders'] = 0
self['Allocates'] = 0
self['Deallocates'] = 0
@ -664,9 +666,10 @@ class InternalStatsRow(OrderedDict):
def is_erase(self, ac):
if ac.type in ['EraseBasic', 'EraseSectors']:
self['Drives Erasure'] += 1
if ac.device in self.disks:
return ac
self['Drives Erasure'] += 1
self['Drives Erasure Uniques'] += 1
self.disks.append(ac.device)
return ac