int
main (int argc, char **argv)
{
  struct submit req;
  struct submitReply reply;
  char *job;
  LS_LONG_INT jobId = -1, *jobIdList = NULL;
  int numJobIds;
  time_t beginTime, terminTime;
  int rc;

  rc = _i18n_init (I18N_CAT_MIN);

  if (lsb_init (argv[0]) < 0)
    {
      sub_perror ("lsb_init");
      fprintf (stderr, ". %s.\n", (_i18n_msg_get (ls_catd, NL_SETN, 351, "Job not modified")));	/* catgets  351  */
      exit (-1);
    }

  if (fillReq (argc, argv, CMD_BMODIFY, &req) < 0)
    {
      fprintf (stderr, ". %s.\n",
	       (_i18n_msg_get (ls_catd, NL_SETN, 351, "Job not modified")));
      exit (-1);
    }

  job = req.command;
  beginTime = req.beginTime;
  terminTime = req.termTime;

  if ((numJobIds = getJobIdList (job, &jobIdList)) < 0)
    {
      exit (-1);
    }
  jobId = jobIdList[0];
  if ((jobId = lsb_modify (&req, &reply, jobId)) < 0)
    {
      if (lsberrno == LSBE_JOB_ARRAY)
	{
	  fprintf (stderr, (_i18n_msg_get (ls_catd, NL_SETN, 352, "Options -q and -O cannot be applied on job array")));	/* catgets  352  */
	}
      else
	prtErrMsg (&req, &reply);
      fprintf (stderr, ". %s.\n",
	       (_i18n_msg_get (ls_catd, NL_SETN, 351, "Job not modified")));
      if (req.nxf)
	free (req.xf);
      exit (-1);
    }

  printf ((_i18n_msg_get (ls_catd, NL_SETN, 353, "Parameters of job <%s> are being changed\n")), job);	/* catgets  353 */
  if (beginTime > 0 || terminTime > 0)
    prtBETime_ (&req);
  if (req.nxf)
    free (req.xf);

  _i18n_end (ls_catd);
  exit (0);
}
Beispiel #2
0
int
main(int argc, char **argv)
{
     _i18n_init(I18N_CAT_MIN);

    bmove(argc, argv, TO_BOTTOM);
    return 0;
}
Beispiel #3
0
int 
main (int argc, char **argv)
{

    int rc;

    rc = _i18n_init ( I18N_CAT_MIN );	
    exit(do_sub(argc, argv, CMD_BSUB));
    _i18n_end ( ls_catd );			
} 
int
main (int argc, char *argv[])
{
  int rt;

  rt = _i18n_init (I18N_CAT_MIN);

  setdefaults ();
  getoptions (argc, argv);
  getpids (argc, argv);
  printheader ();
  initstats ();
  processlogfile ();
  printsummary ();

  _i18n_end (ls_catd);
  return (0);

}
Beispiel #5
0
int
main(int argc, char **argv)
{
    static char fname[] = "res/main";
    int nready;
    int maxfd;
    int i;
    char *sp;
    char *pathname = NULL;
    int didSomething = 0;
    char exbuf;

    time_t thisPeriodic, lastPeriodic = 0, timeDiff;


    fd_set rm, wm, em;

    int sbdPty = FALSE;
    char *sbdClHost = NULL;
    ushort sbdClPort = 0;
    char **sbdArgv = NULL;
    int selectError = 0;


    _i18n_init(I18N_CAT_RES);

    saveDaemonDir_(argv[0]);



    for (i=1; i<argc; i++) {
      if (strcmp(argv[i], "-d") == 0 && argv[i+1] != NULL) {
         pathname = argv[i+1];
         putEnv("LSF_ENVDIR",pathname);
         break;
      }
    }

    if (pathname == NULL) {
	if ((pathname = getenv("LSF_ENVDIR")) == NULL)
	    pathname = LSETCDIR;
    }


    if (argc > 1) {
        if (!strcmp(argv[1],"-V")) {
            fputs(_LS_VERSION_, stderr);
            exit(0);
        }
    }



    if ((ls_readconfenv(resConfParams, NULL) < 0) ||
        (initenv_(resParams, pathname) < 0) ) {
        if ((sp = getenv("LSF_LOGDIR")) != NULL)
            resParams[LSF_LOGDIR].paramValue = sp;
        ls_openlog("res", resParams[LSF_LOGDIR].paramValue, (debug > 1),
                   resParams[LSF_LOG_MASK].paramValue);
        ls_syslog(LOG_ERR, I18N_FUNC_S_FAIL_MM, fname, "initenv_",
            pathname);
        ls_syslog(LOG_ERR, I18N_Exiting);
        exit(-1);
    }



    restart_argc = argc;
    restart_argv = argv;
    for (i=1; i<argc; i++) {
	if (strcmp(argv[i], "-d") == 0 && argv[i+1] != NULL) {
	    pathname = argv[i+1];
	    i++;
	    continue;
	}

	if (strcmp(argv[i], "-1") == 0) {
	    debug = 1;
	    continue;
	}

	if (strcmp(argv[i], "-2") == 0) {
	    debug = 2;
	    continue;
	}


	if (strcmp(argv[i], "-PTY_FIX") == 0) {
	    printf("PTY_FIX");
	    exit(0);
	}


	if ( (strcmp(argv[i], "-j") == 0) && (argv[i+1] != NULL) ) {
	    lsbJobStarter = argv[++i];
	    continue;
	}

	if (strcmp(argv[i], "-P") == 0) {
	    sbdPty = TRUE;
	    continue;
	}

	if (strcmp(argv[i], "-i") == 0) {
	    sbdFlags |= SBD_FLAG_STDIN;
	    continue;
	}

	if (strcmp(argv[i], "-o") == 0) {
	    sbdFlags |= SBD_FLAG_STDOUT;
	    continue;
	}

	if (strcmp(argv[i], "-e") == 0) {
	    sbdFlags |= SBD_FLAG_STDERR;
	    continue;
	}

	if (strcmp(argv[i], "-m") == 0 && argv[i+1] != NULL) {
	    sbdClHost = argv[i+1];
	    i++;
	    sbdMode = TRUE;
	    continue;
	}

	if (strcmp(argv[i], "-p") == 0 && argv[i+1] != NULL) {
	    sbdClPort = atoi(argv[i+1]);
	    i++;
	    sbdMode = TRUE;
	    continue;
	}


	if (argv[i][0] != '-') {
	    sbdMode = TRUE;
	    sbdArgv = argv + i;
	    break;
	}

        usage(argv[0]);
    }

    if (sbdMode) {

	if (sbdClHost == NULL || sbdArgv == NULL) {
	    usage(argv[0]);
	    exit(-1);
	}
	if (sbdClPort) {
	    sbdFlags |= SBD_FLAG_TERM;
	} else {

	    sbdFlags |= SBD_FLAG_STDIN | SBD_FLAG_STDOUT | SBD_FLAG_STDERR;
	}
    } else {


	if (debug < 2)
	    for (i = sysconf(_SC_OPEN_MAX) ; i >= 0 ; i--)
		close(i);
    }


    if (resParams[LSF_SERVERDIR].paramValue == NULL) {
	ls_openlog("res", resParams[LSF_LOGDIR].paramValue, (debug > 1),
				   resParams[LSF_LOG_MASK].paramValue);
	ls_syslog(LOG_ERR, _i18n_msg_get(ls_catd , NL_SETN, 5001,
	    "LSF_SERVERDIR not defined in %s/lsf.conf: %M; res exiting"), /* catgets 5001 */
	    pathname);
	resExit_(-1);
    }


    if (! debug && resParams[LSF_RES_DEBUG].paramValue != NULL) {
	debug = atoi(resParams[LSF_RES_DEBUG].paramValue);
	if (debug <= 0)
	    debug = 1;
    }


    getLogClass_(resParams[LSF_DEBUG_RES].paramValue,
                 resParams[LSF_TIME_RES].paramValue);


    if (getuid() == 0 && debug) {
        if (sbdMode)  {
	   debug = 0;
	} else {
          ls_openlog("res", resParams[LSF_LOGDIR].paramValue, FALSE,
		   resParams[LSF_LOG_MASK].paramValue);
          ls_syslog(LOG_ERR, I18N(5005,"Root cannot run RES in debug mode ... exiting."));/*catgets 5005 */
	   exit(-1);
	}
    }

    if (debug > 1)
	ls_openlog("res", resParams[LSF_LOGDIR].paramValue, TRUE, "LOG_DEBUG");
    else {
 	ls_openlog("res", resParams[LSF_LOGDIR].paramValue, FALSE,
		   resParams[LSF_LOG_MASK].paramValue);
    }
    if (logclass & (LC_TRACE | LC_HANG))
        ls_syslog(LOG_DEBUG, "%s: logclass=%x", fname, logclass);

    ls_syslog(LOG_DEBUG, "%s: LSF_SERVERDIR=%s", fname, resParams[LSF_SERVERDIR].paramValue);



    init_res();
    initSignals();

    periodic(0);



    if (sbdMode) {
	lsbJobStart(sbdArgv, sbdClPort, sbdClHost, sbdPty);
    }

    maxfd = FD_SETSIZE;


    for (;;) {
        struct timeval *timep;
        struct timeval timeout;
loop:
        didSomething = 0;

        for (i = 0; i < child_cnt; i++) {
            if (children[i]->backClnPtr == NULL
                 && !FD_IS_VALID(conn2NIOS.sock.fd)
                 && children[i]->running == 0) {
                delete_child (children[i]);
            }
        }

	if (logclass & LC_TRACE) {
	    ls_syslog(LOG_DEBUG,"\
%s: %s Res child_res=<%d> child_go=<%d> child_cnt=<%d> client_cnt=<%d>",
		      fname, ((child_res) ? "Application" : "Root") ,
		      child_res, child_go, child_cnt, client_cnt);
            if (child_cnt == 1 && children != NULL && children[0] != NULL) {
                dumpChild(children[0], 1, "in main()");
            }
	}

        if (child_res && child_go && child_cnt == 0 && client_cnt == 0)  {


            if (debug > 1)
		printf (" \n Child <%d> Retired! \n", (int)getpid());

	    if (logclass & LC_TRACE) {
		ls_syslog(LOG_DEBUG,"\
%s: Application Res is exiting.....", fname);
	    }


	    millisleep_(5000);


	    if (sbdMode) {

		close(1);
		close(2);
		exit(lastChildExitStatus);
            }
	    resExit_(EXIT_NO_ERROR);
        }
Beispiel #6
0
int
main (int argc, char **argv, char **environ)
{
  char *queue = NULL, *host = NULL, *jobName = NULL, *user = NULL;
  LS_LONG_INT jobId;
  int options;
  struct jobInfoEnt *jInfo;
  char *outFile;
  char fflag = FALSE;
  int cc;
  int rc;

  rc = _i18n_init (I18N_CAT_MIN);

  if (lsb_init (argv[0]) < 0)
    {
      lsb_perror ("lsb_init");
      exit (-1);
    }

  while ((cc = getopt (argc, argv, "Vhfq:m:J:")) != EOF)
    {
      switch (cc)
	{
	case 'q':
	  if (queue || host || jobName)
	    oneOf (argv[0]);
	  queue = optarg;
	  break;
	case 'm':
	  if (queue || host || jobName)
	    oneOf (argv[0]);
	  host = optarg;
	  break;
	case 'J':
	  if (queue || host || jobName)
	    oneOf (argv[0]);
	  jobName = optarg;
	  break;
	case 'V':
	  fputs (_LS_VERSION_, stderr);
	  exit (0);
	case 'f':
	  fflag = TRUE;
	  break;
	case 'h':
	default:
	  usage (argv[0]);
	}
    }

  jobId = 0;
  options = LAST_JOB;
  if (argc >= optind + 1)
    {
      if (queue || host || jobName)
	{
	  oneOf (argv[0]);
	}
      else if ((argc > 2 && !fflag) || (argc > 3 && fflag))
	usage (argv[0]);

      if (getOneJobId (argv[optind], &jobId, 0))
	{
	  usage (argv[0]);
	}

      options = 0;
    }



  if (lsb_openjobinfo (jobId, jobName, NULL, queue, host, options) < 0
      || (jInfo = lsb_readjobinfo (NULL)) == NULL)
    {

      if (jobId != 0 || jobName != NULL)
	{
	  user = ALL_USERS;
	  if (lsb_openjobinfo (jobId, jobName, user, queue, host, options) < 0
	      || (jInfo = lsb_readjobinfo (NULL)) == NULL)
	    {
	      jobInfoErr (jobId, jobName, NULL, queue, host, options);
	      exit (-1);
	    }
	}
      else
	{
	  jobInfoErr (jobId, jobName, NULL, queue, host, options);
	  exit (-1);
	}
    }
  lsb_closejobinfo ();


  if (jobId && jInfo->jobId != jobId)
    {
      lsberrno = LSBE_JOB_ARRAY;
      lsb_perror ("bpeek");
      exit (-1);
    }


  if ((jInfo->submit.options & SUB_INTERACTIVE) &&
      !(jInfo->submit.options & (SUB_OUT_FILE | SUB_ERR_FILE)))
    {
      fprintf (stderr, _i18n_msg_get (ls_catd, NL_SETN, 2456, "Job <%s> : Cannot bpeek an interactive job.\n"),	/* catgets  2456 */
	       lsb_jobid2str (jInfo->jobId));
      exit (-1);
    }

  if (IS_PEND (jInfo->status) || jInfo->execUsername[0] == '\0')
    {
      fprintf (stderr, _i18n_msg_get (ls_catd, NL_SETN, 2454, "Job <%s> : Not yet started.\n"),	/* catgets  2454 */
	       lsb_jobid2str (jInfo->jobId));

      exit (-1);
    }
  if (IS_FINISH (jInfo->status))
    {
      fprintf (stderr, _i18n_msg_get (ls_catd, NL_SETN, 2455, "Job <%s> : Already finished.\n"),	/* catgets  2455  */
	       lsb_jobid2str (jInfo->jobId));
      exit (-1);
    }

  if ((outFile = lsb_peekjob (jInfo->jobId)) == NULL)
    {
      char msg[50];
      sprintf (msg, "%s <%s>", I18N_Job, lsb_jobid2str (jInfo->jobId));
      lsb_perror (msg);
      exit (-1);
    }
  displayOutput (outFile, jInfo, fflag, environ);
  _i18n_end (ls_catd);
  exit (0);

}
Beispiel #7
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++;
    }
Beispiel #8
0
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);
    
} 
Beispiel #9
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);

}
Beispiel #10
0
int
main(int argc, char** argv)
{
    char*                 hosts   = NULL;
    struct runJobRequest  runJobRequest;
    int                   cc;
    int                   c;
    bool_t                fFlag = FALSE;
    bool_t		  bFlag = FALSE;
    int rc;

    rc = _i18n_init ( I18N_CAT_MIN );


    if (lsb_init(argv[0]) < 0) {
	lsb_perror("lsb_init");
	exit (-1);
    }

    while((c = getopt(argc, argv, "m:fbhV")) != EOF) {
	switch(c) {
	case 'm':
	    hosts = putstr_(optarg);
	    if (hosts == NULL) {
		perror("putstr_");
		exit(-1);
	    }
	    break;
        case 'f':
	    fFlag = TRUE;
	    break;
	case 'b':
	    bFlag = TRUE;
	    break;
	case 'V':
	    fputs(_LS_VERSION_, stderr);
	    return (0);
	case 'h':
	    usage(argv[0]);
	    exit(-1);
	}
    }

    if (argc <= optind) {
	usage(argv[0]);
	exit(-1);
    }

    memset((struct runJobRequest* )&runJobRequest, 0,
	   sizeof(struct runJobRequest));


    if (getOneJobId (argv[argc - 1], &(runJobRequest.jobId), 0)) {
	usage(argv[0]);
	exit(-1);
    }
    runJobRequest.numHosts = countHosts(hosts);

    if (runJobRequest.numHosts > 1) {
	int     i;

	runJobRequest.hostname = (char **)calloc(runJobRequest.numHosts,
						 sizeof(char *));
	if (runJobRequest.hostname == NULL) {
	    perror("calloc");
	    exit(-1);
	}

	for (i = 0; i < runJobRequest.numHosts; i++) {
	    while (isspace(*hosts)) hosts++;
	    runJobRequest.hostname[i] = hosts;
	    hosts += strlen(hosts) + 1;
	}
    } else
	runJobRequest.hostname = &hosts;

    runJobRequest.options = (fFlag == TRUE) ?
	RUNJOB_OPT_NOSTOP : RUNJOB_OPT_NORMAL;

    if (bFlag) {
	runJobRequest.options |= RUNJOB_OPT_FROM_BEGIN;
    }


    cc = lsb_runjob(&runJobRequest);
    if (cc < 0) {
	lsb_perror((_i18n_msg_get(ls_catd,NL_SETN,2755, "Failed to run the job"))); /* catgets  2755  */
	exit(-1);
    }

    printf((_i18n_msg_get(ls_catd,NL_SETN,2756, "Job <%s> is being forced to run.\n")), /* catgets  2756  */
	   lsb_jobid2str(runJobRequest.jobId));

    _i18n_end ( ls_catd );
    return (0);
}
Beispiel #11
0
int
main (int argc, char **argv)
{
  int cc, myIndex;
  const char prompt[] = "badmin> ";
  static char line[MAXLINELEN];
  int rc;

  rc = _i18n_init (I18N_CAT_MIN);

  if (lsb_init (argv[0]) < 0)
    {
      lsb_perror ("lsb_init");
      _i18n_end (ls_catd);
      exit (-1);
    }

  while ((cc = getopt (argc, argv, "Vh")) != EOF)
    {
      switch (cc)
	{
	case 'V':
	  fputs (_LS_VERSION_, stderr);
	  exit (0);
	case 'h':
	default:


	  cmdsUsage ("badmin", cmdList,
		     _i18n_msgArray_get (ls_catd, NL_SETN, cmdInfo_ID,
					 cmdInfo));
	}
    }
  if (argc > optind)
    {
      int rc;

      if ((myIndex = adminCmdIndex (argv[optind], cmdList)) == -1)
	{
	  fprintf (stderr, (_i18n_msg_get (ls_catd, NL_SETN, 2552, "Invalid command <%s> \n")), argv[optind]);	/* catgets  2552  */

	  cmdsUsage ("badmin", cmdList,
		     _i18n_msgArray_get (ls_catd, NL_SETN, cmdInfo_ID,
					 cmdInfo));
	}
      optind++;
      rc = doBatchCmd (argc, argv);
      _i18n_end (ls_catd);
      exit (rc);
    }

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

      parseAndDo (line, doBatchCmd);
    }
  return (0);

}
Beispiel #12
0
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;
}
Beispiel #13
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);
}
Beispiel #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++;
    }
Beispiel #15
0
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);
    }