Forgotten example of new statistics.
authorJiří Filipovič <fila@ics.muni.cz>
Tue, 22 Jun 2010 08:38:48 +0000 (08:38 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Tue, 22 Jun 2010 08:38:48 +0000 (08:38 +0000)
org.glite.lb.client/examples/stats-duration-fromto.c [new file with mode: 0644]

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 (file)
index 0000000..e4b5ad9
--- /dev/null
@@ -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 <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+
+#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;
+}
+