Added child CPU time to account for short lived processes

This commit is contained in:
dan 2025-01-18 12:01:49 -05:00
parent 54f22771dc
commit afc17db869
2 changed files with 13 additions and 3 deletions

View File

@ -57,11 +57,19 @@ int parseStatFile(Process *proc, char *filedata) {
// (15) stime - %lu // (15) stime - %lu
proc->cpuTime += fast_str2ull(&location); proc->cpuTime += fast_str2ull(&location);
location += 1;
// (16) cutime - %lu
proc->cpuTime += fast_str2ull(&location);
location += 1;
// (17) cstime - %lu
proc->cpuTime += fast_str2ull(&location);
proc->cCpuTime = proc->cpuTime; proc->cCpuTime = proc->cpuTime;
location += 1; location += 1;
// skip 16-19 // skip 18-19
skipRange(16, 20); skipRange(18, 20);
// (20) num_threads - %ld // (20) num_threads - %ld
proc->nThreads = fast_str2ull(&location); proc->nThreads = fast_str2ull(&location);
@ -354,6 +362,7 @@ nextProcess:
ptr += sprintf(ptr, "process_cumulative_swap_bytes{%s} %lu\n", buffer, cur->cSwap); ptr += sprintf(ptr, "process_cumulative_swap_bytes{%s} %lu\n", buffer, cur->cSwap);
ptr += sprintf(ptr, "process_cumulative_bytes_read{%s} %lu\n", buffer, cur->cRead); ptr += sprintf(ptr, "process_cumulative_bytes_read{%s} %lu\n", buffer, cur->cRead);
ptr += sprintf(ptr, "process_cumulative_bytes_written{%s} %lu\n", buffer, cur->cWrite); ptr += sprintf(ptr, "process_cumulative_bytes_written{%s} %lu\n", buffer, cur->cWrite);
// stats used to make flame chart // stats used to make flame chart
ptr += sprintf(ptr, "process_tree_depth{%s} %d\n", buffer, cur->level); ptr += sprintf(ptr, "process_tree_depth{%s} %d\n", buffer, cur->level);
ptr += sprintf(ptr, "process_visit_index{%s} %d\n", buffer, cur->visited); ptr += sprintf(ptr, "process_visit_index{%s} %d\n", buffer, cur->visited);

View File

@ -86,6 +86,7 @@ void handle_client(int client_socket) {
closeConnection: closeConnection:
printf("Closing connection\n"); printf("Closing connection\n");
// Close the client socket // Close the client socket
usleep(100000);
close(client_socket); close(client_socket);
free(data); free(data);
} }