Speech:Spring 2019 Experiment Group SpyExp

From Openitware
Jump to: navigation, search


Project Logs


Project Member Logs


Tasks

SPY EXPERIMENT SCRIPT

The spy experiment script is a simple Perl script which captures any training or decoding jobs being run on the school servers. After capturing this information via regular expressions, it outputs a plain table containing the most important information for those jobs; the user running them, the job being run, any correlating phases, what experiment number it is running under, and the machine it is being run on. The script currently only finds decoding jobs, and needs a bit more work before it becomes a truly useful utility. Unfortunately, the new implementation of Torque may actually render the spy experiment script useless, but it is a helpful utility for the time being, and could be good practice to get it running the way it should in the near future.

To run Spy Experiment

  • Locate the spyExp.pl script found in /mnt/main/scripts/user/
  • Type 'perl spyExp.pl'
  • Review the results that it displays

Features left to implement:

  • Make the script work across all school servers. (It currently only works on the server the user calls it on)
  • Use regular expressions to capture all the training jobs (there are many child programs running concurrently during training jobs)

Below is the source code for the Spy Experiment Script:

use strict;
use warnings;
use diagnostics;
 
 
my $command = qx /ps -elfwww/;
my $file = 'test.txt';
 
# Write running programs to external temp document.
open(my $filehandle, '>', $file) or die "Could not open file '$file' $!";
 
    print $filehandle $command;
 
    close $filehandle;
 
# Read and sort through programs from temp document.
open($filehandle, '<', $file) or die "Could not open file '$file' $!";
 
    print "\nDisplaying any training or decoding jobs being run:\n";
    print "\nUser\t\tJob\t\tPhase\t\tExperiment\tMachine\n";
    print "-----------\t-----------\t-----------\t-----------\t-----------\n";
 
    # Parse through temp document for training and decoding jobs.
    while(my $info = <$filehandle>){
 
        chomp($info);
 
        # Assigning names to each article in the temp document.
        my ($F, $S, $USER, $PID, $PPID, $C, $PRI, $NI, $ADDR, $SZ, $WCHAN, $STIME, $TTY, $TIME, $CMD) = split (/\s+/, $info);
 
        my $user = $USER;
        my $job = $CMD;
        my $phase = 0;
        my $experiment = 0;
        my $machine = `hostname`; # Assigning the MACHINE variable to take in the users machine name.
 
 
 
        # Parsing through the commands of each process to find training and decoding jobs.
        if ($CMD =~ m/decode|train/) {
 
            # Searching for experiment numbers and assigning them to experiment.
            if ($info =~ m/\d{4}\/\d{3}/){
                $experiment = $info;
            }
 
                # Assigning job and phase values for 'decodes'
                for ($CMD =~ m/decode/) {
                    $job = "Decode";
                    $phase = "<all>";
                    # my $EXP =~ m/\d{4}\/\d{3}/;
                }
 
                # Assigning job and phase values for 'trains'
                for ($CMD =~ m/train/) {
                    $job = "Train";
                    $phase = $PPID;
                    # my $EXP =~ m/\d{4}\/\d{3}/;
 
                }
 
            # Outputting the results to terminal.
            print "$user\t\t$job\t\t$phase\t\t$experiment\t\t$machine";
        }
    }
 
        # print ((exists $experiment{'sublime_text'}) ? 'sublime is running.' : 'sublime is not running.');
 
close $filehandle;