-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFactoryLibrary.h
99 lines (76 loc) · 3.91 KB
/
FactoryLibrary.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef ProcessFactoryLibrary_h_IS_INCLUDED
#define ProcessFactoryLibrary_h_IS_INCLUDED
#include "ProcessFactory/IncludeExtLibs.h"
#include <list>
#include <map>
#include <vector>
// -------------------------------------------------------
// ProcessFactoryLibrary
// -------------------------------------------------------
namespace ProcessFactoryLibrary
{
int isProcessRunning(int64 pid, string executableName = string(""));
void killProcess(const HostInformation& info);
void createProcess(const string &commandLine, const string& title);
namespace Linux
{
struct MetricStateWrapper64
{
HostResources::MapStringInt64 prevState;
HostResources::MapStringInt64 metricState;
};
struct MetricStateWrapper32
{
HostResources::MapStringInt32 prevState;
HostResources::MapStringInt32 metricState;
};
int GetNumberOfThreads(int pid);
int GetNumberOfOpenFileDescriptors(int pid);
int GetNumberOfSockets();
int GetNumberOfFileDescriptors();
HostResources::MapStringInt32 GetCPUTemperatures();
vector<string> SplitString(string line, string delim);
int findChildProcessId(const int &parentProcessId, const string &executableName);
vector<int> findChildZombies(const int &parentProcessId);
bool getProcessResources(int processId, HostResources &);
double getCPUUsagePercent(int pid, int64 &totalUsedPrev, int64 &totalCPUUsedPrev, int64 &totalCPUUsedCurr);
bool getDiskPartitions(vector<string> &vectorPartitions);
bool getDiskTraffic(int measureInterval, vector<string> &vectorPartitions, MetricStateWrapper32 &diskTransfer, MetricStateWrapper32 &diskRead, MetricStateWrapper32 &diskWrite);
#ifdef USE_GCC
size_t getTotalSystemMemory();
#endif
void getNodeResources(HostResources &);
double getCPUUsagePercent(int64 &prev_total, int64 &prev_idle);
bool getNetworkTraffic(MetricStateWrapper64 &sentState, MetricStateWrapper64 &recvState);
bool getCPUUsagePercent(map<string, pair<int64, int64> > &prevStats, map<string, double> ¤tCpuStatus);
#ifdef USE_GCC
int readProcessIdFromFD(FILE *file);
#endif
string createXtermArgumentsString(const string &executableName, const string& componentName, const string &componentArgs);
char** createXtermArgumentsCharV(const string &executableName, const string& componentName, const string &componentArgs);
char** createArgumentsCharV(const string &executableName, const string& componentName, const string &componentArgs);
string createArgumentsString(const string &executableName, const string &componentName, const string &componentArgs);
int createProcessPopenReadPid(const string &executableName, const string &componentName, const string &componentArgs, FILE* &fd);
int createProcessXtermForkExec(const string &executableName, const string& componentName, const string &componentArgs);
int createProcessForkExec(const string &executableName, const string& componentName, const string &componentArgs);
FILE* createProcessPopen(const string &command);
int createProcessForkExec(const char *executable, char *const args[]);
int createProcessForkExecPipe(const char *executable, char *const args[], int *infp, int *outfp);
}
namespace Windows
{
#ifndef USE_GCC
bool isProcessRunning(HANDLE hProcess);
size_t getTotalSystemMemory();
void readDataFromPipe(HANDLE hChildStdoutRdDup, int *pid, int *port);
void readDataFromPipe(int fdStdOutPipe, int *pid, int *port);
void readDataFromPipe(FILE *file, int *pid, int *port);
int createProcess(const string &command, const string& title);
int createProcessSpawnPipe(const char *executable, char *const args[], int *stdOutPipe);
int createProcessPopen(const string &commandLine, const string &title, FILE *file);
int createProcessPipe(const string &commandLine, const string& title, HANDLE &hChildStdoutRdDup, HANDLE &hChildStdinWrDup);
int createProcessPipe(const string &commandLine, const string& title, HANDLE &hChildStd_OUT_Rd);
#endif
}
}; // namesapce ProcessFactoryLibrary
#endif // ProcessFactoryLibrary_h_IS_INCLUDED