/* * This function is called only once by the gmond. Use to * initialize data structures, etc or just return SYNAPSE_SUCCESS; */ g_val_t metric_init(void) { struct utsname u; g_val_t rval; num_cpustates = num_cpustates_func(); rval.int32 = slurpfile("/proc/cpuinfo", proc_cpuinfo, BUFFSIZE); if ( rval.int32 == SYNAPSE_FAILURE ) { err_msg("metric_init() got an error from slurpfile() /proc/cpuinfo"); return rval; } if (uname(&u) == -1) { strncpy(sys_osname, "unknown", MAX_G_STRING_SIZE); strncpy(sys_osrelease, "unknown", MAX_G_STRING_SIZE); } else { strncpy(sys_osname, u.sysname, MAX_G_STRING_SIZE); sys_osname[MAX_G_STRING_SIZE - 1] = '\0'; strncpy(sys_osrelease, u.release, MAX_G_STRING_SIZE); sys_osrelease[MAX_G_STRING_SIZE - 1] = '\0'; } rval.int32 = SYNAPSE_SUCCESS; return rval; }
/* * This function is called only once by the gmond. Use to * initialize data structures, etc or just return SYNAPSE_SUCCESS; */ g_val_t metric_init(void) { g_val_t rval; char * dummy; struct stat struct_stat; num_cpustates = num_cpustates_func(); /* scaling_max_freq will contain the max CPU speed if available */ cpufreq = 0; if ( stat(SCALING_MAX_FREQ, &struct_stat) == 0 ) { cpufreq = 1; dummy = sys_devices_system_cpu; slurpfile(SCALING_MAX_FREQ, &dummy, 32); } dummy = proc_cpuinfo; rval.int32 = slurpfile("/proc/cpuinfo", &dummy, BUFFSIZE); if (proc_cpuinfo == NULL) proc_cpuinfo = dummy; if ( rval.int32 == SLURP_FAILURE ) { err_msg("metric_init() got an error from slurpfile() /proc/cpuinfo"); rval.int32 = SYNAPSE_FAILURE; return rval; } dummy = proc_sys_kernel_osrelease; rval.int32 = slurpfile("/proc/sys/kernel/osrelease", &dummy, MAX_G_STRING_SIZE); if ( rval.int32 == SLURP_FAILURE ) { err_msg("metric_init() got an error from slurpfile()"); rval.int32 = SYNAPSE_FAILURE; return rval; } /* Get rid of pesky \n in osrelease */ proc_sys_kernel_osrelease[rval.int32-1] = '\0'; dummy = update_file(&proc_net_dev); if ( dummy == NULL ) { err_msg("metric_init() got an error from update_file()"); rval.int32 = SYNAPSE_FAILURE; return rval; } update_ifdata("metric_inint"); rval.int32 = SYNAPSE_SUCCESS; return rval; }
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; }