IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30517


Ignore:
Timestamp:
Feb 8, 2011, 10:13:15 AM (15 years ago)
Author:
bills
Message:

add totals by label to the Unfinished Jobs section of the status page

Location:
trunk/pstamp/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/psstatus

    r30483 r30517  
    1313my $running;
    1414my $finished;
    15 my $req_faulted;
    16 my $job_faulted;
     15my $finishing;
     16my $totals;
    1717my $dbname;
    1818my $dbserver;
     
    2020my $dbpassword;
    2121my $verbose;
    22 my $finishing;
    2322
    2423GetOptions(
     
    2625    'finished|f',    \$finished,
    2726    'finishing',     \$finishing,
    28     'req_faulted',   \$req_faulted,
    29     'job_faulted',   \$job_faulted,
     27    'totals|t',      \$totals,
    3028    'limit|l=i',     \$limit,
    3129    'dbname=s',      \$dbname,
     
    3533pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV ;
    3634
    37 $running = 1 if (!$finished and !$finishing and !$running);
    38 
    39 my $no_args = ! (defined $running or defined $finished or defined $req_faulted or defined $job_faulted );
     35$running = 1 if (!$finished and !$finishing and !$running and !$totals);
     36
     37my $no_args = ! (defined $running or defined $finished or defined $finishing or defined $totals );
    4038
    4139die "cannot supply --running and --finished\n" if ($running and $finished);
     
    4442my $ipprc =  PS::IPP::Config->new();
    4543my $dbh = getDBHandle();
     44
     45my $totals_query = "
     46SELECT label, count(job_id) AS 'Unfinished Jobs', priority
     47FROM pstampRequest join pstampJob USING(req_id)
     48JOIN Label USING(label)
     49WHERE pstampJob.state ='run' and pstampRequest.state ='run'
     50GROUP by label";
    4651
    4752my $running_query = "
     
    5156    label,
    5257    reqType,
    53     priority,
     58   -- priority,
    5459    state,
    5560    fault,
     
    233238
    234239my $sql;
    235 if ($finished) {
     240if ($totals) {
     241    $sql = $totals_query;
     242} elsif ($finished) {
    236243    $sql = $finished_query;
    237244} elsif ($running) {
  • trunk/pstamp/scripts/pstamp_server_status

    r30469 r30517  
    4646
    4747
    48 my $down = 0;
    49 if ($down) {
    50     print "Postage Stamp Server will be down for maintenance it will back at approximately 00:00 2010-12-11 UTC\n";
    51     exit 0;
    52 }
    5348
    5449my $now = `date -u`;
     
    5651print "<b>Status updated: &nbsp;&nbsp;&nbsp;</b> $now<br /><br />\n";
    5752
    58 my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps);
     53my $down = 0;
     54if ($down) {
     55    print "Postage Stamp Server will be down for maintenance it will back at approximately 00:00 2010-12-11 UTC\n";
     56    # exit 0;
     57} else {
     58    # talk to pantasks_server and get the status
    5959
    60 print $pts "status\n";
    61 print $pts "quit\n";
    62 close $pts;
     60    my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps);
    6361
    64 my $command = "$pantasks_client < $pantasks_script";
    65 my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    66     run(command => $command, verbose => $verbose);
    67 unless ($success) {
    68     $error_code = (($error_code >> 8) or 1);
    69     if ($error_code == 12) {
    70         #print "Postage Stamp Server is not running\n";
    71         print "Postage Stamp Server will be down for maintenance it will back shortly.\n";
    72         exit 0;
     62    print $pts "status\n";
     63    print $pts "quit\n";
     64    close $pts;
     65
     66
     67    my $command = "$pantasks_client < $pantasks_script";
     68    my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     69        run(command => $command, verbose => $verbose);
     70    unless ($success) {
     71        $error_code = (($error_code >> 8) or 1);
     72        if ($error_code == 12) {
     73            #print "Postage Stamp Server is not running\n";
     74            print "Postage Stamp Server will be down for maintenance it will back shortly.\n";
     75            exit 0;
     76        } else {
     77            warn("$command failed. exit status: $error_code");
     78            exit $error_code;
     79        }
    7380    }
    74     warn("$command failed. exit status: $error_code");
    75     exit $error_code;
    76 }
    7781
    78 my $output = join "", @$stdout_buf;
     82    my $output = join "", @$stdout_buf;
    7983
    80 print "$output" if $verbose;
     84    print "$output" if $verbose;
    8185
    82 my @lines = split "\n", $output;
     86    my @lines = split "\n", $output;
    8387
    84 my ($scheduler_state, $controller_state);
    85 my $got_state = 0;
    86 my %tasks;
    87 foreach my $line (@lines) {
    88     chomp $line;
    89     next if !$line;
    90     my ($first, $second, $third);
     88    my ($scheduler_state, $controller_state);
     89    my $got_state = 0;
     90    my %tasks;
     91    foreach my $line (@lines) {
     92        chomp $line;
     93        next if !$line;
     94        my ($first, $second, $third);
    9195
    92     if ($line =~ /Scheduler is/) {
    93         ($first, $second, $scheduler_state) = split " ", $line;
    94         $got_state = 1;
    95 #        print "$first $second $third $scheduler_state\n";
    96     } elsif ($line =~ /Controller is/) {
    97         ($first, $second, $controller_state) = split " ", $line;
    98 #        print "$first $second $third $controller_state\n";
    99     } elsif ($got_state == 1 and $line =~ /\+|\-/) {
    100 #        print "$line\n";
    101         my ($task_state, $task, $nrun, $njobs, $ngood, $nfail, $ntime, $cmd) = split " ", $line;
    102 #        print "$task $task_state\n";
    103         my %this_task = ( name => $task, nrun=> $nrun, njobs => $njobs, ngood => $ngood, nfail => $nfail, ntime => $ntime, cmd => $cmd );
     96        if ($line =~ /Scheduler is/) {
     97            ($first, $second, $scheduler_state) = split " ", $line;
     98            $got_state = 1;
     99    #        print "$first $second $third $scheduler_state\n";
     100        } elsif ($line =~ /Controller is/) {
     101            ($first, $second, $controller_state) = split " ", $line;
     102    #        print "$first $second $third $controller_state\n";
     103        } elsif ($got_state == 1 and $line =~ /\+|\-/) {
     104    #        print "$line\n";
     105            my ($task_state, $task, $nrun, $njobs, $ngood, $nfail, $ntime, $cmd) = split " ", $line;
     106    #        print "$task $task_state\n";
     107            my %this_task = ( name => $task, nrun=> $nrun, njobs => $njobs, ngood => $ngood, nfail => $nfail, ntime => $ntime, cmd => $cmd );
    104108
    105         # change '.' in task name to '_' so we have a valid hash key
    106         $task =~ s/\./\_/g;
    107         $tasks{$task} =  \%this_task;
     109            # change '.' in task name to '_' so we have a valid hash key
     110            $task =~ s/\./\_/g;
     111            $tasks{$task} =  \%this_task;
     112        }
     113    }
     114
     115    if ($scheduler_state) {
     116        print "Pantasks Scheduler $scheduler_state.\n";
     117        if ($controller_state) {
     118            print $br . "Pantasks Controller $controller_state.\n";
     119        } else {
     120            print STDERR "Controller state not found";
     121            exit 1;
     122        }
     123        print "$br$br\n";
     124    } else {
     125        print STDERR "Scheduler state not found";
     126        exit 1;
     127    }
     128
     129    my $request_run = $tasks{'pstamp_request_run'};
     130    my $request_fin = $tasks{'request_finish_run'};
     131    my $job_run = $tasks{'pstamp_job_run'};
     132
     133
     134    if ($request_run) {
     135        # print "<br >\n";
     136        print "<b>Parser Status:</b> $request_run->{nrun} running. $request_run->{ngood} parsed successfully.&nbsp; $request_run->{nfail} failed to parse.";
     137        if ($request_fin) {
     138            print "  $request_fin->{ngood} Requests finished.";
     139        } else {
     140            print "Task request.finish.run not found.\n";
     141        }
     142        print "\n";
     143        print "\n";
     144        if ($job_run) {
     145            print "<br /><b>Job Status:</b> &nbsp;&nbsp; $job_run->{nrun} running. &nbsp; $job_run->{ngood} completed successfully. &nbsp; $job_run->{nfail} failed";
     146            print "<br />\n";
     147        } else {
     148            print "Task pstamp.job.run not found.<br />\n";
     149        }
     150    } else {
     151        print "Task pstamp.request.run not found.\n";
    108152    }
    109153}
    110154
    111 if ($scheduler_state) {
    112     print "Pantasks Scheduler $scheduler_state.\n";
    113     if ($controller_state) {
    114         print $br . "Pantasks Controller $controller_state.\n";
    115     } else {
    116         print STDERR "Controller state not found";
    117         exit 1;
    118     }
    119     print "$br$br\n";
    120 } else {
    121     print STDERR "Scheduler state not found";
    122     exit 1;
    123 }
     155# now run the script psstatus to check the status of running requests and finished requests
     156print "<br /><b>Unfinished Requests</b><br />\n";
     157print "<pre>\n";
     158system "$status_cmd --totals";
     159print "</pre>\n";
    124160
    125 my $request_run = $tasks{'pstamp_request_run'};
    126 my $request_fin = $tasks{'request_finish_run'};
    127 my $job_run = $tasks{'pstamp_job_run'};
     161#print "<br />\n";
    128162
    129163
    130 if ($request_run) {
    131     print "<br /><b>Parser Status:</b> $request_run->{nrun} running. $request_run->{ngood} parsed successfully.&nbsp; $request_run->{nfail} failed to parse.";
    132     if ($request_fin) {
    133         print "  $request_fin->{ngood} Requests finished.";
    134     } else {
    135         print "Task request.finish.run not found.\n";
    136     }
    137     print "\n";
    138     print "\n";
    139     if ($job_run) {
    140         print "<br /><b>Job Status:</b> &nbsp;&nbsp; $job_run->{nrun} running. &nbsp; $job_run->{ngood} completed successfully. &nbsp; $job_run->{nfail} failed";
    141         print "<br />\n";
    142     } else {
    143         print "Task pstamp.job.run not found.<br />\n";
    144     }
    145 
    146     # now run the script psstatus to check the status of running requests and finished requests
    147     print "<br /><b>Unfinished Requests</b><br />\n";
    148     print "<pre>\n";
    149     system "$status_cmd --running";
    150     print "</pre>\n";
     164# print "<br /><b>Unfinished Requests</b><br />\n";
     165print "<pre>\n";
     166system "$status_cmd --running";
     167print "</pre>\n";
    151168
    152169if (0) {
     
    158175}
    159176
    160     print "<br /><b>Requests completed in last 24 hours (most recently completed first)</b><br />\n";
    161     print "<pre>\n";
    162     system "$status_cmd --finished";
    163     print "</pre>\n";
    164 
    165 } else {
    166     print "Task pstamp.request.run not found.\n";
    167 }
    168 
     177print "<br /><b>Requests completed in last 24 hours (most recently completed first)</b><br />\n";
     178print "<pre>\n";
     179system "$status_cmd --finished";
     180print "</pre>\n";
    169181
    170182
Note: See TracChangeset for help on using the changeset viewer.