From d99ce1cba0dbd26a2ed45a22343f394504ee9463 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Filipovi=C4=8D?= Date: Tue, 22 Jun 2010 08:38:48 +0000 Subject: [PATCH] Forgotten example of new statistics. --- .../examples/stats-duration-fromto.c | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 org.glite.lb.client/examples/stats-duration-fromto.c diff --git a/org.glite.lb.client/examples/stats-duration-fromto.c b/org.glite.lb.client/examples/stats-duration-fromto.c new file mode 100644 index 0000000..e4b5ad9 --- /dev/null +++ b/org.glite.lb.client/examples/stats-duration-fromto.c @@ -0,0 +1,79 @@ +/* +Copyright (c) Members of the EGEE Collaboration. 2004-2010. +See http://www.eu-egee.org/partners for details on the copyright holders. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include +#include +#include +#include + +#ifdef BUILDING_LB_CLIENT +#include "statistics.h" +#else +#include "glite/lb/statistics.h" +#endif + + +int main(int argc,char **argv) +{ + edg_wll_Context ctx; + edg_wll_QueryRec group[2]; + time_t now,from,to; + char *cfrom,*cto; + int from_res,to_res; + float val; + + + edg_wll_InitContext(&ctx); + + if (argc < 3) { + fprintf(stderr,"usage: %s CE state_from state_to\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[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; + + + time(&now); + to = now; + from = now - 600; + + if (edg_wll_StateDurationFromTo(ctx,group,atoi(argv[2]),atoi(argv[3]),argc >=5 ? atoi(argv[4]) : 0, + &from,&to,&val,&from_res,&to_res)) + { + char *et,*ed; + edg_wll_Error(ctx,&et,&ed); + fprintf(stderr,"edg_wll_StateRate(): %s, %s\n",et,ed); + return 1; + } + + cfrom = strdup(ctime(&from)); + cto = strdup(ctime(&to)); + cfrom[strlen(cfrom)-1] = 0; + cto[strlen(cto)-1] = 0; + + printf("Average duration 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); + + return 0; +} + -- 1.8.2.3