1 /** 2 * libcollectdclient - src/libcollectdclient/collectd/types.h 3 * Copyright (C) 2008-2017 Florian octo Forster 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 * 23 * Authors: 24 * Florian octo Forster <octo at collectd.org> 25 **/ 26 27 #ifndef LIBCOLLECTD_COLLECTD_TYPES_H 28 #define LIBCOLLECTD_COLLECTD_TYPES_H 1 29 30 #include "collectd/lcc_features.h" 31 32 #include <stdint.h> /* for uint64_t */ 33 #include <sys/types.h> /* for size_t */ 34 35 /* 36 * Defines 37 */ 38 #define LCC_NAME_LEN 64 39 #define LCC_DEFAULT_PORT "25826" 40 41 /* 42 * Types 43 */ 44 #define LCC_TYPE_COUNTER 0 45 #define LCC_TYPE_GAUGE 1 46 #define LCC_TYPE_DERIVE 2 47 #define LCC_TYPE_ABSOLUTE 3 48 49 LCC_BEGIN_DECLS 50 51 typedef uint64_t counter_t; 52 typedef double gauge_t; 53 typedef uint64_t derive_t; 54 typedef uint64_t absolute_t; 55 56 union value_u { 57 counter_t counter; 58 gauge_t gauge; 59 derive_t derive; 60 absolute_t absolute; 61 }; 62 typedef union value_u value_t; 63 64 struct lcc_identifier_s { 65 char host[LCC_NAME_LEN]; 66 char plugin[LCC_NAME_LEN]; 67 char plugin_instance[LCC_NAME_LEN]; 68 char type[LCC_NAME_LEN]; 69 char type_instance[LCC_NAME_LEN]; 70 }; 71 typedef struct lcc_identifier_s lcc_identifier_t; 72 #define LCC_IDENTIFIER_INIT \ 73 { "localhost", "", "", "", "" } 74 75 struct lcc_value_list_s { 76 value_t *values; 77 int *values_types; 78 size_t values_len; 79 double time; 80 double interval; 81 lcc_identifier_t identifier; 82 }; 83 typedef struct lcc_value_list_s lcc_value_list_t; 84 #define LCC_VALUE_LIST_INIT \ 85 { NULL, NULL, 0, 0, 0, LCC_IDENTIFIER_INIT } 86 87 /* lcc_value_list_writer_t is a write callback to which value lists are 88 * dispatched. */ 89 typedef int (*lcc_value_list_writer_t)(lcc_value_list_t const *); 90 91 /* lcc_password_lookup_t is a callback for looking up the password for a given 92 * user. Must return NULL if the user is not known. */ 93 typedef char const *(*lcc_password_lookup_t)(char const *); 94 95 LCC_END_DECLS 96 97 #endif /* LIBCOLLECTD_COLLECTD_TYPES_H */ 98