Пример #1
0
t_arraylist	*ls_gen_filedirs(char *options, t_filedir *temp_filedir)
{
	t_arraylist		*filedirs;
	DIR				*curr_dir;
	t_dirent		*dir_entry;
	char			*root;
	char			*full_path;

	if (!(curr_dir = opendir(temp_filedir->path)))
		return (ls_perror(temp_filedir->name));
	root = ft_strjoin(temp_filedir->path, "/");
	filedirs = NULL;
	while ((dir_entry = readdir(curr_dir)) != NULL)
	{
		full_path = ft_strjoin(root, dir_entry->d_name);
		if (!(temp_filedir = filedir(full_path)))
			continue;
		if (!filedirs)
			filedirs = check_malloc(arraylist(temp_filedir, DIR_BUF));
		else
			filedirs->push(filedirs, temp_filedir);
		free(full_path);
	}
	closedir(curr_dir);
	ls_gen_filedirs_sort(options, filedirs);
	free(root);
	return (filedirs);
}
Пример #2
0
static void
operateHost (char *host, int opCode, int confirm)
{
    char msg1[MAXLINELEN];
    char msg[MAXLINELEN];

    if (opCode == LIM_CMD_REBOOT)
	sprintf(msg1, I18N(256, "Restart LIM on <%s>"), host); /* catgets 256 */
    else
	sprintf(msg1, I18N(257, "Shut down LIM on <%s>"), host); /* catgets 257 */

    if (confirm) {
	sprintf(msg, "%s ? [y/n] ", msg1);
        if (!getConfirm(msg))
	    return;
    }
    fprintf(stderr, "%s ...... ", msg1);
    fflush(stderr);
    if (ls_limcontrol(host, opCode) == -1) {
	ls_perror ("ls_limcontrol");
	exitrc = -1;
    } else {
	char *delay = getenv("LSF_RESTART_DELAY");
	int  delay_time;
	if (delay == 0)
	    delay_time = 500;
	else
	    delay_time = atoi(delay) * 1000;

	millisleep_(delay_time);
	fprintf (stderr, "%s\n", I18N_done);
    }
    fflush(stderr);

}
Пример #3
0
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);
}
Пример #4
0
static void
setdefaults (void)
{
  int n;
  char *confpath, *localHost;
  struct config_param acctdir[] = { {"LSF_RES_ACCTDIR", NULL},
  {NULL, NULL}
  };
  struct stat statBuf;
  char lsfUserName[MAX_LOGIN + 1];

  details = 0;

  if ((confpath = getenv ("LSF_ENVDIR")) == NULL)
    confpath = "/etc";

  ls_readconfenv (acctdir, confpath);

  if (acctdir[0].paramValue == NULL
      || stat (acctdir[0].paramValue, &statBuf) == -1)
    acctdir[0].paramValue = "/tmp";
  strcpy (logfile, acctdir[0].paramValue);
  n = strlen (logfile);
  strncat (logfile, "/lsf.acct.", MAX_PATH - n);
  if ((localHost = ls_getmyhostname ()) == NULL)
    {
      ls_perror ("ls_getmyhostname");
      return;
    }
  n = strlen (logfile);
  strncat (logfile, localHost, MAX_PATH - n);

  if (getLSFUser_ (lsfUserName, MAX_LOGIN + 1) != 0)
    {
      ls_perror ("getLSFUser_");
      return;
    }

  strcpy (mylogin, lsfUserName);
  users[0] = mylogin;
  users[1] = NULL;

  hosts[0] = NULL;

  eternity = mkinterval (mktime (&creation), mktime (&destruction));
  start = complete = eternity;
}
Пример #5
0
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;
}
Пример #6
0
static int
useTmp (char *exHost, char *fname)
{
  int pid;
  LS_WAIT_T status;
  struct stat st;
  char *fName;

  fName = "useTmp";
  if ((pid = fork ()) == 0)
    {
      if (ls_initrex (1, 0) < 0)
	{
	  ls_perror ("ls_initrex");
	  exit (FALSE);
	}

      ls_rfcontrol (RF_CMD_RXFLAGS, REXF_CLNTDIR);

      if (ls_rstat (exHost, fname, &st) < 0)
	{
	  if (lserrno == LSE_FILE_SYS && (errno == ENOENT || errno == EACCES))
	    {
	      exit (TRUE);
	    }

	  ls_perror ("ls_rstat");
	}

      exit (FALSE);
    }

  if (pid == -1)
    {
      perror ("fork");
      return (FALSE);
    }

  if (waitpid (pid, &status, 0) == -1)
    {
      perror ("waitpid");
      return (FALSE);
    }

  return (WEXITSTATUS (status));
}
Пример #7
0
static struct interval getinterval(char *timeform)
{
    time_t twotimes[2];
    struct interval i;

    if (getBEtime(timeform, 't', twotimes) == -1) {
        ls_perror(timeform);
        exit(-1);
        }

    i.begin = twotimes[0];
    i.end = twotimes[1];

    return i;
}
Пример #8
0
int
limUnlock(int argc, char **argv)
{

    if (argc > optind) {
	fprintf(stderr, I18N(261, "Syntax error: too many arguments.\n")); /* catgets 261 */
	return(-2);
    }

    if (ls_unlockhost() < 0) {
        ls_perror("ls_unlockhost");
        return(-1);
    }

    printf(I18N(262, "Host is unlocked\n")); /* catgets 262 */
    fflush(stdout);

    return(0);
}
Пример #9
0
static void
prtResourcesShort(int num, struct lsbSharedResourceInfo  *info)
{
    struct lsInfo *lsInfo;
    int i, j, k;
    char *buf1, *buf2, *buf3, *buf4;

    if ((lsInfo = ls_info()) == NULL) {
        ls_perror("lsinfo");
        exit(-10);
    }

    buf1 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1645, "RESOURCE")); /* catgets 1645 */
    buf2 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1646, "TOTAL"));  /* catgets  1646 */
    buf3 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1647, "RESERVED")); /* catgets 1647 */
    buf4 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1648, "LOCATION")); /* catgets 1648 */

    printf("%-20s%10s%15s%15s\n", buf1, buf2, buf3, buf4);

    FREEUP(buf1);
    FREEUP(buf2);
    FREEUP(buf3);
    FREEUP(buf4);

    
    for (i = 0; i < num; i++) {
        for (j = 0; j < info[i].nInstances; j++)  {
           

            for (k = 0; k < lsInfo->nRes; k++) {
                if (strcmp(lsInfo->resTable[k].name, 
                           info[i].resourceName) == 0) {

                    if (lsInfo->resTable[k].valueType & LS_NUMERIC) {
                         prtOneInstance(info[i].resourceName,
                                          &(info[i].instances[j]));
                    }
                }
            }
        }
    }

} 
Пример #10
0
int
main(int argc, char **argv)
{
    int cc,  myIndex;
    char *prompt = "lsadmin>";
    char line[MAXLINELEN];

    if (ls_initdebug(argv[0]) < 0) {
	ls_perror("ls_initdebug");
	exit(-1);
    }

    while ((cc = getopt(argc, argv, "Vh")) != EOF) {
        switch (cc) {
            case 'V':
                fputs(_LS_VERSION_, stderr);
                exit(0);
            case 'h':
            default:
                cmdsUsage("lsadmin", cmdList, cmdInfo);
        }
    }
    if (argc > optind) {
        if ((myIndex=adminCmdIndex(argv[optind], cmdList)) == -1) {
            fprintf(stderr, "Invalid command <%s> \n", argv[optind]);
            cmdsUsage("lsadmin", cmdList, cmdInfo);
	}
	optind++;
	exit (doLsCmd (argc, argv));
    }

    for (;;) {
        printf("%s", prompt);
        fflush(stdout);
	if (fgets(line, MAXLINELEN, stdin) == NULL) {
	    printf("\n");
            exit(-1);
        }
        parseAndDo(line , doLsCmd);

    }
}
Пример #11
0
int
limLock(int argc, char **argv)
{
    u_long duration = 0;
    extern int optind;
    extern char *optarg;
    char *optName;

    while ((optName = myGetOpt(argc, argv, "l:")) != NULL) {
        switch(optName[0]) {
            case 'l':
                duration = atoi(optarg);
                if (!isint_(optarg) || atoi(optarg) <= 0) {
	            fprintf(stderr, I18N(258, "The host locking duration <%s> should be a positive integer\n"), optarg); /* catgets 258 */
                    return -2;
		}
		break;
            default:
                return -2;
        }
    }

    if (argc > optind)
        return -2;

    if (ls_lockhost(duration) < 0) {
	ls_perror("failed");
        return(-1);
    }

    if (duration)
        printf(I18N(259, "Host is locked for %lu seconds\n") /* catgets 259 */,
	       (unsigned long)duration);
    else
        printf(I18N(260, "Host is locked\n")); /* catgets 260 */

    fflush(stdout);
    return(0);
}
Пример #12
0
static
void doAllHosts(int opCode)
{
    int numhosts = 0, i;
    struct hostInfo *hostinfo;
    int ask = FALSE, try = FALSE;
    char msg[128];

    hostinfo = ls_gethostinfo("-:server", &numhosts, NULL, 0, LOCAL_ONLY);
    if (hostinfo == NULL) {
	ls_perror("ls_gethostinfo");
	fprintf(stderr, "Operation aborted\n");
        exitrc = -1;
	return;
    }

    if (!fFlag) {
	if (opCode == LIM_CMD_REBOOT)
            sprintf(msg, "Do you really want to restart LIMs on all hosts? [y/n] ");
        else
	    sprintf(msg, "Do you really want to shut down LIMs on all hosts? [y/n] ");
	ask = (!getConfirm(msg));
    }

    for (i = 0; i < numhosts; i++)
        if (hostinfo[i].maxCpus > 0)
	    operateHost (hostinfo[i].hostName, opCode, ask);
        else
	    try = 1;
    if (try) {
        fprintf(stderr, "\n%s :\n\n", "Trying unavailable hosts");
        for (i = 0; i < numhosts; i++)
            if (hostinfo[i].maxCpus <= 0)
	        operateHost (hostinfo[i].hostName, opCode, ask);
    }

}
Пример #13
0
int
sysHist(int argc, char **argv, int opCode)
{
    struct histReq req;
    int all = FALSE, eventFound;
    char **nameList=NULL;
    int numNames = 0;
    char *optName;


    req.opCode = opCode;
    req.names = NULL;
    req.eventFileName = NULL;
    req.eventTime[0] = 0;
    req.eventTime[1] = 0;

    while ((optName = myGetOpt(argc, argv, "t:|f:")) != NULL) {
	switch (optName[0]) {
	case 'f':
            if (strlen(optarg) > MAXFILENAMELEN -1) {
		fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,1051, "%s: File name too long\n")), optarg); /* catgets  1051  */
		return(-1);
            } else
	        req.eventFileName = optarg;
	    break;
        case 't':
            if (getBEtime(optarg, 't', req.eventTime) == -1) {
		ls_perror(optarg);
		return (-1);
            }
            break;
	default:
	    return(-2);
	}
    }

    switch (opCode) {
    case QUEUE_HIST:
    case HOST_HIST:
	if (argc > optind) {
	    numNames = getNames(argc, argv, optind, &nameList, &all, "queueC");
	    if (!all && numNames != 0) {
	        nameList[numNames] = NULL;
		req.names = nameList;
	    }
	}
	break;

    case MBD_HIST:
    case SYS_HIST:
        if (argc > optind)
            return(-2);
	break;

    default:
	fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,1052, "Unknown operation code\n"))); /* catgets  1052  */
	return(-2);
    }

    return (searchEventFile(&req, &eventFound));

}
Пример #14
0
int
main(int argc, char **argv)
{
    static char fname[] = "lsplace/main";
    char *resreq = NULL;
    char *hostnames[MAXLISTSIZE];
    char **desthosts;
    int cc = 0;
    int needed = 1;
    int wanted = 1;
    int i;
    char locality=FALSE;
    int	achar;
    char badHost = FALSE;
    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); 

    opterr = 0;
    while ((achar = getopt(argc, argv, "VR:Lhn:w:")) != EOF)
    {
	switch (achar)
	{
	case 'L':
            locality=TRUE;
            break;

	case 'R':
            resreq = optarg;
            break;

        case 'n':		
            for (i = 0 ; optarg[i] ; i++) 
                if (! isdigit(optarg[i])) 
                    usage(argv[0]);
            needed = atoi(optarg);
            break;

        case 'w':		
            for (i = 0 ; optarg[i] ; i++) 
                if (! isdigit(optarg[i])) 
                    usage(argv[0]);
            wanted = atoi(optarg);
            break;

	case 'V':
	    fputs(_LS_VERSION_, stderr);
	    exit(0);

	case 'h':
	default:
            usage(argv[0]);
        }
    }

    for ( ; optind < argc ; optind++)
    {
        if (cc>=MAXLISTSIZE) {
            fprintf(stderr, 
		_i18n_msg_get(ls_catd,NL_SETN,2201, "%s: too many hosts specified (max %d)\n"), /* catgets  2201  */
		argv[0], MAXLISTSIZE);
            exit(-1);
        }

        if (ls_isclustername(argv[optind]) <= 0
            && !Gethostbyname_(argv[optind])) {
            fprintf(stderr, "\
%s: invalid hostname %s\n", argv[0], argv[optind]);
            badHost = TRUE;
            continue;
        }
        hostnames[cc] = argv[optind];
        cc++;
    }
