Changeset 4573
- Timestamp:
- Jul 16, 2005, 6:01:28 AM (21 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 1 added
- 18 edited
-
doc/scheduler.txt (modified) (2 diffs)
-
include/pcontrol.h (modified) (1 diff)
-
include/scheduler.h (modified) (1 diff)
-
pantasks/CheckSystem.c (modified) (1 diff)
-
pantasks/ControllerOps.c (modified) (6 diffs)
-
pantasks/Makefile (modified) (1 diff)
-
pantasks/controller.c (modified) (1 diff)
-
pantasks/controller_check.c (modified) (2 diffs)
-
pantasks/controller_host.c (modified) (3 diffs)
-
pantasks/controller_output.c (added)
-
pantasks/controller_status.c (modified) (2 diffs)
-
pclient/job.c (modified) (3 diffs)
-
pcontrol/GetJobOutput.c (modified) (1 diff)
-
pcontrol/HostOps.c (modified) (2 diffs)
-
pcontrol/check.c (modified) (2 diffs)
-
pcontrol/host.c (modified) (10 diffs)
-
pcontrol/pclient.c (modified) (1 diff)
-
pcontrol/rconnect.c (modified) (1 diff)
-
pcontrol/status.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/doc/scheduler.txt
r4552 r4573 1 2 2005.07.15 3 4 The controller sends messages to both stdout and stderr. I can easily 5 require the messages which are immediate responses to external 6 commands (status, check, etc) go back on stdout. other messages 7 should go to stderr, or be suppressed. I suppose i can regularly 8 harvest the stderr messages? 1 9 2 10 2005.07.14 … … 50 58 - allow the 'periods' command to define defaults when outside of a 51 59 task 52 53 -54 60 55 61 2005.07.05 -
trunk/Ohana/src/opihi/include/pcontrol.h
r4450 r4573 134 134 Host *PullHost (IDtype HostID, int StackID); 135 135 int FindNamedHost (char *name, int StackID); 136 voidAddHost (char *hostname);136 IDtype AddHost (char *hostname); 137 137 void DownHost (Host *host); 138 138 void OffHost (Host *host); -
trunk/Ohana/src/opihi/include/scheduler.h
r4552 r4573 83 83 } Job; 84 84 85 # define CONTROLLER_PROMPT "pc lient:"85 # define CONTROLLER_PROMPT "pcontrol:" 86 86 87 87 /* scheduler prototypes */ -
trunk/Ohana/src/opihi/pantasks/CheckSystem.c
r4450 r4573 5 5 CheckTasks (); 6 6 CheckJobs (); 7 CheckControllerOutput (); 7 8 8 9 } -
trunk/Ohana/src/opihi/pantasks/ControllerOps.c
r4552 r4573 5 5 static int status = FALSE; 6 6 static int stdin_cntl, stdout_cntl, stderr_cntl; 7 static IOBuffer stdout_buffer; 8 static IOBuffer stderr_buffer; 7 9 8 10 int CheckControllerStatus () { … … 108 110 line = NULL; 109 111 status = -1; 110 for (i = 0; (i < CONTROLLER_TIMEOUT) && (status == -1) && (line == NULL); i++) {112 for (i = 0; (i < CONTROLLER_TIMEOUT) && (status != 0) && (line == NULL); i++) { 111 113 status = ReadtoIOBuffer (buffer, stdout_cntl); 112 114 if ((buffer[0].Nbuffer - Nstart) >= Nbytes) { … … 261 263 p = NULL; 262 264 status = -1; 263 for (i = 0; (i < CONNECT_TIMEOUT) && (status == -1) && (p == NULL); i++) {265 for (i = 0; (i < CONNECT_TIMEOUT) && (status != 0) && (p == NULL); i++) { 264 266 status = ReadtoIOBuffer (&buffer, stdout_fd[0]); 265 267 p = memstr (buffer.buffer, "CONNECTED", buffer.Nbuffer); … … 274 276 stdout_cntl = stdout_fd[0]; 275 277 stderr_cntl = stderr_fd[0]; 278 279 InitIOBuffer (&stdout_buffer, 0x100); 280 InitIOBuffer (&stderr_buffer, 0x100); 276 281 277 282 fprintf (stderr, "Connected\n"); … … 319 324 line = NULL; 320 325 status = -1; 321 for (i = 0; (i < CONTROLLER_TIMEOUT) && (status == -1) && (line == NULL); i++) {326 for (i = 0; (i < CONTROLLER_TIMEOUT) && (status != 0) && (line == NULL); i++) { 322 327 status = ReadtoIOBuffer (buffer, stdout_cntl); 323 328 line = memstr (buffer[0].buffer, response, buffer[0].Nbuffer); … … 330 335 } 331 336 337 int CheckControllerOutput () { 338 339 int Nread; 340 341 /* read stdout buffer */ 342 Nread = ReadtoIOBuffer (&stdout_buffer, stdout_cntl); 343 switch (Nread) { 344 case -2: /* error in read (programming error? system level error?) */ 345 fprintf (stderr, "serious IO error\n"); 346 exit (2); 347 case -1: /* no data in pipe */ 348 break; 349 case 0: /* pipe is closed */ 350 /** change child state? **/ 351 break; 352 default: /* data in pipe */ 353 break; 354 } 355 356 /* read stderr buffer */ 357 Nread = ReadtoIOBuffer (&stderr_buffer, stderr_cntl); 358 switch (Nread) { 359 case -2: /* error in read (programming error? system level error?) */ 360 fprintf (stderr, "serious IO error\n"); 361 exit (2); 362 case -1: /* no data in pipe */ 363 break; 364 case 0: /* pipe is closed */ 365 /** change child state? **/ 366 break; 367 default: /* data in pipe */ 368 break; 369 } 370 return (TRUE); 371 } 372 373 int PrintControllerOutput () { 374 375 fprintf (stderr, "--- stdout ---\n"); 376 fwrite (stdout_buffer.buffer, 1, stdout_buffer.Nbuffer, stderr); 377 fprintf (stderr, "--- stdout ---\n"); 378 fwrite (stderr_buffer.buffer, 1, stderr_buffer.Nbuffer, stderr); 379 fprintf (stderr, "--- done ---\n"); 380 return (TRUE); 381 } 382 383 332 384 /* memstr returns a view, not an allocated string : don't free */ -
trunk/Ohana/src/opihi/pantasks/Makefile
r4552 r4573 48 48 $(SDIR)/controller_check.$(ARCH).o \ 49 49 $(SDIR)/controller_status.$(ARCH).o \ 50 $(SDIR)/controller_output.$(ARCH).o \ 50 51 $(SDIR)/task.$(ARCH).o \ 51 52 $(SDIR)/task_command.$(ARCH).o \ -
trunk/Ohana/src/opihi/pantasks/controller.c
r4552 r4573 4 4 int controller_status PROTO((int, char **)); 5 5 int controller_check PROTO((int, char **)); 6 int controller_output PROTO((int, char **)); 6 7 7 8 static Command controller_cmds[] = { 8 9 {"host", controller_host, "define host for controller"}, 10 {"check", controller_check, "check controller host/job"}, 9 11 {"status", controller_status, "check controller status"}, 10 {" check", controller_check, "check controller host/job"},12 {"output", controller_output, "print controller output"}, 11 13 }; 12 14 -
trunk/Ohana/src/opihi/pantasks/controller_check.c
r4552 r4573 8 8 9 9 if (argc != 3) goto usage; 10 if (strcasecmp (argv[ 2], "JOB") &&11 strcasecmp (argv[ 2], "HOST")) goto usage;10 if (strcasecmp (argv[1], "JOB") && 11 strcasecmp (argv[1], "HOST")) goto usage; 12 12 13 13 /* check if controller is running */ … … 18 18 } 19 19 20 sprintf (command, "check %s %s", argv[ 2], argv[3]);20 sprintf (command, "check %s %s", argv[1], argv[2]); 21 21 InitIOBuffer (&buffer, 0x100); 22 22 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); -
trunk/Ohana/src/opihi/pantasks/controller_host.c
r4539 r4573 7 7 IOBuffer buffer; 8 8 9 if (argc != 3) {9 if (argc != 2) { 10 10 fprintf (stderr, "USAGE: controller host (hostname)\n"); 11 11 return (FALSE); … … 15 15 StartController (); 16 16 17 sprintf (command, "host %s", argv[ 2]);17 sprintf (command, "host %s", argv[1]); 18 18 InitIOBuffer (&buffer, 0x100); 19 19 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); … … 32 32 case CONTROLLER_GOOD: 33 33 fprintf (stderr, "controller command sent\n"); 34 fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr); 35 fprintf (stderr, "\n Nbytes received: %d\n", buffer.Nbuffer); 34 36 return (TRUE); 35 37 -
trunk/Ohana/src/opihi/pantasks/controller_status.c
r4552 r4573 7 7 IOBuffer buffer; 8 8 9 if (argc != 3) {9 if (argc != 1) { 10 10 fprintf (stderr, "USAGE: controller status\n"); 11 11 return (FALSE); … … 37 37 fprintf (stderr, "controller command sent\n"); 38 38 fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr); 39 fprintf (stderr, "\n Nbytes received: %d\n", buffer.Nbuffer); 39 40 return (TRUE); 40 41 -
trunk/Ohana/src/opihi/pclient/job.c
r4450 r4573 3 3 int job (int argc, char **argv) { 4 4 5 int pid, status; 5 int i, pid, status; 6 char **targv; 6 7 7 8 if (argc < 2) { … … 20 21 if (pipe (child_stdout_fd) < 0) goto pipe_error; 21 22 if (pipe (child_stderr_fd) < 0) goto pipe_error; 23 24 /* need to define arg list with NULL termination */ 25 ALLOCATE (targv, char *, argc); 26 for (i = 1; i < argc; i++) { 27 targv[i-1] = strcreate (argv[i]); 28 } 29 targv[i] = 0; 22 30 23 31 pid = fork (); … … 39 47 setvbuf (stdout, (char *) NULL, _IONBF, BUFSIZ); 40 48 setvbuf (stderr, (char *) NULL, _IONBF, BUFSIZ); 41 /* fprintf (stderr, "child is spawned, executing command\n"); */42 /* note that this message comes out on the other side of the stderr pipe */43 49 44 50 /* exec job */ 45 status = execvp ( argv[1], &argv[1]);51 status = execvp (targv[0], targv); 46 52 fprintf (stderr, "error starting child process: %d\n", status); 47 53 exit (1); -
trunk/Ohana/src/opihi/pcontrol/GetJobOutput.c
r4462 r4573 25 25 line = NULL; 26 26 status = -1; 27 for (i = 0; (i < PCLIENT_TIMEOUT) && (status == -1) && (line == NULL); i++) {27 for (i = 0; (i < PCLIENT_TIMEOUT) && (status != 0) && (line == NULL); i++) { 28 28 status = ReadtoIOBuffer (buffer, host[0].stdout); 29 29 if ((buffer[0].Nbuffer - Nstart) >= Nbytes) { -
trunk/Ohana/src/opihi/pcontrol/HostOps.c
r4450 r4573 153 153 } 154 154 155 voidAddHost (char *hostname) {155 IDtype AddHost (char *hostname) { 156 156 157 157 Host *host; … … 168 168 host[0].job = NULL; 169 169 PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM); 170 return (host[0].HostID); 170 171 } 171 172 -
trunk/Ohana/src/opihi/pcontrol/check.c
r4552 r4573 10 10 11 11 if (argc != 3) { 12 fprintf (std err, "USAGE: check job (JobID)\n");13 fprintf (std err, "USAGE: check host (HostID)\n");12 fprintf (stdout, "USAGE: check job (JobID)\n"); 13 fprintf (stdout, "USAGE: check host (HostID)\n"); 14 14 return (FALSE); 15 15 } … … 40 40 } 41 41 42 fprintf (std err, "unknown item to check\n");42 fprintf (stdout, "unknown item to check\n"); 43 43 return (FALSE); 44 44 } -
trunk/Ohana/src/opihi/pcontrol/host.c
r3212 r4573 3 3 int host (int argc, char **argv) { 4 4 5 IDtype HostID; 5 6 int N, Delete, Off, On, Start, Stop, Check; 6 7 Host *host; … … 17 18 if ((N = get_argument (argc, argv, "-off"))) { 18 19 if (Delete) { 19 fprintf (std err, "-delete and -off incompatible\n");20 fprintf (stdout, "-delete and -off incompatible\n"); 20 21 return (FALSE); 21 22 } … … 28 29 if ((N = get_argument (argc, argv, "-on"))) { 29 30 if (Delete || Off) { 30 fprintf (std err, "only one of -delete, -off, -on\n");31 fprintf (stdout, "only one of -delete, -off, -on\n"); 31 32 return (FALSE); 32 33 } … … 57 58 58 59 if (argc != 2) { 59 fprintf (std err, "USAGE: host (hostname) [-delete]\n");60 fprintf (stdout, "USAGE: host (hostname) [-delete]\n"); 60 61 return (FALSE); 61 62 } … … 64 65 N = FindNamedHost (argv[1], PCONTROL_HOST_OFF); 65 66 if (N < 0) { 66 fprintf (std err, "host %s is not OFF\n", argv[1]);67 fprintf (stdout, "host %s is not OFF\n", argv[1]); 67 68 return (FALSE); 68 69 } … … 75 76 N = FindNamedHost (argv[1], PCONTROL_HOST_OFF); 76 77 if (N < 0) { 77 fprintf (std err, "host %s is not OFF\n", argv[1]);78 fprintf (stdout, "host %s is not OFF\n", argv[1]); 78 79 return (FALSE); 79 80 } … … 96 97 return (TRUE); 97 98 } 98 fprintf (std err, "host %s is not BUSY or IDLE\n", argv[1]);99 fprintf (stdout, "host %s is not BUSY or IDLE\n", argv[1]); 99 100 return (FALSE); 100 101 } … … 103 104 N = FindNamedHost (argv[1], PCONTROL_HOST_DOWN); 104 105 if (N < 0) { 105 fprintf (std err, "host %s is not DOWN\n", argv[1]);106 fprintf (stdout, "host %s is not DOWN\n", argv[1]); 106 107 return (FALSE); 107 108 } … … 113 114 N = FindNamedHost (argv[1], PCONTROL_HOST_IDLE); 114 115 if (N < 0) { 115 fprintf (std err, "host %s is not IDLE\n", argv[1]);116 fprintf (stdout, "host %s is not IDLE\n", argv[1]); 116 117 return (FALSE); 117 118 } … … 143 144 return (TRUE); 144 145 } 145 fprintf (std err, "host %s is not BUSY, IDLE, or DOWN\n", argv[1]);146 fprintf (stdout, "host %s is not BUSY, IDLE, or DOWN\n", argv[1]); 146 147 return (FALSE); 147 148 } 148 149 149 AddHost (argv[1]); 150 HostID = AddHost (argv[1]); 151 fprintf (stdout, "HostID: %d\n", HostID); 150 152 return (TRUE); 151 153 } -
trunk/Ohana/src/opihi/pcontrol/pclient.c
r4450 r4573 24 24 line = NULL; 25 25 status = -1; 26 for (i = 0; (i < PCLIENT_TIMEOUT) && (status == -1) && (line == NULL); i++) {26 for (i = 0; (i < PCLIENT_TIMEOUT) && (status != 0) && (line == NULL); i++) { 27 27 status = ReadtoIOBuffer (buffer, host[0].stdout); 28 28 line = memstr (buffer[0].buffer, response, buffer[0].Nbuffer); -
trunk/Ohana/src/opihi/pcontrol/rconnect.c
r4450 r4573 76 76 p = NULL; 77 77 status = -1; 78 for (i = 0; (i < CONNECT_TIMEOUT) && (status == -1) && (p == NULL); i++) {78 for (i = 0; (i < CONNECT_TIMEOUT) && (status != 0) && (p == NULL); i++) { 79 79 status = ReadtoIOBuffer (&buffer, stdout_fd[0]); 80 80 p = memstr (buffer.buffer, "CONNECTED", buffer.Nbuffer); -
trunk/Ohana/src/opihi/pcontrol/status.c
r3212 r4573 30 30 stack = GetJobStack (Nstack); 31 31 Nobject = stack[0].Nobject; 32 fprintf (std err, "job stack %s: %d objects\n", jobname[Nstack], Nobject);32 fprintf (stdout, "job stack %s: %d objects\n", jobname[Nstack], Nobject); 33 33 34 34 for (i = 0; i < Nobject; i++) { 35 35 job = stack[0].object[i]; 36 fprintf (std err, "%d %s %d ", i, job[0].hostname, job[0].argc);36 fprintf (stdout, "%d %s %d ", i, job[0].hostname, job[0].argc); 37 37 for (j = 0; j < job[0].argc; j++) { 38 fprintf (std err, "%s ", job[0].argv[j]);38 fprintf (stdout, "%s ", job[0].argv[j]); 39 39 } 40 PrintID (std err, job[0].JobID);41 fprintf (std err, "\n");40 PrintID (stdout, job[0].JobID); 41 fprintf (stdout, "\n"); 42 42 } 43 43 } … … 51 51 stack = GetHostStack (Nstack); 52 52 Nobject = stack[0].Nobject; 53 fprintf (std err, "host stack %s: %d objects\n", hostname[Nstack], Nobject);53 fprintf (stdout, "host stack %s: %d objects\n", hostname[Nstack], Nobject); 54 54 55 55 for (i = 0; i < Nobject; i++) { 56 56 host = stack[0].object[i]; 57 fprintf (std err, "%d %s ", i, host[0].hostname);58 PrintID (std err, host[0].HostID);59 fprintf (std err, "\n");57 fprintf (stdout, "%d %s ", i, host[0].hostname); 58 PrintID (stdout, host[0].HostID); 59 fprintf (stdout, "\n"); 60 60 } 61 61 }
Note:
See TracChangeset
for help on using the changeset viewer.
