getGraphsFDN.pl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/perl
  2. # Recuperation des graphiques de consommation de FDN dans le repertoire courant
  3. # a partir des identifiants d'adherent du FAI en marque blanche (depuis le
  4. # 31/10/11, l'identification avec le login radius d'un ligne n'est plus
  5. # possible).
  6. #
  7. # USAGE: ./% prenom nom
  8. use strict;
  9. use warnings;
  10. use WWW::Mechanize;
  11. my $mech = WWW::Mechanize->new(
  12. agent => 'SI-LDN'
  13. );
  14. if(@ARGV != 2) {
  15. print "Usage: $0 prenom nom\n";
  16. exit 1;
  17. }
  18. # Identifiants d'adherent du FAI en marque blanche
  19. my $adh_login = 'adhacc-XXX';
  20. my $adh_pwd = '';
  21. # Abonne concerne
  22. my $prenom = $ARGV[0];
  23. my $nom = $ARGV[1];
  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. # Recuperation de l'ID de session dans l'URL de redirection (aucun cookie)
  27. my $graphs_uri = $mech->uri();
  28. # Il faut obligatoirement passer par cette page pour faire generer les graphs et
  29. # s'eviter un "session invalide"
  30. $graphs_uri =~ s/-in/-stats/;
  31. $mech->get($graphs_uri);
  32. # Recuperation du graph de conso totale
  33. $graphs_uri =~ s/-stats/-statimg/;
  34. $mech->get($graphs_uri."&img=total.rrd&freq=daily", ':content_file' => "total.png");
  35. # Recuperation des graphs individuels
  36. $graphs_uri .= "&img=$prenom.$nom%40fdn.nerim.rrd&freq=";
  37. for (qw(daily weekly monthly yearly)) {
  38. $mech->get($graphs_uri.$_, ':content_file' => "$_.png");
  39. }
  40. exit 0;