// This is a sample code used to measure reports response times on a OAS application.
1
2
3
4
5
6
7
8 use strict;
9 require LWP::UserAgent;
10
11 my $ua = LWP::UserAgent->new;
12
13 sub isodate() {
14 my ($day, $mon, $year, $hour, $min, $sec) = (localtime)[3, 4, 5, 2, 1, 0];
15 $mon++;
16 $year = $year + 1900;
17 my $date = sprintf ("%04i-%02i-%02i %02i\:%02i\:%02i", $year, $mon, $day, $hour, $min, $sec);
18 return $date;
19 }
20
21 sub datamart_login {
22 my ( $user, $pass ) = @_;
23 my $time_begin=time();
24 my $url='http://daprd:7782/portal/page?_pageid=37,134413,37_134422&_dad=portal&_schema=PORTAL';
25 my $req = HTTP::Request->new( GET => $url );
26 my $resp = $ua->request($req);
27 my $loginform = $resp->content ;
28 if ( $loginform !~ /Entrez votre nom utilisateur/ ) {
29 die isodate()." Failed to get the logon page of the Web Site\n";
30 } else {
31 my $locale="";
32 my ($v) = $loginform =~ /NAME=\"v\" value=\"(.+)\"/;
33 my ($site2pstoretoken) = $loginform =~ /NAME=\"site2pstoretoken\" value=\"(.+)\"/;
34 my ($submiturl) = $loginform =~ /form method=\"POST\" action=\"(.*?)\"/;
35 $resp = $ua->post( $submiturl,
36 [
37 ssousername => $user,
38 password => $pass,
39 v => $v,
40 locale => $locale,
41 site2pstoretoken => $site2pstoretoken
42 ],
43 );
44 $resp = $ua->get($url);
45 $resp = $ua->get($url);
46 if ( $resp->content !~ /Crit..res de recherche/ ) {
47 die isodate()." Failed to get the main page of Portal\n";
48 }
49 }
50 print join(";",isodate(),"Time to log on the Portal",time()-$time_begin,$url)."\n";
51 }
52
53 sub datamart_testurl {
54 my ($label,$url,$expected)=@_;
55 my $time_begin=time();
56 my $resp;
57 $resp = $ua->get($url);
58 $resp = $ua->get($url) if $resp->content !~ /$expected/;
59 if ( $resp->content !~ /$expected/ ) {
60 print STDERR isodate()." Test Failed on $label. $expected not found in response.\n";
61 print STDERR $resp->as_string;
62 } else {
63 print join(";",isodate(),$label,time()-$time_begin,$url)."\n";
64 }
65 }
66
67 $ua->timeout(1200);
68 $ua->cookie_jar({});
69 $ua->agent( 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)' );
70
71
72
73
74 datamart_login("xxxx","xxxx");
75
76 open FH,"/exploit/scripts/appli/check_datamart.ini" or die "Unable to open check_datamart.ini";
77 while (<FH>) {
78 chomp();
79 my ($report,$expected,$url) = split /;/;
80 datamart_testurl($report,$url,$expected);
81 }
82 close FH;
83
84
85