Debian Codegraph @

gmond/modules/network/mod_net.c

raw
1 #include <gm_metric.h>
2 #include <libmetrics.h>
3
4 mmodule net_module;
5
6
7
8 static int net_metric_init ( apr_pool_t *p )
9 {
10 int i;
11
12 libmetrics_init();
13
14 for (i = 0; net_module.metrics_info[i].name != NULL; i++) {
15 /* Initialize the metadata storage for each of the metrics and then
16 * store one or more key/value pairs. The define MGROUPS defines
17 * the key for the grouping attribute. */
18 MMETRIC_INIT_METADATA(&(net_module.metrics_info[i]),p);
19 MMETRIC_ADD_METADATA(&(net_module.metrics_info[i]),MGROUP,"network");
20 }
21
22 return 0;
23 }
24
25 static void net_metric_cleanup ( void )
26 {
27 }
28
29 static g_val_t net_metric_handler ( int metric_index )
30 {
31 g_val_t val;
32
33 /* The metric_index corresponds to the order in which
34 the metrics appear in the metric_info array
35 */
36 switch (metric_index) {
37 case 0:
38 return bytes_out_func();
39 case 1:
40 return bytes_in_func();
41 case 2:
42 return pkts_in_func();
43 case 3:
44 return pkts_out_func();
45 }
46
47 /* default case */
48 val.f = 0;
49 return val;
50 }
51
52 static Ganglia_25metric net_metric_info[] =
53 {
54 {0, "bytes_out", 300, GANGLIA_VALUE_FLOAT, "bytes/sec", "both", "%.2f", UDP_HEADER_SIZE+8, "Number of bytes out per second"},
55 {0, "bytes_in", 300, GANGLIA_VALUE_FLOAT, "bytes/sec", "both", "%.2f", UDP_HEADER_SIZE+8, "Number of bytes in per second"},
56 {0, "pkts_in", 300, GANGLIA_VALUE_FLOAT, "packets/sec", "both", "%.2f", UDP_HEADER_SIZE+8, "Packets in per second"},
57 {0, "pkts_out", 300, GANGLIA_VALUE_FLOAT, "packets/sec", "both", "%.2f", UDP_HEADER_SIZE+8, "Packets out per second"},
58 {0, NULL}
59 };
60
61 mmodule net_module =
62 {
63 STD_MMODULE_STUFF,
64 net_metric_init,
65 net_metric_cleanup,
66 net_metric_info,
67 net_metric_handler,
68 };
69