static void fill_gmi(Ganglia_25metric* gmi, py_metric_init_t* minfo) { char *s, *lasts; int i; const apr_array_header_t *arr = apr_table_elts(minfo->extra_data); const apr_table_entry_t *elts = (const apr_table_entry_t *)arr->elts; /* gmi->key will be automatically assigned by gmond */ gmi->name = apr_pstrdup (pool, minfo->mname); gmi->tmax = minfo->tmax; if (!strcasecmp(minfo->vtype, "string")) { gmi->type = GANGLIA_VALUE_STRING; gmi->msg_size = UDP_HEADER_SIZE+MAX_G_STRING_SIZE; } else if (!strcasecmp(minfo->vtype, "uint")) { gmi->type = GANGLIA_VALUE_UNSIGNED_INT; gmi->msg_size = UDP_HEADER_SIZE+8; } else if (!strcasecmp(minfo->vtype, "int")) { gmi->type = GANGLIA_VALUE_INT; gmi->msg_size = UDP_HEADER_SIZE+8; } else if (!strcasecmp(minfo->vtype, "float")) { gmi->type = GANGLIA_VALUE_FLOAT; gmi->msg_size = UDP_HEADER_SIZE+8; } else if (!strcasecmp(minfo->vtype, "double")) { gmi->type = GANGLIA_VALUE_DOUBLE; gmi->msg_size = UDP_HEADER_SIZE+16; } else { gmi->type = GANGLIA_VALUE_UNKNOWN; gmi->msg_size = UDP_HEADER_SIZE+8; } gmi->units = apr_pstrdup(pool, minfo->units); gmi->slope = apr_pstrdup(pool, minfo->slope); gmi->fmt = apr_pstrdup(pool, minfo->format); gmi->desc = apr_pstrdup(pool, minfo->desc); MMETRIC_INIT_METADATA(gmi, pool); for (s=(char *)apr_strtok(minfo->groups, ",", &lasts); s!=NULL; s=(char *)apr_strtok(NULL, ",", &lasts)) { char *d = s; /* Strip the leading white space */ while (d && *d && apr_isspace(*d)) { d++; } MMETRIC_ADD_METADATA(gmi,MGROUP,d); } /* transfer any extra data as metric metadata */ for (i = 0; i < arr->nelts; ++i) { if (elts[i].key == NULL) continue; MMETRIC_ADD_METADATA(gmi, elts[i].key, elts[i].val); } }
static int ex_metric_init (apr_pool_t *p) { int i; Ganglia_25metric *gmi; /* Allocate a pool that will be used by this module */ apr_pool_create(&pool, p); /* Initialize each metric */ scan_mounts(pool); /* Add a terminator to the array and replace the empty static metric definition array with the dynamic array that we just created */ gmi = apr_array_push(metric_info); memset (gmi, 0, sizeof(*gmi)); fs_module.metrics_info = (Ganglia_25metric *)metric_info->elts; for (i = 0; fs_module.metrics_info[i].name != NULL; i++) { /* Initialize the metadata storage for each of the metrics and then * store one or more key/value pairs. The define MGROUPS defines * the key for the grouping attribute. */ MMETRIC_INIT_METADATA(&(fs_module.metrics_info[i]),p); MMETRIC_ADD_METADATA(&(fs_module.metrics_info[i]),MGROUP,"disk"); } return 0; }
static int ex_metric_init ( apr_pool_t *p ) { const char* str_params = example_module.module_params; apr_array_header_t *list_params = example_module.module_params_list; mmparam *params; int i; srand(time(NULL)%99); /* Read the parameters from the gmond.conf file. */ /* Single raw string parameter */ if (str_params) { debug_msg("[mod_example]Received string params: %s", str_params); } /* Multiple name/value pair parameters. */ if (list_params) { debug_msg("[mod_example]Received following params list: "); params = (mmparam*) list_params->elts; for(i=0; i< list_params->nelts; i++) { debug_msg("\tParam: %s = %s", params[i].name, params[i].value); if (!strcasecmp(params[i].name, "RandomMax")) { random_max = atoi(params[i].value); } if (!strcasecmp(params[i].name, "ConstantValue")) { constant_value = atoi(params[i].value); } } } /* Initialize the metadata storage for each of the metrics and then * store one or more key/value pairs. The define MGROUPS defines * the key for the grouping attribute. */ MMETRIC_INIT_METADATA(&(example_module.metrics_info[0]),p); MMETRIC_ADD_METADATA(&(example_module.metrics_info[0]),MGROUP,"random"); MMETRIC_ADD_METADATA(&(example_module.metrics_info[0]),MGROUP,"example"); /* * Usually a metric will be part of one group, but you can add more * if needed as shown above where Random_Numbers is both in the random * and example groups. */ MMETRIC_INIT_METADATA(&(example_module.metrics_info[1]),p); MMETRIC_ADD_METADATA(&(example_module.metrics_info[1]),MGROUP,"example"); return 0; }
static int ex_metric_init (apr_pool_t *p) { int i; Ganglia_25metric *gmi; init_cpu_info (); /* Allocate a pool that will be used by this module */ apr_pool_create(&pool, p); metric_info = apr_array_make(pool, 2, sizeof(Ganglia_25metric)); /* Initialize each metric */ cpu_user = init_metric (pool, metric_info, cpu_count, "multicpu_user", "Percentage of CPU utilization that occurred while " "executing at the user level"); cpu_nice = init_metric (pool, metric_info, cpu_count, "multicpu_nice", "Percentage of CPU utilization that occurred while " "executing at the nice level"); cpu_system = init_metric (pool, metric_info, cpu_count, "multicpu_system", "Percentage of CPU utilization that occurred while " "executing at the system level"); cpu_idle = init_metric (pool, metric_info, cpu_count, "multicpu_idle", "Percentage of CPU utilization that occurred while " "executing at the idle level"); cpu_wio = init_metric (pool, metric_info, cpu_count, "multicpu_wio", "Percentage of CPU utilization that occurred while " "executing at the wio level"); cpu_intr = init_metric (pool, metric_info, cpu_count, "multicpu_intr", "Percentage of CPU utilization that occurred while " "executing at the intr level"); cpu_sintr = init_metric (pool, metric_info, cpu_count, "multicpu_sintr", "Percentage of CPU utilization that occurred while " "executing at the sintr level"); /* Add a terminator to the array and replace the empty static metric definition array with the dynamic array that we just created */ gmi = apr_array_push(metric_info); memset (gmi, 0, sizeof(*gmi)); multicpu_module.metrics_info = (Ganglia_25metric *)metric_info->elts; for (i = 0; multicpu_module.metrics_info[i].name != NULL; i++) { /* Initialize the metadata storage for each of the metrics and then * store one or more key/value pairs. The define MGROUPS defines * the key for the grouping attribute. */ MMETRIC_INIT_METADATA(&(multicpu_module.metrics_info[i]),p); MMETRIC_ADD_METADATA(&(multicpu_module.metrics_info[i]),MGROUP,"cpu"); } return 0; }
static int storm_mon_module_init ( apr_pool_t *p ) { int i; libmetrics_init(); for (i = 0; storm_mon_module.metrics_info[i].name != NULL; i++) { MMETRIC_INIT_METADATA (&(storm_mon_module.metrics_info[i]),p); MMETRIC_ADD_METADATA (&(storm_mon_module.metrics_info[i]),MGROUP,"srm"); } return 0; }
static int mem_metric_init ( apr_pool_t *p ) { int i; libmetrics_init(); for (i = 0; mem_module.metrics_info[i].name != NULL; i++) { /* Initialize the metadata storage for each of the metrics and then * store one or more key/value pairs. The define MGROUPS defines * the key for the grouping attribute. */ MMETRIC_INIT_METADATA(&(mem_module.metrics_info[i]),p); MMETRIC_ADD_METADATA(&(mem_module.metrics_info[i]),MGROUP,"memory"); } return 0; }
static int user_metric_init ( apr_pool_t *p ) { int i; libmetrics_init(); pool = p; apr_thread_mutex_create(&mutex, APR_THREAD_MUTEX_UNNESTED, pool); for (i = 0; user_module.metrics_info[i].name != NULL; i++) { /* Initialize the metadata storage for each of the metrics and then * store one or more key/value pairs. The define MGROUPS defines * the key for the grouping attribute. */ MMETRIC_INIT_METADATA(&(user_module.metrics_info[i]),p); MMETRIC_ADD_METADATA(&(user_module.metrics_info[i]),MGROUP,"user"); } return 0; }
static int iostat_metric_init ( apr_pool_t *p ) { const char* str_params = io_module.module_params; apr_array_header_t *list_params = io_module.module_params_list; mmparam *params; int i; if (!VD_DISK_MAJOR) VD_DISK_MAJOR = get_device_major("virtblk"); if (!XVD_DISK_MAJOR) XVD_DISK_MAJOR = get_device_major("xvd"); //libmetrics_init(); num_cpustates = num_cpustates_func(); init_partition_info(NULL, 0); print_io_info(); // prints debug msg /* Read the parameters from the gmond.conf file. */ /* Single raw string parameter */ if (str_params) { debug_msg("[mod_iostat] Received string params: %s", str_params); } /* Multiple name/value pair parameters. */ if (list_params) { debug_msg("[mod_iostat] Received following params list: "); params = (mmparam*) list_params->elts; for(i=0; i< list_params->nelts; i++) { debug_msg("\tParam: %s = %s", params[i].name, params[i].value); } } for (i = 0; io_module.metrics_info[i].name != NULL; i++) { MMETRIC_INIT_METADATA(&(io_module.metrics_info[i]),p); MMETRIC_ADD_METADATA(&(io_module.metrics_info[i]),MGROUP,"disk"); } return 0; }