int main(int argc, char* argv[]) { if (argc < 8) { printf("%s verbose offset1 offset2 nullpos1 nullpos2 iterations function\n", argv[0]); return 1; } int v = atoi(argv[1]); int ofs1 = atoi(argv[2]); int ofs2 = atoi(argv[3]); int len1 = atoi(argv[4]); int len2 = atoi(argv[5]); int cnt = atoi(argv[6]); int fun = atoi(argv[7]); if (v) { printf("string 1 at %d, length %d, ", ofs1, len1-ofs1); printf("string 2 at %d, length %d: ", ofs2, len2-ofs2); if (fun == 0) printf("builtin function, will run %d times", cnt); else if (fun == 1) printf("SSE function, will run %d times", cnt); else printf("verification"); putchar('\n'); } char *text1 = &buffer1[ofs1]; char *text2 = &buffer2[ofs2]; memset(buffer1, 'a', sizeof(buffer1)); memset(buffer2, 'a', sizeof(buffer2)); buffer1[SIZE-1] = buffer1[len1] = 0; buffer2[SIZE-1] = buffer2[len2] = 0; int l1, l2; switch (fun) { case 0: TIMEIT(l1 = strcmp(text1, text2)); break; case 1: TIMEIT(l2 = sse2_strcmp(text1, text2)); break; default: l1 = strcmp(text1, text2); l2 = sse2_strcmp(text1, text2); if (sign(l1) != sign(l2)) { printf("error: result is %d, should be %d\n", l2, l1); return 1; } else if (v) printf("ok, result is %d\n", l1); } return 0; }
int main(int argc, char* argv[]) { if (argc < 8) { printf("%s verbose offset char1pos char2pos nullpos iterations function\n", argv[0]); return 1; } int v = atoi(argv[1]); int ofs = atoi(argv[2]); int p1 = atoi(argv[3]); int p2 = atoi(argv[4]); int len = atoi(argv[5]); int cnt = atoi(argv[6]); int fun = atoi(argv[7]); if (v) { printf("string at %d, length %d, chars at %d and %d: ", ofs, len-ofs, p1-ofs, p2-ofs); if (fun == 0) printf("builtin function, will run %d times", cnt); else if (fun == 1) printf("SSE function, will run %d times", cnt); else printf("verification"); putchar('\n'); } int c = 'X'; char *text = &buffer[ofs]; memset(buffer, 'a', sizeof(buffer)); buffer[p1] = buffer[p2] = c; buffer[SIZE-1] = buffer[len] = 0; char *l1, *l2; switch (fun) { case 0: TIMEIT(l1 = strrchr(text, c)); break; case 1: TIMEIT(l2 = sse2_strrchr(text, c)); break; default: l1 = strrchr(text, c); l2 = sse2_strrchr(text, c); if (l1 != l2) { printf("error: result is 0x%08x, should be 0x%08x\n", (unsigned int)l2, (unsigned int)l1); return 1; } else if (v) printf("ok, result is 0x%08x\n", (unsigned int)l1); } return 0; }
void prtJobSubmit(struct jobInfoEnt *job, int prt_q, int tFormat) { char prline[MAXLINELEN]; char timeBuf[128]; if (tFormat) { sprintf(timeBuf, " Job <%s> s", lsb_jobid2str(job->jobId)); } else { sprintf(timeBuf, " S"); } sprintf(prline, "%-12.19s:%submitted from host <%s>", ctime(&job->submitTime), timeBuf, job->fromHost); prtLineWUF(prline); if (job->submit.options2 & SUB2_HOLD) { sprintf(prline, " on hold"); prtLineWUF(prline); } if (prt_q) { sprintf(prline, " to Queue <%s>", job->submit.queue); prtLineWUF(prline); } TIMEIT(2, prtBTTime(job), "prtBTTime"); }
void prtJobSubmit(struct jobInfoEnt *job, int prt_q, int tFormat) { char prline[MAXLINELEN]; char *timestr; timestr = putstr_(_i18n_ctime(ls_catd, CTIME_FORMAT_a_b_d_T, &job->submitTime)); if (tFormat) { sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,569, "%s: Job <%s> submitted from host <%s>")), /* catgets 569 */ timestr, lsb_jobid2str(job->jobId), job->fromHost); } else { sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,570, "%s: Submitted from host <%s>")), /* catgets 570 */ timestr, job->fromHost); } FREEUP(timestr); prtLine(prline); if (job->submit.options2 & SUB2_HOLD) { sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,570, " with hold"))); /* catgets 570 */ prtLine(prline); } if (prt_q) { sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,571, ", to Queue <%s>")), job->submit.queue); /* catgets 571 */ prtLine(prline); } TIMEIT(2, prtBTTime(job), "prtBTTime"); }
static void displayShareRes(int argc, char **argv, int index) { struct lsbSharedResourceInfo *lsbResourceInfo; int numRes = 0; char **resourceNames = NULL, **resources = NULL; char fname[]="displayShareRes"; if (argc > index) { if ((resourceNames = (char **) malloc ((argc - index) * sizeof (char *))) == NULL) { char i18nBuf[100]; sprintf ( i18nBuf,I18N_FUNC_FAIL,fname,"malloc"); perror( i18nBuf ); exit (-1); } numRes = getResourceNames (argc, argv, index, resourceNames); } if (numRes > 0) resources = resourceNames; TIMEIT(0, (lsbResourceInfo = lsb_sharedresourceinfo (resources, &numRes, NULL, 0)), "lsb_sharedresourceinfo"); if (lsbResourceInfo == NULL) { if (lsberrno == LSBE_BAD_RESOURCE && resources) lsb_perror(NULL); else lsb_perror("lsb_sharedresourceinfo"); exit(-1); } prtResourcesShort(numRes, lsbResourceInfo); FREEUP(resourceNames); }
struct loadIndexLog * initLoadIndex(void) { int i; struct lsInfo *lsInfo; static struct loadIndexLog loadIndex; static char *defNames[] = {"r15s", "r1m", "r15m", "ut", "pg", "io", "ls", "it", "swp", "mem", "tmp"}; static char **names; TIMEIT(1, (lsInfo = ls_info()), "ls_info"); if (lsInfo == NULL) { loadIndex.nIdx = 11; loadIndex.name = defNames; } else { loadIndex.nIdx = lsInfo->nRes; if (!names) if(!(names = malloc(lsInfo->nRes * sizeof(char *)))) { lserrno=LSE_MALLOC; ls_perror("initLoadIndex"); return NULL; } for (i = 0; i < loadIndex.nIdx; i++) names[i] = lsInfo->resTable[i].name; loadIndex.name = names; } return (&loadIndex); }
int main (int argc, char **argv) { char *name; int cc; if (ls_initdebug (argv[0]) < 0) { ls_perror ("ls_initdebug"); return -1; } while ((cc = getopt (argc, argv, "hV")) != EOF) { switch (cc) { case 'h': usage (argv[0]); return 0; case 'V': fputs (_LS_VERSION_, stderr); return 0; default: usage (argv[0]); return -1; } } puts (_LS_VERSION_); TIMEIT (0, (name = ls_getclustername ()), "ls_getclustername"); if (name == NULL) { ls_perror ("ls_getclustername()"); return -1; } printf ("My cluster name is %s\n", name); TIMEIT (0, (name = ls_getmastername ()), "ls_getmastername"); if (name == NULL) { ls_perror ("ls_getmastername()"); return -1; } printf ("My master name is %s\n", name); return 0; }
int do_sub (int argc, char **argv, int option) { static char fname[] = "do_sub"; struct submit req; struct submitReply reply; LS_LONG_INT jobId = -1; if (lsb_init (argv[0]) < 0) { sub_perror ("lsb_init"); fprintf (stderr, ". %s.\n", (_i18n_msg_get (ls_catd, NL_SETN, 1551, "Job not submitted"))); /* catgets 1551 */ return (-1); } if (logclass & (LC_TRACE | LC_SCHED | LC_EXEC)) ls_syslog (LOG_DEBUG, "%s: Entering this routine...", fname); if (fillReq (argc, argv, option, &req) < 0) { fprintf (stderr, ". %s.\n", (_i18n_msg_get (ls_catd, NL_SETN, 1551, "Job not submitted"))); return (-1); } memset (&reply, 0, sizeof (struct submitReply)); TIMEIT (0, (jobId = lsb_submit (&req, &reply)), "lsb_submit"); if (jobId < 0) { prtErrMsg (&req, &reply); fprintf (stderr, ". %s.\n", (_i18n_msg_get (ls_catd, NL_SETN, 1551, "Job not submitted"))); return (-1); } if (req.nxf) free (req.xf); return (0); }
int getJobIds (int argc, char **argv, char *jobName, char *user, char *queue, char *host, LS_LONG_INT ** jobIds0, int extOption) { int numJobIds = 0; int options = LAST_JOB; struct jobInfoHead *jobInfoHead; if (extOption) { options = extOption; } numJobIds = getSpecJobIds (argc, argv, jobIds0, &options); if (extOption & ZOMBIE_JOB) { options |= ZOMBIE_JOB; } if (numJobIds != 0) return (numJobIds); if (strstr (argv[0], "bmig")) { options &= ~CUR_JOB; options |= (RUN_JOB | SUSP_JOB); } if (strstr (argv[0], "brequeue")) { options = 0; options = extOption; } options |= JOBID_ONLY; if (options & DONE_JOB) { options &= ~JOBID_ONLY; } TIMEIT (0, (jobInfoHead = lsb_openjobinfo_a ((LS_LONG_INT) 0, jobName, user, queue, host, options)), "lsb_openjobinfo"); if (jobInfoHead == NULL) { jobInfoErr (0, jobName, user, queue, host, options); exit (-1); } TIMEIT (0, lsb_closejobinfo (), "lsb_closejobinfo"); *jobIds0 = jobInfoHead->jobIds; return (jobInfoHead->numJobs); }
void displayShareResource (int argc, char **argv, int index, int flag, int extflag) { int i, j, k, numRes = 0; struct lsSharedResourceInfo *lsResourceInfo; struct lsInfo *lsInfo; char **resources = NULL, **resourceNames = NULL; int firstFlag = 1; if ((lsInfo = ls_info ()) == NULL) { ls_perror ("lsinfo"); exit (-10); } if (argc > index) { if ((resourceNames = (char **) malloc ((argc - index) * sizeof (char *))) == NULL) { lserrno = LSE_MALLOC; ls_perror ("lshosts"); exit (-1); } numRes = getResourceNames (argc, argv, index, resourceNames); } if (numRes > 0) resources = resourceNames; TIMEIT (0, (lsResourceInfo = ls_sharedresourceinfo (resources, &numRes, NULL, 0)), "ls_sharedresourceinfo"); if (lsResourceInfo == NULL) { ls_perror ("ls_sharedresourceinfo"); exit (-1); } for (k = 0; k < numRes; k++) { for (i = 0; i < lsResourceInfo[k].nInstances; i++) { for (j = 0; j < lsInfo->nRes; j++) { if (!extflag) if (lsInfo->resTable[j].flags & RESF_EXTERNAL) continue; if (strcmp (lsInfo->resTable[j].name, lsResourceInfo[k].resourceName) == 0) { if (flag == TRUE) { if (!(lsInfo->resTable[j].flags & RESF_DYNAMIC)) { if (firstFlag) { firstFlag = 0; prtTableHeader (); } prtOneInstance (lsResourceInfo[k].resourceName, &(lsResourceInfo[k].instances[i])); } } else { if (lsInfo->resTable[j].flags & RESF_DYNAMIC) { if (firstFlag) { firstFlag = 0; prtTableHeader (); } prtOneInstance (lsResourceInfo[k].resourceName, &(lsResourceInfo[k].instances[i])); } } } } } } if (firstFlag) { if (flag) printf (_i18n_msg_get (ls_catd, NL_SETN, 753, "No static shared resources defined \n")); /* catgets 753 */ else printf (_i18n_msg_get (ls_catd, NL_SETN, 754, "No dynamic shared resources defined \n")); /* catgets 754 */ } FREEUP (resourceNames); }
static int makeShare (char *hostname, char ***nameTable, char ***valueTable, char ***formatTable, int (*resourceSelect) (struct resItem *)) { static int first = TRUE; static struct lsSharedResourceInfo *resourceInfo; static struct lsInfo *lsInfo; static char **namTable; static char **valTable; static char **fmtTable; static int numRes, nRes; int k, i, j; char *hPtr; int ii, numHosts, found; if (first == TRUE) { if ((lsInfo = ls_info ()) == NULL) { return (-1); } TIMEIT (0, (resourceInfo = ls_sharedresourceinfo (NULL, &numRes, NULL, 0)), "ls_sharedresourceinfo"); if (resourceInfo == NULL) { return (-1); } if ((namTable = (char **) malloc (numRes * sizeof (char *))) == NULL) { lserrno = LSE_MALLOC; return (-1); } if ((valTable = (char **) malloc (numRes * sizeof (char *))) == NULL) { lserrno = LSE_MALLOC; return (-1); } if ((fmtTable = (char **) malloc (numRes * sizeof (char *))) == NULL) { lserrno = LSE_MALLOC; return (-1); } first = FALSE; } else { for (i = 0; i < nRes; i++) { FREEUP (fmtTable[i]); } } nRes = 0; for (k = 0; k < numRes; k++) { found = FALSE; for (j = 0; j < lsInfo->nRes; j++) { if (strcmp (lsInfo->resTable[j].name, resourceInfo[k].resourceName) == 0) { if (resourceSelect (&lsInfo->resTable[j])) { found = TRUE; break; } break; } } if (!found) { continue; } namTable[nRes] = resourceInfo[k].resourceName; found = FALSE; for (i = 0; i < resourceInfo[k].nInstances; i++) { numHosts = resourceInfo[k].instances[i].nHosts; for (ii = 0; ii < numHosts; ii++) { hPtr = resourceInfo[k].instances[i].hostList[ii]; if (strcmp (hPtr, hostname) == 0) { valTable[nRes] = resourceInfo[k].instances[i].value; found = TRUE; break; } } if (found) { break; } } if (!found) { valTable[nRes] = "-"; } nRes++; } if (nRes) { j = 0; for (i = 0; i < nRes; i++) { char fmt[16]; int nameLen; nameLen = strlen (namTable[i]); sprintf (fmt, "%s%d.%d%s", "%", nameLen + 2, nameLen + 1, "s"); fmtTable[j++] = putstr_ (fmt); } } *nameTable = namTable; *valueTable = valTable; *formatTable = fmtTable; return (nRes); }
static void print_long(struct hostInfo *hostInfo) { int i; float *li; char *sp; static char first = TRUE; static char line[132]; static char newFmt[10]; int newIndexLen, retVal; static char **indxnames; char **shareNames, **shareValues, **formats; char strbuf1[30],strbuf2[30],strbuf3[30]; if (first) { char tmpbuf[MAXLSFNAMELEN]; int fmtid; if(!(fmt=(struct indexFmt *) malloc((hostInfo->numIndx+2)*sizeof (struct indexFmt)))) { lserrno=LSE_MALLOC; ls_perror("print_long"); exit(-1); } for (i=0; i<NBUILTINDEX+2; i++) fmt[i]=fmt1[i]; TIMEIT(0, (indxnames = ls_indexnames(NULL)), "ls_indexnames"); if (indxnames == NULL) { ls_perror("ls_indexnames"); exit(-1); } for(i=0; indxnames[i]; i++) { if (i > MEM) fmtid = MEM + 1; else fmtid = i; if ((fmtid == MEM +1) && (newIndexLen = strlen(indxnames[i])) >= 7) { sprintf(newFmt, "%s%d%s", "%", newIndexLen+1, "s"); sprintf(tmpbuf, newFmt, indxnames[i]); } else sprintf(tmpbuf, fmt[fmtid].hdr, indxnames[i]); strcat(line, tmpbuf); } first = FALSE; } printf("\n%s: %s\n", _i18n_msg_get(ls_catd,NL_SETN, 1601, "HOST_NAME"), /* catgets 1601 */ hostInfo->hostName); { char *buf1, *buf2, *buf3, *buf4, *buf5, *buf6, *buf7, *buf8, *buf9, *buf10; buf1 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1602, "type")); /* catgets 1602 */ buf2 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1603, "model")); /* catgets 1603 */ buf3 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1604, "cpuf")); /* catgets 1604 */ buf4 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1605, "ncpus")); /* catgets 1605 */ buf5 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1606, "ndisks")); /* catgets 1606 */ buf6 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1607, "maxmem")); /* catgets 1607 */ buf7 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1608, "maxswp")); /* catgets 1608 */ buf8 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1609, "maxtmp")); /* catgets 1609 */ buf9 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1610, "rexpri")); /* catgets 1610 */ buf10= putstr_(_i18n_msg_get(ls_catd,NL_SETN,1611, "server")); /* catgets 1611 */ printf("%-10.10s %11.11s %5.5s %5.5s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s\n", buf1, buf2, buf3, buf4, buf5, buf6, buf7, buf8, buf9, buf10); FREEUP(buf1); FREEUP(buf2); FREEUP(buf3); FREEUP(buf4); FREEUP(buf5); FREEUP(buf6); FREEUP(buf7); FREEUP(buf8); FREEUP(buf9); FREEUP(buf10); } if (hostInfo->isServer) { sprintf(strbuf1,"%-10s",hostInfo->hostType);strbuf1[10]='\0'; sprintf(strbuf2,"%11s",hostInfo->hostModel);strbuf2[11]='\0'; sprintf(strbuf3,"%5.1f",hostInfo->cpuFactor);strbuf3[5]='\0'; printf("%-10s %11s %5s ",strbuf1,strbuf2,strbuf3); if (hostInfo->maxCpus > 0) printf("%5d %6d %5dM %5dM %5dM %6d %6s\n", hostInfo->maxCpus, hostInfo->nDisks, hostInfo->maxMem, hostInfo->maxSwap, hostInfo->maxTmp, hostInfo->rexPriority, I18N_Yes); else printf("%5s %6s %6s %6s %6s %6d %6s\n", "-", "-", "-", "-", "-", hostInfo->rexPriority, I18N_Yes); /* catgets 1612 */ } else { sprintf(strbuf1,"%-10s",hostInfo->hostType);strbuf1[10]='\0'; sprintf(strbuf2,"%11s",hostInfo->hostModel);strbuf2[11]='\0'; sprintf(strbuf3,"%5.1f",hostInfo->cpuFactor);strbuf3[5]='\0'; printf("%-10s %11s %5s ",strbuf1,strbuf2,strbuf3); printf("%5s %6s %6s %6s %6s %6s %6s\n", "-", "-", "-", "-", "-", "-", I18N_No); /* catgets 1613 */ } if (sharedResConfigured_ == TRUE) { if ((retVal = makeShareField(hostInfo->hostName, TRUE, &shareNames, &shareValues, &formats)) > 0) { for (i = 0; i < retVal; i++) { printf(formats[i], shareNames[i]); } printf("\n"); for (i = 0; i < retVal; i++) { printf(formats[i], shareValues[i]); } printf("\n"); } } printf("\n"); printf("%s: ", _i18n_msg_get(ls_catd,NL_SETN,1614, "RESOURCES")); /* catgets 1614 */ if (hostInfo->nRes) { int first = TRUE; for (i=0; i < hostInfo->nRes; i++) { if (! first) printf(" "); else printf("("); printf("%s", hostInfo->resources[i]); first = FALSE; } printf(")\n"); } else { printf("%s\n", _i18n_msg_get(ls_catd,NL_SETN,1615, "Not defined")); /* catgets 1615 */ } printf("%s: ", _i18n_msg_get(ls_catd,NL_SETN,1616, "RUN_WINDOWS")); /* catgets 1616 */ if (hostInfo->isServer) { if (strcmp(hostInfo->windows, "-") == 0) fputs( _i18n_msg_get(ls_catd,NL_SETN,1617, " (always open)\n"), /* catgets 1617 */ stdout); else printf("%s\n", hostInfo->windows); } else { printf(_i18n_msg_get(ls_catd,NL_SETN,1618, "Not applicable for client-only host\n")); /* catgets 1618 */ } if (! hostInfo->isServer) { printf("\n"); return; } printf("\n"); printf(_i18n_msg_get(ls_catd,NL_SETN,1626, "LOAD_THRESHOLDS:")); /* catgets 1626 */ printf("\n%s\n",line); li = hostInfo->busyThreshold; for(i=0; indxnames[i]; i++) { char tmpfield[MAXLSFNAMELEN]; int id; if (i > MEM) id = MEM + 1; else id = i; if (fabs(li[i]) >= (double) INFINIT_LOAD) sp = "-"; else { sprintf(tmpfield, fmt[id].ok, li[i] * fmt[id].scale); sp = stripSpaces(tmpfield); } if ((id == MEM + 1) && (newIndexLen = strlen (indxnames[i])) >= 7 ){ sprintf(newFmt, "%s%d%s", "%", newIndexLen+1, "s"); printf(newFmt, sp); } else printf(fmt[id].hdr, sp); } printf("\n"); }
static void show_timings(void) { v_f = 1+(hal.scheduler->micros() % 5); v_out = 1+(hal.scheduler->micros() % 3); v_32 = 1+(hal.scheduler->micros() % 5); v_out_32 = 1+(hal.scheduler->micros() % 3); v_16 = 1+(hal.scheduler->micros() % 5); v_out_16 = 1+(hal.scheduler->micros() % 3); v_8 = 1+(hal.scheduler->micros() % 5); v_out_8 = 1+(hal.scheduler->micros() % 3); hal.console->println("Operation timings:"); hal.console->println("Note: timings for some operations are very data dependent"); TIMEIT("nop", asm volatile("nop"::), 255); TIMEIT("micros()", hal.scheduler->micros(), 200); TIMEIT("millis()", hal.scheduler->millis(), 200); TIMEIT("fadd", v_out += v_f, 100); TIMEIT("fsub", v_out -= v_f, 100); TIMEIT("fmul", v_out *= v_f, 100); TIMEIT("fdiv /=", v_out /= v_f, 100); TIMEIT("fdiv 2/x", v_out = 2.0f/v_f, 100); TIMEIT("dadd", v_out_d += v_d, 100); TIMEIT("dsub", v_out_d -= v_d, 100); TIMEIT("dmul", v_out_d *= v_d, 100); TIMEIT("ddiv", v_out_d /= v_d, 100); TIMEIT("sin()", v_out = sinf(v_f), 20); TIMEIT("cos()", v_out = cosf(v_f), 20); TIMEIT("tan()", v_out = tanf(v_f), 20); TIMEIT("acos()", v_out = acosf(v_f * 0.2), 20); TIMEIT("asin()", v_out = asinf(v_f * 0.2), 20); TIMEIT("atan2()", v_out = atan2f(v_f * 0.2, v_f * 0.3), 20); TIMEIT("sqrt()",v_out = sqrtf(v_f), 20); TIMEIT("iadd8", v_out_8 += v_8, 100); TIMEIT("isub8", v_out_8 -= v_8, 100); TIMEIT("imul8", v_out_8 *= v_8, 100); TIMEIT("idiv8", v_out_8 /= v_8, 100); TIMEIT("iadd16", v_out_16 += v_16, 100); TIMEIT("isub16", v_out_16 -= v_16, 100); TIMEIT("imul16", v_out_16 *= v_16, 100); TIMEIT("idiv16", v_out_16 /= v_16, 100); TIMEIT("iadd32", v_out_32 += v_32, 100); TIMEIT("isub32", v_out_32 -= v_32, 100); TIMEIT("imul32", v_out_32 *= v_32, 100); TIMEIT("idiv32", v_out_32 /= v_32, 100); TIMEIT("iadd64", v_out_64 += v_64, 100); TIMEIT("isub64", v_out_64 -= v_64, 100); TIMEIT("imul64", v_out_64 *= v_64, 100); TIMEIT("idiv64", v_out_64 /= v_64, 100); TIMEIT("memcpy128", memcpy((void*)mbuf1, (const void *)mbuf2, sizeof(mbuf1)), 20); TIMEIT("memset128", memset((void*)mbuf1, 1, sizeof(mbuf1)), 20); TIMEIT("delay(1)", hal.scheduler->delay(1), 5); }
static int makeShareFields(char *hostname, struct lsInfo *lsInfo, char ***nameTable, char ***totalValues, char ***rsvValues, char ***formatTable) { static int first = TRUE; static struct lsbSharedResourceInfo *resourceInfo; static char **namTable; static char **totalTable; static char **rsvTable; static char **fmtTable; static int numRes, nRes; int k, i, j; char *hPtr; int ii, numHosts, found; if (first == TRUE) { TIMEIT(0, (resourceInfo = lsb_sharedresourceinfo (NULL, &numRes, NULL, 0)), "ls_sharedresourceinfo"); if (resourceInfo == NULL) { return (-1); } if ((namTable = (char **) malloc (numRes * sizeof(char *))) == NULL){ lserrno = LSE_MALLOC; return (-1); } if ((totalTable = (char **) malloc (numRes * sizeof(char *))) == NULL){ lserrno = LSE_MALLOC; return (-1); } if ((rsvTable = (char **) malloc (numRes * sizeof(char *))) == NULL){ lserrno = LSE_MALLOC; return (-1); } if ((fmtTable = (char **) malloc (numRes * sizeof(char *))) == NULL){ lserrno = LSE_MALLOC; return (-1); } first = FALSE; } else { for (i = 0; i < nRes; i++) { FREEUP(fmtTable[i]); } } nRes = 0; for (k = 0; k < numRes; k++) { found = FALSE; for (j = 0; j < lsInfo->nRes; j++) { if (strcmp(lsInfo->resTable[j].name, resourceInfo[k].resourceName) == 0) { if ((lsInfo->resTable[j].flags & RESF_SHARED) && (lsInfo->resTable[j].valueType & LS_NUMERIC)) { found = TRUE; break; } break; } } if (!found) { continue; } namTable[nRes] = resourceInfo[k].resourceName; found = FALSE; for (i = 0; i < resourceInfo[k].nInstances; i++) { numHosts = resourceInfo[k].instances[i].nHosts; for (ii = 0; ii < numHosts; ii++) { hPtr = resourceInfo[k].instances[i].hostList[ii]; if (strcmp(hPtr, hostname) == 0) { totalTable[nRes] = resourceInfo[k].instances[i].totalValue; rsvTable[nRes] = resourceInfo[k].instances[i].rsvValue; found = TRUE; break; } } if (found == TRUE) { break; } } if (found == FALSE) { totalTable[nRes] = "-"; rsvTable[nRes] = "-"; } nRes++; } if (nRes) { j = 0; for (i = 0; i < nRes; i++) { char fmt[16]; int lens, tmplens; lens = strlen( namTable[i] ); tmplens = strlen( stripSpaces(totalTable[i]) ); if( lens < tmplens ) lens = tmplens; tmplens = strlen( stripSpaces(rsvTable[i]) ); if( lens < tmplens ) lens = tmplens; sprintf(fmt, "%s%ld%s", "%", (long)(lens + 1), "s"); fmtTable[j++] = putstr_(fmt); } } *nameTable = namTable; *totalValues = totalTable; *rsvValues = rsvTable; *formatTable = fmtTable; return (nRes); }
struct jobInfoHead * lsb_openjobinfo_a (LS_LONG_INT jobId, char *jobName, char *userName, char *queueName, char *hostName, int options) { static int first = TRUE; static struct jobInfoReq jobInfoReq; static struct jobInfoHead jobInfoHead; mbdReqType mbdReqtype; XDR xdrs, xdrs2; char request_buf[MSGSIZE]; char *reply_buf, *clusterName = NULL; int cc, aa; struct LSFHeader hdr; char lsfUserName[MAXLINELEN]; if (first) { if ( !(jobInfoReq.jobName = (char *) malloc(MAX_CMD_DESC_LEN)) || !(jobInfoReq.queue = (char *) malloc(MAX_LSB_NAME_LEN)) || !(jobInfoReq.userName = (char *) malloc(MAX_LSB_NAME_LEN)) || !(jobInfoReq.host = (char *) malloc(MAXHOSTNAMELEN))) { lsberrno = LSBE_SYS_CALL; return(NULL); } first = FALSE; } if (queueName == NULL) jobInfoReq.queue[0] = '\0'; else { if (strlen (queueName) >= MAX_LSB_NAME_LEN - 1) { lsberrno = LSBE_BAD_QUEUE; return(NULL); } TIMEIT(1, strcpy(jobInfoReq.queue, queueName), "strcpy"); } if (hostName == NULL) jobInfoReq.host[0] = '\0'; else { if (ls_isclustername(hostName) > 0) { jobInfoReq.host[0] = '\0'; clusterName = hostName; } else { struct hostent *hp; TIMEIT(0, (hp = Gethostbyname_(hostName)), "getHostOfficialByName_"); if (hp != NULL) { struct hostInfo *hostinfo; char officialNameBuf[MAXHOSTNAMELEN]; strcpy(officialNameBuf, hp->h_name); hostinfo = ls_gethostinfo("-", NULL, (char **)&hp->h_name, 1, LOCAL_ONLY); if (hostinfo == NULL) { strcpy(jobInfoReq.host, hostName); } else { strcpy(jobInfoReq.host, officialNameBuf); } } else { if (strlen (hostName) >= MAXHOSTNAMELEN - 1) { lsberrno = LSBE_BAD_HOST; return(NULL); } strcpy(jobInfoReq.host, hostName); } } } if (jobName == NULL) jobInfoReq.jobName[0] = '\0'; else { if (strlen (jobName) >= MAX_CMD_DESC_LEN - 1) { lsberrno = LSBE_BAD_JOB; return(NULL); } strcpy(jobInfoReq.jobName, jobName); } if (userName == NULL ) { TIMEIT(0, (cc = getLSFUser_(lsfUserName, MAXLINELEN)), "getLSFUser_"); if (cc != 0) { return (NULL); } TIMEIT(1, strcpy(jobInfoReq.userName, lsfUserName), "strcpy"); } else { if (strlen (userName) >= MAX_LSB_NAME_LEN - 1) { lsberrno = LSBE_BAD_USER; return(NULL); } strcpy(jobInfoReq.userName, userName); } if ((options & ~(JOBID_ONLY | JOBID_ONLY_ALL | HOST_NAME | NO_PEND_REASONS)) == 0) jobInfoReq.options = CUR_JOB; else jobInfoReq.options = options; if (jobId < 0) { lsberrno = LSBE_BAD_ARG; return(NULL); } jobInfoReq.jobId = jobId; mbdReqtype = BATCH_JOB_INFO; xdrmem_create(&xdrs, request_buf, MSGSIZE, XDR_ENCODE); hdr.opCode = mbdReqtype; TIMEIT(1, (aa = xdr_encodeMsg(&xdrs, (char *) &jobInfoReq , &hdr, xdr_jobInfoReq, 0, NULL)), "xdr_encodeMsg"); if (aa == FALSE) { lsberrno = LSBE_XDR; return(NULL); } TIMEIT(0, (cc = callmbd (clusterName, request_buf, XDR_GETPOS(&xdrs), &reply_buf, &hdr, &mbdSock, NULL, NULL)), "callmbd"); if (cc == -1) { xdr_destroy(&xdrs); return (NULL); } xdr_destroy(&xdrs); lsberrno = hdr.opCode; if (lsberrno == LSBE_NO_ERROR) { xdrmem_create(&xdrs2, reply_buf, XDR_DECODE_SIZE_(cc), XDR_DECODE); if (! xdr_jobInfoHead (&xdrs2, &jobInfoHead, &hdr)) { lsberrno = LSBE_XDR; xdr_destroy(&xdrs2); if (cc) free(reply_buf); return(NULL); } xdr_destroy(&xdrs2); if (cc) free(reply_buf); return (&jobInfoHead); } if (cc) free(reply_buf); return(NULL); }
int main (int argc, char **argv) { int i, cc, local = FALSE; struct hostInfoEnt *hInfo; char **hosts=NULL, **hostPoint, *resReq = NULL; char lflag = FALSE, sOption = FALSE, otherOption = FALSE; int numHosts; int rc; _lsb_recvtimeout = 30; rc = _i18n_init ( I18N_CAT_MIN ); if (lsb_init(argv[0]) < 0) { lsb_perror("lsb_init"); _i18n_end ( ls_catd ); exit(-1); } for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-h") == 0) { usage(argv[0]); _i18n_end ( ls_catd ); exit (0); } else if (strcmp(argv[i], "-V") == 0) { fputs(_LS_VERSION_, stderr); _i18n_end ( ls_catd ); exit(0); } else if (strcmp(argv[i], "-s") == 0) { if (otherOption == TRUE) { usage(argv[0]); _i18n_end ( ls_catd ); exit(-1); } sOption = TRUE; optind = i + 1; } else if (strcmp(argv[i], "-R") == 0 || strcmp(argv[i], "-l") == 0 || strcmp(argv[i], "-w") == 0) { otherOption = TRUE; if (sOption == TRUE) { usage(argv[0]); _i18n_end ( ls_catd ); exit(-1); } } } if (sOption) { displayShareRes(argc, argv, optind); return (0); } while ((cc = getopt(argc, argv, "lwR:")) != EOF) { switch (cc) { case 'l': lflag = TRUE; if (wflag) usage(argv[0]); break; case 'w': wflag = TRUE; if (lflag) usage(argv[0]); break; case 'R': resReq = optarg; break; default: usage(argv[0]); } } numHosts = getNames (argc, argv, optind, &hosts, &local, "host"); if ((local && numHosts == 1) || !numHosts) hostPoint = NULL; else hostPoint = hosts; TIMEIT(0, (hInfo = lsb_hostinfo_ex(hostPoint, &numHosts, resReq, 0)), "lsb_hostinfo"); if (!hInfo) { if (lsberrno == LSBE_BAD_HOST && hostPoint) lsb_perror (hosts[numHosts]); else lsb_perror (NULL); exit (-1); } if (numHosts > 1 && resReq == NULL) sort_host (numHosts, hInfo); if ( lflag ) prtHostsLong(numHosts, hInfo); else prtHostsShort(numHosts, hInfo); _i18n_end ( ls_catd ); exit(0); }
void displayLong(struct jobInfoEnt *job, struct jobInfoHead *jInfoH, float cpuFactor) { char *hostPtr, *sp; char hostName[MAXHOSTNAMELEN]; float hostFactor, *getFactor; static int first = TRUE; static struct lsInfo *lsInfo; char prline[MAXLINELEN]; if (first) { first = FALSE; TIMEIT(0, (lsInfo = ls_info()), "ls_info"); if (lsInfo == NULL) { ls_perror("ls_info"); exit(-1); } } prtHeader(job, TRUE, FALSE); prtJobSubmit(job, FALSE, FALSE); TIMEIT(1, prtFileNames(job, TRUE), "prtFileNames"); hostPtr = job->submit.hostSpec; hostFactor = 1.0; if (job->numExHosts > 0 && (strcmp (job->exHosts[0], LOST_AND_FOUND) != 0) && !IS_PEND (job->status)) { strcpy (hostName, job->exHosts[0]); if ((sp = strstr (hostName, "@")) != NULL) { *sp = '\0'; if (strcmp(hostName, hostPtr) == 0) { if ((getFactor=getCpuFactor(hostName, TRUE)) == NULL) { prtLine("\n"); fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,1451, "Cannot obtain execution host information: %s\n")), ls_errmsg[lserrno]); exit(-1); } else { hostFactor = *getFactor; hostPtr = job->exHosts[0]; } } } } TIMEIT(1, prtSubDetails(job, hostPtr, hostFactor), "prtSubDetails"); if (job->numExHosts > 0 && job->reserveTime > 0) { TIMEIT(1, prtJobReserv(job), "prtJobReserv"); sprintf(prline, ";\n"); prtLine(prline); } if (job->predictedStartTime && IS_PEND(job->status)) { char localTimeStr[60]; strcpy ( localTimeStr, _i18n_ctime(ls_catd, CTIME_FORMAT_a_b_d_T, &job->predictedStartTime)); sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,1466, "%s: Will be started;\n")), /* catgets 1466 */ localTimeStr ); prtLine(prline); } if (job->startTime && !IS_PEND(job->status)) { TIMEIT(1, prtJobStart(job, BJOBS_PRINT, job->jobPid, FALSE), "prtJobStart"); } if ((cpuFactor > 0.0) && (job->cpuTime > 0)) job->cpuTime = job->cpuTime * hostFactor / cpuFactor; if (job->jType == JGRP_NODE_ARRAY) { printf("\n %s:\n", _i18n_msg_get(ls_catd,NL_SETN,1467, "COUNTERS")); /* catgets 1467 */ printf( (_i18n_msg_get(ls_catd,NL_SETN,1468, " NJOBS PEND DONE RUN EXIT SSUSP USUSP PSUSP\n"))); /* catgets 1468 */ printf(" %5d %4d %3d %4d %4d %5d %5d %5d\n", job->counter[JGRP_COUNT_NJOBS], job->counter[JGRP_COUNT_PEND], job->counter[JGRP_COUNT_NDONE], job->counter[JGRP_COUNT_NRUN], job->counter[JGRP_COUNT_NEXIT], job->counter[JGRP_COUNT_NSSUSP], job->counter[JGRP_COUNT_NUSUSP], job->counter[JGRP_COUNT_NPSUSP]); return; } TIMEIT(1, prtJobFinish(job, jInfoH), "prtJobFinish"); if (lsbMode_ & LSB_MODE_BATCH) { sprintf(prline, "\n %s:\n", _i18n_msg_get(ls_catd,NL_SETN,1469, "SCHEDULING PARAMETERS")); /* catgets 1469 */ prtLine(prline); if (printThresholds (job->loadSched, job->loadStop, NULL, NULL, job->nIdx, lsInfo) < 0) exit (-1); } return; }
struct jobInfoEnt * lsb_readjobinfo(int *more) { XDR xdrs; int num, i, aa; struct LSFHeader hdr; char *buffer = NULL; static struct jobInfoReply jobInfoReply; static struct jobInfoEnt jobInfo; static struct submitReq submitReq; static int first = TRUE; static int npids = 0; static struct pidInfo *pidInfo = NULL; static int npgids = 0; static int *pgid = NULL; TIMEIT(0, (num = readNextPacket(&buffer, _lsb_recvtimeout, &hdr, mbdSock)), "readNextPacket"); if (num < 0) { closeSession(mbdSock); lsberrno = LSBE_EOF; return NULL; } if (first) { if ( (submitReq.fromHost = malloc(MAXHOSTNAMELEN)) == NULL || (submitReq.jobFile = malloc(MAXFILENAMELEN)) == NULL || (submitReq.inFile = malloc(MAXFILENAMELEN)) == NULL || (submitReq.outFile = malloc(MAXFILENAMELEN)) == NULL || (submitReq.errFile = malloc(MAXFILENAMELEN)) == NULL || (submitReq.inFileSpool = malloc(MAXFILENAMELEN)) == NULL || (submitReq.commandSpool = malloc(MAXFILENAMELEN)) == NULL || (submitReq.hostSpec = malloc(MAXHOSTNAMELEN)) == NULL || (submitReq.chkpntDir = malloc(MAXFILENAMELEN)) == NULL || (submitReq.subHomeDir = malloc(MAXFILENAMELEN)) == NULL || (jobInfoReply.userName = malloc(MAXLSFNAMELEN)) == NULL || (submitReq.cwd = malloc(MAXFILENAMELEN)) == NULL) { lsberrno = LSBE_NO_MEM; FREEUP(submitReq.fromHost); FREEUP(submitReq.jobFile); FREEUP(submitReq.inFile); FREEUP(submitReq.outFile); FREEUP(submitReq.errFile); FREEUP(submitReq.inFileSpool); FREEUP(submitReq.commandSpool); FREEUP(submitReq.hostSpec); FREEUP(submitReq.chkpntDir); FREEUP(submitReq.subHomeDir); FREEUP(jobInfoReply.userName); FREEUP(submitReq.cwd); free(buffer); return NULL; } submitReq.xf = NULL; submitReq.nxf = 0; jobInfoReply.numToHosts = 0; submitReq.numAskedHosts = 0; first = FALSE; } jobInfoReply.jobBill = &submitReq; if (jobInfoReply.numToHosts > 0) { for (i=0; i<jobInfoReply.numToHosts; i++) FREEUP(jobInfoReply.toHosts[i]); FREEUP(jobInfoReply.toHosts); jobInfoReply.numToHosts = 0; jobInfoReply.toHosts = NULL; } if (submitReq.xf) { free(submitReq.xf); submitReq.xf = NULL; } FREEUP( jobInfoReply.execHome ); FREEUP( jobInfoReply.execCwd ); FREEUP( jobInfoReply.execUsername ); FREEUP( jobInfoReply.parentGroup ); FREEUP( jobInfoReply.jName ); TIMEIT(1, xdrmem_create(&xdrs, buffer, XDR_DECODE_SIZE_(hdr.length), XDR_DECODE), "xdrmem_create"); TIMEIT(1, (aa = xdr_jobInfoReply(&xdrs, &jobInfoReply, &hdr)), "xdr_jobInfoReply"); if (aa == FALSE) { lsberrno = LSBE_XDR; xdr_destroy(&xdrs); free(buffer); jobInfoReply.toHosts = NULL; jobInfoReply.numToHosts = 0; return NULL; } TIMEIT(1, xdr_destroy(&xdrs), "xdr_destroy"); free(buffer); jobInfo.jobId = jobInfoReply.jobId; jobInfo.status = jobInfoReply.status; jobInfo.numReasons = jobInfoReply.numReasons; jobInfo.reasonTb = jobInfoReply.reasonTb; jobInfo.reasons = jobInfoReply.reasons; jobInfo.subreasons = jobInfoReply.subreasons; jobInfo.startTime = jobInfoReply.startTime; jobInfo.predictedStartTime = jobInfoReply.predictedStartTime; jobInfo.endTime = jobInfoReply.endTime; jobInfo.cpuTime = jobInfoReply.cpuTime; jobInfo.numExHosts = jobInfoReply.numToHosts; jobInfo.exHosts = jobInfoReply.toHosts; jobInfo.nIdx = jobInfoReply.nIdx; jobInfo.loadSched = jobInfoReply.loadSched; jobInfo.loadStop = jobInfoReply.loadStop; jobInfo.exitStatus = jobInfoReply.exitStatus; jobInfo.reserveTime = jobInfoReply.reserveTime; jobInfo.jobPid = jobInfoReply.jobPid; jobInfo.port = jobInfoReply.port; jobInfo.jobPriority = jobInfoReply.jobPriority; jobInfo.user = jobInfoReply.userName; jobInfo.execUid = jobInfoReply.execUid; jobInfo.execHome = jobInfoReply.execHome; jobInfo.execCwd = jobInfoReply.execCwd; jobInfo.execUsername = jobInfoReply.execUsername; jobInfo.jType = jobInfoReply.jType; jobInfo.parentGroup = jobInfoReply.parentGroup; jobInfo.jName = jobInfoReply.jName; for (i=0; i<NUM_JGRP_COUNTERS; i++) jobInfo.counter[i] = jobInfoReply.counter[i]; jobInfo.submitTime = jobInfoReply.jobBill->submitTime; jobInfo.umask = jobInfoReply.jobBill->umask; jobInfo.cwd = jobInfoReply.jobBill->cwd; jobInfo.subHomeDir = jobInfoReply.jobBill->subHomeDir; jobInfo.submit.options = jobInfoReply.jobBill->options; jobInfo.submit.options2 = jobInfoReply.jobBill->options2; jobInfo.submit.numProcessors = jobInfoReply.jobBill->numProcessors; jobInfo.submit.maxNumProcessors = jobInfoReply.jobBill->maxNumProcessors; jobInfo.submit.jobName = jobInfoReply.jobBill->jobName; jobInfo.submit.command = jobInfoReply.jobBill->command; jobInfo.submit.resReq = jobInfoReply.jobBill->resReq; jobInfo.submit.queue = jobInfoReply.jobBill->queue; jobInfo.fromHost = jobInfoReply.jobBill->fromHost; jobInfo.submit.inFile = jobInfoReply.jobBill->inFile; jobInfo.submit.outFile = jobInfoReply.jobBill->outFile; jobInfo.submit.errFile = jobInfoReply.jobBill->errFile; jobInfo.submit.beginTime = jobInfoReply.jobBill->beginTime; jobInfo.submit.termTime = jobInfoReply.jobBill->termTime; jobInfo.submit.userPriority = jobInfoReply.jobBill->userPriority; for (i=0; i<LSF_RLIM_NLIMITS; i++) { jobInfo.submit.rLimits[i] = jobInfoReply.jobBill->rLimits[i]; } jobInfo.submit.hostSpec = jobInfoReply.jobBill->hostSpec; jobInfo.submit.sigValue = jobInfoReply.jobBill->sigValue; jobInfo.submit.chkpntDir = jobInfoReply.jobBill->chkpntDir; jobInfo.submit.dependCond = jobInfoReply.jobBill->dependCond; jobInfo.submit.preExecCmd = jobInfoReply.jobBill->preExecCmd; jobInfo.submit.chkpntPeriod = jobInfoReply.jobBill->chkpntPeriod; jobInfo.submit.numAskedHosts = jobInfoReply.jobBill->numAskedHosts; jobInfo.submit.askedHosts = jobInfoReply.jobBill->askedHosts; jobInfo.submit.projectName = jobInfoReply.jobBill->projectName; jobInfo.submit.mailUser = jobInfoReply.jobBill->mailUser; jobInfo.submit.loginShell = jobInfoReply.jobBill->loginShell; jobInfo.submit.nxf = jobInfoReply.jobBill->nxf; jobInfo.submit.xf = jobInfoReply.jobBill->xf; jobInfo.jRusageUpdateTime = jobInfoReply.jRusageUpdateTime; jobInfo.runRusage.npids = npids; jobInfo.runRusage.pidInfo = pidInfo; jobInfo.runRusage.npgids = npgids; jobInfo.runRusage.pgid = pgid; copyJUsage(&(jobInfo.runRusage), &jobInfoReply.runRusage); npids = jobInfo.runRusage.npids; pidInfo = jobInfo.runRusage.pidInfo; npgids = jobInfo.runRusage.npgids; pgid = jobInfo.runRusage.pgid; if (jobInfoReply.runRusage.npids > 0) { FREEUP(jobInfoReply.runRusage.pidInfo); jobInfoReply.runRusage.npids = 0; } if (jobInfoReply.runRusage.npgids > 0) { FREEUP(jobInfoReply.runRusage.pgid); jobInfoReply.runRusage.npgids = 0; } if (more) *more = hdr.reserved; return &jobInfo; }
void prtJobFinish(struct jobInfoEnt *job, struct jobInfoHead *jInfoH) { char prline[MSGSIZE]; time_t doneTime; static struct loadIndexLog *loadIndex = NULL; char *pendReasons; if (loadIndex == NULL) TIMEIT(1, loadIndex = initLoadIndex(), "initLoadIndex"); doneTime = job->endTime; switch (job->status) { case JOB_STAT_DONE: case (JOB_STAT_DONE | JOB_STAT_PDONE): case (JOB_STAT_DONE | JOB_STAT_PERR): if ((job->startTime < job->submitTime) && (job->endTime < (job->submitTime + (time_t) MAX(job->cpuTime, MIN_CPU_TIME)))) { doneTime = job->submitTime + (time_t) MAX(job->cpuTime, 0.0001); } else if (job->startTime >= job->submitTime && job->endTime < (job->startTime + (time_t)MAX(job->cpuTime, 0.0001)) && job->numExHosts == 1) { doneTime = job->startTime + (time_t) MAX(job->cpuTime, 0.0001); if (job->endTime <= doneTime) { doneTime = job->endTime; } } case (JOB_STAT_EXIT | JOB_STAT_PDONE): case (JOB_STAT_EXIT | JOB_STAT_PERR): case JOB_STAT_EXIT: if (job->reasons & EXIT_ZOMBIE) { sprintf(prline, "%s: ", _i18n_ctime(ls_catd, CTIME_FORMAT_a_b_d_T, &job->endTime)); prtLineWUF(prline); sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,623, "Termination request issued; the job will be killed once the host is ok;"))); /* catgets 623 */ prtLineWUF(prline); break; } sprintf(prline, "%s: ", _i18n_ctime(ls_catd, CTIME_FORMAT_a_b_d_T, &doneTime)); prtLineWUF(prline); if (strcmp(get_status(job), "DONE") == 0) { sprintf(prline, I18N(624, "Done successfully.")); /* catgets 624 */ } else { LS_WAIT_T wStatus; LS_STATUS(wStatus) = job->exitStatus; if (job->cpuTime >= MIN_CPU_TIME && job->exitStatus) { if (WEXITSTATUS(wStatus)) sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,626, "Exited with exit code %d.")), /* catgets 626 */ WEXITSTATUS(wStatus)); else sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,627, "Exited by signal %d.")), WTERMSIG(wStatus)); /* catgets 627 */ } else sprintf(prline, I18N_Exited); } prtLineWUF(prline); if (job->numExHosts > 0) { if (job->cpuTime < MIN_CPU_TIME) sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,629, " The CPU time used is unknown.\n"))); /* catgets 629 */ else sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,630, " The CPU time used is %1.1f seconds.\n")), /* catgets 630 */ job->cpuTime); } else { sprintf(prline, "\n"); } prtLineWUF(prline); break; case JOB_STAT_PSUSP: case JOB_STAT_PEND: sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,631, " PENDING REASONS:\n"))); /* catgets 631 */ prtLineWUF(prline); pendReasons = lsb_pendreason(job->numReasons, job->reasonTb, jInfoH, loadIndex); prtLineWUF(pendReasons); break; case JOB_STAT_SSUSP: case JOB_STAT_USUSP: TIMEIT(1, prtJobRusage(job), "prtJobRusage"); sprintf(prline, (_i18n_msg_get(ls_catd,NL_SETN,632, " SUSPENDING REASONS:\n"))); /* catgets 632 */ prtLineWUF(prline); if (job->reasons) { sprintf(prline, "%s", lsb_suspreason(job->reasons, job->subreasons, loadIndex)); prtLineWUF(prline); } break; case JOB_STAT_RUN: TIMEIT(1, prtJobRusage(job), "prtJobRusage"); break; default: break; } }
int main(int argc, char **argv) { static char fname[] = "lshosts/main"; char *namebufs[256]; struct hostInfo *hostinfo; int numhosts = 0; struct hostent *hp; int i, j; char *resReq = NULL; char longformat = FALSE; char longname = FALSE; char staticResource = FALSE, otherOption = FALSE; int extView = FALSE; int achar; int unknown; int options=0; int isClus; int rc; rc = _i18n_init ( I18N_CAT_MIN ); if (ls_initdebug(argv[0]) < 0) { ls_perror("ls_initdebug"); exit(-1); } if (logclass & (LC_TRACE)) ls_syslog(LOG_DEBUG, "%s: Entering this routine...", fname); for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-h") == 0) { usage(argv[0]); exit (0); } else if (strcmp(argv[i], "-V") == 0) { fputs(_LS_VERSION_, stderr); exit(0); } else if (strcmp(argv[i], "-s") == 0) { if (otherOption == TRUE) { usage(argv[0]); exit(-1); } staticResource = TRUE; optind = i + 1; } else if (strcmp(argv[i], "-e") == 0) { if (otherOption == TRUE || staticResource == FALSE) { usage(argv[0]); exit(-1); } optind = i + 1; extView = TRUE; } else if (strcmp(argv[i], "-R") == 0 || strcmp(argv[i], "-l") == 0 || strcmp(argv[i], "-w") == 0) { otherOption = TRUE; if (staticResource == TRUE) { usage(argv[0]); exit(-1); } } } if (staticResource == TRUE) { displayShareResource(argc, argv, optind, TRUE, extView ); } else { while ((achar = getopt(argc, argv, "R:lw")) != EOF) { switch (achar) { case 'R': if (strlen(optarg) > MAXLINELEN) { printf(" %s", I18N(1645, "The resource requirement string exceeds the maximum length of 512 characters. Specify a shorter resource requirement.\n")); /* catgets 1645 */ exit (-1); } resReq = optarg; break; case 'l': longformat = TRUE; break; case 'w': longname = TRUE; break; default: usage(argv[0]); exit(-1); } } i=0; unknown = 0; for ( ; optind < argc ; optind++) { if (strcmp(argv[optind],"allclusters") == 0) { options = ALL_CLUSTERS; i = 0; break; } if ( (isClus = ls_isclustername(argv[optind])) < 0 ) { fprintf(stderr, "lshosts: %s\n", ls_sysmsg()); unknown = 1; continue; } else if ((isClus == 0) && ((hp = Gethostbyname_(argv[optind])) == NULL)) { fprintf(stderr, "\ %s: gethostbyname() failed for host %s.\n", __func__, argv[optind]); unknown = 1; continue; } namebufs[i] = strdup(hp->h_name); if (namebufs[i] == NULL) { perror("strdup()"); exit(-1); } i++; } if (i == 0 && unknown == 1) exit(-1); if (i == 0) { TIMEIT(0, (hostinfo = ls_gethostinfo(resReq, &numhosts, NULL, 0, options)), "ls_gethostinfo"); if (hostinfo == NULL) { ls_perror("ls_gethostinfo()"); exit(-1); } } else { TIMEIT(0, (hostinfo = ls_gethostinfo(resReq, &numhosts, namebufs, i, 0)), "ls_gethostinfo"); if (hostinfo == NULL) { ls_perror("ls_gethostinfo"); exit(-1); } } if (!longformat && !longname) { char *buf1, *buf2, *buf3, *buf4, *buf5; char *buf6, *buf7, *buf8, *buf9; buf1 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1628, "HOST_NAME")); /* catgets 1628 */ buf2 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1602, "type")); /* catgets 1602 */ buf3 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1603, "model")); /* catgets 1603 */ buf4 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1604, "cpuf")); /* catgets 1604 */ buf5 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1605, "ncpus")); /* catgets 1605 */ buf6 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1607, "maxmem")); /* catgets 1607 */ buf7 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1608, "maxswp")); /* catgets 1608 */ buf8 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1611, "server")); /* catgets 1611 */ buf9 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1614, "RESOURCES")); /* catgets 1614 */ printf("%-11.11s %7.7s %8.8s %5.5s %5.5s %6.6s %6.6s %6.6s %9.9s\n", buf1, buf2, buf3, buf4, buf5, buf6, buf7, buf8, buf9); FREEUP(buf1); FREEUP(buf2); FREEUP(buf3); FREEUP(buf4); FREEUP(buf5); FREEUP(buf6); FREEUP(buf7); FREEUP(buf8); FREEUP(buf9); } else if (longname) { char *buf1, *buf2, *buf3, *buf4, *buf5; char *buf6, *buf7, *buf8, *buf9; buf1 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1628, "HOST_NAME")); /* catgets 1628 */ buf2 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1602, "type")); /* catgets 1602 */ buf3 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1603, "model")); /* catgets 1603 */ buf4 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1604, "cpuf")); /* catgets 1604 */ buf5 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1605, "ncpus")); /* catgets 1605 */ buf6 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1607, "maxmem")); /* catgets 1607 */ buf7 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1608, "maxswp")); /* catgets 1608 */ buf8 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1611, "server")); /* catgets 1611 */ buf9 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1614, "RESOURCES")); /* catgets 1614 */ printf("%-25.25s %10.10s %11.11s %5.5s %5.5s %6.6s %6.6s %6.6s %9.9s\n", buf1, buf2, buf3, buf4, buf5, buf6, buf7, buf8, buf9); FREEUP(buf1); FREEUP(buf2); FREEUP(buf3); FREEUP(buf4); FREEUP(buf5); FREEUP(buf6); FREEUP(buf7); FREEUP(buf8); FREEUP(buf9); } for (i=0;i<numhosts;i++) { char *server; int first; if (longformat) { print_long(&hostinfo[i]); continue; } if (hostinfo[i].isServer) server = I18N_Yes; else server = I18N_No; if(longname) printf("%-25s %10s %11s %5.1f ", hostinfo[i].hostName, hostinfo[i].hostType, hostinfo[i].hostModel, hostinfo[i].cpuFactor); else printf("%-11.11s %7.7s %8.8s %5.1f ", hostinfo[i].hostName, hostinfo[i].hostType, hostinfo[i].hostModel, hostinfo[i].cpuFactor); if (hostinfo[i].maxCpus > 0) printf("%5d",hostinfo[i].maxCpus); else printf("%5.5s", "-"); if (hostinfo[i].maxMem > 0) printf(" %5dM",hostinfo[i].maxMem); else printf(" %6.6s", "-"); if (hostinfo[i].maxSwap > 0) printf(" %5dM",hostinfo[i].maxSwap); else printf(" %6.6s", "-"); printf(" %6.6s", server); printf(" ("); first = TRUE; for (j=0; j<hostinfo[i].nRes; j++) { if (! first) printf(" "); printf("%s", hostinfo[i].resources[j]); first = FALSE; } fputs(")\n", stdout); } _i18n_end ( ls_catd ); exit(0); }
int main(int argc, char **argv) { int numQueues; char **queues; struct queueInfoEnt *queueInfo; char lflag = FALSE; int cc; char *host; char *user; numQueues = 0; user = host = NULL; if (lsb_init(argv[0]) < 0) { lsb_perror("lsb_init"); return -1; } while ((cc = getopt(argc, argv, "Vhlwm:u:")) != EOF) { switch (cc) { case 'l': lflag = TRUE; if (wflag) { usage(argv[0]); return -1; } break; case 'w': wflag = TRUE; if (lflag) { usage(argv[0]); return -1; } break; case 'm': if (host != NULL || *optarg == '\0') usage(argv[0]); host = optarg; break; case 'u': if (user != NULL || *optarg == '\0') usage(argv[0]); user = optarg; break; case 'V': fputs(_LS_VERSION_, stderr); return 0; case 'h': default: usage(argv[0]); return -1; } } queues = NULL; numQueues = 0; if (optind < argc) { numQueues = argc - optind; queues = calloc(argc - optind, sizeof(char *)); for (cc = 0; cc < argc - optind; cc++) queues[cc] = argv[optind + cc]; } TIMEIT(0, (queueInfo = lsb_queueinfo(queues, &numQueues, host, user, 0)), "lsb_queueinfo"); if (!queueInfo) { if (lsberrno == LSBE_BAD_QUEUE && queues) lsb_perror(queues[numQueues]); else { switch (lsberrno) { case LSBE_BAD_HOST : case LSBE_QUEUE_HOST : lsb_perror(host); break; case LSBE_BAD_USER : case LSBE_QUEUE_USE : lsb_perror(user); break; default : lsb_perror(NULL); } } _free_(queues); return -1; } if (lflag) prtQueuesLong(numQueues, queueInfo); else prtQueuesShort(numQueues, queueInfo); _free_(queues); return 0; }
int lsb_msgjob (LS_LONG_INT jobId, char *msg) { struct lsbMsg jmsg; char src[LSB_MAX_SD_LENGTH]; char dest[LSB_MAX_SD_LENGTH]; struct lsbMsgHdr header; char request_buf[MSGSIZE]; char *reply_buf; XDR xdrs; mbdReqType mbdReqtype; int cc; struct LSFHeader hdr; struct passwd *pw; header.src = src; header.dest = dest; jmsg.header = &header; TIMEIT (0, (pw = getpwuid (getuid ())), "getpwuid"); if (pw == NULL) { lsberrno = LSBE_BAD_USER; return (-1); } jmsg.header->usrId = pw->pw_uid; jmsg.header->jobId = jobId; jmsg.msg = msg; strcpy (jmsg.header->src, "lsbatch"); strcpy (jmsg.header->dest, "user job"); jmsg.header->msgId = 999; jmsg.header->type = -1; mbdReqtype = BATCH_JOB_MSG; xdrmem_create (&xdrs, request_buf, MSGSIZE, XDR_ENCODE); hdr.opCode = mbdReqtype; if (!xdr_encodeMsg (&xdrs, (char *) &jmsg, &hdr, xdr_lsbMsg, 0, NULL)) { lsberrno = LSBE_XDR; xdr_destroy (&xdrs); return (-1); } cc = callmbd (NULL, request_buf, XDR_GETPOS (&xdrs), &reply_buf, &hdr, NULL, NULL, NULL); if (cc < 0) { xdr_destroy (&xdrs); return (-1); } xdr_destroy (&xdrs); if (cc != 0) free (reply_buf); lsberrno = hdr.opCode; if (lsberrno == LSBE_NO_ERROR) return (0); else return (-1); }
int main(int argc, char **argv) { int numQueues; char **queueNames=NULL, **queues = NULL; struct queueInfoEnt *queueInfo; char lflag = FALSE; int cc, defaultQ = FALSE; char *host = NULL, *user = NULL; int rc; numQueues = 0; rc = _i18n_init ( I18N_CAT_MIN ); if (lsb_init(argv[0]) < 0) { lsb_perror("lsb_init"); exit(-1); } while ((cc = getopt(argc, argv, "Vhlwm:u:")) != EOF) { switch (cc) { case 'l': lflag = TRUE; if (wflag) usage(argv[0]); break; case 'w': wflag = TRUE; if (lflag) usage(argv[0]); break; case 'm': if (host != NULL || *optarg == '\0') usage(argv[0]); host = optarg; break; case 'u': if (user != NULL || *optarg == '\0') usage(argv[0]); user = optarg; break; case 'V': fputs(_LS_VERSION_, stderr); exit(0); case 'h': default: usage(argv[0]); } } numQueues = getNames(argc, argv, optind, &queueNames, &defaultQ, "queue"); if (!defaultQ && numQueues != 0) queues = queueNames; else queues = NULL; TIMEIT(0, (queueInfo = lsb_queueinfo(queues, &numQueues, host, user, 0)), "lsb_queueinfo"); if (!queueInfo) { if (lsberrno == LSBE_BAD_QUEUE && queues) lsb_perror(queues[numQueues]); else { switch (lsberrno) { case LSBE_BAD_HOST : case LSBE_QUEUE_HOST : lsb_perror (host); break; case LSBE_BAD_USER : case LSBE_QUEUE_USE : lsb_perror (user); break; default : lsb_perror (NULL); } } return -1; } if (lflag) prtQueuesLong(numQueues, queueInfo); else prtQueuesShort(numQueues, queueInfo); return 0; }