stats/README.md

335 lines
9.4 KiB
Markdown

# Service stats.chalec.org
Service de statistiques/métriques du candidat chaton de Libre en communs basé sur le logiciel libre StatoolInfos : https://forge.devinsy.fr/devinsy/statoolinfos.
Responsable : Christian Momon (@cpm)
Anciens responsables : n/a.
# Installation basique du site web
Actuellement, le site web est statique et généré par la moulinette `statoolinfos` toutes les heures.
Installer les paquets :
```
apt-get install nginx python3-certbot-nginx
```
Ouvrir les ports http (80) et https (443) :
```
ufw allow 'Nginx HTTP'
ufw allow 'Nginx HTTPS'
```
Configurer a minima le site web dans `/etc/nginx/sites-available/stats.chalec.org` :
```
server
{
listen 80;
listen [::]:80;
server_name stats.chalec.org;
access_log /var/log/nginx/stats.chalec.org-access.log;
error_log /var/log/nginx/stats.chalec.org-error.log;
}
```
Activer la configuration :
```
cd /etc/nginx/sites-enabled/
ln -s ../sites-available/stats.chalec.org
```
Vérifier que c'est bon et recharger :
```
nginx -t && systemctl reload nginx
```
Configurer le certificat SSl :
```
certbot --nginx
```
Créer un fichier générique `cat /etc/nginx/statoolinfos.conf` qui sera includé plus tard :
```
location /.well-known/statoolinfos/
{
types
{
text/plain properties;
}
alias /srv/statoolinfos/well-known/statoolinfos/;
autoindex on;
}
```
Mettre beau le fichier `/etc/nginx/sites-enabled/stats.chalec.org` :
```
server
{
listen 80;
listen [::]:80;
server_name stats.chalec.org;
access_log /var/log/nginx/stats.chalec.org-access.log;
error_log /var/log/nginx/stats.chalec.org-error.log;
#return 302 https://$host$request_uri;
return 302 https://stats.chalec.org$request_uri;
}
server
{
set_real_ip_from 192.169.1.1;
real_ip_header proxy_protocol;
listen [::]:443 ssl ipv6only=on;
listen 443 ssl proxy_protocol;
server_name stats.chalec.org;
access_log /var/log/nginx/stats.chalec.org-access.log;
error_log /var/log/nginx/stats.chalec.org-error.log;
ssl_certificate /etc/letsencrypt/live/stats.chalec.org/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/stats.chalec.org/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
# StatoolInfos.
include /etc/nginx/statoolinfos.conf;
root /var/www/stats.chalec.org;
location = /
{
index index.xhtml;
}
}
```
Vérifier que c'est bon et recharger :
```
nginx -t && systemctl reload nginx
```
# Déploiement du générateur de site web
## Configuration /etc/hosts
Le programme StatoolInfos va faire des requêtes web sur la vm donc il a besoin de la voir.
Pour éviter d'avoir un court-circuit proxy ipv4, modifier le fichier `/etc/hosts` pour déclarer stats.chalec.org en ipv6 locale uniquement :
```
127.0.0.1 localhost
127.0.1.1 stats
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback stats.chalec.org stats
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
```
## Configuration de Java
Java :
```
apt-get install openjdk-11-jre-headless
```
## Espace de travail
Dossiers de travail :
```
mkdir -p /srv/statoolinfos/{conf,inputs,well-known}
mkdir -p /srv/statoolinfos/well-known/statoolinfos/
ln -s /var/www/stats.chalec.org /srv/statoolinfos/www
```
Déployer les catégories : copier le dossier https://framagit.org/chatons/chatonsinfos/-/tree/master/StatoolInfos/categories dans `/srv/statoolinfos/inputs/`.
Créer un fichier de configuration pour le générateur :
```
# [Configuration]
conf.class=federation
conf.protocol=StatoolInfos-0.5
conf.crawl.input=https://stats.chalec.org/.well-known/statoolinfos/chalec.properties
conf.crawl.cache=/srv/statoolinfos/cache/
conf.htmlize.categories=/srv/statoolinfos/inputs/categories/categories.properties
conf.htmlize.input=https://stats.chalec.org/.well-known/statoolinfos/chalec.properties
conf.htmlize.directory=/srv/statoolinfos/www/
```
Créer le fichier `properties` de type `federation` nommé `/srv/statoolinfos/well-known/statoolinfos/chalec.properties` :
```
# [File]
file.class=federation
file.generator=Cpm
file.datetime=2022-01-12T02:24:35
file.protocol=StatoolInfos-0.4.0
# [Federation]
federation.name=Chalec
federation.description=Le chaton de Libre-en-communs
federation.website=https://www.chalec.org/
federation.logo=https://stats.chalec.org/.well-known/statoolinfos/chalec-logo.svg
federation.contact.url=
federation.contact.email=contact@chalec.org
federation.socialnetworks.mastodon=
federation.legal.url=
federation.guide.user=
federation.guide.technical=
federation.startdate=12/2021
federation.enddate=
# [Subs]
subs.infra=https://stats.chalec.org/.well-known/statoolinfos/infra.properties
subs.services=https://stats.chalec.org/.well-known/statoolinfos/services.properties
# [Metrics]
metrics.members.count.2021 = 2
metrics.members.in.2021 = 2
metrics.members.out.2021 = 0
metrics.members.count.2022 = 2
metrics.members.in.2022 = 0
metrics.members.out.2022 = 0
```
Vérifier la validé des valeurs et placer dans `/srv/statoolinfos/well-known/statoolinfos/` les images de logos nécessaires.
Créer le fichier `properties` de type `organization` nommé `/srv/statoolinfos/well-known/statoolinfos/infra.properties` :
```
# [File]
file.class=organization
file.generator=Cpm
file.datetime=2022-01-12T02:22:02.096451
file.protocol=StatoolInfos-0.5
# [Organization]
organization.name=Infra
organization.description=Les services d'infrastructure de Chalec
organization.website=https://www.chalec.org/
organization.logo=https://stats.chalec.org/.well-known/statoolinfos/chalec-infra-logo.svg
organization.status.level=ACTIVE
organization.status.description=En activité
organization.owner.name=Chalec
organization.owner.website=https://www.chalec.org/
organization.owner.logo=https://stats.chalec.org/.well-known/statoolinfos/alec-logo-carre.png
organization.contact.url=
organization.contact.email=contact@chalec.org
organization.socialnetworks.mastodon=
organization.legal.url=
organization.guide.user=
organization.guide.technical=
organization.startdate=12/2021
organization.enddate=
organization.memberof.chalec.status.level=IDLE
organization.memberof.chalec.status.description=
organization.memberof.chalec.startdate=01/10/2021
organization.memberof.chalec.enddate=
organization.country.name=France
organization.country.code=FR
# [Subs]
subs.stats.chalec.org=https://stats.chalec.org/.well-known/statoolinfos/stats.chalec.org.properties
subs.www.chalec.org=https://www.chalec.org/.well-known/statoolinfos/www.chalec.org.properties
```
Vérifier la validé des valeurs et placer dans `/srv/statoolinfos/well-known/statoolinfos/` les images de logos nécessaires.
Créer le fichier `properties` de type `federation` nommé `/srv/statoolinfos/well-known/statoolinfos/services.properties` :
```
# [File]
file.class=organization
file.generator=Cpm
file.datetime=2022-01-12T02:22:02.096451
file.protocol=StatoolInfos-0.5
# [Organization]
organization.name=Services au public
organization.description=Les services au public de Chalec
organization.website=https://www.chalec.org/
organization.logo=https://stats.chalec.org/.well-known/statoolinfos/chalec-services-logo.svg
organization.status.level=ACTIVE
organization.status.description=En activité
organization.owner.name=Chalec
organization.owner.website=https://www.chalec.org/
organization.owner.logo=https://www.chalec.org/.well-known/statoolinfos/chalec-logo-carre.png
organization.contact.url=
organization.contact.email=contact@chalec.org
organization.socialnetworks.mastodon=
organization.legal.url=
organization.guide.user=
organization.guide.technical=
organization.startdate=12/2021
organization.enddate=
organization.memberof.chalec.status.level=IDLE
organization.memberof.chalec.status.description=
organization.memberof.chalec.startdate=12/2021
organization.memberof.chalec.enddate=
organization.country.name=France
organization.country.code=FR
# [Subs]
subs.audio=https://audio.chalec.org/.well-known/statoolinfos/audio.chalec.org.properties
subs.libreverse=https://libreverse.chalec.org/.well-known/statoolinfos/libreverse.chalec.org.properties
```
Vérifier la validé des valeurs et placer dans `/srv/statoolinfos/well-known/statoolinfos/` les images de logos nécessaires.
Récupérer la dernièer version de StatoolInfos sur https://forge.devinsy.fr/devinsy/statoolinfos/releases. Puis placer dans `/srv/statoolinfos/bin/` les fichiers `statoolinfos.jar` et `statoolinfos.sh`. Faire un lien :
```
cd /srv/statoolinfos/bin/
ln -s statoolinfos.sh statoolinfos
```
Créer le script `/srv/statoolinfos/bin/crawl` :
```
#!/bin/bash
cd $(dirname "$0")
./statoolinfos crawl ../conf/chalec.conf
```
Créer le script `/srv/statoolinfos/bin/htmlize` :
```
#!/bin/bash
cd $(dirname "$0")
./statoolinfos htmlize ../conf/chalec.conf
chmod -R go+rX ../www/
```
Créer le script `/srv/statoolinfos/bin/probe` :
```
#!/bin/bash
cd $(dirname "$0")
./statoolinfos probe -previousday ../conf/
```
Créer le script `/srv/statoolinfos/bin/refresh` :
```
#!/bin/bash
cd $(dirname "$0")
./probe
./crawl
./uptime
./htmlize
```
Créer le script `/srv/statoolinfos/bin/uptime` :
```
#!/bin/bash
cd $(dirname "$0")
./statoolinfos uptime ../conf/chalec.conf
```
Créer le cron `/etc/cron.d/statoolinfos` :
```
4 * * * * root /srv/statoolinfos/bin/refresh >> /srv/statoolinfos/statoolinfos-cron.log
```