forked from ganglia/monitor-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgm_metric.h
106 lines (87 loc) · 2.7 KB
/
gm_metric.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#ifndef GM_METRIC_H
#define GM_METRIC_H 1
#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <gm_mmn.h>
#ifndef GM_PROTOCOL_GUARD
#include <netinet/in.h>
#include <gm_protocol.h>
#endif
#include <gm_value.h>
#include <gm_msg.h>
#include <confuse.h> /* header for libconfuse */
#include <apr.h>
#include <apr_pools.h>
#include <apr_tables.h>
#define MGROUP "GROUP"
typedef void (*metric_info_func)(Ganglia_25metric *gmi);
typedef g_val_t (*metric_func)(int metric_index);
typedef g_val_t (*metric_func_void)(void);
/**
* Module structures.
*/
typedef struct mmodule_param mmparam;
struct mmodule_param {
char *name;
char *value;
};
typedef struct mmodule_struct mmodule;
struct mmodule_struct {
/** API version, *not* module version; check that module is
* compatible with this version of the server.
*/
int version;
/** API minor version. Provides API feature milestones. */
int minor_version;
/** The name of the module's C file */
const char *name;
/** The handle for the DSO. Internal use only */
void *dynamic_load_handle;
/** The module name */
char *module_name;
/** The metric name */
char *metric_name;
/** Single string parameter */
char *module_params;
/** Multiple name/value pair parameter list */
apr_array_header_t *module_params_list;
/** Configuration file handle */
cfg_t *config_file;
/** A pointer to the next module in the list
* @defvar module_struct *next */
struct mmodule_struct *next;
/** Magic Cookie to identify a module structure. */
unsigned long magic;
/** Metric init callback function */
int (*init)(apr_pool_t *p); /* callback function */
/** Metric cleanup callback function */
void (*cleanup)(void); /* callback function */
/** Metric info callback function */
Ganglia_25metric *metrics_info;
/** Metric callback function */
metric_func handler;
};
/* Convenience macros for adding metadata key/value pairs to a metric structure element */
#define MMETRIC_INIT_METADATA(m,p) \
do { \
void **t = (void**)&((m)->metadata); \
*t = (void*)apr_table_make(p, 2); \
} while (0)
#define MMETRIC_ADD_METADATA(m,k,v) \
apr_table_add((apr_table_t*)(m)->metadata,k,v)
/** Use this in all standard modules */
#define STD_MMODULE_STUFF MMODULE_MAGIC_NUMBER_MAJOR, \
MMODULE_MAGIC_NUMBER_MINOR, \
__FILE__, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
NULL, \
MMODULE_MAGIC_COOKIE
#endif /* GM_METRIC_H */