From e92fcb850af76ea7a179050b2eab1bcab7c84dda Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Posp=C3=AD=C5=A1il?= Date: Thu, 23 Mar 2006 16:38:45 +0000 Subject: [PATCH] removed monitoring examples (will be in lb.utils module) --- org.glite.lb.client/Makefile | 7 +- org.glite.lb.client/examples/lbmon-db.c | 90 --------------------- org.glite.lb.client/examples/lbmon.c | 137 -------------------------------- 3 files changed, 2 insertions(+), 232 deletions(-) delete mode 100644 org.glite.lb.client/examples/lbmon-db.c delete mode 100644 org.glite.lb.client/examples/lbmon.c diff --git a/org.glite.lb.client/Makefile b/org.glite.lb.client/Makefile index afd7c9e..2fe63d0 100644 --- a/org.glite.lb.client/Makefile +++ b/org.glite.lb.client/Makefile @@ -136,7 +136,7 @@ PLUSLIB:=libglite_lb_clientpp_${nothrflavour}.la THRPLUSLIB:=libglite_lb_clientpp_${thrflavour}.la TOOLS:=dump load purge lb_dump_exporter -EXAMPLES:=log_usertag_proxy job_log job_reg feed_shark notify query_ext query_seq_code stats abort_job change_acl lbmon stresslog +EXAMPLES:=log_usertag_proxy job_log job_reg feed_shark notify query_ext query_seq_code stats abort_job change_acl stresslog EXAMPLES_CL=user_jobs job_status FAKE_EXAMPLES:=job_log_fake @@ -181,9 +181,6 @@ ${THRPLUSLIB}: ${PLUSTHROBJS} logevent: logevent.o args.o ${LINK} -o $@ logevent.o args.o ${LIB} ${EXT_LIB} -lbmon-db: lbmon-db.o - ${LINK} -o $@ lbmon-db.o -lmysqlclient -lglite_lb_bkserver ${LIB} ${EXT_LIB} - ${TOOLS} ${EXAMPLES}: %: %.o ${LINK} -o $@ $< ${LIB} ${EXT_LIB} @@ -292,7 +289,7 @@ install: for p in ${TOOLS} ; do \ ${INSTALL} -m 755 "$$p" "${PREFIX}/sbin/glite-lb-$$p"; \ done - for p in ${EXAMPLES} lbmon-db ${EXAMPLES_CL} ${sh_PROGS} ; do \ + for p in ${EXAMPLES} ${EXAMPLES_CL} ${sh_PROGS} ; do \ ${INSTALL} -m 755 "$$p" "${PREFIX}/examples/glite-lb-$$p"; \ done ${INSTALL} -m 755 ${top_srcdir}/examples/export.sh "${PREFIX}/examples/glite-lb-export.sh" diff --git a/org.glite.lb.client/examples/lbmon-db.c b/org.glite.lb.client/examples/lbmon-db.c deleted file mode 100644 index fee46cd..0000000 --- a/org.glite.lb.client/examples/lbmon-db.c +++ /dev/null @@ -1,90 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/strmd5.h" -#include "glite/lb/consumer.h" -#include "glite/lb/context-int.h" -#include "glite/lb/lbs_db.h" -#include "glite/lb/jobstat.h" - -static struct option opts[] = { - { "mysql",1,NULL,'m' }, - { "verbose",0,NULL,'v' }, - { NULL, 0, NULL, 0 } -}; - -static void usage(); -static void do_exit(edg_wll_Context,int); -static const char *me; - -int main(int argc,char **argv) -{ - int opt; - char *dbstring = getenv("LBDB"); - int verbose = 0, rows = 0, fields = 0, jobs = 0, i; - edg_wll_Context ctx; - char *stmt = NULL, *status = NULL; - char *str[2]; - edg_wll_Stmt sh; - - me = strdup(argv[0]); - - while ((opt = getopt_long(argc,argv,"m:v",opts,NULL)) != EOF) switch (opt) { - case 'm': dbstring = optarg; break; - case 'v': verbose++; break; - case '?': usage(); exit(EX_USAGE); - } - - edg_wll_InitContext(&ctx); - if (edg_wll_Open(ctx,dbstring)) do_exit(ctx,EX_UNAVAILABLE); - if (edg_wll_DBCheckVersion(ctx)) do_exit(ctx,EX_SOFTWARE); - if (asprintf(&stmt,"SELECT status,count(status) FROM states GROUP BY status;") < 0) do_exit(ctx,EX_OSERR); - if (verbose) fprintf(stderr,"mysql query: %s\n",stmt); - if ((rows = edg_wll_ExecStmt(ctx,stmt,&sh)) < 0) do_exit(ctx,EX_SOFTWARE); - if (verbose) fprintf(stderr,"number of states returned: %d\n",rows); - if (rows > 0) fprintf(stdout,"Number of jobs in each state: \n"); - for (i = 0; i < rows; i++) { - fields = edg_wll_FetchRow(sh, str); - if (fields != 2) { - edg_wll_FreeStmt(&sh); - do_exit(ctx,EX_SOFTWARE); - } - status = edg_wll_StatToString((edg_wll_JobStatCode) atoi(str[0])); - jobs += atoi(str[1]); - fprintf(stdout,"%s: %s\n",status,str[1]); - if (str[0]) free(str[0]); - if (str[1]) free(str[1]); - if (status) free(status); - } - fprintf(stdout,"Total number of jobs: %d\n",jobs); - - if (stmt) free(stmt); - edg_wll_FreeStmt(&sh); - edg_wll_FreeContext(ctx); - - return 0; -} - -static void do_exit(edg_wll_Context ctx,int code) -{ - char *et,*ed; - - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"%s: %s (%s)\n",me,et,ed); - exit(code); -} - -static void usage() -{ - fprintf(stderr,"usage: %s \n" - " -m,--mysql use non-default database connection\n" - " -v,--verbose be verbose\n", - me); -} diff --git a/org.glite.lb.client/examples/lbmon.c b/org.glite.lb.client/examples/lbmon.c deleted file mode 100644 index 2d466b9..0000000 --- a/org.glite.lb.client/examples/lbmon.c +++ /dev/null @@ -1,137 +0,0 @@ -#ident "$Header$" - -#include -#include -#include -#include -#include -#include - -#include "glite/lb/consumer.h" - -static void usage(char *); -static int query_all(edg_wll_Context, int, struct timeval, edg_wll_JobStat **, edg_wlc_JobId **); -static void dgerr(edg_wll_Context,char *); - -static char *myname = NULL; -static int debug = 0, verbose = 0, lbproxy =0; -static const char rcsid[] = "@(#)$Id$"; - -static struct option const long_options[] = { - { "help", no_argument, 0, 'h' }, - { "version", no_argument, 0, 'V' }, - { "verbose", no_argument, 0, 'v' }, - { "debug", no_argument, 0, 'd' }, - { "lbproxy", required_argument, 0, 'x' }, - { NULL, 0, NULL, 0} -}; - -int main(int argc,char *argv[]) { - edg_wll_Context ctx; - edg_wll_JobStat *statesOut = NULL; - edg_wlc_JobId *jobsOut = NULL; - struct timeval time_now; - - int i, result, opt, nJobs; - i = result = opt = 0; - gettimeofday(&time_now,0); - - myname = argv[0]; - fprintf(stdout,"\n"); - /* get arguments */ - while ((opt = getopt_long(argc,argv, - "h" /* help */ - "V" /* version */ - "v" /* verbose */ - "d" /* debug */ - "x", /* lbproxy */ - long_options, (int *) 0)) != EOF) { - - switch (opt) { - case 'V': fprintf(stdout,"%s:\t%s\n",argv[0],rcsid); exit(0); - case 'v': verbose = 1; break; - case 'd': debug = 1; break; - case 'x': lbproxy = 1; break; - case 'h': - default: - usage(argv[0]); exit(0); - } - } - if ( edg_wll_InitContext(&ctx) ) { - fprintf(stderr,"%s: cannot initialize edg_wll_Context\n ",myname); - exit(1); - } - - if ( (result = query_all(ctx, EDG_WLL_JOB_CLEARED, time_now, &statesOut, &jobsOut)) ) { - dgerr(ctx, "edg_wll_QueryJobs"); - } else { - fprintf(stdout,"Number of jobs... "); - } - - nJobs = 0; - if ( jobsOut ) { - for (i=0; jobsOut[i]; i++) edg_wlc_JobIdFree(jobsOut[i]); { - nJobs++; - free(jobsOut); - } - } - if ( statesOut ) { - for (i=0; statesOut[i].state; i++) edg_wll_FreeStatus(&statesOut[i]); - free(statesOut); - } - edg_wll_FreeContext(ctx); - - - return result; -} - -static void -usage(char *name) { - fprintf(stderr,"Usage: %s [-x]\n", name); -} - -static int -query_all(edg_wll_Context ctx, int query_status, struct timeval query_time, edg_wll_JobStat **statesOut, edg_wlc_JobId **jobsOut) { - edg_wll_QueryRec jc[3]; - int ret; - - memset(jc, 0, sizeof jc); - - /* jobs in the state 'query_status' within last hour */ - jc[0].attr = EDG_WLL_QUERY_ATTR_STATUS; - jc[0].op = EDG_WLL_QUERY_OP_EQUAL; - jc[0].value.i = query_status; - jc[1].attr = EDG_WLL_QUERY_ATTR_TIME; - jc[1].attr_id.state = query_status; - jc[1].op = EDG_WLL_QUERY_OP_WITHIN; - jc[1].value.t.tv_sec = query_time.tv_sec - 3600; - jc[1].value.t.tv_usec = query_time.tv_usec; - jc[1].value2.t.tv_sec = query_time.tv_sec; - jc[1].value2.t.tv_usec = query_time.tv_usec; - jc[2].attr = EDG_WLL_QUERY_ATTR_UNDEF; - - if ( (ret = edg_wll_QueryJobs(ctx, jc, 0, jobsOut, statesOut)) ) { - if ( ret == E2BIG ) { - int r; - if ( edg_wll_GetParam(ctx, EDG_WLL_PARAM_QUERY_RESULTS, &r) ) return ret; - if ( r != EDG_WLL_QUERYRES_LIMITED ) return ret; - - fprintf(stderr," edg_wll_QueryJobs() Warning: only limited result returned!\n"); - return 0; - } else return ret; - } - - return ret; -} - -static void -dgerr(edg_wll_Context ctx,char *where) { - char *etxt,*edsc; - - edg_wll_Error(ctx,&etxt,&edsc); - fprintf(stderr,"%s: %s: %s",myname,where,etxt); - if (edsc) fprintf(stderr," (%s)",edsc); - putc('\n',stderr); - if(etxt) free(etxt); - if(edsc) free(edsc); -} -- 1.8.2.3