- Timestamp:
- Feb 11, 2011, 2:49:34 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20101205/pstamp/scripts/pstamp_server_status
r30446 r30579 25 25 26 26 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 27 #pod2usage( -msg => "Required options: --first --stage",28 # -exitval => 3) unless29 # defined $first and30 # defined $stage;31 27 32 28 # Look for programs we need … … 39 35 } 40 36 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 41 40 my $ipphome = "/home/panstarrs/ipp"; 41 my $status_cmd = "psstatus"; 42 42 43 $rundir = "$ipphome/pstamp" if !$rundir; 43 44 … … 45 46 46 47 48 49 my $now = `date -u`; 50 51 print "<b>Status updated: </b> $now<br /><br />\n"; 52 47 53 my $down = 0; 48 54 if ($down) { 49 55 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 52 59 53 my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps);60 my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps); 54 61 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; 58 65 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 } 68 80 } 69 warn("$command failed. exit status: $error_code");70 exit $error_code;71 }72 81 73 my $output = join "", @$stdout_buf;82 my $output = join "", @$stdout_buf; 74 83 75 print "$output" if $verbose;84 print "$output" if $verbose; 76 85 77 my @lines = split "\n", $output;86 my @lines = split "\n", $output; 78 87 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); 86 95 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 ); 99 108 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. $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> $job_run->{nrun} running. $job_run->{ngood} completed successfully. $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"; 103 152 } 104 153 } 105 154 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 156 print "<br /><b>Unfinished Requests</b><br />\n"; 157 print "<pre>\n"; 158 system "$status_cmd --totals"; 159 print "</pre>\n"; 160 161 #print "<br />\n"; 162 163 164 # print "<br /><b>Unfinished Requests</b><br />\n"; 165 print "<pre>\n"; 166 system "$status_cmd --running"; 167 print "</pre>\n"; 168 169 if (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"; 118 175 } 119 176 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. $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> $job_run->{nrun} running. $job_run->{ngood} completed successfully. $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 177 print "<br /><b>Requests completed in last 24 hours (most recently completed first)</b><br />\n"; 178 print "<pre>\n"; 179 system "$status_cmd --finished"; 180 print "</pre>\n"; 154 181 155 182
Note:
See TracChangeset
for help on using the changeset viewer.
