-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.h
64 lines (59 loc) · 1.6 KB
/
process.h
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
#include <string>
#include "process_parcer.h"
using std::string;
/*
Basic class for Process representation
It contains relevant attributes as shown below
*/
class Process {
private:
string pid;
string user;
string cmd;
string cpu;
string mem;
string upTime;
public:
Process(string pid)
{
this->pid = pid;
this->user = ProcessParser::getProcUser(pid);
this->mem = ProcessParser::getVmSize(pid);
this->cmd = ProcessParser::getCmd(pid);
this->upTime = ProcessParser::getProcUpTime(pid);
this->cpu = ProcessParser::getCpuPercent(pid);
}
void setPid(int pid);
string getPid() const;
string getUser() const;
string getCmd() const;
int getCpu() const;
int getMem() const;
string getUpTime() const;
string getProcess();
};
void Process::setPid(int pid)
{
this->pid = pid;
}
string Process::getPid() const
{
return this->pid;
}
string Process::getProcess()
{
this->mem = ProcessParser::getVmSize(this->pid);
this->upTime = ProcessParser::getProcUpTime(this->pid);
this->cpu = ProcessParser::getCpuPercent(this->pid);
return (this->pid + " "
+ this->user
+ " "
+ this->mem.substr(0,5)
+ " "
+ this->cpu.substr(0,5)
+ " "
+ this->upTime.substr(0,5)
+ " "
+ this->cmd.substr(0,45)
+ "...");
}