Пример #15
0
static void
remoteOutput (int fidx, char **disOut, char *exHost, char *fname,
	      char *execUsername, char **envp)
{
  char buf[MAXFILENAMELEN];
  char *args[MAX_PEEK_ARGS + 4];
  char lsfUserName[MAXLINELEN];

#   define RSHCMD "rsh"

  if ((getLSFUser_ (lsfUserName, MAXLINELEN) == 0)
      && strcmp (lsfUserName, execUsername))
    {


      if (useTmp (exHost, fname))
	{
	  sprintf (buf, "/tmp/.lsbtmp%d/%s", (int) getuid (), fname);
	  disOut[fidx] = buf;
	}
      else
	{
	  disOut[fidx] = fname;
	}

      args[0] = RSHCMD;
      args[1] = exHost;
      args[2] = "-l";
      args[3] = execUsername;
      if (fidx == 2)
	{
	  args[4] = disOut[0];
	  args[5] = disOut[1];
	  args[6] = disOut[2];
	  args[7] = NULL;
	}
      else
	{
	  args[4] = disOut[0];
	  args[5] = disOut[1];
	  args[6] = NULL;
	}


      lsfExecvp (RSHCMD, args);
      fprintf (stderr, I18N_FUNC_S_S_FAIL_S, "execvp", args[0],
	       strerror (errno));
      return;
    }

  if (useTmp (exHost, fname))
    {
      sprintf (buf, "/tmp/.lsbtmp%d/%s", (int) getuid (), fname);
      disOut[fidx] = buf;
    }
  else
    disOut[fidx] = fname;

  if (ls_initrex (1, 0) < 0)
    {
      ls_perror ("ls_initrex");
      return;
    }

  ls_rfcontrol (RF_CMD_RXFLAGS, REXF_CLNTDIR);
  ls_rexecve (exHost, disOut, REXF_CLNTDIR, envp);

  fprintf (stderr, I18N_FUNC_S_S_FAIL_S, "ls_rexecv", disOut[0],
	   ls_sysmsg ());

}
Пример #16
0
int
main(int argc, char **argv)
{
    static char fname[] = "lsload:main";
    int i,j, num, numneeded;
    char *resreq = NULL;
    struct hostLoad *hosts;
    char *hostnames[MAXLISTSIZE];
    char statusbuf[20];
    int options = 0;
    static char **loadval;
    char *indexfilter = NULL;
    char **nlp;
    static char *defaultindex[] = {"r15s", "r1m", "r15m", "ut", "pg", "ls",
                                   "it", "tmp", "swp", "mem", NULL};
    int	achar;
    char longFormat = FALSE;
    char wideFormat = FALSE;
    char badHost = FALSE, sOption = FALSE, otherOption = FALSE;
    int extView = FALSE;
    char **shareNames, **shareValues, **formats;
    int isClus, retVal = 0;
    int rc;

    num = 0;
    numneeded = 0;
    opterr = 0;

    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);
           }
           sOption = TRUE;
           optind = i + 1;
       } else if (strcmp(argv[i], "-e") == 0) {
           if (otherOption == TRUE || sOption == FALSE) {
               usage(argv[0]);
               exit(-1);
           }
           extView = TRUE;
           optind = i + 1;
       } else if (strcmp(argv[i], "-R") == 0 || strcmp(argv[i], "-l") == 0
                  || strcmp(argv[i], "-I") == 0 || strcmp(argv[i], "-N") == 0
                  || strcmp(argv[i], "-E") == 0 || strcmp(argv[i], "-n") == 0
		  || strcmp(argv[i], "-w") == 0 ) {
            otherOption = TRUE;
            if (sOption == TRUE) {
                usage(argv[0]);
                exit(-1);
            }
        }
    }

    if (sOption == TRUE) {
        displayShareResource(argc, argv, optind, FALSE, extView);
        return(0);
    }

    while ((achar = getopt(argc, argv, "R:I:NEln:w")) != EOF)
    {
	switch (achar)
	{
	case 'R':
            resreq = optarg;
            break;
	case 'I':
            indexfilter = optarg;
            break;

	case 'N':
	    if (options & EFFECTIVE)
		usage(argv[0]);
            options = NORMALIZE;
	    break;

        case 'E':
	    if (options & NORMALIZE)
		usage(argv[0]);
             options = EFFECTIVE;
	     break;
	case 'n':
            numneeded = atoi(optarg);
            if (numneeded <= 0)
                usage(argv[0]);
            break;

        case 'l':
	    longFormat = TRUE;
	    if (wideFormat == TRUE)
		usage(argv[0]);
	    break;

	case 'w':
	    wideFormat = TRUE;
	    if (longFormat == TRUE)
		usage(argv[0]);
	    break;

	case 'V':
	    fputs(_LS_VERSION_, stderr);
	    exit(0);

	case 'h':
	default:
            usage(argv[0]);

        }
    }

    for ( ; optind < argc ; optind++)
    {
        if (num>=MAXLISTSIZE) {
            fprintf(stderr, _i18n_msg_get(ls_catd,NL_SETN,1951, "too many hosts specified (maximum %d)\n"), /* catgets  1951  */
			MAXLISTSIZE);
            exit(-1);
        }
        if ( (isClus = ls_isclustername(argv[optind])) < 0 ) {
	    fprintf(stderr, "lsload: %s\n", ls_sysmsg());
            badHost = TRUE;
	    continue;
	} else if ( (isClus == 0) &&
		    (!Gethostbyname_(argv[optind])) ) {
	    fprintf(stderr, "\
%s: invalid hostname %s\n", __func__, argv[optind]);
            badHost = TRUE;
            continue;
	}
        hostnames[num] = argv[optind];
        num++;
    }
