This tool monitors CPU and memory utilization, along with hardware specifications like core count and clock speed, on a Linux system. The program uses multiple child processes—one for each type of resource—fetching data concurrently and sending it back to the parent process via pipes.
The tool tracks CPU utilization by reading the /proc/stat file, comparing data from two points in time. For memory stats, it leverages the sysinfo library, which provides total and free RAM. The data is fetched by child processes, which send it back to the parent for further handling. Below is a flowchart illustrating the interaction between modules:
To compile the project, run:
makeNote: You may need to reduce your terminal’s text size to ensure that all output fits on the screen, especially with a large number of samples.
./main
./main --memory
./main --cpu
./main --cores
./main --memory --cpu
./main 100 200000 --memory --cpu --cores
- GeeksforGeeks - Typedef in C
- GeeksforGeeks - Convert int to float
- GeeksforGeeks - C program to read contents of a file
- GeeksforGeeks - Pipe system call
- GeeksforGeeks - Fork system call
- W3Schools - atoi function
- W3Schools - File reading in C
- W3Schools - strtok function
- CS.uwaterloo.ca - strtok function
- GNU Getopt - Long Option Parsing Example
- IBM Docs - waitpid function
- IBM Docs - getopt-long command parsing
- Man7 - fork system call
- Man7 - sysinfo system call
- Man7 - get_nprocs function
- StackOverflow - Maximum CPU frequency
- StackOverflow - Erase current console line
- Kernel.org - CPU Frequency Guide
- IDNT - CPU frequency
- GNU Make - Automatic Variables
- Linux Die - usleep function
- HackerNoon - Phony in Makefiles
- Makefile Tutorial
- Labex - Signal handling in Linux
- LinuxQuestions - Passing input to a signal handler






