summaryrefslogtreecommitdiffstats
path: root/veslibrary/ves_cpplibrary/src/lib/encode/XProcessStatsImp.cpp
blob: ee2cc549d086401b897e8d1c37987efad41d53db (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
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
67
68
69
#include "XProcessStatsImp.h"

XProcessStatsImp::XProcessStatsImp(const XString& processIdentifier):
        processIdentifier_(processIdentifier)
{

}

void XProcessStatsImp::setForkRate(XNumber forkRate)
{
    comVals_["forkRate"] = forkRate;
}
            
void XProcessStatsImp::setPsStateStopped(XNumber psStateStopped)
{
    comVals_["psStateStopped"] = psStateStopped;
}
            
void XProcessStatsImp::setPsStatePaging(XNumber psStatePaging)
{
    comVals_["psStatePaging"] = psStatePaging;
}
            
void XProcessStatsImp::setPsStateSleeping(XNumber psStateSleeping)
{
    comVals_["psStateSleeping"] = psStateSleeping;
}
            
void XProcessStatsImp::setProcessIdentifier(const XString& processIdentifier)
{
    comVals_["processIdentifier"] = processIdentifier;
}
            
void XProcessStatsImp::setPsStateBlocked(XNumber psStateBlocked)
{
    comVals_["psStateBlocked"] = psStateBlocked;
}
            
void XProcessStatsImp::setPsStateZombie(XNumber psStateZombie)
{
    comVals_["psStateZombie"] = psStateZombie;
}
            
void XProcessStatsImp::setPsStateRunning(XNumber psStateRunning)
{
    comVals_["psStateRunning"] = psStateRunning;
}

json XProcessStatsImp::toJson()
{
    try
    {
        json field = {
            {"processIdentifier", processIdentifier_}
        };

        //optional val
        
        field = mergeCommonValues(field, comVals_);

        return field;
    }
    catch (json::exception& e)
    {
        SPDLOG_ERROR("Fail to build XProcessStats to json object:{}.", e.what());
        return json();
    }
}