Пример #17
0
static int
setDefaults(struct resVal *resVal, struct lsInfo *lsInfo, int options)
{
    int i;

    if (options & PR_DEFFROMTYPE)
        strcpy(resVal->selectStr, "expr [type \"eq\" \"local\"]");
    else
        strcpy(resVal->selectStr, "expr [type \"eq\" \"any\"]");

    resVal->nphase = 2;
    resVal->order[0] = R15S + 1;
    resVal->order[1] = PG + 1;
    resVal->val = calloc(lsInfo->nRes, sizeof(float));
    resVal->indicies = calloc((lsInfo->numIndx), sizeof(int));
    if (!resVal->val || !resVal->indicies) {
	freeResVal (resVal);
        lserrno = LSE_MALLOC;
        ls_perror("intlib:resreq");
        return PARSE_BAD_MEM;
    }

    for (i = 0; i < lsInfo->nRes; i++)
        resVal->val[i] = INFINIT_LOAD;

    resVal->genClass =  0;
    if (!(options & PR_BATCH)) {
        resVal->genClass |=  1 << R15S;
        resVal->genClass |=  1 << R1M;
        resVal->genClass |=  1 << R15M;
        resVal->val[R15S] = 1.0;
        resVal->val[R1M]  = 1.0;
        resVal->val[R15M] = 1.0;
    }

    resVal->nindex = lsInfo->numIndx;
    for(i = 0; i < resVal->nindex; i++)
        resVal->indicies[i] = i;

    resVal->rusage_bit_map =
        calloc (GET_INTNUM(lsInfo->nRes), sizeof(int));
    if (resVal->rusage_bit_map == NULL) {
	lserrno = LSE_MALLOC;
	freeResVal (resVal);
        return PARSE_BAD_MEM;
    }

    for (i = 0; i < GET_INTNUM(lsInfo->nRes); i++)
	resVal->rusage_bit_map[i] = 0;

    if (!(options &PR_BATCH)) {
        SET_BIT(R15S, resVal->rusage_bit_map);
        SET_BIT(R1M, resVal->rusage_bit_map);
        SET_BIT(R15M, resVal->rusage_bit_map);
    }

    resVal->duration = INFINIT_INT;
    resVal->decay = INFINIT_FLOAT;
    resVal->numHosts = INFINIT_INT;
    resVal->maxNumHosts = INFINIT_INT;
    resVal->pTile = INFINIT_INT;

    resVal->options = 0;
    return 0;
}
Пример #18
0
static void
prtHostsLong (int numReply, struct hostInfoEnt  *hInfo)
{
    struct hostInfoEnt *hPtr;
    int i, j, retVal = 0;
    char *status, maxJobs[MAX_CHARLEN], userJobLimit[MAX_CHARLEN];
    char **nameTable, **totalValues, **rsvValues, **formats;
    struct lsInfo *lsInfo;
   
    if ((lsInfo = ls_info()) == NULL) {
	ls_perror("ls_info");
	exit(-1);
    }
    
    lsInfoPtr = lsInfo;

    for (i = 0; i < numReply; i++) {
	hPtr = &(hInfo[i]);
        if (repeatHost (i, hInfo))
            continue;
	printf("%s  %s\n",
		(_i18n_msg_get(ls_catd,NL_SETN,1604, "HOST")), /* catgets  1604  */
		hPtr->host); 

	
        prtWord(HOST_STATUS_LENGTH, I18N_STATUS, 0);

	if (lsbMode_ & LSB_MODE_BATCH) {
            prtWord(HOST_CPUF_LENGTH, I18N_CPUF, -1);
            prtWord(HOST_JL_U_LENGTH, I18N_JL_U, -1);
	};

            prtWord(HOST_MAX_LENGTH,   I18N_MAX, -1);
            prtWord(HOST_NJOBS_LENGTH, I18N_NJOBS, -1);
            prtWord(HOST_RUN_LENGTH,   I18N_RUN, -1);
            prtWord(HOST_SSUSP_LENGTH, I18N_SSUSP, -1);
            prtWord(HOST_USUSP_LENGTH, I18N_USUSP, -1);
            prtWord(HOST_RSV_LENGTH,   I18N_RSV, -1);

	if (lsbMode_ & LSB_MODE_BATCH)
	    printf(I18N(1608, "DISPATCH_WINDOW\n")); /* catgets  1608  */
	else
	    printf("\n");
	
	status = I18N_ok; 
	if (hPtr->hStatus & HOST_STAT_UNAVAIL)
	    status = I18N_unavail; 
	else if (hPtr->hStatus & HOST_STAT_UNREACH)
	    status = (_i18n_msg_get(ls_catd,NL_SETN,1611, "unreach")); /* catgets  1611  */
      
        else if (hPtr->hStatus & (HOST_STAT_BUSY
                                             | HOST_STAT_WIND
                                             | HOST_STAT_DISABLED
                                             | HOST_STAT_EXCLUSIVE
                                             | HOST_STAT_LOCKED
                                             | HOST_STAT_LOCKED_MASTER
                                             | HOST_STAT_FULL
                                             | HOST_STAT_NO_LIM)) 
            getCloseString (hPtr->hStatus, &status);

	if (hPtr->userJobLimit < INFINIT_INT)   
            strcpy(userJobLimit, 
                   prtValue(HOST_JL_U_LENGTH, hPtr->userJobLimit));
        else 
            strcpy(userJobLimit,  prtDash(HOST_JL_U_LENGTH));

        if ( hPtr->maxJobs < INFINIT_INT )
            strcpy(maxJobs,
                   prtValue(HOST_MAX_LENGTH, hPtr->maxJobs));
        else 
            strcpy(maxJobs,  prtDash(HOST_MAX_LENGTH));

        prtWordL(HOST_STATUS_LENGTH, status);

	if (lsbMode_ & LSB_MODE_BATCH) {
            sprintf(fomt, "%%%d.2f %%s", HOST_CPUF_LENGTH );
	    printf(fomt, hPtr->cpuFactor, userJobLimit);
	};


            sprintf(fomt, "%%s%%%dd %%%dd %%%dd %%%dd %%%dd ", 
                                  HOST_NJOBS_LENGTH,
                                  HOST_RUN_LENGTH,
                                  HOST_SSUSP_LENGTH,
                                  HOST_USUSP_LENGTH,
                                  HOST_RSV_LENGTH);
            
            printf(fomt,
                   maxJobs, hPtr->numJobs, hPtr->numRUN, 
		   hPtr->numSSUSP, hPtr->numUSUSP, hPtr->numRESERVE);

	if (lsbMode_ & LSB_MODE_BATCH)	    
	    printf("%s\n\n",	
		   hPtr->windows[0] != '\0' ? hPtr->windows : "     -");
	else
	    printf("\n\n");	    

	if (!(hPtr->hStatus & (HOST_STAT_UNAVAIL | HOST_STAT_UNREACH))){ 
	    printf(" %s:\n",
		_i18n_msg_get(ls_catd,NL_SETN,1612, "CURRENT LOAD USED FOR SCHEDULING")); /* catgets  1612  */
	    prtLoad(hPtr, lsInfo);

	    if (lsbSharedResConfigured_) {
		
		retVal = makeShareFields(hPtr->host, lsInfo, &nameTable, 
					 &totalValues, &rsvValues,
					 &formats); 
		if (retVal > 0) {
		    int start =0;
		    int end;
                    while ((end = getDispLastItem(nameTable, start, retVal)) > start 
	                   && start < retVal) { 
		        printf(" %11s", " ");
		        for (j = start; j < end; j++) 
                            printf(formats[j], nameTable[j]);
		    
		        printf("\n %-11.11s",
                               _i18n_msg_get(ls_catd,NL_SETN,1613, "Total"));   /* catgets  1613  */
	                for (j = start; j < end; j++) 
                            printf(formats[j], totalValues[j]);

		        printf("\n %-11.11s",
                               _i18n_msg_get(ls_catd,NL_SETN,1614, "Reserved"));  /* catgets 1614 */
		        for (j = start; j < end; j++) 
                            printf(formats[j], rsvValues[j]);
		        putchar('\n');
		        putchar('\n');
			start = end;
                    }
		    putchar('\n');
		}
	    }
	}
	printf(" %s:\n",
	    _i18n_msg_get(ls_catd,NL_SETN,1615, "LOAD THRESHOLD USED FOR SCHEDULING"));	 /* catgets  1615  */
	if (printThresholds(hPtr->loadSched, hPtr->loadStop, 
			    hPtr->busySched, hPtr->busyStop,
			    MIN(hInfo->nIdx, lsInfo->numIndx),
			    lsInfo) < 0)
	    continue;
	printf("\n");
	
        
	if (hPtr->mig < INFINIT_INT) 
	    printf(( _i18n_msg_get(ls_catd, NL_SETN, 1616, "Migration threshold is %d min \n")), hPtr->mig);  /* catgets  1616  */

        printf("\n");
    } 
} 
Пример #19
0
int
main( int argc, char *argv[] )
{

    lsRcpXfer lsXfer;
    int iCount;
    char* buf;
    int rc;

    rc = _i18n_init ( I18N_CAT_MIN );


    Signal_(SIGUSR1, SIG_IGN);



    if (ls_initdebug(argv[0]) < 0) {
        ls_perror("ls_initdebug");
        exit(-1);
    }


    if (ls_initrex(1,0) == -1) {
        ls_perror("lsrcp: ls_initrex");
        return(-1);
    }


    ls_rfcontrol(RF_CMD_RXFLAGS, REXF_CLNTDIR);


    if (setuid(getuid()) < 0) {
        perror("lsrcp: setuid");
        goto handle_error;
    }

    if (createXfer(&lsXfer)) {
        perror("lsrcp");
        goto handle_error;
    }

    doXferOptions(&lsXfer, argc, argv);



    buf = (char*)malloc(LSRCP_MSGSIZE);
    if(!buf) {

        ls_donerex();
        ls_syslog(LOG_ERR, I18N_FUNC_FAIL_S,"lsrcp","main",
	    _i18n_msg_get(ls_catd,NL_SETN,2301,"try rcp...")); /* catgets 2301 */
        if (doXferRcp(&lsXfer, 0) < 0)
            return(-1);
        return(0);
    }
    for (iCount=0;iCount < lsXfer.iNumFiles; iCount++) {
        if (copyFile(&lsXfer, buf, 0)) {

                ls_donerex();
        	ls_syslog(LOG_ERR, I18N_FUNC_FAIL_S,"lsrcp","main",
		    _i18n_msg_get(ls_catd,NL_SETN,2301,"try rcp..."));
                if (doXferRcp(&lsXfer, 0) < 0)
		    return(-1);
                return(0);
        }
	if (logclass & (LC_FILE))
            ls_syslog(LOG_DEBUG, "main(), copy file succeeded.");
    }
    free(buf);

    ls_donerex();

    if (destroyXfer(&lsXfer)) {
        perror("lsrcp");
        return(-1);
    }


    _i18n_end ( ls_catd );

    return(0);

handle_error:
    ls_donerex();
    return(-1);

}
Пример #20
0
void
parseAndDo (char *cmdBuf, int (*func)() )
{
#define MAX_ARG 100

    extern int optind;
    int  argc, i ;
    char *argv[MAX_ARG];

    int see_string = 0;

    for (i=0; i<MAX_ARG; i++) {

        while(isspace(*cmdBuf) && !see_string)
            cmdBuf++;

        if (*cmdBuf == '"')
        {   cmdBuf++;
            see_string = 1;
        }

        if (*cmdBuf == '\0')
            break;

        argv[i] = cmdBuf;

        while(*cmdBuf !='\0' && !isspace(*cmdBuf) && *cmdBuf != '"')
        {
            cmdBuf++;
        }

        while ( see_string && *cmdBuf != '"')
        {
            cmdBuf++;
            if (*cmdBuf == '\0')
            {
                see_string = 0;
                ls_perror (_i18n_msg_get(ls_catd, NL_SETN, 100,
                                         "Syntax Error of line parameter! \n"));  /* catgets 100 */
                exit(-1);
            }

        }
        if (see_string)
            see_string = 0;

        if (*cmdBuf != '\0') {
            *cmdBuf = '\0';
            cmdBuf++;
        }
    }
    if (i == 0)
        return;

    argv[i] = NULL;
    argc = i;
    optind = 1;

    (void) (*func) (argc, argv);

}
Пример #21
0
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);
}
Пример #22
0
/* prtQueuesLong()
 */
