|
1 #!/usr/bin/perl |
|
2 # This Source Code Form is subject to the terms of the Mozilla Public |
|
3 # License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
5 |
|
6 |
|
7 #______________________________________________________________________________________ |
|
8 # these variables will need to be changed to fit the host machine configuration/directories. |
|
9 # |
|
10 # this is where the linux.dat files live; currently /home/usr/ftp/pub/data/memtests |
|
11 $directory_root = "/u/curt/reflow/results/"; |
|
12 # |
|
13 $host_server = "smoketest1"; |
|
14 # |
|
15 # note: the /plots_tmp directory under $results_dir will need to be cleaned out periodically |
|
16 # because this is where the .png files will be put on creation (it could become a memory hog) |
|
17 $results_dir = "/usr/local/apache/htdocs"; |
|
18 |
|
19 # this is where gnuplot app lives |
|
20 $gnuplot = "/usr/bin/gnuplot"; |
|
21 # |
|
22 #-------------------------------------------------------------------------------------- |
|
23 |
|
24 # take in form info and convert it to usable variables -------------------------------- |
|
25 |
|
26 $query_string = $ENV{'QUERY_STRING'}; |
|
27 #$query_string = "first_date=04%2F17%2F01&compare_date=04%2F12%2F01"; |
|
28 |
|
29 @key_value_pairs = split (/&/, $query_string); |
|
30 |
|
31 foreach $key_value (@key_value_pairs) |
|
32 { |
|
33 ($key, $value) = split (/=/, $key_value); |
|
34 $value =~ tr/+/ /; |
|
35 $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; |
|
36 $form_data{$key} = $value; |
|
37 @list_keys = keys(%form_data); |
|
38 @values_keys = values(%form_data); |
|
39 } |
|
40 |
|
41 # error check for user selecting both fields ------------------------------------ |
|
42 |
|
43 $number_of_values = @key_value_pairs; |
|
44 |
|
45 if ($number_of_values != 2) { |
|
46 print "Content-type: text/html", "\n\n"; |
|
47 |
|
48 print "<HTML>", "\n"; |
|
49 print "<HEAD><TITLE>Plotting Error</TITLE><HEAD>", "\n"; |
|
50 print "<BODY>", "\n"; |
|
51 print "<H1>", "Plotting Error", "</H1>", "<HR>", "\n"; |
|
52 print "Please make a selection from each of the date fields in the green form.", "\n"; |
|
53 print "</BODY></HTML>", "\n"; |
|
54 } |
|
55 |
|
56 # create variables to point to directories containg the reflow.dat files --------------- |
|
57 |
|
58 else { |
|
59 ($month, $day, $year) = split (/\//, $form_data{"first_date"}); |
|
60 $first_date = "$year$month$day"; |
|
61 ($month, $day, $year) = split (/\//, $form_data{"compare_date"}); |
|
62 $compare_date = "$year$month$day"; |
|
63 $first_date_dir = join ("/",$directory_root , $test_list, $first_date, "reflow.dat"); |
|
64 $compare_date_dir = join ("/", $directory_root, $test_list, $compare_date, "reflow.dat"); |
|
65 |
|
66 |
|
67 # generate gnuplot graph -------------------------------------------------------------- |
|
68 |
|
69 $process_id = $$; |
|
70 $output_file = join ("", $results_dir, "/plots_tmp/", $process_id, ".png"); |
|
71 $output_location = join ("", "http://", $host_server, "/plots_tmp/", $process_id, ".png"); |
|
72 open(GNUPLOT, "|$gnuplot"); |
|
73 print GNUPLOT <<gnuplot_Commands_Done; |
|
74 |
|
75 set term png color |
|
76 set output '$output_file' |
|
77 set title 'Reflow counts of selcted URL's on $test_list_in list on $form_data{"first_date"} and $form_data{"compare_date"}' |
|
78 set xlabel 'URLs' |
|
79 set ylabel 'Reflows' |
|
80 set key top left Right title 'Legend' box -1 |
|
81 plot "$compare_date_dir" using 1:2 title "Reflows on $form_data{"compare_date"}" with line 1,"$first_date_dir" using 1:2 title "Reflows on $form_data{"first_date"}" with line 3 |
|
82 |
|
83 gnuplot_Commands_Done |
|
84 |
|
85 close(GNUPLOT); |
|
86 |
|
87 # send graph to users browser---------------------------------------------------------- |
|
88 |
|
89 print "Location: $output_location", "\n\n"; |
|
90 |
|
91 } |
|
92 #end if |
|
93 |
|
94 exit (0); |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 |