From b48a826beb3b61dba1605785cb0560bc47949c48 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Thu, 16 Oct 2008 16:07:22 +0000 Subject: [PATCH] -f fields option --- org.glite.lb.utils/Makefile | 11 ++++++----- org.glite.lb.utils/src/state_history.c | 35 +++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/org.glite.lb.utils/Makefile b/org.glite.lb.utils/Makefile index c1634ff..3e03c34 100644 --- a/org.glite.lb.utils/Makefile +++ b/org.glite.lb.utils/Makefile @@ -53,9 +53,11 @@ EXT_LIBS:= \ ${expatlib} -lexpat COMMON_LIB:=-lglite_lb_common_${nothrflavour} CLIENT_LIB:=-lglite_lb_client_${nothrflavour} +PLUS_LIB:=-lglite_lb_clientpp_${nothrflavour} JP_LIBS:=-lglite_jp_common_${nothrflavour} -UTILS:=mon purge dump load dump_exporter state_history +UTILS:=mon purge dump load dump_exporter +ALLUTILS:=${UTILS} state_history statistics STATISTICS_OBJS:=statistics.o process_attrs.o process_attrs2.o MAN_GZ:=glite-lb-mon.1.gz @@ -64,7 +66,7 @@ MAN = $(MAN_GZ:.gz=) default: all -compile all: ${UTILS} ${MAN_GZ} statistics +compile all: ${ALLUTILS} ${MAN_GZ} ${UTILS}: %: %.o ${LINK} -o $@ $< ${COMMON_LIB} ${CLIENT_LIB} ${EXT_LIBS} -lglite_lbu_maildir @@ -73,7 +75,7 @@ statistics: ${STATISTICS_OBJS} ${LINK} -rdynamic -o $@ ${STATISTICS_OBJS} ${COMMON_LIB} ${JP_LIBS} ${EXT_LIBS} state_history: state_history.o - ${LINK} -o $@ state_history.o -L${stagedir}/lib -lglite_lb_statemachine ${CLIENT_LIB} ${COMMON_LIB} + ${LINK} -o $@ state_history.o -L${stagedir}/lib -lglite_lb_statemachine ${PLUS_LIB} check: compile @@ -97,10 +99,9 @@ install: ${INSTALL} -m 644 ${MAN_GZ} ${PREFIX}/share/man/man1 ${INSTALL} -m 755 ${top_srcdir}/src/glite-lb-bkpurge-offline.sh ${PREFIX}/bin/glite-lb-bkpurge-offline - for p in ${UTILS} ; do \ + for p in ${ALLUTILS} ; do \ ${INSTALL} -m 755 "$$p" "${PREFIX}/bin/glite-lb-$$p"; \ done - ${INSTALL} -m 755 statistics ${PREFIX}/bin/glite-lb-statistics clean: rm -rfv ${UTILS} statistics ${MAN_GZ} *.{lo,o} .libs/ diff --git a/org.glite.lb.utils/src/state_history.c b/org.glite.lb.utils/src/state_history.c index 6fbdf6a..6c38ba1 100644 --- a/org.glite.lb.utils/src/state_history.c +++ b/org.glite.lb.utils/src/state_history.c @@ -1,26 +1,45 @@ #include #include #include +#include #include "glite/lb/context.h" #include "glite/lb/consumer.h" #include "glite/lb/intjobstat.h" #include "glite/lb/seqcode_aux.h" +#include "glite/lb/stat_fields.h" +#include "glite/lb/process_event.h" -/*comment */ +#define usage() { \ + fprintf(stderr,"usage: %s [-f fields] \n",argv[0]); \ + fprintf(stderr,"\navailable fields:\n\t"); \ + glite_lb_dump_stat_fields(); \ + putc(10,stderr); \ +} int main (int argc, char ** argv) { edg_wll_Context ctx; edg_wll_QueryRec jc[2]; edg_wll_Event *events; - int i,n; + int i,n,opt; intJobStat is; + char *farg = "network_server,jdl:VirtualOrganisation,destination,done_code,reason"; + void *fields; + + while ((opt = getopt(argc,argv,"f:")) != -1) switch (opt) { + case 'f': farg = optarg; break; + default: usage(); return 1; + } + memset(&jc,0,sizeof jc); - if (argc != 2 || glite_jobid_parse(argv[1],&jc[0].value.j)) { - fprintf(stderr,"usage: %s \n",argv[0]); + if (optind+1 != argc + || glite_jobid_parse(argv[optind],&jc[0].value.j) + || glite_lb_parse_stat_fields(farg,&fields)) + { + usage(); return 1; } @@ -39,18 +58,20 @@ int main (int argc, char ** argv) for (n=0; events[n].type; n++); init_intJobStat(&is); + glite_jobid_dup(jc[0].value.j,&is.pub.jobId); qsort(events,n,sizeof *events,compare_events_by_seq); for (i=0; i