Mise a jour mineures

This commit is contained in:
David 2022-12-18 22:38:54 +01:00
parent 7c06d545c2
commit 809c738acd
2 changed files with 33 additions and 13 deletions

View File

@ -16,7 +16,6 @@ statsPath = '/srv/visio.chapril.org/statistiques'
# Fonctions
def runMain():
#print('getting...')
response = requests.get(api_url,timeout=1)
current_ts = response.json()['current_timestamp']
@ -36,16 +35,6 @@ def runMain():
with open(f'/{statsPath}/jisti_meet_stats_{timestamp}.csv','w') as fh:
for (k,v) in response.json().items():
fh.write(f"{k};{v};{timestamp}\n")
#print('-------------------------------------------------------')
#print(f"conferences {conferences} {timestamp}")
#print(f"participants {participants} {timestamp}")
#print(f"bit_rate_upload {bit_rate_upload} {timestamp}")
#print(f"total_participants {total_participants} {timestamp}")
#print(f"total_visitors {total_visitors} {timestamp}")
#print(f"total_conference_seconds {total_conference_seconds} {timestamp}")
#print(f"total_conferences_created {total_conferences_created} {timestamp}")
#print(f"total_failed_conferences {total_failed_conferences} {timestamp}")
#print(f"total_loss_degraded_participant_seconds {total_loss_degraded_participant_seconds} {timestamp}")
# Principal
if __name__ == '__main__':

View File

@ -11,8 +11,9 @@ from calendar import monthrange
# Constantes
STAT_DIR = '/srv/visio.chapril.org/statistiques/'
STATS_TOT_FIELDS = ['total_participants','total_visitors','total_conferences_completed','total_conferences_created','total_partially_failed_conferences','total_failed_conferences',]
STATS_FR_TOT_FIELDS = ['participants total','visiteurs total','conferences terminees total','conferences creees total','conferences partiellement echouees','conferences totalement echouees',]
STATS_TOT_FIELDS = ['total_conferences_created','total_failed_conferences','total_conferences_completed','total_conference_seconds','total_bytes_received','total_bytes_sent','total_participants','conferences','videochannels','endpoints_sending_audio',]
STATS_FR_TOT_FIELDS = ['conferences creees total','conferences totalement echouees','conferences terminees total','duree totale conferences','total octets reçus','total octets envoyés','total participants','nombre de conferences','canaux video','clients en audio',]
STATS_AVG_FIELDS = ['largest_conference',]
STATS_FR_AVG_FIELDS = ['plus grande conference',]
@ -55,6 +56,30 @@ class Stats:
timestamp = time.mktime(time.strptime(thisDate, '%Y-%m-%d %H:%M:%S'))
return int(timestamp)
def __conv(self,octets,dataType='b'):
if dataType == 'b':
unit = 'octets'
if int(octets) > 1024:
octets = int(octets) / 1024
unit = 'ko'
if int(octets) > 1024:
octets = int(octets) / 1024
unit = 'Mo'
if int(octets) > 1024:
octets = int(octets) / 1024
unit = 'Go'
elif dataType == 't':
unit = 's'
if int(octets) > 60:
unit = 'min'
octets = octets / 60
if int(octets) > 60:
unit = 'h'
octets = octets / 60
octets = int(octets * 10) / 10
return octets,unit
def parse(self):
if len(self.files) <= 0:
return None
@ -88,6 +113,12 @@ class Stats:
for (k,v) in self.consolided_datas.items():
self.consolided[k] = v[1] - v[0]
if 'byte' in k:
octets,unit = self.__conv(self.consolided[k])
self.consolided[k] = f"{octets} {unit}"
elif 'seconds' in k:
octets,unit = self.__conv(self.consolided[k],'t')
self.consolided[k] = f"{octets} {unit}"
return self.consolided
# Fonctions