static void
prtQueuesLong(int numQueues, struct queueInfoEnt *queueInfo)
{
    struct queueInfoEnt *qp;
    char *status;
    char userJobLimit[MAX_CHARLEN];
    char procJobLimit[MAX_CHARLEN];
    char hostJobLimit[MAX_CHARLEN];
    char maxJobs[MAX_CHARLEN];
    int i;
    int numDefaults = 0;
    struct lsInfo *lsInfo;
    int printFlag = 0;
    int printFlag1 = 0;
    int printFlag2 = 0;
    int printFlag3 = 0;
    int procLimits[3];

    if ((lsInfo = ls_info()) == NULL) {
        ls_perror("ls_info");
        exit(-1);
    }

    printf("\n");

    for (i = 0; i < numQueues; i++ )  {
        qp = &(queueInfo[i]);
        if (qp->qAttrib & Q_ATTRIB_DEFAULT)
            numDefaults++;
    }

    for (i = 0; i < numQueues; i++ ) {

        qp = &(queueInfo[i]);

        if (qp->qStatus & QUEUE_STAT_OPEN) {
            if ((qp->qStatus & QUEUE_STAT_ACTIVE)
                && (qp->qStatus & QUEUE_STAT_RUN))
                status = "   Open:Active  ";
            if ((qp->qStatus & QUEUE_STAT_ACTIVE)
                && !(qp->qStatus & QUEUE_STAT_RUN))
                status = " Open:Inact_Win "; /* windows are closed */
            if (!(qp->qStatus & QUEUE_STAT_ACTIVE))
                status = " Open:Inact_Adm "; /* By user (manager) */
        } else {  /* queue is disabled */
            if ((qp->qStatus & QUEUE_STAT_ACTIVE)
                && (qp->qStatus & QUEUE_STAT_RUN))
                status = "  Closed:Active ";
            if ((qp->qStatus & QUEUE_STAT_ACTIVE)
                && !(qp->qStatus & QUEUE_STAT_RUN))
                status = "Closed:Inact_Win"; /* by time window */
            if (!(qp->qStatus & QUEUE_STAT_ACTIVE))
                status = "Closed:Inact_Adm"; /* by user (manager) */
        }

        if (qp->maxJobs < INFINIT_INT)
            sprintf (maxJobs, "%5d", qp->maxJobs);
        else
            sprintf (maxJobs, "   - ");
        if (qp->userJobLimit < INFINIT_INT)
            sprintf (userJobLimit, "%4d", qp->userJobLimit);
        else
            sprintf (userJobLimit, "  - ");
        if (qp->procJobLimit < INFINIT_FLOAT)
            sprintf (procJobLimit, "%4.1f", qp->procJobLimit);
        else
            sprintf (procJobLimit, "  - ");
        if (qp->hostJobLimit < INFINIT_INT)
            sprintf (hostJobLimit, "%4d", qp->hostJobLimit);
        else
            sprintf (hostJobLimit, "  - ");

        if (i > 0)
            printf("-------------------------------------------------------------------------------\n\n");
        printf("QUEUE: %s\n", qp->queue);
        printf("  -- %s", qp->description);
        if (qp->qAttrib & Q_ATTRIB_DEFAULT) {
            if (numDefaults == 1)
                printf("  This is the default queue.\n\n");
            else
                printf("  This is one of the default queues.\n\n");
        } else
            printf("\n\n");

        printf("PARAMETERS/STATISTICS\n");
        printf("PRIO");
        printf(" NICE");
        printf("     STATUS       ");
        printf("MAX JL/U JL/P JL/H ");
        printf("NJOBS  PEND  RUN  SSUSP USUSP  RSV\n");
        printf("%4d", qp->priority);
        printf(" %3d", qp->nice);
        printf(" %-16.16s", status);

        printf("%s %s %s %s",
               maxJobs, userJobLimit, procJobLimit,hostJobLimit);

        printf("%5d %5d %5d %5d %5d %4d\n\n",
               qp->numJobs, qp->numPEND, qp->numRUN,
               qp->numSSUSP, qp->numUSUSP, qp->numRESERVE);

        if (qp->mig < INFINIT_INT)
            printf("Migration threshold is %d minutes\n", qp->mig);

        if (qp->schedDelay < INFINIT_INT)
            printf("Schedule delay for a new job is %d seconds\n",
                   qp->schedDelay);

        if (qp->acceptIntvl < INFINIT_INT)
            printf("Interval for a host to accept two jobs is %d seconds\n",
                   qp->acceptIntvl);


        if (((qp->defLimits[LSF_RLIMIT_CPU] != INFINIT_INT) &&
             (qp->defLimits[LSF_RLIMIT_CPU] > 0 )) ||
            ((qp->defLimits[LSF_RLIMIT_RUN] != INFINIT_INT) &&
             (qp->defLimits[LSF_RLIMIT_RUN] > 0 )) ||
            ((qp->defLimits[LSF_RLIMIT_DATA] != INFINIT_INT) &&
             (qp->defLimits[LSF_RLIMIT_DATA] > 0 )) ||
            ((qp->defLimits[LSF_RLIMIT_RSS] != INFINIT_INT) &&
             (qp->defLimits[LSF_RLIMIT_RSS] > 0 )) ||
            ((qp->defLimits[LSF_RLIMIT_PROCESS] != INFINIT_INT) &&
             (qp->defLimits[LSF_RLIMIT_PROCESS] > 0 ))) {


            printf("\n");
            printf("DEFAULT LIMITS:");
            prtResourceLimit (qp->defLimits, qp->hostSpec, 1.0, 0);
            printf("\n");
            printf("MAXIMUM LIMITS:");
        }

        procLimits[0] = qp->minProcLimit;
        procLimits[1] = qp->defProcLimit;
        procLimits[2] = qp->procLimit;
        prtResourceLimit (qp->rLimits, qp->hostSpec, 1.0, procLimits);

        printf("\nSCHEDULING PARAMETERS\n");
        if (printThresholds(qp->loadSched,  qp->loadStop, NULL, NULL,
                            MIN(lsInfo->numIndx, qp->nIdx), lsInfo) < 0)
            exit(-1);

        if ((qp->qAttrib & Q_ATTRIB_EXCLUSIVE)
            || (qp->qAttrib & Q_ATTRIB_BACKFILL)
            || (qp->qAttrib & Q_ATTRIB_IGNORE_DEADLINE)
            || (qp->qAttrib & Q_ATTRIB_ONLY_INTERACTIVE)
            || (qp->qAttrib & Q_ATTRIB_NO_INTERACTIVE)
            || (qp->qAttrib & Q_ATTRIB_FAIRSHARE)) {
            printf("\nSCHEDULING POLICIES:");
            if (qp->qAttrib & Q_ATTRIB_FAIRSHARE)
                printf("  FAIRSHARE");
            if (qp->qAttrib & Q_ATTRIB_BACKFILL)
                printf("  BACKFILL");
            if (qp->qAttrib & Q_ATTRIB_IGNORE_DEADLINE)
                printf("  IGNORE_DEADLINE");
            if (qp->qAttrib & Q_ATTRIB_EXCLUSIVE)
                printf("  EXCLUSIVE");
            if (qp->qAttrib & Q_ATTRIB_NO_INTERACTIVE)
                printf("  NO_INTERACTIVE");
            if (qp->qAttrib & Q_ATTRIB_ONLY_INTERACTIVE)
                printf("  ONLY_INTERACTIVE");
            if (qp->qAttrib & Q_ATTRIB_ROUND_ROBIN)
                printf("ROUND_ROBIN_SCHEDULING:  yes\n");
            printf("\n");
        }

        /* If the queue has the FAIRSHARE policy on, print out
         * shareAcctInforEnt data structure.
         */
        if (qp->qAttrib & Q_ATTRIB_FAIRSHARE) {
            print_slot_shares(qp);
        }

        if (qp->qAttrib & Q_ATTRIB_PREEMPTIVE)
            printf("\nPREEMPTION = %s", qp->preemption);

        if (strcmp (qp->defaultHostSpec, " ") !=  0)
            printf("\nDEFAULT HOST SPECIFICATION:  %s\n", qp->defaultHostSpec);

        if (qp->windows && strcmp (qp->windows, " " ) !=0)
            printf("\nRUN_WINDOWS:  %s\n", qp->windows);
        if (strcmp (qp->windowsD, " ")  !=  0)
            printf("\nDISPATCH_WINDOW:  %s\n", qp->windowsD);

        if ( strcmp(qp->userList, " ") == 0) {
            printf("\nUSERS:  all users\n");
        } else {
            if (strcmp(qp->userList, " ") != 0 && qp->userList[0] != 0)
                printf("\nUSERS:  %s\n", qp->userList);
        }

        if (strcmp(qp->hostList, " ") == 0) {
            printf("HOSTS:  all hosts used by the OpenLava system\n");
        } else {
            if (strcmp(qp->hostList, " ") != 0 && qp->hostList[0])
                printf("HOSTS:  %s\n", qp->hostList);
        }
        if (strcmp (qp->admins, " ") != 0)
            printf("ADMINISTRATORS:  %s\n", qp->admins);
        if (strcmp (qp->preCmd, " ") != 0)
            printf("PRE_EXEC:  %s\n", qp->preCmd);
        if (strcmp (qp->postCmd, " ") != 0)
            printf("POST_EXEC:  %s\n", qp->postCmd);
        if (strcmp (qp->requeueEValues, " ") != 0)
            printf("REQUEUE_EXIT_VALUES:  %s\n", qp->requeueEValues);
        if (strcmp (qp->resReq, " ") != 0)
            printf("RES_REQ:  %s\n", qp->resReq);
        if (qp->slotHoldTime > 0)
            printf("Maximum slot reservation time: %d seconds\n", qp->slotHoldTime);
        if (strcmp (qp->resumeCond, " ") != 0)
            printf("RESUME_COND:  %s\n", qp->resumeCond);
        if (strcmp (qp->stopCond, " ") != 0)
            printf("STOP_COND:  %s\n", qp->stopCond);
        if (strcmp (qp->jobStarter, " ") != 0)
            printf("JOB_STARTER:  %s\n", qp->jobStarter);

        /* CONF_SIG_ACT */

        printf("\n");
        printFlag = 0;
        if  ((qp->suspendActCmd != NULL)
             && (qp->suspendActCmd[0] != ' '))
            printFlag = 1;

        printFlag1 = 0;
        if  ((qp->resumeActCmd != NULL)
             && (qp->resumeActCmd[0] != ' '))
            printFlag1 = 1;

        printFlag2 = 0;
        if  ((qp->terminateActCmd != NULL)
             && (qp->terminateActCmd[0] != ' '))
            printFlag2 = 1;

        if (printFlag || printFlag1 || printFlag2)
            printf("JOB_CONTROLS:\n");


        if (printFlag) {
            printf("    SUSPEND:  ");
            if (strcmp (qp->suspendActCmd, " ") != 0)
                printf("    [%s]\n", qp->suspendActCmd);
        }

        if (printFlag1) {
            printf("    RESUME:   ");
            if (strcmp (qp->resumeActCmd, " ") != 0)
                printf("    [%s]\n", qp->resumeActCmd);
        }

        if (printFlag2) {
            printf("    TERMINATE:");
            if (strcmp (qp->terminateActCmd, " ") != 0)
                printf("    [%s]\n", qp->terminateActCmd);
        }

        if (printFlag || printFlag1 || printFlag2)
            printf("\n");

        printFlag = terminateWhen_(qp->sigMap, "USER");
        printFlag1 = terminateWhen_(qp->sigMap, "PREEMPT");
        printFlag2 = terminateWhen_(qp->sigMap, "WINDOW");
        printFlag3 = terminateWhen_(qp->sigMap, "LOAD");

        if (printFlag | printFlag1 | printFlag2 | printFlag3) {
            printf("TERMINATE_WHEN = ");
            if (printFlag) printf("USER ");
            if (printFlag1) printf("PREEMPT ");
            if (printFlag2) printf("WINDOW ");
            if (printFlag3) printf("LOAD");
            printf("\n");
        }
    }
}
Пример #23
0
int
main(int argc, char **argv)
{
    char *resreq;
    struct placeInfo  placeadvice[MAXLISTSIZE];
    char *p, *hname;
    int cc = 0;
    int	achar;

    if (ls_initdebug(argv[0]) < 0) {
        ls_perror("ls_initdebug");
        return -1;
    }

    opterr = 0;
    while ((achar = getopt(argc, argv, "VhR:")) != EOF) {
	switch (achar) {
	case 'R':
	    resreq = optarg;
	    break;
	case 'V':
	    fputs(_LS_VERSION_, stderr);
            return 0;
	case 'h':
	    usage(argv[0]);
            return -1;
	default:
	    usage(argv[0]);
            return -1;
	}
    }

    for ( ; optind < argc ; optind++) {

        if (cc >= MAXLISTSIZE) {
	    fprintf(stderr, "%s: too many hostnames (maximum %d)\n",
		__func__, MAXLISTSIZE);
	    usage(argv[0]);
            return -1;
	}

        p = strchr(argv[optind],':');
        if ( (p != NULL) && (*(p+1) != '\0') )  {
             *p++ = '\0';
             placeadvice[cc].numtask = atoi(p);
             if (errno == ERANGE) {
                 fprintf(stderr, "%s: invalid format for number of components\n",
                         __func__);
                 usage(argv[0]);
                 return -1;
             }
        } else {
             placeadvice[cc].numtask = 1;
        }

        if (!Gethostbyname_(argv[optind])) {
	    fprintf(stderr, "\
%s: invalid hostname %s\n", __func__, argv[optind]);
	    usage(argv[0]);
            return -1;
	}
        strcpy(placeadvice[cc++].hostName, argv[optind]);
    }
Пример #24
0
int
ctrlSbdDebug(struct debugReq  *pdebug)
{
    static char   fname[]="ctrlSbdDebug()";
    int           opCode;
    int           level;
    int           newClass;
    int           options;
    char          logFileName[MAXLSFNAMELEN];
    char          lsfLogDir[MAXPATHLEN];
    char          *dir;
    char          dynDbgEnv[MAXPATHLEN];

    memset(logFileName, 0, sizeof(logFileName));
    memset(lsfLogDir, 0, sizeof(lsfLogDir));

    opCode = pdebug->opCode;
    level = pdebug->level;
    newClass = pdebug->logClass;
    options = pdebug->options;

    if (pdebug->logFileName[0] != '\0') {
        if (((dir = strrchr(pdebug->logFileName,'/')) != NULL) ||
            ((dir = strrchr(pdebug->logFileName,'\\')) != NULL)) {
            dir++;
            ls_strcat(logFileName, sizeof(logFileName), dir);
            *(--dir) = '\0';
            ls_strcat(lsfLogDir, sizeof(lsfLogDir), pdebug->logFileName);
        }
        else {
            ls_strcat(logFileName, sizeof(logFileName), pdebug->logFileName);
            if (daemonParams[LSF_LOGDIR].paramValue
                && *(daemonParams[LSF_LOGDIR].paramValue)) {
                ls_strcat(lsfLogDir, sizeof(lsfLogDir),
                          daemonParams[LSF_LOGDIR].paramValue);
            }
            else {
                lsfLogDir[0] = '\0';
            }
        }
        ls_strcat(logFileName, sizeof(logFileName), ".sbatchd");
    }
    else {
  	ls_strcat(logFileName, sizeof(logFileName), "sbatchd");
        if (daemonParams[LSF_LOGDIR].paramValue
            && *(daemonParams[LSF_LOGDIR].paramValue)) {
            ls_strcat(lsfLogDir, sizeof(lsfLogDir),
                      daemonParams[LSF_LOGDIR].paramValue);
        } else {
            lsfLogDir[0] = '\0';
        }
    }

    if (options==1) {
        struct config_param *plp;
        for (plp = daemonParams; plp->paramName != NULL; plp++) {
            if (plp->paramValue != NULL)
                FREEUP(plp->paramValue);
        }

        if (initenv_(daemonParams, env_dir) < 0){
            ls_openlog("sbatchd", daemonParams[LSF_LOGDIR].paramValue,
                       (debug > 1), daemonParams[LSF_LOG_MASK].paramValue);
  	    ls_syslog(LOG_ERR, I18N_FUNC_FAIL_MM, fname, "initenv_");
            die(SLAVE_FATAL);
            return -1;
        }

        getLogClass_(daemonParams[LSB_DEBUG_SBD].paramValue,
                     daemonParams[LSB_TIME_SBD].paramValue);
        closelog();
        if (debug > 1)
            ls_openlog("sbatchd", daemonParams[LSF_LOGDIR].paramValue, TRUE,
                       daemonParams[LSF_LOG_MASK].paramValue);
        else
            ls_openlog("sbatchd", daemonParams[LSF_LOGDIR].paramValue, FALSE,
                       daemonParams[LSF_LOG_MASK].paramValue);

        if (logclass & LC_TRACE)
            ls_syslog(LOG_DEBUG, "%s: logclass=%x", fname, logclass);

        cleanDynDbgEnv();

        return(LSBE_NO_ERROR);
    }

    if (opCode==SBD_DEBUG) {
        putMaskLevel(level, &(daemonParams[LSF_LOG_MASK].paramValue));

        if (newClass>=0) {
            logclass = newClass;

            sprintf(dynDbgEnv, "%d", logclass);
            putEnv("DYN_DBG_LOGCLASS", dynDbgEnv);
        }

        if ( pdebug->level>=0 ){
            closelog();
            if (debug > 1)
                ls_openlog(logFileName, lsfLogDir, TRUE,
                           daemonParams[LSF_LOG_MASK].paramValue);
            else
                ls_openlog(logFileName, lsfLogDir, FALSE,
                           daemonParams[LSF_LOG_MASK].paramValue);

            putEnv("DYN_DBG_LOGDIR", lsfLogDir);
            putEnv("DYN_DBG_LOGFILENAME", logFileName);
            sprintf(dynDbgEnv, "%d", pdebug->level);
            putEnv("DYN_DBG_LOGLEVEL", dynDbgEnv);
        }
    }
    else if (opCode == SBD_TIMING) {
        if (level>=0)
 	    timinglevel = level;
        if (pdebug->logFileName[0] != '\0') {
            if (debug > 1)
                ls_openlog(logFileName, lsfLogDir,
                           TRUE, daemonParams[LSF_LOG_MASK].paramValue);
            else
                ls_openlog(logFileName, lsfLogDir,
                           FALSE, daemonParams[LSF_LOG_MASK].paramValue);
        }
    }
    else {
        ls_perror("No this debug command!\n");
        return -1;
    }
    return (LSBE_NO_ERROR);
}
Пример #25
0
static void
prtQueuesLong(int numQueues, struct queueInfoEnt *queueInfo)
{
    struct queueInfoEnt   *qp;
    char                  statusStr[64];
    char                  userJobLimit[MAX_CHARLEN];
    char                  procJobLimit[MAX_CHARLEN];
    char                  hostJobLimit[MAX_CHARLEN];
    char                  maxJobs[MAX_CHARLEN];
    int                   i;
    int                   numDefaults = 0;
    struct lsInfo         *lsInfo;
    int                   printFlag = 0;
    int                   printFlag1 = 0;
    int                   printFlag2 = 0;
    int                   procLimits[3];

    if ((lsInfo = ls_info()) == NULL) {
        ls_perror("ls_info");
        exit(-1);
    }

    printf("\n");

    for (i = 0; i < numQueues; i++ )  {
        qp = &(queueInfo[i]);
        if (qp->qAttrib & Q_ATTRIB_DEFAULT)
            numDefaults++;
    }

    for (i = 0; i < numQueues; i++) {

        qp = &(queueInfo[i]);

        if (qp->qStatus & QUEUE_STAT_OPEN) {
            sprintf(statusStr, "%s:", I18N_Open);
        }
        else {
            sprintf(statusStr, "%s:", I18N_Closed);
        }
        if (qp->qStatus & QUEUE_STAT_ACTIVE) {
            if (qp->qStatus & QUEUE_STAT_RUN) {
                strcat(statusStr, I18N_Active);
            } else {
                strcat(statusStr, I18N_Inact__Win);
            }
        } else {
            strcat(statusStr, I18N_Inact__Adm);
        }


        if (qp->maxJobs < INFINIT_INT)
            strcpy(maxJobs, prtValue(QUEUE_MAX_LENGTH, qp->maxJobs) );
        else
            strcpy(maxJobs, prtDash(QUEUE_MAX_LENGTH) );


        if (qp->userJobLimit < INFINIT_INT)
            strcpy(userJobLimit,
                   prtValue(QUEUE_JL_U_LENGTH, qp->userJobLimit) );
        else
            strcpy(userJobLimit, prtDash(QUEUE_JL_U_LENGTH) );


        if (qp->procJobLimit < INFINIT_FLOAT) {
            sprintf(fomt, "%%%d.1f ", QUEUE_JL_P_LENGTH);
            sprintf (procJobLimit, fomt, qp->procJobLimit);
        }
        else
            strcpy(procJobLimit, prtDash(QUEUE_JL_P_LENGTH) );


        if (qp->hostJobLimit < INFINIT_INT)
            strcpy(hostJobLimit,
                   prtValue(QUEUE_JL_H_LENGTH, qp->hostJobLimit) );
        else
            strcpy(hostJobLimit, prtDash(QUEUE_JL_H_LENGTH) );

        if (i > 0)
            printf("-------------------------------------------------------------------------------\n\n");
        printf("%s: %s\n", _i18n_msg_get(ls_catd,NL_SETN,1210,
                                         "QUEUE"), qp->queue); /* catgets  1210  */

        printf("  -- %s", qp->description);
        if (qp->qAttrib & Q_ATTRIB_DEFAULT) {
            if (numDefaults == 1)
                printf("  %s.\n\n", _i18n_msg_get(ls_catd,NL_SETN,1211,
                                                  "This is the default queue")); /* catgets  1211  */
            else
                printf("  %s.\n\n", _i18n_msg_get(ls_catd,NL_SETN,1212,
                                                  "This is one of the default queues")); /* catgets  1212  */
        } else
            printf("\n\n");

        printf((_i18n_msg_get(ls_catd,NL_SETN,1213, "PARAMETERS/STATISTICS\n"))); /* catgets  1213  */

        prtWord(QUEUE_PRIO_LENGTH, I18N_PRIO, 0);

        if ( lsbMode_ & LSB_MODE_BATCH )
            prtWord(QUEUE_NICE_LENGTH, I18N_NICE, 1);

        prtWord(QUEUE_STATUS_LENGTH, I18N_STATUS, 0);

        if ( lsbMode_ & LSB_MODE_BATCH ) {
            prtWord(QUEUE_MAX_LENGTH,  I18N_MAX, -1);
            prtWord(QUEUE_JL_U_LENGTH, I18N_JL_U, -1);
            prtWord(QUEUE_JL_P_LENGTH, I18N_JL_P, -1);
            prtWord(QUEUE_JL_H_LENGTH, I18N_JL_H, -1);
        };

        prtWord(QUEUE_NJOBS_LENGTH, I18N_NJOBS, -1);
        prtWord(QUEUE_PEND_LENGTH,  I18N_PEND,  -1);
        prtWord(QUEUE_RUN_LENGTH,   I18N_RUN,   -1);
        prtWord(QUEUE_SSUSP_LENGTH, I18N_SSUSP, -1);
        prtWord(QUEUE_USUSP_LENGTH, I18N_USUSP, -1);
        prtWord(QUEUE_RSV_LENGTH,   I18N_RSV,   -1);
        printf("\n");

        prtWordL(QUEUE_PRIO_LENGTH,
                 prtValue(QUEUE_PRIO_LENGTH-1, qp->priority));

        if ( lsbMode_ & LSB_MODE_BATCH )
            prtWordL(QUEUE_NICE_LENGTH,
                     prtValue(QUEUE_NICE_LENGTH-1, qp->nice));

        prtWord(QUEUE_STATUS_LENGTH, statusStr, 0);

        if ( lsbMode_ & LSB_MODE_BATCH ) {
            sprintf(fomt, "%%%ds%%%ds%%%ds%%%ds", QUEUE_MAX_LENGTH,
                    QUEUE_JL_U_LENGTH,
                    QUEUE_JL_P_LENGTH,
                    QUEUE_JL_H_LENGTH );
            printf(fomt,
                   maxJobs, userJobLimit, procJobLimit, hostJobLimit);
        };

        sprintf(fomt, "%%%dd %%%dd %%%dd %%%dd %%%dd %%%dd\n",
                QUEUE_NJOBS_LENGTH,
                QUEUE_PEND_LENGTH,
                QUEUE_RUN_LENGTH,
                QUEUE_SSUSP_LENGTH,
                QUEUE_USUSP_LENGTH,
                QUEUE_RSV_LENGTH );
        printf(fomt,
               qp->numJobs, qp->numPEND, qp->numRUN,
               qp->numSSUSP, qp->numUSUSP, qp->numRESERVE);

        if ( qp->mig < INFINIT_INT )
            printf((_i18n_msg_get(ls_catd,NL_SETN,1215,
                                  "Migration threshold is %d minutes\n")), qp->mig); /* catgets  1215  */

        if ( qp->schedDelay < INFINIT_INT )
            printf((_i18n_msg_get(ls_catd,NL_SETN,1216, "Schedule delay for a new job is %d seconds\n")),  /* catgets  1216  */
                   qp->schedDelay);

        if ( qp->acceptIntvl < INFINIT_INT )
            printf((_i18n_msg_get(ls_catd,NL_SETN,1217, "Interval for a host to accept two jobs is %d seconds\n")), /* catgets  1217  */
                   qp->acceptIntvl);

        if (((qp->defLimits[LSF_RLIMIT_CPU] != INFINIT_INT) &&
                (qp->defLimits[LSF_RLIMIT_CPU] > 0 )) ||
                ((qp->defLimits[LSF_RLIMIT_RUN] != INFINIT_INT) &&
                 (qp->defLimits[LSF_RLIMIT_RUN] > 0 )) ||
                ((qp->defLimits[LSF_RLIMIT_DATA] != INFINIT_INT) &&
                 (qp->defLimits[LSF_RLIMIT_DATA] > 0 )) ||
                ((qp->defLimits[LSF_RLIMIT_RSS] != INFINIT_INT) &&
                 (qp->defLimits[LSF_RLIMIT_RSS] > 0 )) ||
                ((qp->defLimits[LSF_RLIMIT_PROCESS] != INFINIT_INT) &&
                 (qp->defLimits[LSF_RLIMIT_PROCESS] > 0 ))) {


            printf("\n");
            printf(_i18n_msg_get(ls_catd,NL_SETN,1270,
                                 "DEFAULT LIMITS:") /* catgets 1270 */ );
            prtResourceLimit (qp->defLimits, qp->hostSpec, 1.0, 0);
            printf("\n");
            printf(_i18n_msg_get(ls_catd,NL_SETN,1271,
                                 "MAXIMUM LIMITS:") /* catgets 1271 */ );
        }

        procLimits[0] = qp->minProcLimit;
        procLimits[1] = qp->defProcLimit;
        procLimits[2] = qp->procLimit;
        prtResourceLimit (qp->rLimits, qp->hostSpec, 1.0, procLimits);

        if ( lsbMode_ & LSB_MODE_BATCH ) {
            printf((_i18n_msg_get(ls_catd,NL_SETN,1218, "\nSCHEDULING PARAMETERS\n")));  /* catgets 1218 */

            if (printThresholds (qp->loadSched,  qp->loadStop, NULL, NULL,
                                 MIN(lsInfo->numIndx, qp->nIdx), lsInfo) < 0)
                exit (-1);
        }

        if ((qp->qAttrib & Q_ATTRIB_EXCLUSIVE)
                || (qp->qAttrib & Q_ATTRIB_BACKFILL)
                || (qp->qAttrib & Q_ATTRIB_IGNORE_DEADLINE)
                || (qp->qAttrib & Q_ATTRIB_ONLY_INTERACTIVE)
                || (qp->qAttrib & Q_ATTRIB_NO_INTERACTIVE)) {

            printf("\n%s:", _i18n_msg_get(ls_catd,NL_SETN,1219,
                                          "SCHEDULING POLICIES")); /* catgets  1219  */
            if (qp->qAttrib & Q_ATTRIB_BACKFILL)
                printf("  %s", (_i18n_msg_get(ls_catd,NL_SETN,1223,
                                              "BACKFILL"))); /* catgets  1223  */
            if (qp->qAttrib & Q_ATTRIB_IGNORE_DEADLINE)
                printf("  %s", (_i18n_msg_get(ls_catd,NL_SETN,1224,
                                              "IGNORE_DEADLINE"))); /* catgets  1224  */
            if (qp->qAttrib & Q_ATTRIB_EXCLUSIVE)
                printf("  %s", (_i18n_msg_get(ls_catd,NL_SETN,1225,
                                              "EXCLUSIVE"))); /* catgets  1225  */
            if (qp->qAttrib & Q_ATTRIB_NO_INTERACTIVE)
                printf("  %s", (_i18n_msg_get(ls_catd,NL_SETN,1226,
                                              "NO_INTERACTIVE"))); /* catgets  1226  */
            if (qp->qAttrib & Q_ATTRIB_ONLY_INTERACTIVE)
                printf("  %s", (_i18n_msg_get(ls_catd,NL_SETN,1227,
                                              "ONLY_INTERACTIVE")));                   /* catgets  1227  */
            printf("\n");
        }

        if (strcmp (qp->defaultHostSpec, " ") !=  0)
            printf("\n%s: %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1230, "DEFAULT HOST SPECIFICATION")), qp->defaultHostSpec); /* catgets  1230  */

        if (qp->windows && strcmp (qp->windows, " " ) !=0)
            printf("\n%s: %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1231, "RUN_WINDOW")), qp->windows); /* catgets  1231  */
        if (strcmp (qp->windowsD, " ")  !=  0)
            printf("\n%s: %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1232, "DISPATCH_WINDOW")), qp->windowsD); /* catgets  1232  */

        if (lsbMode_ & LSB_MODE_BATCH) {
            if ( strcmp(qp->userList, " ") == 0) {
                printf("\n%s:  %s\n", I18N_USERS,
                       I18N(408, "all users")); /* catgets 408 */
            } else {
                if (strcmp(qp->userList, " ") != 0 && qp->userList[0] != 0)
                    printf("\n%s: %s\n", I18N_USERS, qp->userList);
            }
        }

        if (strcmp(qp->hostList, " ") == 0) {
            if (lsbMode_ & LSB_MODE_BATCH)
                printf("%s\n",
                       (_i18n_msg_get(ls_catd,NL_SETN,1235, "HOSTS:  all hosts used by the LSF Batch system"))); /* catgets  1235  */
            else
                printf("%s\n",
                       (_i18n_msg_get(ls_catd,NL_SETN,1236, "HOSTS: all hosts used by the LSF JobScheduler system"))); /* catgets  1236  */
        } else {
            if (strcmp(qp->hostList, " ") != 0 && qp->hostList[0])
                printf("%s:  %s\n", I18N_HOSTS, qp->hostList);
        }
        if (strcmp (qp->prepostUsername, " ") != 0)
            printf("%s:  %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1238, "PRE_POST_EXEC_USER")), qp->prepostUsername); /* catgets  1238  */
        if (strcmp (qp->admins, " ") != 0)
            printf("%s:  %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1239, "ADMINISTRATORS")), qp->admins); /* catgets  1239  */
        if (strcmp (qp->preCmd, " ") != 0)
            printf("%s:  %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1240, "PRE_EXEC")), qp->preCmd); /* catgets  1240  */
        if (strcmp (qp->postCmd, " ") != 0)
            printf("%s:  %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1241, "POST_EXEC")), qp->postCmd); /* catgets  1241  */
        if (strcmp (qp->requeueEValues, " ") != 0)
            printf("%s:  %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1242, "REQUEUE_EXIT_VALUES")), qp->requeueEValues); /* catgets  1242  */
        if (strcmp (qp->resReq, " ") != 0)
            printf("%s:  %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1243, "RES_REQ")), qp->resReq); /* catgets  1243  */
        if (qp->slotHoldTime > 0)
            printf((_i18n_msg_get(ls_catd,NL_SETN,1244, "Maximum slot reservation time: %d seconds\n")), qp->slotHoldTime); /* catgets  1244  */
        if (strcmp (qp->resumeCond, " ") != 0)
            printf("%s:  %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1245, "RESUME_COND")), qp->resumeCond); /* catgets  1245  */
        if (strcmp (qp->stopCond, " ") != 0)
            printf("%s:  %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1246, "STOP_COND")), qp->stopCond); /* catgets  1246  */
        if (strcmp (qp->jobStarter, " ") != 0)
            printf("%s:  %s\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1247, "JOB_STARTER")), qp->jobStarter);   /* catgets  1247  */
        if (qp->qAttrib & Q_ATTRIB_RERUNNABLE)
            printf("RERUNNABLE :  yes\n");

        if ( qp->qAttrib & Q_ATTRIB_CHKPNT ) {
            printf((_i18n_msg_get(ls_catd,NL_SETN,1261, "CHKPNTDIR : %s\n")), qp->chkpntDir); /* catgets  1261  */
            printf((_i18n_msg_get(ls_catd,NL_SETN,1262, "CHKPNTPERIOD : %d\n")), qp->chkpntPeriod); /* catgets  1262  */
        }

        if (qp->qAttrib & Q_ATTRIB_ROUND_ROBIN)
            printf("ROUN_ROBIN_SCHEDULING:  yes\n");

        printf("\n");
        printFlag = 0;
        if  ((qp->suspendActCmd != NULL)
                && (qp->suspendActCmd[0] != ' '))
            printFlag = 1;

        printFlag1 = 0;
        if  ((qp->resumeActCmd != NULL)
                && (qp->resumeActCmd[0] != ' '))
            printFlag1 = 1;

        printFlag2 = 0;
        if  ((qp->terminateActCmd != NULL)
                && (qp->terminateActCmd[0] != ' '))
            printFlag2 = 1;

        if (printFlag || printFlag1 || printFlag2)
            printf("%s:\n",
                   (_i18n_msg_get(ls_catd,NL_SETN,1251, "JOB_CONTROLS"))); /* catgets  1251  */

        if (printFlag) {
            printf("    %-9.9s", (_i18n_msg_get(ls_catd,NL_SETN,1252, "SUSPEND:"))); /* catgets  1252  */
            if (strcmp (qp->suspendActCmd, " ") != 0)
                printf("    [%s]\n", qp->suspendActCmd);
        }

        if (printFlag1) {
            printf("    %-9.9s", (_i18n_msg_get(ls_catd,NL_SETN,1253, "RESUME:"))); /* catgets  1253  */
            if (strcmp (qp->resumeActCmd, " ") != 0)
                printf("    [%s]\n", qp->resumeActCmd);
        }

        if (printFlag2) {
            printf("    %-9.9s", (_i18n_msg_get(ls_catd,NL_SETN,1254, "TERMINATE:"))); /* catgets  1254  */
            if (strcmp (qp->terminateActCmd, " ") != 0)
                printf("    [%s]\n", qp->terminateActCmd);
        }

        if (printFlag || printFlag1 || printFlag2)
            printf("\n");

        printFlag = terminateWhen_(qp->sigMap, "USER");
        printFlag1 = terminateWhen_(qp->sigMap, "WINDOW");
        printFlag2 = terminateWhen_(qp->sigMap, "LOAD");

        if (printFlag | printFlag1 | printFlag2) {
            printf((_i18n_msg_get(ls_catd,NL_SETN,1255, "TERMINATE_WHEN = "))); /* catgets  1255  */
            if (printFlag) printf((_i18n_msg_get(ls_catd,NL_SETN,1256, "USER "))); /* catgets  1256  */
            if (printFlag1) printf((_i18n_msg_get(ls_catd,NL_SETN,1258, "WINDOW "))); /* catgets  1258  */
            if (printFlag2) printf((_i18n_msg_get(ls_catd,NL_SETN,1259, "LOAD"))); /* catgets  1259  */
            printf("\n");
        }
    }

    printf("\n");

}
Пример #26
0
int
main(int argc, char **argv)
{
    static char fname[] = "lsinfo/main";
    struct lsInfo *lsInfo;
    int i, cc, nnames;
    char *namebufs[256];
    char longFormat = FALSE;
    char rFlag = FALSE;
    char tFlag = FALSE;
    char mFlag = FALSE;
    char mmFlag = FALSE;
    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);

    while ((cc = getopt(argc, argv, "VhlrmMt")) != EOF) {
        switch(cc) {
            case 'V':
                fputs(_LS_VERSION_, stderr);
                exit(0);
            case 'l':
                longFormat = TRUE;
                break;
            case 'r':
                rFlag = TRUE;
                break;
            case 't':
                tFlag = TRUE;
                break;
            case 'm':
                mFlag = TRUE;
                break;
            case 'M':
                mFlag  = TRUE;
                mmFlag = TRUE;
                break;
            case 'h':
            default:
                usage(argv[0]);
        }
    }

    for (nnames=0; optind < argc; optind++, nnames++)
        namebufs[nnames] = argv[optind];

    if ((lsInfo = ls_info()) == NULL) {
	ls_perror("lsinfo");
        exit(-10);
    }


    if (!nnames && !rFlag && !mFlag && !tFlag && !mmFlag)
        rFlag = mFlag = tFlag = TRUE;
    else if (nnames)
        rFlag = TRUE;

    if (rFlag) {
        if (!longFormat) {
	    char *buf1, *buf2, *buf3, *buf4;

	    buf1 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1804, "RESOURCE_NAME")), /* catgets  1804  */
	    buf2 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1805, "  TYPE ")), /* catgets  1805  */
	    buf3 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1806, "ORDER")), /* catgets  1806  */
	    buf4 = putstr_(_i18n_msg_get(ls_catd,NL_SETN,1807, "DESCRIPTION")), /* catgets  1807  */

            printf("%-13.13s %7.7s  %5.5s  %s\n",
		buf1, buf2, buf3, buf4);

	    FREEUP(buf1);
	    FREEUP(buf2);
	    FREEUP(buf3);
	    FREEUP(buf4);
	}

        for (i=0; i < lsInfo->nRes; i++) {
            if (!nameInList(namebufs, nnames, lsInfo->resTable[i].name))
                continue;
            if (!longFormat) {
               printf("%-13.13s %7.7s %5.5s   %s\n",
                   lsInfo->resTable[i].name,
                   valueTypeToStr(lsInfo->resTable[i].valueType),
                   orderTypeToStr(lsInfo->resTable[i].orderType),
                   lsInfo->resTable[i].des);
            } else
               print_long(&(lsInfo->resTable[i]));
        }

        for (i=0; i < nnames; i++)
            if (namebufs[i])
                printf(_i18n_msg_get(ls_catd,NL_SETN,1808, "%s: Resource name not found\n"),/* catgets  1808  */
		    namebufs[i]);

    }

    if (tFlag) {
        if (rFlag)
            putchar('\n');
        puts(_i18n_msg_get(ls_catd,NL_SETN,1809, "TYPE_NAME")); /* catgets  1809  */
        for (i=0;i<lsInfo->nTypes;i++)
            puts(lsInfo->hostTypes[i]);
    }

    if (mFlag) {
        if (rFlag || tFlag)
            putchar('\n');
        puts(_i18n_msg_get(ls_catd,NL_SETN,1810,
            "MODEL_NAME      CPU_FACTOR      ARCHITECTURE")); /* catgets  1810  */
        for (i = 0; i < lsInfo->nModels; ++i)
            if (mmFlag || lsInfo->modelRefs[i])
                printf("%-16s    %6.2f      %s\n", lsInfo->hostModels[i],
                    lsInfo->cpuFactor[i], lsInfo->hostArchs[i]);
    }

    _i18n_end ( ls_catd );

    exit(0);
}
Пример #27
0
int
limCtrl(int argc, char **argv, int opCode)
{
    char *optName;
    char *localHost;
    int vFlag = 0;
    int config = 0, checkReply;

    fFlag = 0;
    if (strcmp(argv[optind-1], "reconfig") == 0) {
	config = 1;
    }

    while ((optName = myGetOpt(argc, argv, "f|v|")) != NULL) {
        switch (optName[0]) {
            case 'v':
                if (opCode == LIM_CMD_SHUTDOWN)
                    return(-2);
                vFlag = 1;
                break;
            case 'f':
                fFlag = 1;
                break;
            default:
                return(-2);
        }
    }
    exitrc = 0;
    if (config && optind != argc)
        return -2;

    switch (checkReply)  {
	case EXIT_FATAL_ERROR:
            return -1;
	case EXIT_WARNING_ERROR:
            if (fFlag)
                break;
            if (!getConfirm(I18N(250, "Do you want to reconfigure? [y/n] "))) /* catgets 250 */ {
                fprintf(stderr, I18N(251, "Reconfiguration aborted.\n")); /* catgets 251 */
                return(-1);
            }
            break;
        default:
            break;
    }

    if (config) {
        doAllHosts(opCode);
        return(exitrc);
    }

    if (optind == argc) {
	if ((localHost = ls_getmyhostname()) == NULL) {
            ls_perror("ls_getmyhostname");
            return -1;
	}
        operateHost(localHost, opCode, 0);
    }
    else
    {
	doHosts(argc, argv, opCode);
    }

    return(exitrc);

}
Пример #28
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;
}
Пример #29
0
int
checkConf(int verbose, int who)
{
    char confCheckBuf[] = "RECONFIG_CHECK=TRUE";
    pid_t pid;
    char *daemon, *lsfEnvDir;
    static struct config_param lsfParams[] =
    {
        {"LSF_SERVERDIR", NULL},
        {"LSF_CONFDIR", NULL},
        {"LSB_CONFDIR", NULL},
        {"LSB_SHAREDIR", NULL},
        {NULL, NULL},
    };
    struct config_param *plp;
    LS_WAIT_T status;
    int fatalErr = FALSE, cc = 0;
    int fd;

    if (lsfParams[0].paramValue == NULL) {
        lsfEnvDir = getenv("LSF_ENVDIR");
        cc = initenv_(lsfParams, lsfEnvDir);
    }
    if (cc < 0) {
        if (lserrno == LSE_CONF_SYNTAX) {
            char lno[20];
            sprintf (lno, _i18n_msg_get(ls_catd, NL_SETN, 110,
                                        "Line %d"), errLineNum_); /* catgets 110 */
            ls_perror(lno);
        } else
            ls_perror("initenv_");
    }
    plp = lsfParams;
    for (; plp->paramName != NULL; plp++)
        if (plp->paramValue == NULL) {
            fprintf(stderr,
                    _i18n_msg_get(ls_catd, NL_SETN, 111,
                                  "%s is missing or has a syntax error in lsf.conf file\n"),/* catgets 111 */
                    plp->paramName);
            fatalErr = TRUE;
        }
    if (fatalErr)
        return (EXIT_FATAL_ERROR);
    if (cc < 0)
        return (EXIT_WARNING_ERROR);

    if ((daemon = calloc(strlen(lsfParams[0].paramValue)+15,
                         sizeof(char))) == NULL) {
        perror("calloc");
        return (EXIT_FATAL_ERROR);
    }

    strcpy(daemon, lsfParams[0].paramValue);

    strcat(daemon, ((who == 1) ? "/lim" : "/mbatchd"));

    if (access(daemon, X_OK) < 0) {
        perror(daemon);
        free(daemon);
        return (EXIT_FATAL_ERROR);
    }

    if (putenv(confCheckBuf)) {
        fprintf(stderr,
                _i18n_msg_get(ls_catd, NL_SETN, 112,
                              "Failed to set environment variable RECONFIG_CHECK\n"));    /* catgets 112 */
        free(daemon);
        return(EXIT_FATAL_ERROR);
    }


    if ((pid = fork()) < 0) {
        perror("fork");
        free(daemon);
        return (EXIT_FATAL_ERROR);
    }

    if (pid == 0) {
        if (!verbose) {
            fd = open(LSDEVNULL, O_RDWR);
            dup2(fd, 1);
            dup2(fd, 2);
        }

        if (changeUserEUId() < 0) {
            exit(EXIT_FATAL_ERROR);
        }

        execlp(daemon, daemon, "-C", (char *)0);
        perror("execlp");

        exit(EXIT_RUN_ERROR);
    }


    free(daemon);
    fprintf(stderr, (_i18n_msg_get(ls_catd,NL_SETN,115, "\nChecking configuration files ...\n"))); /* catgets 115 */

    if (waitpid(pid, &status, 0) < 0) {
        perror("waitpid");
        return(EXIT_FATAL_ERROR);
    }

    if (WIFEXITED(status) != 0 && WEXITSTATUS(status) != 0xf8)
        if (verbose)
            fprintf(stderr, "---------------------------------------------------------\n");


    if (WIFEXITED(status) == 0) {
        fprintf(stderr,
                _i18n_msg_get(ls_catd, NL_SETN, 116,
                              "Child process killed by signal.\n\n")); /* catgets 116 */
        return(EXIT_FATAL_ERROR);
    }

    switch (WEXITSTATUS(status)) {
    case  0 :
        fprintf(stderr,
                _i18n_msg_get(ls_catd, NL_SETN, 117,
                              "No errors found.\n\n"));  /* catgets 117 */
        return(EXIT_NO_ERROR);

    case  0xff :
        fprintf(stderr,
                _i18n_msg_get(ls_catd, NL_SETN, 118,
                              "There are fatal errors.\n\n")); /* catgets 118 */
        return(EXIT_FATAL_ERROR);

    case  0xf8 :
        fprintf(stderr,
                _i18n_msg_get(ls_catd, NL_SETN, 119,
                              "Fail to run checking program \n\n")); /* catgets 119 */
        return(EXIT_FATAL_ERROR);

    case  0xfe :
        fprintf(stderr,
                _i18n_msg_get(ls_catd, NL_SETN, 120,
                              "No fatal errors found.\n\n"));/* catgets 120 */
        fprintf(stderr,
                _i18n_msg_get(ls_catd, NL_SETN, 121, "Warning: Some configuration parameters may be incorrect.\n"));  /* catgets 121 */
        fprintf(stderr,
                _i18n_msg_get(ls_catd, NL_SETN, 122,
                              "         They are either ignored or replaced by default values.\n\n"));  /* catgets 122  */
        return(EXIT_WARNING_ERROR);

    default :
        fprintf(stderr,
                _i18n_msg_get(ls_catd, NL_SETN, 123,
                              "Errors found.\n\n"));  /* catgets 123 */
        return(EXIT_FATAL_ERROR);
    }

}
Пример #30
0
int
searchEventFile(struct histReq *req, int *eventFound)
{
    char eventFileName[MAXFILENAMELEN];
    int lineNum = 0;
    struct stat statBuf;
    struct eventRec *log;
    FILE *log_fp;
    char *envdir;

    struct config_param histParams[] = {
#define LSB_SHAREDIR 0
        {"LSB_SHAREDIR", NULL},
        {NULL, NULL}
    };

    if ((envdir = getenv("LSF_ENVDIR")) == NULL)
	envdir = "/etc";

    if (ls_readconfenv(histParams, envdir) < 0) {
	ls_perror("ls_readconfenv");
	return(-1);
    }

    if (!req->eventFileName) {
	memset(eventFileName, 0, sizeof(eventFileName));
	ls_strcat(eventFileName, sizeof(eventFileName),
                  histParams[LSB_SHAREDIR].paramValue);
	ls_strcat(eventFileName, sizeof(eventFileName),"/logdir/lsb.events");
    } else {
	memset(eventFileName,0, sizeof(eventFileName));
	ls_strcat(eventFileName, sizeof(eventFileName),req->eventFileName);
    }

    FREEUP (histParams[LSB_SHAREDIR].paramValue);

    if (stat(eventFileName, &statBuf) < 0) {
        perror(eventFileName);
        return (-1);
    }

    if ((log_fp = fopen(eventFileName, "r")) == NULL) {
	perror(eventFileName);
	return(-1);
    }

    eventMatched = FALSE;
    while (TRUE) {

	log = lsb_geteventrec(log_fp, &lineNum);
        if (log) {
	    displayEvent(log, req);
	    continue;
        }

        if (lsberrno == LSBE_EOF)
	    break;
	fprintf(stderr, "\
File %s at line %d: %s\n", eventFileName, lineNum, lsb_sysmsg());
    }

    if (!eventMatched)
        fprintf(stderr, "No matching event found\n");
    *eventFound = eventMatched;

    fclose(log_fp);

    return 0;
}