10 #include <proc/readproc.h> 61 string GetProcStat_(
int pid,
int field)
const;
66 template<
typename TYPE> TYPE
GetProcStat(
int pid,
int field)
const 69 string str = GetProcStat_(pid, field);
70 istringstream(str) >> val;
85 available_memory_ = 0;
109 out <<
"Status: " << (app.
is_running() ?
"running" :
"stopped") << endl;
110 out <<
"Available memory: " << setiosflags(ios::fixed) << setprecision(2) << app.
available_memory() <<
" MB" << endl;
113 out <<
"Father PID: " << app->
father_pid << endl;
114 out <<
"Child PID: " << app->
child_pid << endl;
115 out <<
"Child threads: " << app.
num_threads() << endl;
118 out <<
"Father used memory: " << setiosflags(ios::fixed) << setprecision(2) << app.
father_memory() <<
" MB" << endl;
119 out <<
"Child used memory: " << setiosflags(ios::fixed) << setprecision(2) << app.
child_memory() <<
" MB" << endl;
135 return available_memory_;
143 return father_memory_;
151 return child_memory_;
bool is_running() const
Returns true if the application is running.
Definition: app_info.h:102
unsigned long time() const
Returns the time spent by the father process.
Definition: app_info.h:173
unsigned long child_time_
Time spend by the child.
Definition: app_info.h:56
unsigned long time_
Time spent by the father.
Definition: app_info.h:53
Data * operator->() const
Definition: app_info.h:178
int num_threads_
Number of active threads.
Definition: app_info.h:51
Contains the run-time information of the application.
Definition: app_info.h:21
unsigned long child_time() const
Returns the time spent by the child process.
Definition: app_info.h:165
int num_threads() const
Returns the number of active threads.
Definition: app_info.h:157
int father_pid
PID of the father process.
Definition: app_info.h:30
double available_memory() const
Returns the available memory of the system.
Definition: app_info.h:133
int child_iterations
Number of iterations done by the child.
Definition: app_info.h:33
AppInfo()
Initializes the object.
Definition: app_info.h:78
double father_memory() const
Returns the memory used by the father process.
Definition: app_info.h:141
double child_memory() const
Returns the memory used by the child process.
Definition: app_info.h:149
int shmid
Identifier of the shared memory block.
Definition: app_info.h:47
Data * data_ptr
Pointer to the shared memory block.
Definition: app_info.h:49
void Reset()
Clears the values.
Definition: app_info.h:38
Contains the data block that is maintained in shared memory.
Definition: app_info.h:28
double father_memory_
Memory used by the father process.
Definition: app_info.h:54
double child_memory_
Memory used by the child process.
Definition: app_info.h:52
int num_connections
Number of open connections.
Definition: app_info.h:32
double available_memory_
Available memory in the system.
Definition: app_info.h:55
bool is_running_
true if the application is running
Definition: app_info.h:50
int child_pid
PID of the child process.
Definition: app_info.h:31
int lock_file
Lock file.
Definition: app_info.h:48
TYPE GetProcStat(int pid, int field) const
Returns a specific field of /proc/<pid>/stat as a defined type.
Definition: app_info.h:66
ostream & operator<<(ostream &out, const Request &request)
Definition: request.cc:65