michael@0: #!/usr/bin/perl
michael@0: # This Source Code Form is subject to the terms of the Mozilla Public
michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0:
michael@0:
michael@0: #______________________________________________________________________________________
michael@0: # these variables will need to be changed to fit the host machine configuration/directories.
michael@0: #
michael@0: # this is where the linux.dat files live; currently /home/usr/ftp/pub/data/memtests
michael@0: $directory_root = "/u/twalker/memtest/results/daily";
michael@0: #
michael@0: $host_server = "smoketest1";
michael@0: #
michael@0: # note: the /plots_tmp directory under $results_dir will need to be cleaned out periodically
michael@0: # because this is where the .png files will be put on creation (it could become a memory hog)
michael@0: $results_dir = "/usr/local/apache/htdocs";
michael@0:
michael@0: # this is where gnuplot app lives
michael@0: $gnuplot = "/usr/bin/gnuplot";
michael@0: #
michael@0: #--------------------------------------------------------------------------------------
michael@0:
michael@0: # take in form info and convert it to usable variables --------------------------------
michael@0:
michael@0: $query_string = $ENV{'QUERY_STRING'};
michael@0:
michael@0: @key_value_pairs = split (/&/, $query_string);
michael@0:
michael@0: foreach $key_value (@key_value_pairs)
michael@0: {
michael@0: ($key, $value) = split (/=/, $key_value);
michael@0: $value =~ tr/+/ /;
michael@0: $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
michael@0: $form_data{$key} = $value;
michael@0: @list_keys = keys(%form_data);
michael@0: @values_keys = values(%form_data);
michael@0: }
michael@0:
michael@0: # error check for user selecting all three fields ------------------------------------
michael@0:
michael@0: $number_of_values = @key_value_pairs;
michael@0:
michael@0: if ($number_of_values != 3) {
michael@0: print "Content-type: text/html", "\n\n";
michael@0:
michael@0: print "", "\n";
michael@0: print "
Plotting Error", "\n";
michael@0: print "", "\n";
michael@0: print "", "Plotting Error", "
", "
", "\n";
michael@0: print "Please close this window and make a selection from each of the three fields.", "\n";
michael@0: print "", "\n";
michael@0: }
michael@0:
michael@0: # create variables to point to directories containg the linux.dat files ---------------
michael@0:
michael@0: else {
michael@0: ($month, $day, $year) = split (/\//, $form_data{"first_date"});
michael@0: $first_date = "$year$month$day";
michael@0: ($month, $day, $year) = split (/\//, $form_data{"compare_date"});
michael@0: $compare_date = "$year$month$day";
michael@0: $test_list_in = $form_data{"test_list"};
michael@0: if ($test_list_in eq "large to small") {
michael@0: $test_list = "static41x3_gtol";
michael@0: }
michael@0: elsif ($test_list_in eq "small to large") {
michael@0: $test_list = "static41x3_ltog";
michael@0: }
michael@0: elsif ($test_list_in eq "plain text") {
michael@0: $test_list = "static_vanillaX100";
michael@0: }
michael@0: elsif ($test_list_in eq "memory hog") {
michael@0: $test_list = "static_iplanetX100";
michael@0: }
michael@0:
michael@0: open(FIRST_DATE_DIR,"$directory_root/$test_list/$first_date/linux.dat") || die "could not create directory\n";
michael@0: open(COMPARE_DATE_DIR,"$directory_root/$test_list/$compare_date/linux.dat") || die "could not create directory\n";
michael@0: $first_date_dir = join ("/",$directory_root , $test_list, $first_date, "linux.dat");
michael@0: $compare_date_dir = join ("/", $directory_root, $test_list, $compare_date, "linux.dat");
michael@0:
michael@0: # get slope of first date line---------------------------------------------------------
michael@0:
michael@0: while () {
michael@0: $line = $_;
michael@0: }
michael@0: @slope_array_first = split (' ',$line);
michael@0: $slope_first = $slope_array_first[1];
michael@0: $label_placement_first = $slope_array_first[5];
michael@0: $line_formula_first = join (" ", $slope_array_first[3], $slope_array_first[2], $slope_array_first[1], $slope_array_first[4], $slope_array_first[5]);
michael@0: chop($slope_first);chop($slope_first);chop($slope_first);
michael@0: close (FIRST_DATE_DIR);
michael@0:
michael@0: # get slope of compare date line---------------------------------------------------------
michael@0:
michael@0: while () {
michael@0: $line = $_;
michael@0: }
michael@0: @slope_array_compare = split (' ',$line);
michael@0: $slope_compare = $slope_array_compare[1];
michael@0: $label_placement_compare = $slope_array_compare[5];
michael@0: $line_formula_compare = join (" ", $slope_array_compare[3], $slope_array_compare[2], $slope_array_compare[1], $slope_array_compare[4], $slope_array_compare[5]);
michael@0: chop($slope_compare);chop($slope_compare);chop($slope_compare);
michael@0: close(COMPARE_DATE_DIR);
michael@0:
michael@0: # generate gnuplot graph --------------------------------------------------------------
michael@0:
michael@0: $process_id = $$;
michael@0: $output_file = join ("", $results_dir, "/plots_tmp/", $process_id, ".png");
michael@0: $output_location = join ("", "http://", $host_server, "/plots_tmp/", $process_id, ".png");
michael@0: open(GNUPLOT, "|$gnuplot");
michael@0: print GNUPLOT <