-
Notifications
You must be signed in to change notification settings - Fork 0
/
Process.h
58 lines (53 loc) · 1.46 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
#pragma once
#include <string>
using namespace std;
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->cmd = ProcessParser::getCmd(pid);
this->cpu = ProcessParser::getCpuPercent(pid);
this->mem = ProcessParser::getVmSize(pid);
this->upTime = ProcessParser::getProcUpTime(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(){
// if(!ProcessParser::isPidExisting(this->pid))
// return "";
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,30)
+ "...");
}