⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xpbs_datadump.c

📁 openPBS的开放源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
        walltimeu[0] = '\0';        state[0] = '\0';        location[0] = '\0';        nodes[0] = '\0';        if ( full ) {            printf("Job Id: %s@%s\n", p->name, server_name);            a = p->attribs;            while ( a != NULL ) {                if ( a->name != NULL ) {		    if ( strcmp(a->name, ATTR_ctime)==0 ||		         strcmp(a->name, ATTR_mtime)==0 ||		         strcmp(a->name, ATTR_qtime)==0 ||			 strcmp(a->name, ATTR_a)==0 ) {			epoch = (time_t) atoi(a->value);			prt_attr(a->name, a->resource, ctime(&epoch));		    } else {			prt_attr(a->name, a->resource, a->value);			printf("\n");		    }                }                a = a->next;            }        } else {	     	             if ( p->name != NULL ) {	       if( (e = mystrdup( p->name)) == NULL ) {	           fprintf(stderr, "Error getting more space to malloc\n");	           exit(2);                }                c = e;		/* we need e as the starting address for */				/* future free */                while ( *c != '.' && *c != '\0' ) c++;                c++;    /* List the first part of the server name, too. */                while ( *c != '.' && *c != '\0' ) c++;                c++;    /* List also the 2nd part of the server name, too. */                while ( *c != '.' && *c != '\0' ) c++;                *c = '\0';                l = strlen(e);                if ( l > (PBS_MAXSEQNUM+14) ) {	   	        c  = e + PBS_MAXSEQNUM + 14;			*c = '\0';                }                strcpy(jid, e);                free(e);            }            a = p->attribs;            while ( a != NULL ) {                if ( a->name != NULL )  {	           if( (e = mystrdup(a->value)) == NULL ) {	               fprintf(stderr, "Error getting more space to malloc\n");	               exit(2);                    }                    c = e;	/* we need e as the starting address for */				/* future free */                    if ( strcmp(a->name,ATTR_name) == 0 ) {                        l = strlen(e);                        if ( l > NAMEL ) {			    l = l - NAMEL + 3;                            c = e + l;			    while ( *c != '/' && *c != '\0' ) c++;			    if ( *c == '\0' ) c = e + l;			    strcpy(long_name, "...");                            strcat(long_name, c);			    c = long_name;			} else			    c = e;                        strcpy(name, c);                    } else if ( strcmp(a->name,ATTR_owner) == 0 ) {                        c = e;                        while ( *c != '@' && *c != '\0' ) c++;                        *c = '\0';                        l = strlen(e);                        if ( l > OWNERL ) {                            c = e + OWNERL;                            *c = '\0';                        }                        strcpy(owner, e);                    } else if ( strcmp(a->name,ATTR_used) == 0 ) {                        if ( strcmp(a->resource, "cput") == 0 ) {                            l = strlen(e);                            if ( l > TIMEUL ) {                                c = e + TIMEUL;                                *c = '\0';                            }                            strcpy(cputimeu, e);                        } else if ( strcmp(a->resource, "walltime") == 0 ) {                            l = strlen(e);                            if ( l > TIMEUL ) {                                c = e + TIMEUL;                                *c = '\0';                            }                            strcpy(walltimeu, e);                        }                    } else if ( strcmp(a->name, ATTR_state) == 0 ) {                        l = strlen(e);                        if ( l > STATEL ) {                            c = e + STATEL;                            *c = '\0';                        }                        strcpy(state, e);                    } else if ( strcmp(a->name,ATTR_queue) == 0 ) {                        c = e;                        while ( *c != '@' && *c != '\0' ) c++;                        *c = '\0';                        l = strlen(e);                        if ( l > LOCL ) {                            c = e + LOCL;                            *c = '\0';                        }                        strcpy(location, e);                    } else if ( strcmp(a->name, ATTR_l) == 0 ) {                	if ( strcmp(a->resource, "nodect") == 0 || \			     strcmp(a->resource, "ncpus") == 0 ) {                            l = strlen(e);                            if ( l > NODEL ) {                                c = e + NODEL;                                *c = '\0';                            }                            strcpy(nodes, e);                        }		    }                }                a = a->next;                free(e);            }            if ( cputimeu[0] == '\0' )		strcpy(cputimeu,"0");            if ( walltimeu[0] == '\0' )		strcpy(walltimeu,"0");            if ( nodes[0] == '\0' )		strcpy(nodes,"-");            printf(format, jid, name, owner, nodes, cputimeu, walltimeu, state,				location, server_name, server_name, p->name);        }	if ( full ) printf("\n");        p = p->next;    }    return;}void display_trackstatjob(status, server_name)struct batch_status *status;char *server_name;{    struct batch_status *p;    struct attrl *a;    char owner[OWNERL+1];    char output_path[MAXPATHLEN];    char error_path[MAXPATHLEN];    int l;    char *c, *e;    p = status;    while ( p != NULL ) {      printf("%s@%s ", p->name, server_name);      a = p->attribs;      while ( a != NULL ) {          if ( a->name != NULL ) {	     if( (e = mystrdup(a->value)) == NULL ) {	         fprintf(stderr, "Error getting more space to malloc\n");	         exit(2);             }             c = e;	/* we need e as the starting address for */		        /* future free */             if ( strcmp(a->name,ATTR_owner) == 0 ) {                  c = e;                  while ( *c != '@' && *c != '\0' ) c++;                    *c = '\0';                    l = strlen(e);                    if ( l > OWNERL ) {                       c = e + OWNERL;                       *c = '\0';		    }                  strcpy(owner, e);             } else if ( strcmp(a->name,ATTR_o) == 0 ) {		  strcpy(output_path, a->value);             } else if ( strcmp(a->name,ATTR_e) == 0 ) {		  strcpy(error_path, a->value);	     }          }          free(e);          a = a->next;      }      printf("%s %s %s\n", owner, output_path, error_path);      p = p->next;    }    return;}#define QNAMEL  16#define NUML    5#define TYPEL   10voiddisplay_statque(status, prtheader, full, server_name)struct batch_status *status;int prtheader;int full;char *server_name;{    struct batch_status *p;    struct attrl *a;    int l;    char *c, *e;    char name[QNAMEL+1];    char max[NUML+1];    char tot[NUML+1];    char ena[NUML+1];    char str[NUML+1];    char que[NUML+1];    char run[NUML+1];    char hld[NUML+1];    char wat[NUML+1];    char trn[NUML+1];    char ext[NUML+1];    char type[TYPEL+1];    char format[80];    sprintf(format, "%%-%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%-%ds %%s\n",            QNAMEL, NUML, NUML, NUML, NUML, NUML,            NUML, NUML, NUML, NUML, NUML, TYPEL);    if ( ! full && prtheader ) {	printf(":");	printf(format, "Queue", "Max", "Tot", "Ena", "Str", "Que", "Run", "Hld", "Wat", "Trn", "Ext", "Type", "Server");    }    p = status;    while ( p != NULL ) {        name[0] = '\0';        strcpy(max, "0");        strcpy(tot, "0");        strcpy(ena, "no");        strcpy(str, "no");        strcpy(que, "0");        strcpy(run, "0");        strcpy(hld, "0");        strcpy(wat, "0");        strcpy(trn, "0");        strcpy(ext, "0");        type[0] = '\0';        if (full) {            printf("Queue: %s@%s\n", p->name, server_name);            a = p->attribs;            while ( a != NULL ) {                if ( a->name != NULL ) {		    prt_attr(a->name, a->resource, a->value);		    printf("\n");                }                a = a->next;            }        } else {            if ( p->name != NULL ) {	       if( (e = mystrdup(p->name)) == NULL ) {	           fprintf(stderr, "Error getting more space to malloc\n");	           exit(2);                }                c = e;		/* we need e as the starting address for */				/* future free */                l = strlen(e);                if ( l > NAMEL ) {                    c = e + NAMEL;                    *c = '\0';                }                strcpy(name, e);		free(e);            }            a = p->attribs;            while ( a != NULL ) {	       if( (e = mystrdup(a->value)) == NULL ) {	           fprintf(stderr, "Error getting more space to malloc\n");	           exit(2);                }                c = e;		/* we need e as the starting address for */				/* future free */                if ( a->name != NULL ) {                    if ( strcmp(a->name,ATTR_maxrun) == 0 ) {                        l = strlen(e);                        if ( l > NUML ) {                            c = e + NUML;                            *c = '\0';                        }                        strcpy(max, e);                    } else if ( strcmp(a->name,ATTR_total) == 0 ) {                        l = strlen(e);                        if ( l > NUML ) {                            c = e + NUML;                            *c = '\0';                        }                        strcpy(tot, e);                    } else if ( strcmp(a->name,ATTR_enable) == 0 ) {                        if ( istrue(e) )                            strcpy(ena,"yes");                        else                            strcpy(ena,"no");                    } else if ( strcmp(a->name,ATTR_start) == 0 ) {                        if ( istrue(e) )                            strcpy(str,"yes");                        else                            strcpy(str,"no");                    } else if ( strcmp(a->name,ATTR_count) == 0 ) {                        states(e, que, run, hld, wat, trn, ext, NUML);                    } else if ( strcmp(a->name,ATTR_qtype) == 0 ) {                        l = strlen(e);                        if ( l > TYPEL ) {                            c = e + TYPEL;                            *c = '\0';                        }                        strcpy(type, e);                    }                }                a = a->next;		free(e);            }            printf(format, name, max, tot, ena, str, que, run, hld, wat, trn, ext, type, server_name);        }	if ( full ) printf("\n");        p = p->next;    }    return;}#define SERVERL 23#define STATUSL 10#define NODESL  9 voiddisplay_statserver(status, prtheader, full, nodesInUse)struct batch_status *status;int prtheader;int full;int nodesInUse;{    struct batch_status *p;    struct attrl *a;    int l;    char *c, *e;    char name[SERVERL+1];    char max[NUML+1];    char tot[NUML+1];    char que[NUML+1];    char run[NUML+1];    char hld[NUML+1];    char wat[NUML+1];    char trn[NUML+1];    char ext[NUML+1];    char nod[NODESL+1];    char stats[STATUSL+1];    char format[80];    sprintf(format, "%%-%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%%ds %%-%ds %%%ds                    %%s\n", SERVERL, NUML, NUML, NUML, NUML, NUML, NUML, NUML, NUML, STATUSL, NODESL);    if ( ! full && prtheader ) {	printf(":");        printf(format, "Server", "Max", "Tot", "Que", "Run", "Hld", "Wat", "Trn", "Ext", "Status", "PEsInUse", "");    }    p = status;    while ( p != NULL ) {        name[0] = '\0';        strcpy(max, "0");        strcpy(tot, "0");        strcpy(que, "0");        strcpy(run, "0");        strcpy(hld, "0");        strcpy(wat, "0");        strcpy(trn, "0");        strcpy(ext, "0");        strcpy(nod, "-/-");        stats[0] = '\0';        if (full) {            printf("Server: %s\n", p->name);            a = p->attribs;            while ( a != NULL ) {                if ( a->name != NULL ) {		    prt_attr(a->name, a->resource, a->value);		    printf("\n");                }                a = a->next;            }        } else {            if ( p->name != NULL ) {	       if( (e = mystrdup(p->name)) == NULL ) {	           fprintf(stderr, "Error getting more space to malloc\n");	           exit(2);                }                c = e;		/* we need e as the starting address for */				/* future free */                  l = strlen(e);                if ( l > SERVERL ) {                    c = e + SERVERL;                    *c = '\0';                }                strcpy(name, e);		free(e);            }            a = p->attribs;            while ( a != NULL ) {	       if( (e = mystrdup(a->value)) == NULL ) {	           fprintf(stderr, "Error getting more space to malloc\n");	           exit(2);                }                c = e;		/* we need e as the starting address for */				/* future free */                if ( a->name != NULL ) {                    if ( strcmp(a->name,ATTR_maxrun) == 0 ) {                        l = strlen(e);                        if ( l > NUML ) {                            c = e + NUML;                            *c = '\0';                        }                        strcpy(max, e);                    } else if ( strcmp(a->name,ATTR_total) == 0 ) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -