Debian Codegraph @

gmond/modules/system/mod_proc.c

raw
1 #include <gm_metric.h>
2 #include <libmetrics.h>
3
4 mmodule proc_module;
5
6
7 static int proc_metric_init ( apr_pool_t *p )
8 {
9 int i;
10
11 libmetrics_init();
12
13 for (i = 0; proc_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(&(proc_module.metrics_info[i]),p);
18 MMETRIC_ADD_METADATA(&(proc_module.metrics_info[i]),MGROUP,"process");
19 }
20
21 return 0;
22 }
23
24 static void proc_metric_cleanup ( void )
25 {
26 }
27
28 static g_val_t proc_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 proc_run_func();
38 case 1:
39 return proc_total_func();
40 }
41
42 /* default case */
43 val.uint32 = 0;
44 return val;
45 }
46
47 static Ganglia_25metric proc_metric_info[] =
48 {
49 {0, "proc_run", 950, GANGLIA_VALUE_UNSIGNED_INT, " ", "both", "%u", UDP_HEADER_SIZE+8, "Total number of running processes"},
50 {0, "proc_total", 950, GANGLIA_VALUE_UNSIGNED_INT, " ", "both", "%u", UDP_HEADER_SIZE+8, "Total number of processes"},
51 {0, NULL}
52
53 };
54
55 mmodule proc_module =
56 {
57 STD_MMODULE_STUFF,
58 proc_metric_init,
59 proc_metric_cleanup,
60 proc_metric_info,
61 proc_metric_handler,
62 };
63