Backporting configurable querying intervals.
authorZdeněk Šustr <sustr4@cesnet.cz>
Wed, 13 Oct 2010 13:58:35 +0000 (13:58 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Wed, 13 Oct 2010 13:58:35 +0000 (13:58 +0000)
org.glite.lb.client/examples/stats.c

index e0adf1f..67e1f35 100644 (file)
@@ -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;