Changeset 30517 for trunk/pstamp/scripts/pstamp_server_status
- Timestamp:
- Feb 8, 2011, 10:13:15 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_server_status (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_server_status
r30469 r30517 46 46 47 47 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 }53 48 54 49 my $now = `date -u`; … … 56 51 print "<b>Status updated: </b> $now<br /><br />\n"; 57 52 58 my ($pts, $pantasks_script) = tempfile ('/tmp/pts.XXXX', UNLINK => !$save_temps); 53 my $down = 0; 54 if ($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 59 59 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); 63 61 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 } 73 80 } 74 warn("$command failed. exit status: $error_code");75 exit $error_code;76 }77 81 78 my $output = join "", @$stdout_buf;82 my $output = join "", @$stdout_buf; 79 83 80 print "$output" if $verbose;84 print "$output" if $verbose; 81 85 82 my @lines = split "\n", $output;86 my @lines = split "\n", $output; 83 87 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); 91 95 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 ); 104 108 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. $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"; 108 152 } 109 153 } 110 154 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 156 print "<br /><b>Unfinished Requests</b><br />\n"; 157 print "<pre>\n"; 158 system "$status_cmd --totals"; 159 print "</pre>\n"; 124 160 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"; 128 162 129 163 130 if ($request_run) { 131 print "<br /><b>Parser Status:</b> $request_run->{nrun} running. $request_run->{ngood} parsed successfully. $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> $job_run->{nrun} running. $job_run->{ngood} completed successfully. $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"; 165 print "<pre>\n"; 166 system "$status_cmd --running"; 167 print "</pre>\n"; 151 168 152 169 if (0) { … … 158 175 } 159 176 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 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"; 169 181 170 182
Note:
See TracChangeset
for help on using the changeset viewer.
