summaryrefslogtreecommitdiffstats
path: root/src/collectors/common-contexts/mem.pgfaults.h
blob: 503b9f7e81d7a34cde233fdd58f72f6fb00f3ab5 (plain)
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
// SPDX-License-Identifier: GPL-3.0-or-later

#ifndef NETDATA_MEM_PGFAULTS_H
#define NETDATA_MEM_PGFAULTS_H

#include "common-contexts.h"

static inline void common_mem_pgfaults(uint64_t minor, uint64_t major, int update_every) {
    static RRDSET *st_pgfaults = NULL;
    static RRDDIM *rd_minor = NULL, *rd_major = NULL;

    if(unlikely(!st_pgfaults)) {
        st_pgfaults = rrdset_create_localhost(
            "mem"
            , "pgfaults"
            , NULL
            , "page faults"
            , NULL
            , "Memory Page Faults"
            , "faults/s"
            , _COMMON_PLUGIN_NAME
            , _COMMON_PLUGIN_MODULE_NAME
            , NETDATA_CHART_PRIO_MEM_SYSTEM_PGFAULTS
            , update_every
            , RRDSET_TYPE_LINE
        );

        rrdset_flag_set(st_pgfaults, RRDSET_FLAG_DETAIL);

        rd_minor = rrddim_add(st_pgfaults, "minor", NULL,  1, 1, RRD_ALGORITHM_INCREMENTAL);
        rd_major = rrddim_add(st_pgfaults, "major", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
    }

    // this always have to be in base units, so that exporting sends base units to other time-series db
    rrddim_set_by_pointer(st_pgfaults, rd_minor, minor);
    rrddim_set_by_pointer(st_pgfaults, rd_major, major);
    rrdset_done(st_pgfaults);
}

#endif //NETDATA_MEM_PGFAULTS_H