>>> On 11/25/2009 at 9:16 AM, in message <[email protected]>, Sylvester Steele <[email protected]> wrote: > Ok, so I tried to make a dynamically initializing module. I am > basically trying to convert the example module to a dynamically > initializing one.. > > My metrc_init function looks like this: > > static int ex_metric_init ( apr_pool_t *p ) > { > > > Ganglia_25metric* gmi; > apr_pool_create(&pool, p); > > metric_info = apr_array_make(pool, 10, sizeof(Ganglia_25metric)); > // metric_mapping_info = apr_array_make(pool, 10, sizeof(mapped_info_t)); > > gmi = (Ganglia_25metric*)apr_array_push(metric_info); > > gmi->name= "Random_Numbers_2"; > gmi->tmax=90; > gmi->type=GANGLIA_VALUE_UNSIGNED_INT; > gmi->msg_size= UDP_HEADER_SIZE+8; > gmi->units= "Num"; > gmi->slope="both"; > gmi->fmt="%u"; > gmi->desc= "Example module metric (random numbers) 2"; > MMETRIC_INIT_METADATA(gmi, pool); > MMETRIC_ADD_METADATA(gmi,MGROUP,"example_2"); > > gmi = (Ganglia_25metric*)apr_array_push(metric_info); > > gmi->name= "Constant_Number_2"; > gmi->tmax=90; > gmi->type=GANGLIA_VALUE_UNSIGNED_INT; > gmi->msg_size= UDP_HEADER_SIZE+8; > gmi->units= "Num"; > gmi->slope="zero"; > gmi->fmt="%u"; > gmi->desc= "Example module metric (constant number) 2"; > MMETRIC_INIT_METADATA(gmi, pool); > MMETRIC_ADD_METADATA(gmi,MGROUP,"example_2"); > > > gmi = (Ganglia_25metric*)apr_array_push(metric_info); > > memset (gmi, 0, sizeof(*gmi)); > > > return 0; > } > > > Q1. For some reason this gives me a segmentation fault. Any ideas why? >
My guess is because you have static string pointers being passed from a DSO module to gmond. I would suggest using apr_pstrdup(p, <string literal here>) to allocate the memory from an APR memory pool before handing the pointers back to gmond. > Q2. How do I put printf / cout statements so I can see them when gmond > runs- which will be very helpful for debugging. > You should be able to just use printf statements and then run gmond in debug mode. With gmond running in debug mode, all printf statements should print out on the console. Brad ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Ganglia-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ganglia-developers
