File: core_metrics.c

package info (click to toggle)
ganglia 3.6.0-7
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 6,484 kB
  • ctags: 3,880
  • sloc: ansic: 27,874; sh: 11,052; python: 6,695; makefile: 565; perl: 366; php: 126; xml: 28
file content (66 lines) | stat: -rw-r--r-- 1,702 bytes parent folder | download | duplicates (4)
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
#include <gm_metric.h>
#include <libmetrics.h>

mmodule core_metrics;

/*
** A helper function to determine the number of cpustates in /proc/stat (MKN)
*/

static int core_metrics_init ( apr_pool_t *p )
{
    int i;

    for (i = 0; core_metrics.metrics_info[i].name != NULL; i++) {
        /* Initialize the metadata storage for each of the metrics and then
         *  store one or more key/value pairs.  The define MGROUPS defines
         *  the key for the grouping attribute. */
        MMETRIC_INIT_METADATA(&(core_metrics.metrics_info[i]),p);
        MMETRIC_ADD_METADATA(&(core_metrics.metrics_info[i]),MGROUP,"core");
    }

    return 0;
}

static void core_metrics_cleanup ( void )
{
}

static g_val_t core_metrics_handler ( int metric_index )
{
    g_val_t val;

    /* The metric_index corresponds to the order in which
       the metrics appear in the metric_info array
    */
    switch (metric_index) {
    case 0:
        return gexec_func();
    case 1:
        return heartbeat_func();
    case 2:
        return location_func();
    }

    /* default case */
    val.int32 = 0;
    return val;
}

static Ganglia_25metric core_metrics_info[] = 
{
    {0, "gexec",      300, GANGLIA_VALUE_STRING,       "",        "zero", "%s", UDP_HEADER_SIZE+32, "gexec available"},
    {0, "heartbeat",   20, GANGLIA_VALUE_UNSIGNED_INT, "",        "",     "%u", UDP_HEADER_SIZE+8,  "Last heartbeat"},
    {0, "location",  1200, GANGLIA_VALUE_STRING,       "(x,y,z)", "",     "%s", UDP_HEADER_SIZE+12, "Location of the machine"},
    {0, NULL}
};

mmodule core_metrics =
{
    STD_MMODULE_STUFF,
    core_metrics_init,
    core_metrics_cleanup,
    core_metrics_info,
    core_metrics_handler,
};