18 struct zbuf : std::filebuf
20 void rewind() { std::filebuf::seekpos(0, std::ios_base::out); }
30 int main(
int argc,
char **argv)
44 JParser<> zap(
"Auxiliary program to continually monitor processes.");
46 zap[
'P'] =
make_field(process,
"name of process");
48 zap[
'T'] =
make_field(T_us,
"interval time [us]") = 1000;
49 zap[
'n'] =
make_field(prescale,
"pre-scale for logging") = 1000;
55 catch(
const exception &error) {
56 FATAL(error.what() << endl);
59 if (process.empty()) {
60 FATAL(
"No process." << endl);
68 os <<
"ps -o comm= -o pid=";
89 ostream os(
outputFile !=
"" ? &buffer : cout.rdbuf());
99 const auto start = chrono::system_clock::now();
103 for (
long int count = 1;
monitor != STOPPED; usleep(T_us)) {
111 for (
string buffer; shell.getline(buffer); ) {
116 istringstream
is(buffer);
118 if (is >> command >> pid) {
128 ERROR(
"Error reading \"" << buffer <<
"\"" << endl);
136 if (count%prescale == 0) {
140 os <<
"top " <<
FIXED(9,1) << chrono::duration<double>(chrono::system_clock::now() - start).count() <<
" [s]" << endl;
146 const long int value = top[*
i];
148 os << setw(24) << left << *
i <<
' ' <<
FIXED(5,3) << (double) value / (
double) count << endl;
153 os << setw(24) << left <<
"Total" <<
' ' <<
FIXED(5,3) << (double) total / (
double) count << endl;
Utility class to parse command line options.
then echo Test string reversed by master(hit< return > to continue)." $DIR/JProcess -c "$DIR/JEcho" -rC fi if (( 1 ))
int main(int argc, char *argv[])
Auxiliary data structure for floating point format specification.
std::ostream & rewind(std::ostream &out)
Rewind character.
I/O formatting auxiliaries.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
General purpose messaging.
Utility class to parse command line options.
Shell interaction via I/O streams.
#define DEBUG(A)
Message macros.