g_val_t bytes_in_func ( void ) { g_val_t val; update_ifdata("BI"); val.f = bytes_in; debug_msg(" ********** bytes_in: %f", bytes_in); return val; }
g_val_t bytes_out_func ( void ) { g_val_t val; update_ifdata("BO"); val.f = bytes_out; debug_msg(" ********** bytes_out: %f", bytes_out); return val; }
g_val_t pkts_in_func ( void ) { g_val_t val; update_ifdata("PI"); val.f = pkts_in; debug_msg(" ********** pkts_in: %f", pkts_in); return val; }
g_val_t pkts_out_func ( void ) { g_val_t val; update_ifdata("PO"); val.f = pkts_out; debug_msg(" ********** pkts_out: %f", pkts_out); return val; }
/* * 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; }