31 int main(
int argc,
char **argv)
44 JParser<> zap(
"Auxiliary program to monitor memory and CPU usage of process.");
47 zap[
'P'] =
make_field(process,
"name of process");
48 zap[
'T'] =
make_field(T_us,
"interval time [us]") = 100000;
49 zap[
'u'] =
make_field(interactive,
"run in interactive mode");
54 catch(
const exception &error) {
55 FATAL(error.what() << endl);
59 JKeypress keypress(
false);
61 const char QUIT =
'q';
64 cout <<
"Press '" << QUIT <<
"' to quit." << endl;
69 for (
int i = 0; ;++i) {
73 pid =
getPID(shell, process.c_str());
77 catch(
const exception& error) {
80 cout <<
"No process " << setw(8) << i << endl;
83 if (keypress.timeout(T_us)) {
84 if (keypress.get() == QUIT && interactive) {
91 NOTICE(
"Process identifier " << pid << endl);
94 FATAL(
"Invalid process identifier " << pid << endl);
97 TH1D h0(
"h0", NULL, 101,-0.5, 100.5);
98 TH1D h1(
"h1", NULL, 101,-0.5, 100.5);
106 for (
int i = 0; ;++i) {
121 cout << setw(8) << i <<
' ' <<
FIXED(7,3) << mem <<
' ' <<
FIXED(7,3) << cpu << endl;
124 if (keypress.timeout(T_us)) {
125 if (keypress.get() == QUIT && interactive) {
130 catch(
const exception& error) {
136 TGraph g0(X.size(), X.data(), Y.data());
137 TGraph
g1(X.size(), X.data(), Z.data());
Utility class to parse command line options.
float getMemoryUsage(JShell &shell, const pid_t pid)
Get memory usage in percent of given process identifier.
#define MAKE_CSTRING(A)
Make C-string.
Auxiliary data structure for floating point format specification.
I/O formatting auxiliaries.
Keyboard settings for unbuffered input.
static const JLocalTime getLocalTime
Function object to get local time in micro seconds.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
float getCpuUsage(JShell &shell, const pid_t pid)
Get cpu usage in percent of given process identifier.
pid_t getPID(JShell &shell, const char *process)
Get process identifier.
General purpose messaging.
long long int localtime_t
Type definition of local time.
Utility class to parse command line options.
Shell interaction via I/O streams.
Double_t g1(const Double_t x)
Function.
int main(int argc, char *argv[])