Loading Makefiledeleted 100644 → 0 +0 −35 Original line number Diff line number Diff line # $Id: Makefile,v 1.1.1.1 2006/03/13 18:31:16 bino Exp $ # variables PROGRAM=pbsacct CC=c++ CFLAGS=-O -c LFLAGS=-O INSTALL_DIR=/usr/local/sbin # make VPATH=./ all: $(PROGRAM) OBJECTS=main.o alloc.o read.o print.o $(PROGRAM): $(OBJECTS) $(CC) $(LFLAGS) -o $(PROGRAM) $(OBJECTS) rm $(OBJECTS) $(OBJECTS): main.h $(OBJECTS): %.o: %.cpp $(CC) $(CFLAGS) $< clean: rm -f $(PROGRAM) $(OBJECTS) install: cp $(PROGRAM) $(INSTALL_DIR) cp mk_pbsacct $(INSTALL_DIR) uninstall: rm -f $(INSTALL_DIR)/$(PROGRAM) rm -f $(INSTALL_DIR)/mk_pbsacct main.cpp +13 −3 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ /* global variables */ GROUP *pgroups; USER *pusers; int f_user=0, f_group=0, f_bill=0, f_stat=0, f_cpu=0, f_stdin=0, opt=1; int f_user=0, f_group=0, f_bill=0, f_stat=0, f_cpu=0, f_stdin=0, opt=1, memorypernode; char unit[4]={"SBU"}; double value; int cpuvalue; Loading @@ -45,7 +45,7 @@ void usage_exit(void) void help() { puts("pbsacct: program to make summary and report for PBS system."); puts("usage: pbsacct [-a][-u][-g][-b value][-n opt][-p value][-c][-s][-h] [file(s)]"); puts("usage: pbsacct [-a][-u][-g][-b value][-n opt][-p value][-m value][-c][-s][-h] [file(s)]"); puts("\toptions:"); puts("\t-a : report per-user and per-group usage"); puts("\t-u : report per-user usage"); Loading @@ -62,6 +62,7 @@ void help() puts("\t (if your operations system support)"); puts("\t-s : include statistic information"); puts("\t-p Custom Option added by Fabio Vitello: set the number of core to compute the to compute cputime in case of exclusive node request"); puts("\t-m Custom Option added by Fabio Vitello: set the memory per node in GB"); puts("\t-h : help"); puts("\tIf there isn't input file, it use the stdin.\n"); puts("\tExamples:"); Loading @@ -80,7 +81,13 @@ void parse_args(int ac, char **av) { int options, err=0; while ((options = getopt(ac, av, "augb:B:np:sch"))!=EOF) /* f_group = 1; f_stat = 1; f_cpu = 1; */ while ((options = getopt(ac, av, "augb:B:np:m:sch"))!=EOF) switch(options) { case 'a': f_user = f_group = 1; Loading Loading @@ -110,6 +117,9 @@ void parse_args(int ac, char **av) case 'p': cpuvalue = atoi(optarg); break; case 'm': memorypernode = atoi(optarg); break; case 'h': help(); break; Loading main.h +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ extern int f_user, f_group, f_bill, f_stat, f_cpu, f_stdin, opt; extern char unit[4]; extern double value; extern int cpuvalue; extern int memorypernode; /* functions */ Loading print.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ void print_report(char *hostname) printf("\n*** Portable Batch System accounting ***\n"); printf("Server Name: %s\n", hostname); f_cpu=false; f_stat=false; /* print report user */ if (f_user) { printf("\n*** PBS Per-User Usage Report ***\n"); Loading read.cpp +36 −5 Original line number Diff line number Diff line Loading @@ -18,13 +18,14 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include "main.h" /* read file(s) */ void read_file(char *file) { int len, nodes, hour, min, sec, test, linenum = 0; double cpu_used, wall_used; int len, nodes, hour, min, sec, test, linenum = 0, reqmemory,corememory; double cpu_used, wall_used, memorypercore; char buffer[BUFSIZ], *p, *ptr, *line; char uid[MAX_NAME_SIZE], gid[MAX_NAME_SIZE]; GROUP *pg, *pg_aux; Loading @@ -49,6 +50,27 @@ void read_file(char *file) line = static_cast<char*>(malloc(len * sizeof(char))); strcpy(line, buffer); ptr = strstr(line, "Resource_List.mem"); if (ptr != NULL) { /* try node */ p = strtok(ptr, "="); p = strtok(NULL, "="); p = strtok(p, " "); const char *unit = &p[strlen(p)-2]; if ( strcmp (unit,"gb") == 0) { p[strlen(p)-2] = 0; reqmemory = atoi(p); corememory = floor((float)reqmemory/((float)memorypernode/cpuvalue)); if (corememory>cpuvalue) corememory=cpuvalue; } // nodes = atoi(p); } strcpy(line, buffer); ptr = strstr(line, "Resource_List.ncpus"); if (ptr == NULL) { Loading @@ -61,13 +83,22 @@ void read_file(char *file) p = strtok(ptr, "="); p = strtok(NULL, "="); nodes = atoi(p); if (corememory>nodes) nodes=corememory; strcpy(line, buffer); ptr = strstr(line, "Resource_List.nodect"); p = strtok(ptr, "="); p = strtok(NULL, "="); nodes *= atoi(p); } else { nodes = 1; } strcpy(line, buffer); // printf("%s",line); ptr = strstr(line, "Resource_List.place"); if (ptr != NULL) { Loading Loading
Makefiledeleted 100644 → 0 +0 −35 Original line number Diff line number Diff line # $Id: Makefile,v 1.1.1.1 2006/03/13 18:31:16 bino Exp $ # variables PROGRAM=pbsacct CC=c++ CFLAGS=-O -c LFLAGS=-O INSTALL_DIR=/usr/local/sbin # make VPATH=./ all: $(PROGRAM) OBJECTS=main.o alloc.o read.o print.o $(PROGRAM): $(OBJECTS) $(CC) $(LFLAGS) -o $(PROGRAM) $(OBJECTS) rm $(OBJECTS) $(OBJECTS): main.h $(OBJECTS): %.o: %.cpp $(CC) $(CFLAGS) $< clean: rm -f $(PROGRAM) $(OBJECTS) install: cp $(PROGRAM) $(INSTALL_DIR) cp mk_pbsacct $(INSTALL_DIR) uninstall: rm -f $(INSTALL_DIR)/$(PROGRAM) rm -f $(INSTALL_DIR)/mk_pbsacct
main.cpp +13 −3 Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ /* global variables */ GROUP *pgroups; USER *pusers; int f_user=0, f_group=0, f_bill=0, f_stat=0, f_cpu=0, f_stdin=0, opt=1; int f_user=0, f_group=0, f_bill=0, f_stat=0, f_cpu=0, f_stdin=0, opt=1, memorypernode; char unit[4]={"SBU"}; double value; int cpuvalue; Loading @@ -45,7 +45,7 @@ void usage_exit(void) void help() { puts("pbsacct: program to make summary and report for PBS system."); puts("usage: pbsacct [-a][-u][-g][-b value][-n opt][-p value][-c][-s][-h] [file(s)]"); puts("usage: pbsacct [-a][-u][-g][-b value][-n opt][-p value][-m value][-c][-s][-h] [file(s)]"); puts("\toptions:"); puts("\t-a : report per-user and per-group usage"); puts("\t-u : report per-user usage"); Loading @@ -62,6 +62,7 @@ void help() puts("\t (if your operations system support)"); puts("\t-s : include statistic information"); puts("\t-p Custom Option added by Fabio Vitello: set the number of core to compute the to compute cputime in case of exclusive node request"); puts("\t-m Custom Option added by Fabio Vitello: set the memory per node in GB"); puts("\t-h : help"); puts("\tIf there isn't input file, it use the stdin.\n"); puts("\tExamples:"); Loading @@ -80,7 +81,13 @@ void parse_args(int ac, char **av) { int options, err=0; while ((options = getopt(ac, av, "augb:B:np:sch"))!=EOF) /* f_group = 1; f_stat = 1; f_cpu = 1; */ while ((options = getopt(ac, av, "augb:B:np:m:sch"))!=EOF) switch(options) { case 'a': f_user = f_group = 1; Loading Loading @@ -110,6 +117,9 @@ void parse_args(int ac, char **av) case 'p': cpuvalue = atoi(optarg); break; case 'm': memorypernode = atoi(optarg); break; case 'h': help(); break; Loading
main.h +1 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ extern int f_user, f_group, f_bill, f_stat, f_cpu, f_stdin, opt; extern char unit[4]; extern double value; extern int cpuvalue; extern int memorypernode; /* functions */ Loading
print.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ void print_report(char *hostname) printf("\n*** Portable Batch System accounting ***\n"); printf("Server Name: %s\n", hostname); f_cpu=false; f_stat=false; /* print report user */ if (f_user) { printf("\n*** PBS Per-User Usage Report ***\n"); Loading
read.cpp +36 −5 Original line number Diff line number Diff line Loading @@ -18,13 +18,14 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include "main.h" /* read file(s) */ void read_file(char *file) { int len, nodes, hour, min, sec, test, linenum = 0; double cpu_used, wall_used; int len, nodes, hour, min, sec, test, linenum = 0, reqmemory,corememory; double cpu_used, wall_used, memorypercore; char buffer[BUFSIZ], *p, *ptr, *line; char uid[MAX_NAME_SIZE], gid[MAX_NAME_SIZE]; GROUP *pg, *pg_aux; Loading @@ -49,6 +50,27 @@ void read_file(char *file) line = static_cast<char*>(malloc(len * sizeof(char))); strcpy(line, buffer); ptr = strstr(line, "Resource_List.mem"); if (ptr != NULL) { /* try node */ p = strtok(ptr, "="); p = strtok(NULL, "="); p = strtok(p, " "); const char *unit = &p[strlen(p)-2]; if ( strcmp (unit,"gb") == 0) { p[strlen(p)-2] = 0; reqmemory = atoi(p); corememory = floor((float)reqmemory/((float)memorypernode/cpuvalue)); if (corememory>cpuvalue) corememory=cpuvalue; } // nodes = atoi(p); } strcpy(line, buffer); ptr = strstr(line, "Resource_List.ncpus"); if (ptr == NULL) { Loading @@ -61,13 +83,22 @@ void read_file(char *file) p = strtok(ptr, "="); p = strtok(NULL, "="); nodes = atoi(p); if (corememory>nodes) nodes=corememory; strcpy(line, buffer); ptr = strstr(line, "Resource_List.nodect"); p = strtok(ptr, "="); p = strtok(NULL, "="); nodes *= atoi(p); } else { nodes = 1; } strcpy(line, buffer); // printf("%s",line); ptr = strstr(line, "Resource_List.place"); if (ptr != NULL) { Loading