From 56f8c6aabc44dc49eab9410ba0f98a7ba2362c5b Mon Sep 17 00:00:00 2001 From: Evan Felix Date: Thu, 18 Apr 2013 13:28:04 -0700 Subject: [PATCH] Initial implementation of build addition, and memory gathering for the mic card --- src/mic.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 src/mic.c diff --git a/src/mic.c b/src/mic.c new file mode 100644 index 00000000..efd7c1da --- /dev/null +++ b/src/mic.c @@ -0,0 +1,125 @@ +/** + * collectd - src/xmms.c + * Copyright (C) 2013 + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; only version 2 of the License is applicable. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * Authors: + * Evan Felix +#include +#include + +#define MAX_MICS 32 + +static MicDeviceOnSystem mics[MAX_MICS]; +static U32 numMics = MAX_MICS; +static HANDLE micHandle=NULL; + +static int mic_init (void) +{ + U32 ret; + + ret = MicInitAPI(&micHandle, eTARGET_SCIF_DRIVER, mics, &numMics); + if (ret != MIC_ACCESS_API_SUCCESS) { + ERROR("Problem initializing MicAccessAPI: %s",MicGetErrorString(ret)); + } + INFO("MICs found: %d",numMics); + if (numMics<0 || numMics>=MAX_MICS) + return (1); + else + return (0); +} + +static void mic_submit_memory_use(int micnumber, char *type, gauge_t val) +{ + value_t values[1]; + value_list_t vl = VALUE_LIST_INIT; + + values[0].gauge = val; + + vl.values=values; + vl.values_len=1; + + strncpy (vl.host, hostname_g, sizeof (vl.host)); + strncpy (vl.plugin, "mic", sizeof (vl.plugin)); + ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance), "%i", micnumber); + strncpy (vl.type, "memory", sizeof (vl.type)); + strncpy (vl.type_instance, type, sizeof (vl.type_instance)); + + plugin_dispatch_values (&vl); +} + +static int mic_read (void) +{ + int i; + U32 ret; + int error; + U32 mem_total,mem_used,mem_bufs; + + error=0; + for (i=0;i