Poor man's extension of the period covered by statistics.
authorZdeněk Šustr <sustr4@cesnet.cz>
Fri, 25 Jun 2010 14:34:16 +0000 (14:34 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Fri, 25 Jun 2010 14:34:16 +0000 (14:34 +0000)
org.glite.lb.client/examples/stats.c

index 82cab20..14e273a 100644 (file)
@@ -33,27 +33,37 @@ 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;
        float   val;
+       int     CEidx = 1, MAJidx = 2, MINidx = 3; 
 
 
        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;
-       group[0].value.c = argv[1];
+       group[0].value.c = argv[CEidx];
        group[1].attr = EDG_WLL_QUERY_ATTR_UNDEF;
 
 
        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,
@@ -73,14 +83,14 @@ 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_StateRate(ctx,group,atoi(argv[2]),argc >=4 ? atoi(argv[3]) : 0,
+       if (edg_wll_StateRate(ctx,group,atoi(argv[MAJidx]),argc >= (argOK+1) ? atoi(argv[MINidx]) : 0,
                                &from,&to,&val,&from_res,&to_res))
        {
                char    *et,*ed;
@@ -97,7 +107,7 @@ int main(int argc,char **argv)
        printf("Average failure rate at \"%s\": %f jobs/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);
 
        return 0;
 }