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

View File

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