IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 11, 2011, 2:49:34 PM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/pstamp/scripts/pstamp_server_status

    r30446 r30579  
    2525
    2626pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    27 #pod2usage( -msg => "Required options: --first --stage",
    28 #          -exitval => 3) unless
    29 #    defined $first and
    30 #    defined $stage;
    3127
    3228# Look for programs we need
     
    3935}
    4036
     37# XXX: Note under pantasks this will be the curent directory, so this
     38# isn't necessary if the pstamp/web stuff is configured to point at the
     39# ipp build. But currently it's running out of Bill's build
    4140my $ipphome = "/home/panstarrs/ipp";
     41my $status_cmd = "psstatus";
     42
    4243$rundir = "$ipphome/pstamp" if !$rundir;
    4344
     
    4546
    4647
     48
     49my $now = `date -u`;
     50
     51print "<b>Status updated: &nbsp;&nbsp;&nbsp;</b> $now<br /><br />\n";
     52
    4753my $down = 0;
    4854if ($down) {
    4955    print "Postage Stamp Server will be down for maintenance it will back at approximately 00:00 2010-12-11 UTC\n";
    50     exit 0;
    51 }
     56    # exit 0;
     57} else {
     58    # talk to pantasks_server and get the status
    5259
    53 my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps);
     60    my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps);
    5461
    55 print $pts "status\n";
    56 print $pts "quit\n";
    57 close $pts;
     62    print $pts "status\n";
     63    print $pts "quit\n";
     64    close $pts;
    5865
    59 my $command = "$pantasks_client < $pantasks_script";
    60 my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    61     run(command => $command, verbose => $verbose);
    62 unless ($success) {
    63     $error_code = (($error_code >> 8) or 1);
    64     if ($error_code == 12) {
    65         #print "Postage Stamp Server is not running\n";
    66         print "Postage Stamp Server will be down for maintenance it will back shortly.\n";
    67         exit 0;
     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        }
    6880    }
    69     warn("$command failed. exit status: $error_code");
    70     exit $error_code;
    71 }
    7281
    73 my $output = join "", @$stdout_buf;
     82    my $output = join "", @$stdout_buf;
    7483
    75 print "$output" if $verbose;
     84    print "$output" if $verbose;
    7685
    77 my @lines = split "\n", $output;
     86    my @lines = split "\n", $output;
    7887
    79 my ($scheduler_state, $controller_state);
    80 my $got_state = 0;
    81 my %tasks;
    82 foreach my $line (@lines) {
    83     chomp $line;
    84     next if !$line;
    85     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);
    8695
    87     if ($line =~ /Scheduler is/) {
    88         ($first, $second, $scheduler_state) = split " ", $line;
    89         $got_state = 1;
    90 #        print "$first $second $third $scheduler_state\n";
    91     } elsif ($line =~ /Controller is/) {
    92         ($first, $second, $controller_state) = split " ", $line;
    93 #        print "$first $second $third $controller_state\n";
    94     } elsif ($got_state == 1 and $line =~ /\+|\-/) {
    95 #        print "$line\n";
    96         my ($task_state, $task, $nrun, $njobs, $ngood, $nfail, $ntime, $cmd) = split " ", $line;
    97 #        print "$task $task_state\n";
    98         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 );
    99108
    100         # change '.' in task name to '_' so we have a valid hash key
    101         $task =~ s/\./\_/g;
    102         $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";
    103152    }
    104153}
    105154
    106 if ($scheduler_state) {
    107     print "Pantasks Scheduler $scheduler_state.\n";
    108     if ($controller_state) {
    109         print $br . "Pantasks Controller $controller_state.\n";
    110     } else {
    111         print STDERR "Controller state not found";
    112         exit 1;
    113     }
    114     print "$br$br\n";
    115 } else {
    116     print STDERR "Scheduler state not found";
    117     exit 1;
     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";
     160
     161#print "<br />\n";
     162
     163
     164# print "<br /><b>Unfinished Requests</b><br />\n";
     165print "<pre>\n";
     166system "$status_cmd --running";
     167print "</pre>\n";
     168
     169if (0) {
     170    # these are included in running requests above
     171    print "<br /><b>Requests building results fileset</b><br/>\n";
     172    print "<pre>\n";
     173    system "$status_cmd --finishing";
     174    print "</pre>\n";
    118175}
    119176
    120 my $request_run = $tasks{'pstamp_request_run'};
    121 my $request_fin = $tasks{'request_finish_run'};
    122 my $job_run = $tasks{'pstamp_job_run'};
    123 
    124 
    125 if ($request_run) {
    126     print "<br /><b>Parser Status:</b> $request_run->{nrun} running. $request_run->{ngood} parsed successfully.&nbsp; $request_run->{nfail} failed to parse.";
    127     if ($request_fin) {
    128         print "  $request_fin->{ngood} Requests finished.";
    129     } else {
    130         print "Task request.finish.run not found.\n";
    131     }
    132     print "\n";
    133     print "\n";
    134     if ($job_run) {
    135         print "<br /><b>Job Status:</b> &nbsp;&nbsp; $job_run->{nrun} running. &nbsp; $job_run->{ngood} completed successfully. &nbsp; $job_run->{nfail} failed";
    136         print "<br />\n";
    137     } else {
    138         print "Task pstamp.job.run not found.<br />\n";
    139     }
    140     print "<br /><b>Unfinished Requests</b><br />\n";
    141     print "<pre>\n";
    142     system "/home/panstarrs/bills/ipp/tools/psstatus -r ";
    143     print "</pre>\n";
    144     print "<br /><b>Requests completed in last 24 hours (most recently completed first)</b><br />\n";
    145     print "<pre>\n";
    146     # finished requests
    147     system "/home/panstarrs/bills/ipp/tools/psstatus -f";
    148     print "</pre>\n";
    149 } else {
    150     print "Task pstamp.request.run not found.\n";
    151 }
    152 
    153 
     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";
    154181
    155182
Note: See TracChangeset for help on using the changeset viewer.