Debian Codegraph @

gmond/modules/system/mod_sys.c

raw
1 #include <gm_metric.h>
2 #include <libmetrics.h>
3
4 mmodule sys_module;
5
6 static int sys_metric_init ( apr_pool_t *p )
7 {
8 int i;
9
10 libmetrics_init();
11
12 for (i = 0; sys_module.metrics_info[i].name != NULL; i++) {
13 /* Initialize the metadata storage for each of the metrics and then
14 * store one or more key/value pairs. The define MGROUPS defines
15 * the key for the grouping attribute. */
16 MMETRIC_INIT_METADATA(&(sys_module.metrics_info[i]),p);
17 MMETRIC_ADD_METADATA(&(sys_module.metrics_info[i]),MGROUP,"system");
18 }
19
20 return 0;
21 }
22
23 static void sys_metric_cleanup ( void )
24 {
25 }
26
27 static g_val_t sys_metric_handler ( int metric_index )
28 {
29 g_val_t val;
30
31 /* The metric_index corresponds to the order in which
32 the metrics appear in the metric_info array
33 */
34 switch (metric_index) {
35 case 0:
36 return boottime_func();
37 case 1:
38 return sys_clock_func();
39 case 2:
40 return machine_type_func();
41 case 3:
42 return os_name_func();
43 case 4:
44 return os_release_func();
45 case 5:
46 return mtu_func();
47 }
48
49 /* default case */
50 val.uint32 = 0;
51 return val;
52 }
53
54 static Ganglia_25metric sys_metric_info[] =
55 {
56 {0, "boottime", 1200, GANGLIA_VALUE_UNSIGNED_INT, "s", "zero", "%u", UDP_HEADER_SIZE+8, "The last time that the system was started"},
57 {0, "sys_clock", 1200, GANGLIA_VALUE_UNSIGNED_INT, "s", "zero", "%u", UDP_HEADER_SIZE+8, "Time as reported by the system clock"},
58 {0, "machine_type", 1200, GANGLIA_VALUE_STRING, "", "zero", "%s", UDP_HEADER_SIZE+32, "System architecture"},
59 {0, "os_name", 1200, GANGLIA_VALUE_STRING, "", "zero", "%s", UDP_HEADER_SIZE+32, "Operating system name"},
60 {0, "os_release", 1200, GANGLIA_VALUE_STRING, "", "zero", "%s", UDP_HEADER_SIZE+32, "Operating system release date"},
61 {0, "mtu", 1200, GANGLIA_VALUE_UNSIGNED_INT, "", "both", "%u", UDP_HEADER_SIZE+8, "Network maximum transmission unit"},
62 {0, NULL}
63
64 };
65
66 mmodule sys_module =
67 {
68 STD_MMODULE_STUFF,
69 sys_metric_init,
70 sys_metric_cleanup,
71 sys_metric_info,
72 sys_metric_handler,
73 };
74