Parcourir la source

Ajout getGraphsFDN (récuprération des rrds FDN) pour abonnés

Sebastien Badia il y a 13 ans
commit
5efd0a4cf6
2 fichiers modifiés avec 105 ajouts et 0 suppressions
  1. 52 0
      getGraphsFDN/base.html
  2. 53 0
      getGraphsFDN/getGraphsFDN.pl

+ 52 - 0
getGraphsFDN/base.html

@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<head>
+<title>État de mon 95e centile - Lorraine Data Network</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style type="text/css">
+<!--
+	body {
+		font-family: sans-serif;
+		text-align: center;
+		margin: 0;
+		padding: 0;
+		background: #eaefad url(../../ressources/logo_ldn.png) no-repeat 30px 70px;
+	}
+
+	h1 {
+		background-color: #000;
+		margin-top: 0;
+		padding: 10px;
+		color: #FFF;
+	}
+-->
+</style>
+</head>
+
+<body>
+
+<h1>État en temps réel de mon 95e centile</h1>
+
+<h2>Les dernières 24 heures</h2>
+<img src="daily.png" alt="daily" />
+
+<h2>Les 7 derniers jours</h2>
+<img src="weekly.png" alt="weekly" />
+
+<h2>Les 4 dernières semaines</h2>
+<img src="monthly.png" alt="monthly" />
+
+<h2>Les 12 derniers mois</h2>
+<img src="yearly.png" alt="yearly" />
+
+<h2>Bande passante totale de FDN (prestataire de LDN)</h2>
+<img src="total.png" alt="total" />
+
+<p>
+	Le dernier graphique permet de situer les heures à privilégier pour d'éventuels gros téléchargements.<br />
+</p>
+
+<p>
+	Contacter le bureau : <em>bureau@ldn-fai.net</em>
+</p>
+</body>
+</html>

+ 53 - 0
getGraphsFDN/getGraphsFDN.pl

@@ -0,0 +1,53 @@
+#!/usr/bin/perl
+
+# Recuperation des graphiques de consommation de FDN dans le repertoire courant
+# a partir des identifiants d'adherent du FAI en marque blanche (depuis le
+# 31/10/11, l'identification avec le login radius d'un ligne n'est plus
+# possible).
+#
+# USAGE: ./% prenom nom
+
+use strict;
+use warnings;
+use WWW::Mechanize;
+
+my $mech = WWW::Mechanize->new(
+	agent => 'SI-LDN'
+);
+
+if(@ARGV != 2) {
+	print "Usage: $0 prenom nom\n";
+	exit 1;
+}
+
+# Identifiants d'adherent du FAI en marque blanche
+my $adh_login = 'adhacc-XXX';
+my $adh_pwd = '';
+
+# Abonne concerne
+my $prenom = $ARGV[0];
+my $nom = $ARGV[1];
+
+# Identification sur le SI de FDN
+$mech->get("https://vador.fdn.fr/adherents/index.cgi?adhlogin=$adh_login&adhpasswd=$adh_pwd&do=yes");
+
+# Recuperation de l'ID de session dans l'URL de redirection (aucun cookie)
+my $graphs_uri = $mech->uri();
+
+# Il faut obligatoirement passer par cette page pour faire generer les graphs et
+# s'eviter un "session invalide"
+$graphs_uri =~ s/-in/-stats/;
+$mech->get($graphs_uri);
+
+# Recuperation du graph de conso totale
+$graphs_uri =~ s/-stats/-statimg/;
+$mech->get($graphs_uri."&img=total.rrd&freq=daily", ':content_file' => "total.png");
+
+# Recuperation des graphs individuels
+$graphs_uri .= "&img=$prenom.$nom%40fdn.nerim.rrd&freq=";
+
+for (qw(daily weekly monthly yearly)) {
+	$mech->get($graphs_uri.$_, ':content_file' => "$_.png");
+}
+
+exit 0;