Changeset 42900
- Timestamp:
- Jun 18, 2025, 9:16:15 AM (13 months ago)
- Location:
- tags/ipp-unions-20250528/Ohana/src/opihi
- Files:
-
- 1 added
- 2 edited
-
pantasks/controller_hoststats.c (modified) (3 diffs)
-
pantasks/test/hoststats.sh (added)
-
pcontrol/hoststats.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-unions-20250528/Ohana/src/opihi/pantasks/controller_hoststats.c
r42899 r42900 4 4 5 5 int N, status; 6 char command[1024];7 6 IOBuffer buffer; 8 7 … … 13 12 } 14 13 14 char *filename = NULL; 15 if ((N = get_argument (argc, argv, "-file"))) { 16 remove_argument (N, &argc, argv); 17 filename = strcreate (argv[N]); 18 remove_argument (N, &argc, argv); 19 } 15 20 if (argc != 2) { 16 gprint (GP_ERR, "USAGE: controller hoststats (stack) \n");21 gprint (GP_ERR, "USAGE: controller hoststats (stack) [-reset] [-file output]\n"); 17 22 gprint (GP_ERR, " (stack) : all, idle, busy, done, down, off, resp\n"); 23 FREE (filename); 18 24 return (FALSE); 19 25 } … … 23 29 if (!status) { 24 30 gprint (GP_LOG, "controller is not active\n"); 31 FREE (filename); 25 32 return (TRUE); 26 33 } 27 34 28 35 // XXX this has an error? test this out... 29 if (Reset) {30 sprintf (command, "hoststats %s -reset", argv[1]);31 } else {32 sprintf (command, "hoststats %s", argv[1]);33 } 36 char *command = NULL; 37 strextend (&command, "hoststats %s", argv[1]); 38 if (Reset) { strextend (&command, " -reset"); } 39 if (filename) { strextend (&command, " -file %s", filename); } 40 34 41 InitIOBuffer (&buffer, 0x100); 35 42 36 43 status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer); 44 free (command); 37 45 38 46 if (status) { -
tags/ipp-unions-20250528/Ohana/src/opihi/pcontrol/hoststats.c
r42899 r42900 13 13 } 14 14 15 char *filename = NULL; 16 if ((N = get_argument (argc, argv, "-file"))) { 17 remove_argument (N, &argc, argv); 18 filename = strcreate (argv[N]); 19 remove_argument (N, &argc, argv); 20 } 21 15 22 if (argc != 2) { 16 gprint (GP_ERR, "USAGE: hoststats (stack) [-reset] \n");23 gprint (GP_ERR, "USAGE: hoststats (stack) [-reset] [-file output]\n"); 17 24 gprint (GP_ERR, " (stack) : all, idle, busy, done, down, off, resp\n"); 25 FREE (filename); 18 26 return (FALSE); 19 27 } … … 22 30 stack = GetHostStackByName (argv[1]); 23 31 if (stack == NULL) { 24 gprint (GP_ERR, "hoststack not found\n"); 32 gprint (GP_LOG, "hoststack not found\n"); 33 FREE (filename); 25 34 return (FALSE); 35 } 36 37 FILE *fout = NULL; 38 if (filename) { 39 fout = fopen (filename, "a"); 40 if (!fout) { 41 gprint (GP_LOG, "error opening %s for output\n", filename); 42 FREE (filename); 43 return (FALSE); 44 } 26 45 } 27 46 28 47 /* print list */ 29 48 LockStack (stack); 30 gprint (GP_LOG, "Nhosts: %d\n", stack[0].Nobject); 49 if (filename) { 50 fprintf (fout, "Nhosts: %d\n", stack[0].Nobject); 51 } else { 52 gprint (GP_LOG, "Nhosts: %d\n", stack[0].Nobject); 53 } 31 54 for (i = 0; i < stack[0].Nobject; i++) { 32 55 host = stack[0].object[i]; 33 gprint (GP_LOG, "%lld %s %d : %f %d %d %d\n", host[0].HostID, host[0].hostname, host[0].pid, host[0].read_time, host[0].read_N_Pclient, host[0].read_N_GetJobOutput, host[0].N_jobs_total); 56 if (filename) { 57 fprintf (fout, "%lld %s %d : %f %d %d %d\n", host[0].HostID, host[0].hostname, host[0].pid, host[0].read_time, host[0].read_N_Pclient, host[0].read_N_GetJobOutput, host[0].N_jobs_total); 58 } else { 59 gprint (GP_LOG, "%lld %s %d : %f %d %d %d\n", host[0].HostID, host[0].hostname, host[0].pid, host[0].read_time, host[0].read_N_Pclient, host[0].read_N_GetJobOutput, host[0].N_jobs_total); 60 } 34 61 if (Reset) { 35 62 host[0].read_time = 0.0; … … 41 68 UnlockStack (stack); 42 69 70 if (filename) { 71 free (filename); 72 fclose (fout); 73 } 43 74 return (TRUE); 44 75 }
Note:
See TracChangeset
for help on using the changeset viewer.
