ConcurrentSystemStats (main executable: mySystemStats) is a real-time, terminal-based system monitoring utility. It reports live system metrics like CPU usage, memory consumption, and active user sessions — all while showcasing concurrent programming using multiple child processes and inter-process communication (IPC).
ConcurrentSystemStats captures system health data using a multi-process architecture. Each major system metric is collected by a dedicated child process, allowing parallel, non-blocking data gathering. A parent process aggregates and renders the data in an organized and user-friendly format.
Features include:
- Real-time updates
- Graphics (bars) for CPU and memory usage
- Graceful exit on
Ctrl-C - Terminal-clearing for clean refresh
Each system component (CPU, memory, user sessions) is handled by an individual child process to enable simultaneous collection.
Child processes use pipes to send data to the parent, allowing the parent process to coordinate output.
Custom signal handlers:
- Intercept
SIGINT(Ctrl-C) for controlled termination - Ignore
SIGTSTP(Ctrl-Z) to avoid suspending the program
| Function | Description |
|---|---|
storeMemArr(int samples, int memFD[2], int tdelay); |
Collects memory usage and writes to a pipe |
storeUserInfoThird(int userFD[2], int ucountFD[2]); |
Gathers user session data and count |
storeCpuArr(int cpuFD[2]); |
Reads CPU statistics from /proc/stat and writes to a pipe |
| Function | Description |
|---|---|
fcnForPrintMemoryArr(...) |
Displays memory info using the received pipe data |
printUserInfoThird(...) |
Reads and prints user session data |
- SIGINT (Ctrl-C):
- Asks user whether to quit
- If yes, terminates all child processes and exits cleanly
- SIGTSTP (Ctrl-Z):
- Ignored to prevent suspending the process
signal(SIGTSTP, SIG_IGN); // Prevent Ctrl-Z from suspending the program