From 751e587a32ba35cea46924e959b1bd3a467d9ba8 Mon Sep 17 00:00:00 2001 From: thopic Date: Fri, 19 Nov 2021 17:09:24 +0100 Subject: [PATCH] First draft --- .env.example | 1 + .gitignore | 3 +++ html/includes/menu.php | 1 + html/stats.php | 49 ++++++++++++++++++++++++++++++++++++++++++ print_stats.py | 33 ++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 .env.example create mode 100644 html/stats.php create mode 100755 print_stats.py diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5983708 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +ES_TOKEN = "" diff --git a/.gitignore b/.gitignore index 9e8b459..16d8e91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ credentials.info html/.htpasswd html/.htaccess +.env +geckodriver.log +html/ressources/stats diff --git a/html/includes/menu.php b/html/includes/menu.php index 19fd414..458950a 100644 --- a/html/includes/menu.php +++ b/html/includes/menu.php @@ -1,6 +1,7 @@
+ + Cette page vous donne les éléments nécessaires pour pouvoir entrer en contact avec GNOUS de manière sécurisée.

+ +
+ + +

Mattermost

+

Dernières 24h

+
+

Dernière semaine

+
+

Dernier mois

+
+

Dernière année

+
+ +

Nextcloud

+

Dernières 24h

+
+

Dernière semaine

+
+

Dernier mois

+
+

Dernière année

+
+ + + + diff --git a/print_stats.py b/print_stats.py new file mode 100755 index 0000000..27d012f --- /dev/null +++ b/print_stats.py @@ -0,0 +1,33 @@ +#!/usr/bin/python3 + +import os +from time import sleep +from dotenv import load_dotenv +from seleniumwire import webdriver +from seleniumwire.webdriver import FirefoxOptions + +os.chdir(os.path.dirname(os.path.abspath(__file__))) +load_dotenv() + +opts = FirefoxOptions() +opts.add_argument("--headless") +browser = webdriver.Firefox(options=opts,executable_path="/usr/local/bin/geckodriver") +browser.set_window_size(3000, 1120) + +def interceptor(request): + request.headers['Authorization'] = 'Basic '+os.environ["ES_TOKEN"] +browser.request_interceptor = interceptor + +for duration in ["24h", "7d", "1M", "1y"]: + browser.get("https://mon.gnous.fr/app/dashboards#/view/380099d0-4944-11ec-81a9-95d7ffa23468?embed=true&_g=(filters%3A!()%2CrefreshInterval%3A(pause%3A!t%2Cvalue%3A0)%2Ctime%3A(from%3Anow-"+duration+"%2Cto%3Anow))&hide-filter-bar=true") + sleep(30) + if duration == "24h": + sleep(15) + browser.get_screenshot_as_file("html/ressources/stats/mm"+duration+".png") + +for duration in ["24h", "7d", "1M", "1y"]: + browser.get("https://mon.gnous.fr/app/dashboards#/view/ef70de60-4947-11ec-81a9-95d7ffa23468?embed=true&_g=(filters%3A!()%2CrefreshInterval%3A(pause%3A!t%2Cvalue%3A0)%2Ctime%3A(from%3Anow-"+duration+"%2Cto%3Anow))&hide-filter-bar=true") + sleep(30) + browser.get_screenshot_as_file("html/ressources/stats/nc"+duration+".png") + +print('done')