43 JParser<> zap(
"Auxiliary program to monitor memory and CPU usage of process.");
46 zap[
'P'] =
make_field(process,
"name of process");
47 zap[
'T'] =
make_field(T_us,
"interval time [us]") = 100000;
48 zap[
'u'] =
make_field(interactive,
"run in interactive mode");
53 catch(
const exception &error) {
54 FATAL(error.what() << endl);
60 const char QUIT =
'q';
63 cout <<
"Press '" << QUIT <<
"' to quit." << endl;
68 for (
int i = 0; ;++i) {
72 pid =
getPID(shell, process.c_str());
76 catch(
const exception& error) {
79 cout <<
"No process " << setw(8) << i << endl;
82 if (keypress.timeout(T_us)) {
83 if (keypress.get() == QUIT && interactive) {
90 NOTICE(
"Process identifier " << pid << endl);
93 FATAL(
"Invalid process identifier " << pid << endl);
96 TH1D h0(
"h0", NULL, 101,-0.5, 100.5);
97 TH1D h1(
"h1", NULL, 1001,-0.5, 1000.5);
105 for (
int i = 0; ;++i) {
109 const double t1 = double (
getLocalTime() - t0) * 1.0e-6;
121 cout << setw(8) << i <<
' ' <<
FIXED(12,3) << t1 <<
' ' <<
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());
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_CSTRING(A)
Make C-string.
Double_t g1(const Double_t x)
Function.
Utility class to parse command line options.
Enable unbuffered terminal input.
The JShell clas can be used to interact with the shell via I/O streams.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static const JLocalTime getLocalTime
Function object to get local time in micro seconds.
float getMemoryUsage(JShell &shell, const pid_t pid)
Get memory usage in percent of given process identifier.
long long int localtime_t
Type definition of local time.
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.
Auxiliary data structure for floating point format specification.