aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/core/process_stats.h
blob: 66346d0b5aa4076e575a9044cbb73ab4259aae5f (plain) (blame)
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
#pragma once

#include "defs.h"
#include "actor.h"

#include <library/cpp/monlib/dynamic_counters/counters.h>

namespace NMonitoring {
    class TMetricRegistry;
}

namespace NActors {
    struct TProcStat {
        ui64 Rss;
        ui64 VolCtxSwtch;
        ui64 NonvolCtxSwtch;

        int Pid;
        char State;
        int Ppid;
        int Pgrp;
        int Session;
        int TtyNr;
        int TPgid;
        unsigned Flags;
        unsigned long MinFlt;
        unsigned long CMinFlt;
        unsigned long MajFlt;
        unsigned long CMajFlt;
        unsigned long Utime;
        unsigned long Stime;
        long CUtime;
        long CStime;
        long Priority;
        long Nice;
        long NumThreads;
        long ItRealValue;
        // StartTime is measured from system boot
        unsigned long long StartTime;
        unsigned long Vsize;
        long RssPages;
        unsigned long RssLim;
        ui64 FileRss;
        ui64 AnonRss;
        ui64 CGroupMemLim = 0;

        TDuration Uptime;
        TDuration SystemUptime;
        // ...

        TProcStat() {
            Zero(*this);
            Y_UNUSED(PageSize);
        }

        bool Fill(pid_t pid);

    private:
        long PageSize = 0;

        long ObtainPageSize();
    };

    IActor* CreateProcStatCollector(ui32 intervalSec, NMonitoring::TDynamicCounterPtr counters);
    IActor* CreateProcStatCollector(TDuration interval, NMonitoring::TMetricRegistry& registry);
}