Changeset 36144
- Timestamp:
- Sep 23, 2013, 12:52:57 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130904/Ohana/src/opihi
- Files:
-
- 4 edited
-
include/pcontrol.h (modified) (2 diffs)
-
pcontrol/JobOps.c (modified) (1 diff)
-
pcontrol/jobstack.c (modified) (1 diff)
-
pcontrol/status.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130904/Ohana/src/opihi/include/pcontrol.h
r33662 r36144 8 8 /** job status values **/ 9 9 typedef enum { 10 PCONTROL_JOB_NONE, // XXX OK? 10 11 PCONTROL_JOB_ALLJOBS, 11 12 PCONTROL_JOB_PENDING, … … 309 310 char *GetJobStackName (int StackID); 310 311 Stack *GetJobStackByName (char *name); 312 int GetJobStackIDbyName (char *name); 311 313 int PutJob (Job *job, int StackID, int where); 312 314 int PutJobSetState (Job *job, int StackID, int where, int state); -
branches/eam_branches/ipp-20130904/Ohana/src/opihi/pcontrol/JobOps.c
r32632 r36144 59 59 pcontrol_exit (53); 60 60 return (NULL); 61 } 62 63 int GetJobStackIDbyName (char *name) { 64 if (!strcasecmp (name, "ALLJOBS")) return PCONTROL_JOB_ALLJOBS; 65 if (!strcasecmp (name, "PENDING")) return PCONTROL_JOB_PENDING; 66 if (!strcasecmp (name, "BUSY")) return PCONTROL_JOB_BUSY ; 67 if (!strcasecmp (name, "RESP")) return PCONTROL_JOB_RESP ; 68 if (!strcasecmp (name, "DONE")) return PCONTROL_JOB_DONE ; 69 if (!strcasecmp (name, "KILL")) return PCONTROL_JOB_KILL ; 70 if (!strcasecmp (name, "EXIT")) return PCONTROL_JOB_EXIT ; 71 if (!strcasecmp (name, "CRASH")) return PCONTROL_JOB_CRASH ; 72 return (PCONTROL_JOB_NONE); 61 73 } 62 74 -
branches/eam_branches/ipp-20130904/Ohana/src/opihi/pcontrol/jobstack.c
r12470 r36144 22 22 /* print list */ 23 23 LockStack (stack); 24 gprint (GP_LOG, " Njobs: %d\n", stack[0].Nobject);24 gprint (GP_LOG, "BEGIN BLOCK Njobs: %d\n", stack[0].Nobject); 25 25 for (i = 0; i < stack[0].Nobject; i++) { 26 26 job = stack[0].object[i]; -
branches/eam_branches/ipp-20130904/Ohana/src/opihi/pcontrol/status.c
r32632 r36144 1 1 # include "pcontrol.h" 2 2 3 int PrintJobStack (int Nstack );3 int PrintJobStack (int Nstack, char *command, char *hostname, int state, float age); 4 4 int PrintHostStack (int Nstack); 5 5 6 6 int status (int argc, char **argv) { 7 7 8 PrintJobStack (PCONTROL_JOB_ALLJOBS); 9 PrintHostStack (PCONTROL_HOST_ALLHOSTS); 8 int N; 9 10 if (get_argument (argc, argv, "-h")) goto usage; 11 if (get_argument (argc, argv, "-help")) goto usage; 12 if (get_argument (argc, argv, "--help")) goto usage; 13 14 /* I would like to add the following options: 15 * strsub on argv[0] 16 * strsub on hostname, realhost 17 * list hostname and realhost 18 * filter by state 19 * filter by dtime 20 */ 21 22 // -cmd (cmd) 23 // -host (hostname) 24 // -state (busy, pending, done, kill, exit, crash, resp, hung 25 // -age (seconds?) (minutes?) 26 // -nohost 27 28 char *COMMAND = NULL; 29 if ((N = get_argument (argc, argv, "-cmd"))) { 30 remove_argument (N, &argc, argv); 31 COMMAND = strcreate (argv[N]); 32 remove_argument (N, &argc, argv); 33 } 34 35 char *HOSTNAME = NULL; 36 if ((N = get_argument (argc, argv, "-host"))) { 37 remove_argument (N, &argc, argv); 38 HOSTNAME = strcreate (argv[N]); 39 remove_argument (N, &argc, argv); 40 } 41 42 int STATE = PCONTROL_JOB_ALLJOBS; 43 if ((N = get_argument (argc, argv, "-state"))) { 44 remove_argument (N, &argc, argv); 45 STATE = GetJobStackIDbyName (argv[N]); 46 remove_argument (N, &argc, argv); 47 if (STATE == PCONTROL_JOB_NONE) goto usage; 48 } 49 50 float AGE = 0.0; 51 if ((N = get_argument (argc, argv, "-age"))) { 52 remove_argument (N, &argc, argv); 53 AGE = atof (argv[N]); 54 remove_argument (N, &argc, argv); 55 } 56 57 int SHOWHOST = TRUE; 58 if ((N = get_argument (argc, argv, "-nohost"))) { 59 remove_argument (N, &argc, argv); 60 SHOWHOST = FALSE; 61 } 62 if ((N = get_argument (argc, argv, "+jobs"))) { 63 remove_argument (N, &argc, argv); 64 SHOWHOST = FALSE; 65 } 66 67 int SHOWJOBS = TRUE; 68 if ((N = get_argument (argc, argv, "-nojobs"))) { 69 remove_argument (N, &argc, argv); 70 SHOWJOBS = FALSE; 71 } 72 if ((N = get_argument (argc, argv, "+host"))) { 73 remove_argument (N, &argc, argv); 74 SHOWJOBS = FALSE; 75 } 76 77 if (SHOWJOBS) { 78 PrintJobStack (PCONTROL_JOB_ALLJOBS, COMMAND, HOSTNAME, STATE, AGE); 79 } 80 if (SHOWHOST) { 81 PrintHostStack (PCONTROL_HOST_ALLHOSTS); 82 } 10 83 11 84 return (TRUE); 85 86 usage: 87 gprint (GP_ERR, "USAGE: status [-cmd command] [-host hostname] [-state state] [-age seconds] [+jobs,-nohost] [+host,-nojobs]\n"); 88 return FALSE; 12 89 } 13 90 14 int PrintJobStack (int Nstack ) {91 int PrintJobStack (int Nstack, char *command, char *hostname, int state, float age) { 15 92 16 93 int i, j, Nobject; … … 30 107 job = stack[0].object[i]; 31 108 ASSERT (job != NULL, "programming error"); 32 if (job[0].realhost == NULL) { 33 gprint (GP_LOG, "%3d %9s ", i, job[0].hostname); 34 } else { 35 gprint (GP_LOG, "%3d %9s ", i, job[0].realhost); 36 } 37 gprint (GP_LOG, "%7s ", GetJobStackName (job[0].state)); 109 110 char *thishost = (job[0].realhost == NULL) ? job[0].hostname : job[0].realhost; 38 111 39 112 switch (job[0].state) { … … 45 118 gettimeofday (&now, (void *) NULL); 46 119 dtime = DTIME (now, job[0].start); 47 gprint (GP_LOG, "%8.2f ", dtime);48 120 break; 49 121 … … 55 127 default: 56 128 dtime = DTIME (job[0].stop, job[0].start); 57 gprint (GP_LOG, "%8.2f ", dtime);58 129 break; 59 130 } 131 132 // check on the filters 133 if (command) { 134 if (!strstr (job[0].argv[0], command)) continue; 135 } 136 if (hostname) { 137 if (!strstr (thishost, hostname)) continue; 138 } 139 if (age > 0.0) { 140 if (dtime < age) continue; 141 } 142 if (state != PCONTROL_JOB_ALLJOBS) { 143 // allow PCONTROL_JOB_RESP == BUSY 144 int validState = FALSE; 145 validState |= (state == PCONTROL_JOB_RESP) && (job[0].state == PCONTROL_JOB_BUSY); 146 validState |= (state == PCONTROL_JOB_BUSY) && (job[0].state == PCONTROL_JOB_RESP); 147 validState |= (state == job[0].state); 148 if (!validState) continue; 149 } 150 151 gprint (GP_LOG, "%3d %9s ", i, thishost); 152 gprint (GP_LOG, "%7s ", GetJobStackName (job[0].state)); 153 gprint (GP_LOG, "%8.2f ", dtime); 60 154 61 155 PrintID (GP_LOG, job[0].JobID);
Note:
See TracChangeset
for help on using the changeset viewer.
