getGraphsFDN.pl 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/perl
  2. # Recuperation des graphiques de consommation de FDN a partir des identifiants
  3. # d'adherent du FAI en marque blanche (depuis le 31/10/11, l'identification avec
  4. # le login radius d'un ligne n'est plus possible).
  5. #
  6. # USAGE: ./% prenom nom
  7. use strict;
  8. use warnings;
  9. use WWW::Mechanize;
  10. my $mech = WWW::Mechanize->new(
  11. agent => 'SI-LDN'
  12. );
  13. if(@ARGV != 2) {
  14. print "Usage: $0 prenom nom\n";
  15. exit 1;
  16. }
  17. # Identifiants d'adherent du FAI en marque blanche
  18. my $adh_login = '';
  19. my $adh_pwd = '';
  20. # Abonne concerne
  21. my $prenom = $ARGV[0];
  22. my $nom = $ARGV[1];
  23. eval {
  24. # Identification sur le SI de FDN
  25. $mech->get("https://vador.fdn.fr/adherents/index.cgi?adhlogin=$adh_login&adhpasswd=$adh_pwd&do=yes");
  26. };
  27. if($@) {
  28. print "<div id='error'>Le service semble indisponible actuellement,<br />la version des graphs consultés dernièrement est affichée.</div>";
  29. exit 1;
  30. }
  31. # Recuperation de l'ID de session dans l'URL de redirection (aucun cookie)
  32. my $graphs_uri = $mech->uri();
  33. # Il faut obligatoirement passer par cette page pour faire generer les graphs et
  34. # s'eviter un "session invalide"
  35. $graphs_uri =~ s/-in/-stats/;
  36. $mech->get($graphs_uri);
  37. # Recuperation du graph de conso totale
  38. $graphs_uri =~ s/-stats/-statimg/;
  39. $mech->get($graphs_uri."&img=total.rrd&freq=daily", ':content_file' => "total.png");
  40. # Recuperation des graphs individuels
  41. $graphs_uri .= "&img=$prenom.$nom%40fdn.nerim.rrd&freq=";
  42. for (qw(daily weekly monthly yearly)) {
  43. $mech->get($graphs_uri.$_, ':content_file' => "$_.png");
  44. }
  45. exit 0;