From 7d6cb62de9409d0b451a560e43ab879da1d64232 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Posp=C3=AD=C5=A1il?= Date: Sun, 3 Sep 2006 16:22:09 +0000 Subject: [PATCH] - issues concerning bug#19533 - cleanup --- org.glite.lb.utils/Makefile | 4 +- org.glite.lb.utils/src/statistics.c | 83 ++++++++++++++++++++++++++++++------- 2 files changed, 70 insertions(+), 17 deletions(-) diff --git a/org.glite.lb.utils/Makefile b/org.glite.lb.utils/Makefile index 2741043..3a25ada 100644 --- a/org.glite.lb.utils/Makefile +++ b/org.glite.lb.utils/Makefile @@ -43,7 +43,7 @@ SOLINK:=libtool --mode=link ${CC} -module ${LDFLAGS} -rpath ${stagedir}/lib LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} INSTALL:=libtool --mode=install install LINKXX:=libtool --mode=link ${CXX} -rpath ${stagedir}/lib ${LDFLAGS} -XSLTPROC:=xsltproc --valid +XSLTPROC:=xsltproc GLOBUS_LIBS:= -L${globus_prefix}/lib \ -lglobus_common_${nothrflavour} \ @@ -91,7 +91,7 @@ mon-db: mon-db.o ${LINK} -o $@ $< ${COMMON_LIB} ${BKSERVER_LIB} ${EXT_LIBS} statistics: statistics.o - ${LINK} -rdynamic -o $@ $< ${JP_LIBS} ${EXT_LIBS} + ${LINK} -rdynamic -o $@ $< ${COMMON_LIB} ${JP_LIBS} ${EXT_LIBS} check: compile diff --git a/org.glite.lb.utils/src/statistics.c b/org.glite.lb.utils/src/statistics.c index f60d406..6c34c4b 100644 --- a/org.glite.lb.utils/src/statistics.c +++ b/org.glite.lb.utils/src/statistics.c @@ -1,18 +1,22 @@ +#ident "$Header$" /* - * load and test L&B plugin - * + * loads L&B plugin to obtain statistics data from a dump file * (requires -rdynamic to use fake JP backend symbols) */ #include #include #include +#include #include #include #include #include #include +#include "glite/lb/context.h" +#include "glite/lb/jobstat.h" + #include "glite/jp/types.h" #include "glite/jp/context.h" #include "glite/jp/backend.h" @@ -25,12 +29,14 @@ typedef int init_f(glite_jp_context_t ctx, glite_jpps_fplug_data_t *data); typedef void done_f(glite_jp_context_t ctx, glite_jpps_fplug_data_t *data); -static const char rcsid[] = "@(#)$$"; +static const char rcsid[] = "@(#)$Id$"; static int verbose = 0; static char *file = NULL; +static int jdl = 0; static struct option const long_options[] = { { "file", required_argument, 0, 'f' }, + { "jdl", no_argument, 0, 'j' }, { "help", no_argument, 0, 'h' }, { "verbose", no_argument, 0, 'v' }, { "version", no_argument, 0, 'V' }, @@ -43,14 +49,15 @@ static struct option const long_options[] = { static void usage(char *program_name) { fprintf(stdout,"LB statistics\n" - "- reads a dump file (one job only) \n" - "- and outputs an XML with statistics to stdout \n\n" - "Usage: %s [option]\n" - "-h, --help display this help and exit\n" - "-V, --version output version information and exit\n" - "-v, --verbose print extensive debug output to stderr\n" - "-f, --file dump file to process\n\n", - program_name); + "- reads a dump file (one job only) \n" + "- and outputs an XML with statistics to stdout \n\n" + "Usage: %s [option]\n" + "-h, --help display this help and exit\n" + "-V, --version output version information and exit\n" + "-v, --verbose print extensive debug output to stderr\n" + "-f, --file dump file to process\n" + "-j, --jdl prit also JDL in the XML\n\n", + program_name); } /* @@ -72,7 +79,7 @@ int glite_jppsbe_pread(glite_jp_context_t ctx, void *handle, void *buf, size_t n int glite_jp_stack_error(glite_jp_context_t ctx, const glite_jp_error_t *jperror) { - fprintf(stderr,"lb_statistics: JP backend error %d: %s\n", jperror->code, jperror->desc); + if (verbose) fprintf(stderr,"lb_statistics: JP backend error %d: %s\n", jperror->code, jperror->desc); return 0; } @@ -108,11 +115,12 @@ int main(int argc, char *argv[]) char *err; init_f *plugin_init; done_f *plugin_done; - int opt; + int i,opt; /* get arguments */ while ((opt = getopt_long(argc,argv, "f:" /* file */ + "j" /* jdl */ "h" /* help */ "v" /* verbose */ "V", /* version */ @@ -122,6 +130,7 @@ int main(int argc, char *argv[]) case 'V': fprintf(stdout,"%s:\t%s\n",argv[0],rcsid); return(0); case 'v': verbose = 1; break; case 'f': file = optarg; break; + case 'j': jdl = 1; break; case 'h': default: usage(argv[0]); return(0); @@ -173,6 +182,12 @@ int main(int argc, char *argv[]) free_attrs(attrval); } + plugin_data.ops.attr(jpctx, data_handle, GLITE_JP_LB_VO, &attrval); + if (attrval) { + fprintf(stdout,"\t%s\n", attrval->value); + free_attrs(attrval); + } + plugin_data.ops.attr(jpctx, data_handle, GLITE_JP_LB_aTag, &attrval); if (attrval) { fprintf(stdout,"\t%s\n", attrval->value); @@ -295,15 +310,53 @@ int main(int argc, char *argv[]) plugin_data.ops.attr(jpctx, data_handle, GLITE_JP_LB_lastStatusHistory, &attrval); if (attrval) { - fprintf(stdout,"\t%s\n", attrval->value); + fprintf(stdout,"\t\n"); +/* + for (i = 1; i < EDG_WLL_NUMBER_OF_STATCODES; i++) { + char *stat = edg_wll_StatToString(i); + fprintf(stdout,"\t\n"); + fprintf(stdout,"\t\t%s\n", stat); + fprintf(stdout,"\t\t%ld.%06ld\n", attrval[i].timestamp,0); + fprintf(stdout,"\t\t%s\n", attrval[i].value ? attrval[i].value : ""); + fprintf(stdout,"\t\n"); + if (stat) free(stat); + } +*/ + i = 1; + while (attrval[i].name) { + fprintf(stdout,"\t\n"); + fprintf(stdout,"\t\t%s\n", attrval[i].name); + fprintf(stdout,"\t\t%ld.%06ld\n", attrval[i].timestamp,0); + fprintf(stdout,"\t\t%s\n", attrval[i].value ? attrval[i].value : ""); + fprintf(stdout,"\t\n"); + i++; + } + fprintf(stdout,"\t\n"); free_attrs(attrval); } plugin_data.ops.attr(jpctx, data_handle, GLITE_JP_LB_fullStatusHistory, &attrval); if (attrval) { - fprintf(stdout,"\t%s\n", attrval->value); + fprintf(stdout,"\t\n"); + i = 1; + while (attrval[i].name) { + fprintf(stdout,"\t\n"); + fprintf(stdout,"\t\t%s\n", attrval[i].name); + fprintf(stdout,"\t\t%ld.%06ld\n", attrval[i].timestamp,0); + fprintf(stdout,"\t\t%s\n", attrval[i].value ? attrval[i].value : ""); + fprintf(stdout,"\t\n"); + i++; + } + fprintf(stdout,"\t\n"); free_attrs(attrval); } + if (jdl) { + plugin_data.ops.attr(jpctx, data_handle, GLITE_JP_LB_JDL, &attrval); + if (attrval) { + fprintf(stdout,"\t%s\n", attrval->value); + free_attrs(attrval); + } + } fprintf(stdout,"\n"); -- 1.8.2.3