Debian Codegraph @

gmond/modules/cpu/mod_load.c

raw
1 #include <gm_metric.h>
2 #include <libmetrics.h>
3
4 mmodule load_module;
5
6
7 static int load_metric_init ( apr_pool_t *p )
8 {
9 int i;
10
11 libmetrics_init();
12
13 for (i = 0; load_module.metrics_info[i].name != NULL; i++) {
14 /* Initialize the metadata storage for each of the metrics and then
15 * store one or more key/value pairs. The define MGROUPS defines
16 * the key for the grouping attribute. */
17 MMETRIC_INIT_METADATA(&(load_module.metrics_info[i]),p);
18 MMETRIC_ADD_METADATA(&(load_module.metrics_info[i]),MGROUP,"load");
19 }
20
21 return 0;
22 }
23
24 static void load_metric_cleanup ( void )
25 {
26 }
27
28 static g_val_t load_metric_handler ( int metric_index )
29 {
30 g_val_t val;
31
32 /* The metric_index corresponds to the order in which
33 the metrics appear in the metric_info array
34 */
35 switch (metric_index) {
36 case 0:
37 return load_one_func();
38 case 1:
39 return load_five_func();
40 case 2:
41 return load_fifteen_func();
42 }
43
44 /* default case */
45 val.f = 0;
46 return val;
47 }
48
49 static Ganglia_25metric load_metric_info[] =
50 {
51 {0, "load_one", 70, GANGLIA_VALUE_FLOAT, " ", "both", "%.2f", UDP_HEADER_SIZE+8, "One minute load average"},
52 {0, "load_five", 325, GANGLIA_VALUE_FLOAT, " ", "both", "%.2f", UDP_HEADER_SIZE+8, "Five minute load average"},
53 {0, "load_fifteen", 950, GANGLIA_VALUE_FLOAT, " ", "both", "%.2f", UDP_HEADER_SIZE+8, "Fifteen minute load average"},
54 {0, NULL}
55 };
56
57 mmodule load_module =
58 {
59 STD_MMODULE_STUFF,
60 load_metric_init,
61 load_metric_cleanup,
62 load_metric_info,
63 load_metric_handler,
64 };
65