Hi,
i'm trying to development a plugin for collectd. But it dosen't work.
The plugin is running/loading but no data are submitted/dispatched.
My searches in the internet -> no results.
waht wrong with my plugin?
code and makefile in attachment.
best regards
Sebastian Kuhnert
makefile
Description: Binary data
/***************************************************************************** * author : Sebastian Kuhnert * * company : Ammonit Measurement GmbH * * Wrangelstr. 100, DE 10997 Berlin * * http://www.ammonit.com * * date : 2014-04-10 * * change : 2014-04-10 * *****************************************************************************/ /***************************************************************************** * Ammonit_life is an plugin for the collectd daemon. * * This plugin read the logger data and send the data to an server in use * * of collectd. * *****************************************************************************/ /***************************************************************************** * License * * ======= * * * * Ammonit_life.c * * Copyright (C) 2014 Ammonit Measurements GmbH * * * * 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: * * Sebastian Kuhnert <Kuhnse at gmx.net> * * * *****************************************************************************/
#include <stdio.h> #include <stdint.h> #include <collectd/config.h> #include <collectd/collectd.h> #include <collectd/common.h> /* auxiliary functions */ #include <collectd/plugin.h> /* plugin_register_*, plugin_dispatch_values */ const char* PLUGIN_NAME = "ammonit_life"; /*test code only for testing, remove this code if release*/ const char* FILE_NAME = "/home/sebastian/projekte/ammonit_life/test.txt"; /* submit the life data */ static void lifedata_submit (double value) { int i; value_t values[1]; value_list_t vl = VALUE_LIST_INIT; values[0].gauge = value; vl.values = values; vl.values_len = 1; sstrncpy (vl.host , hostname_g , sizeof (vl.host )); sstrncpy (vl.plugin, PLUGIN_NAME , sizeof (vl.plugin)); sstrncpy (vl.type , "ammonit_life", sizeof (vl.type )); //ssnprintf (vl.plugin_instance, sizeof (vl.plugin_instance), "ammonit_life"); //sstrncpy (vl.type_instance, "ammonit_life", sizeof (vl.type_instance)); plugin_dispatch_values (&vl); /*test code only for testing, remove this code if release*/ FILE *testfile; testfile = fopen (FILE_NAME, "w"); for (i=0; i<vl.values_len; i++) fprintf (testfile, "value : %f\n", vl.values[i]); fprintf (testfile, "host name : %s\n", vl.host ); fprintf (testfile, "plugin name : %s\n", vl.plugin ); fprintf (testfile, "plugin instnce: %s\n", vl.plugin_instance); fprintf (testfile, "type : %s\n", vl.type ); fprintf (testfile, "type instance : %s\n", vl.type_instance ); fclose (testfile); /*\test code*/ } /*lifedata_submit*/ /* initializing this plugin */ static int ammonit_life_init (void) { return 0; } /*ammonit_life_init*/ /* read function: read the logger file and parse the data for transmit them by collectd. */ #if 0 static int lifedata_read_cb (user_data_t *ud) { lifedata_submit (5.00); return 0; } /*lifedata_read_cb*/ #endif static int lifedata_read (void) { lifedata_submit (5.67); return 0; } /*lifedata_read*/ /* plugin register function, see the collectd Plugin_architecture */ void module_register (void) { //struct timespec ts_ld_read = { 1, 000000000 }; /* call every 1,0 seconds */ plugin_register_init (PLUGIN_NAME, ammonit_life_init); plugin_register_read (PLUGIN_NAME, lifedata_read); //plugin_register_complex_read ( // "ammonit_life", /*Group: ???*/ // PLUGIN_NAME, // lifedata_read_cb, // &ts_ld_read, // NULL // ); } /*module_register*/ /***************************************************************************** * change log * * * * date author description * * ------------------------------------------------------------------------- * * 2014-04-10 Sebastian Kuhnert - create the file * * - add main * * - add module_register * * - add ammonit_life_init * * - add lifedata_write * * - add ammonit_life_flush * * - add ammonit_life_shutdown * * 2014-04-15 Sebastian Kuhnert - dirty testing: Is collectd running * * this plugin? -> Yes * * test method: writing an text file on * * HDD. * * - function lifedata-write removed * * - function lifedata_submit added * * * *****************************************************************************/
_______________________________________________ collectd mailing list collectd@verplant.org http://mailman.verplant.org/listinfo/collectd