54 lines
2.1 KiB
Python
Executable File
54 lines
2.1 KiB
Python
Executable File
#! /usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Imports
|
|
import os
|
|
import sys
|
|
import requests
|
|
import time
|
|
import datetime
|
|
|
|
# Constantes
|
|
api_url = 'http://localhost:8080/colibri/stats'
|
|
statsPath = '/srv/visio.chapril.org/statistiques'
|
|
|
|
# Classes
|
|
|
|
# Fonctions
|
|
def runMain():
|
|
#print('getting...')
|
|
response = requests.get(api_url,timeout=1)
|
|
|
|
current_ts = response.json()['current_timestamp']
|
|
total_participants = response.json()['total_participants']
|
|
bit_rate_download = response.json()['bit_rate_download']
|
|
total_loss_degraded_participant_seconds = response.json()['total_loss_degraded_participant_seconds']
|
|
conferences = response.json()['conferences']
|
|
participants = response.json()['participants']
|
|
bit_rate_upload = response.json()['bit_rate_upload']
|
|
total_visitors = response.json()['total_visitors']
|
|
total_conference_seconds = response.json()['total_conference_seconds']
|
|
total_conferences_created = response.json()['total_conferences_created']
|
|
total_failed_conferences = response.json()['total_failed_conferences']
|
|
element = datetime.datetime.strptime(response.json()['current_timestamp'],'%Y-%m-%d %H:%M:%S.%f')
|
|
tpl = element.timetuple()
|
|
timestamp = int(time.mktime(tpl))
|
|
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__':
|
|
runMain()
|
|
sys.exit(0)
|