From bc0f9846cdf90abcb4ee84da66404b75137f5382 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zden=C4=9Bk=20=C5=A0ustr?= Date: Wed, 13 Oct 2010 13:58:35 +0000 Subject: [PATCH] Backporting configurable querying intervals. --- org.glite.lb.client/examples/stats.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/org.glite.lb.client/examples/stats.c b/org.glite.lb.client/examples/stats.c index e0adf1f..67e1f35 100644 --- a/org.glite.lb.client/examples/stats.c +++ b/org.glite.lb.client/examples/stats.c @@ -33,7 +33,8 @@ int main(int argc,char **argv) edg_wll_QueryRec group[2]; time_t now,from,to; char *cfrom,*cto; - int from_res,to_res; + int from_res,to_res,argOK = 3, era = 60; + int CEidx = 1, MAJidx = 2, MINidx = 3; float *vals; char **groups; int i; @@ -41,16 +42,25 @@ int main(int argc,char **argv) edg_wll_InitContext(&ctx); - if (argc < 3) { - fprintf(stderr,"usage: %s CE major [minor]\n",argv[0]); + if (!strcmp(argv[1],"-n")) { + era = atoi(argv[2]); + CEidx = 3; MAJidx = 4; MINidx = 5; + argOK = 5; + } + + + if (argc < argOK) { + fprintf(stderr,"usage: %s [-n sec] CE major [minor]\n",argv[0]); return 1; } + + /* the only supported grouping for now */ group[0].attr = EDG_WLL_QUERY_ATTR_DESTINATION; group[0].op = EDG_WLL_QUERY_OP_EQUAL; - if (strcmp(argv[1], "ALL")) - group[0].value.c = argv[1]; + if (strcmp(argv[CEidx], "ALL")) + group[0].value.c = argv[CEidx]; else group[0].value.c = NULL; group[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; @@ -58,7 +68,7 @@ int main(int argc,char **argv) time(&now); to = now; - from = now - 60; + from = now - (time_t)era; /* not implemented yet if (edg_wll_StateDuration(ctx,group,EDG_WLL_JOB_SCHEDULED,0, @@ -78,14 +88,11 @@ int main(int argc,char **argv) printf("Average queue traversal time at \"%s\": %f s\n" " Measuered from %s to %s\n" " With resolution from %d to %d s\n", - argv[1],val,cfrom,cto,from_res,to_res); + argv[CEidx],val,cfrom,cto,from_res,to_res); */ - to = now; - from = now - 60; - - if (edg_wll_StateRates(ctx,group,atoi(argv[2]),argc >=4 ? atoi(argv[3]) : 0, + if (edg_wll_StateRates(ctx,group,atoi(argv[MAJidx]),argc >= (argOK+1) ? atoi(argv[MINidx]) : 0, &from,&to,&vals,&groups,&from_res,&to_res)) { char *et,*ed; -- 1.8.2.3