From: Evan Felix Date: Mon, 22 Apr 2013 15:04:50 +0000 (-0700) Subject: Add config options X-Git-Tag: collectd-5.4.0~42^2~20 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=31c9003882cafe0c36d0d28d11f977e5d5818014;p=collectd.git Add config options --- diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 89a1b234..270da310 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -1028,8 +1028,18 @@ # # +# ShowTotalCPU true +# ShowPerCPU true +# ShowMemory true +# ShowTemps true +#Temperature Sensors can be ignored/shown by repeaded +#TempSensor Lines, and then inverted with a IgnoreTempSelected +#Known Temperature sensors: die, devmem, fin, fout, vccp, vddg, vddq +# TempSensor vddg +# IgnoreTempSelected true # + # # This tag support an argument if you want to # monitor the local instance just use diff --git a/src/mic.c b/src/mic.c index d9eb8254..3a3a17e7 100644 --- a/src/mic.c +++ b/src/mic.c @@ -22,6 +22,7 @@ #include "collectd.h" #include "plugin.h" #include "common.h" +#include "utils_ignorelist.h" #include #include @@ -38,6 +39,23 @@ static HANDLE micHandle=NULL; static const int therms[NUM_THERMS] = {eMicThermalDie,eMicThermalDevMem,eMicThermalFin,eMicThermalFout,eMicThermalVccp,eMicThermalVddg,eMicThermalVddq}; static const char *thermNames[NUM_THERMS] = {"die","devmem","fin","fout","vccp","vddg","vddq"}; +static const char *config_keys[] = +{ + "ShowTotalCPU", + "ShowPerCPU", + "ShowTemps", + "ShowMemory", + "TempSensor", + "IgnoreTempSelected", +}; +static int config_keys_num = STATIC_ARRAY_SIZE (config_keys); + +static _Bool show_total_cpu = 1; +static _Bool show_per_cpu = 1; +static _Bool show_temps = 1; +static _Bool show_memory = 1; +static ignorelist_t *temp_ignore = NULL; + static int mic_init (void) { @@ -47,13 +65,54 @@ static int mic_init (void) if (ret != MIC_ACCESS_API_SUCCESS) { ERROR("Problem initializing MicAccessAPI: %s",MicGetErrorString(ret)); } - INFO("MICs found: %d",numMics); + DEBUG("MICs found: %d",numMics); + if (numMics<0 || numMics>=MAX_MICS) return (1); else return (0); } +static int mic_config (const char *key, const char *value) { + if (temp_ignore == NULL) + temp_ignore = ignorelist_create(1); + if (temp_ignore == NULL) + return (1); + + if (strcasecmp("ShowTotalCPU",key) == 0) + { + show_total_cpu = IS_TRUE(value); + } + else if (strcasecmp("ShowPerCPU",key) == 0) + { + show_per_cpu = IS_TRUE(value); + } + else if (strcasecmp("ShowTemps",key) == 0) + { + show_temps = IS_TRUE(value); + } + else if (strcasecmp("ShowMemory",key) == 0) + { + show_memory = IS_TRUE(value); + } + else if (strcasecmp("TempSensor",key) == 0) + { + ignorelist_add(temp_ignore,value); + } + else if (strcasecmp("IgnoreTempSelected",key) == 0) + { + int invert = 1; + if (IS_TRUE(value)) + invert = 0; + ignorelist_set_invert(temp_ignore,invert); + } + else + { + return (-1); + } + return (0); +} + static void mic_submit_memory_use(int micnumber, const char *type, gauge_t val) { value_t values[1]; @@ -73,6 +132,25 @@ static void mic_submit_memory_use(int micnumber, const char *type, gauge_t val) plugin_dispatch_values (&vl); } +/* Gather memory Utilization */ +static int mic_read_memory(int mic) +{ + U32 ret; + U32 mem_total,mem_used,mem_bufs; + + ret = MicGetMemoryUtilization(micHandle,&mem_total,&mem_used,&mem_bufs); + if (ret != MIC_ACCESS_API_SUCCESS) { + ERROR("Problem getting Memory Utilization: %s",MicGetErrorString(ret)); + return (1); + } + /* API reprots KB's of memory, adjust for this */ + mic_submit_memory_use(mic,"total",mem_total*1024); + mic_submit_memory_use(mic,"used",mem_used*1024); + mic_submit_memory_use(mic,"bufs",mem_bufs*1024); + /*INFO("Memory Read: %u %u %u",mem_total,mem_used,mem_bufs);*/ + return (0); +} + static void mic_submit_temp(int micnumber, const char *type, gauge_t val) { value_t values[1]; @@ -92,6 +170,30 @@ static void mic_submit_temp(int micnumber, const char *type, gauge_t val) plugin_dispatch_values (&vl); } +/* Gather Temperature Information */ +static int mic_read_temps(int mic) +{ + int j; + U32 ret; + U32 bufferSize; + U32 *tempBuffer; + + bufferSize = sizeof(U32); + tempBuffer = malloc(bufferSize); + for (j=0;j